55 lines
2.1 KiB
Java
55 lines
2.1 KiB
Java
package _VisualDVM.Passes.All;
|
||
import Common.Passes.Pass;
|
||
import Common.Utils.Utils_;
|
||
import Common.Visual.UI;
|
||
import _VisualDVM.Current;
|
||
import _VisualDVM.Global;
|
||
import _VisualDVM.Passes.PassCode;
|
||
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||
public class DeleteSelectedFiles extends Pass {
|
||
@Override
|
||
public String getIconPath() {
|
||
return "/Common/icons/Delete.png";
|
||
}
|
||
@Override
|
||
protected boolean canStart(Object... args) throws Exception {
|
||
if (Global.mainModule.getProject().db.files.getSelectedCount() == 0) {
|
||
Log.Writeln_("Не отмечено ни одного файла.");
|
||
return false;
|
||
}
|
||
return UI.Warning("Удалить " + Global.mainModule.getProject().db.files.getSelectedCount() + " файлов.");
|
||
}
|
||
@Override
|
||
protected void performPreparation() throws Exception {
|
||
boolean hasCurrent = false;
|
||
boolean hasSelected = false;
|
||
if (Global.mainModule.HasFile()) {
|
||
for (DBProjectFile file : Global.mainModule.getProject().db.files.getSelectedItems()) {
|
||
if (Global.mainModule.getFile().file.equals(file.file))
|
||
hasCurrent = true;
|
||
if (Global.mainModule.getSelectedFile().file.equals(file.file))
|
||
hasSelected = true;
|
||
}
|
||
}
|
||
if (hasCurrent)
|
||
Global.mainModule.getPass(PassCode.CloseCurrentFile).Do();
|
||
if (hasSelected) {
|
||
Global.mainModule.set(Current.SelectedFile, null);
|
||
Global.mainModule.set(Current.ProjectNode, null);
|
||
}
|
||
}
|
||
@Override
|
||
protected boolean needsAnimation() {
|
||
return true;
|
||
}
|
||
@Override
|
||
protected void body() throws Exception {
|
||
for (DBProjectFile file : Global.mainModule.getProject().db.files.getSelectedItems()) {
|
||
ShowMessage1(file.name);
|
||
Global.mainModule.getUI().getMainWindow().getProjectWindow().getFilesTreeForm().getTree().RemoveNode(file.node);
|
||
Global.mainModule.getProject().db.Delete(file);
|
||
Utils_.forceDeleteWithCheck(file.file);
|
||
}
|
||
}
|
||
}
|