Files
VisualSapfor/src/_VisualDVM/Passes/All/DeleteSelectedFiles.java

55 lines
2.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
}
}
}