2023-11-19 02:12:44 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
2024-10-09 23:37:58 +03:00
|
|
|
import Common.Current_;
|
2024-10-07 14:22:52 +03:00
|
|
|
import Common.Utils.CommonUtils;
|
2024-10-08 22:33:49 +03:00
|
|
|
import Common.Visual.CommonUI;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Current;
|
|
|
|
|
import _VisualDVM.Visual.UI;
|
|
|
|
|
import _VisualDVM.Utils;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.ProjectData.Project.db_project_info;
|
2024-10-09 23:37:58 +03:00
|
|
|
import Visual_DVM_2021.Passes.PassCode;
|
|
|
|
|
import Visual_DVM_2021.Passes.Pass;
|
|
|
|
|
public class DeleteVersion extends Pass<db_project_info> {
|
2023-09-17 22:13:42 +03:00
|
|
|
db_project_info parent;
|
|
|
|
|
boolean current;
|
|
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
return "/icons/Delete.png";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) {
|
|
|
|
|
if (args.length > 0) {
|
|
|
|
|
target = (db_project_info) args[0];
|
|
|
|
|
current = (Current.getVersion() != null) && Current.getVersion().Home.equals(target.Home);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
2024-10-08 22:33:49 +03:00
|
|
|
if (((target = Current.getVersion()) != null) && (!CommonUI.isActive() ||
|
|
|
|
|
CommonUI.Warning("Удалить " +
|
2023-09-17 22:13:42 +03:00
|
|
|
((Current.HasProject() && target.Home.equals(Current.getProject().Home)) ? "текущий проект" : "версию ")
|
2024-10-07 14:22:52 +03:00
|
|
|
+ CommonUtils.Brackets(target.name)))) {
|
2023-09-17 22:13:42 +03:00
|
|
|
current = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performPreparation() throws Exception {
|
|
|
|
|
if (target.parent != null)
|
|
|
|
|
target.parent.checkLastModification(target);
|
|
|
|
|
if (Current.HasProject()) {
|
|
|
|
|
if ((Current.getProject().Home.getAbsolutePath().startsWith(target.Home.getAbsolutePath())))
|
2024-10-09 23:37:58 +03:00
|
|
|
passes.get(PassCode.CloseCurrentProject).Do();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
2024-10-08 22:33:49 +03:00
|
|
|
if (CommonUI.isActive()) {
|
2023-09-17 22:13:42 +03:00
|
|
|
UI.getVersionsWindow().RemoveVersionFromComparison(target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
Utils.forceDeleteWithCheck(target.Home);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
parent = target.parent;
|
|
|
|
|
if (current)
|
2024-10-09 23:37:58 +03:00
|
|
|
Current_.set(Current.Version, null);
|
2023-09-17 22:13:42 +03:00
|
|
|
if (parent != null) {
|
|
|
|
|
UI.getVersionsWindow().getVersionsForm().getTree().RemoveNode(target.node);
|
|
|
|
|
parent.versions.remove(target.name);
|
|
|
|
|
} else
|
2024-10-09 23:37:58 +03:00
|
|
|
Current_.set(Current.Root, null);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|