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;
|
2024-10-13 22:08:13 +03:00
|
|
|
|
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 {
|
2024-10-13 22:08:13 +03:00
|
|
|
|
if (Global.mainModule.getProject().db.files.getCheckedCount() == 0) {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
Log.Writeln_("Не отмечено ни одного файла.");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2024-10-13 22:08:13 +03:00
|
|
|
|
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;
|
2024-10-13 22:08:13 +03:00
|
|
|
|
if (Global.mainModule.HasFile()) {
|
2024-10-14 15:19:13 +03:00
|
|
|
|
for (DBProjectFile file : Global.mainModule.getProject().db.files.getCheckedItems()) {
|
2024-10-13 22:08:13 +03:00
|
|
|
|
if (Global.mainModule.getFile().file.equals(file.file))
|
2023-09-17 22:13:42 +03:00
|
|
|
|
hasCurrent = true;
|
2024-10-13 22:08:13 +03:00
|
|
|
|
if (Global.mainModule.getSelectedFile().file.equals(file.file))
|
2023-09-17 22:13:42 +03:00
|
|
|
|
hasSelected = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (hasCurrent)
|
2024-10-13 23:55:03 +03:00
|
|
|
|
Global.mainModule.getPass(PassCode.CloseCurrentFile).Do();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
if (hasSelected) {
|
2024-10-13 22:08:13 +03:00
|
|
|
|
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 {
|
2024-10-13 22:08:13 +03:00
|
|
|
|
for (DBProjectFile file : Global.mainModule.getProject().db.files.getCheckedItems()) {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
ShowMessage1(file.name);
|
2024-10-15 02:32:52 +03:00
|
|
|
|
Global.mainModule.getUI().getMainWindow().getProjectWindow().getFilesTreeForm().getTree().RemoveNode(file.node);
|
2024-10-13 22:08:13 +03:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|