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

55 lines
2.1 KiB
Java
Raw Normal View History

2024-10-14 12:14:01 +03:00
package _VisualDVM.Passes.All;
2024-10-14 15:19:13 +03:00
import Common.Passes.Pass;
2024-10-14 12:54:52 +03:00
import Common.Utils.Utils_;
2024-10-11 00:00:30 +03:00
import Common.Visual.UI_;
2024-10-09 22:01:19 +03:00
import _VisualDVM.Current;
import _VisualDVM.Global;
2024-10-14 12:14:01 +03:00
import _VisualDVM.Passes.PassCode;
2024-10-14 15:19:13 +03:00
import _VisualDVM.ProjectData.Files.DBProjectFile;
2024-10-09 23:37:58 +03:00
public class DeleteSelectedFiles extends Pass {
2023-09-17 22:13:42 +03:00
@Override
public String getIconPath() {
return "/icons/Delete.png";
}
@Override
protected boolean canStart(Object... args) throws Exception {
if (Global.mainModule.getProject().db.files.getCheckedCount() == 0) {
2023-09-17 22:13:42 +03:00
Log.Writeln_("Не отмечено ни одного файла.");
return false;
}
return UI_.Warning("Удалить " + Global.mainModule.getProject().db.files.getCheckedCount() + " файлов.");
2023-09-17 22:13:42 +03:00
}
@Override
protected void performPreparation() throws Exception {
boolean hasCurrent = false;
boolean hasSelected = false;
if (Global.mainModule.HasFile()) {
2024-10-14 15:19:13 +03:00
for (DBProjectFile file : Global.mainModule.getProject().db.files.getCheckedItems()) {
if (Global.mainModule.getFile().file.equals(file.file))
2023-09-17 22:13:42 +03:00
hasCurrent = true;
if (Global.mainModule.getSelectedFile().file.equals(file.file))
2023-09-17 22:13:42 +03:00
hasSelected = true;
}
}
if (hasCurrent)
Global.mainModule.getPass(PassCode.CloseCurrentFile).Do();
2023-09-17 22:13:42 +03:00
if (hasSelected) {
Global.mainModule.set(Current.SelectedFile, null);
Global.mainModule.set(Current.ProjectNode, null);
2023-09-17 22:13:42 +03:00
}
}
@Override
protected boolean needsAnimation() {
return true;
}
@Override
protected void body() throws Exception {
for (DBProjectFile file : Global.mainModule.getProject().db.files.getCheckedItems()) {
2023-09-17 22:13:42 +03:00
ShowMessage1(file.name);
Global.mainModule.getUI().getMainWindow().getProjectWindow().getFilesTreeForm().getTree().RemoveNode(file.node);
Global.mainModule.getProject().db.Delete(file);
2024-10-14 12:54:52 +03:00
Utils_.forceDeleteWithCheck(file.file);
2023-09-17 22:13:42 +03:00
}
}
}