Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/DeleteFile.java

40 lines
1.4 KiB
Java
Raw Normal View History

package Visual_DVM_2021.Passes.All;
import Common.CurrentAnchestor;
2024-10-07 14:22:52 +03:00
import Common.Utils.CommonUtils;
2024-10-08 22:33:49 +03:00
import Common.Visual.CommonUI;
import Common_old.Current;
import Common_old.UI.UI;
import Common_old.Utils.Utils;
2023-09-17 22:13:42 +03:00
import ProjectData.Files.DBProjectFile;
import Visual_DVM_2021.Passes.ChangeFilePass;
import Visual_DVM_2021.Passes.PassCode_2021;
2023-09-17 22:13:42 +03:00
public class DeleteFile extends ChangeFilePass<DBProjectFile> {
@Override
public String getIconPath() {
return "/icons/Delete.png";
}
@Override
protected boolean canStart(Object... args) {
resetArgs();
return (CurrentAnchestor.Check(Log, Current.SelectedFile)) &&
2024-10-08 22:33:49 +03:00
CommonUI.Warning("Удалить файл "
2024-10-07 14:22:52 +03:00
+ CommonUtils.Brackets((target = Current.getSelectedFile()).name));
2023-09-17 22:13:42 +03:00
}
@Override
protected void performPreparation() throws Exception {
if (Current.HasFile() && (Current.getFile().file.equals(target.file)))
passes.get(PassCode_2021.CloseCurrentFile).Do();
}
@Override
protected void body() throws Exception {
UI.getMainWindow().getProjectWindow().getFilesTreeForm().getTree().RemoveNode(target.node);
project.db.Delete(target);
Utils.forceDeleteWithCheck(target.file);
}
@Override
protected void performDone() throws Exception {
CurrentAnchestor.set(Current.SelectedFile, null);
CurrentAnchestor.set(Current.ProjectNode, null);
2023-09-17 22:13:42 +03:00
}
}