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

42 lines
1.4 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-12 00:17:51 +03:00
import _VisualDVM.Global;
2024-10-09 22:21:57 +03:00
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
2023-09-17 22:13:42 +03:00
import java.util.Vector;
2024-10-09 23:37:58 +03:00
public class DeleteSelectedRunTasks extends Pass<Vector<RunTask>> {
2023-09-17 22:13:42 +03:00
@Override
public String getIconPath() {
return "/Common/icons/Delete.png";
2023-09-17 22:13:42 +03:00
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) throws Exception {
target = new Vector<>();
2024-10-12 00:17:51 +03:00
(Global.mainModule.getDb()).runTasks.Data.values().stream().filter(task -> task.isVisible() && task.isSelected() && task.isPassive()).forEach(task -> target.add(task));
2023-09-17 22:13:42 +03:00
if (target.isEmpty()) {
Log.Writeln_("Не отмечено ни одной задачи для удаления.");
return false;
} else return true;
}
@Override
protected void showPreparation() throws Exception {
2024-10-12 00:17:51 +03:00
Global.mainModule.getDb().runTasks.ClearUI();
2023-09-17 22:13:42 +03:00
}
@Override
protected void body() throws Exception {
for (RunTask task : target) {
2024-10-12 00:17:51 +03:00
Global.mainModule.getDb().Delete(task);
2024-10-14 12:54:52 +03:00
Utils_.forceDeleteWithCheck(task.getLocalWorkspace());
2023-09-17 22:13:42 +03:00
}
}
@Override
protected void showFinish() throws Exception {
2024-10-12 00:17:51 +03:00
Global.mainModule.getDb().runTasks.ShowUI();
2023-09-17 22:13:42 +03:00
}
}