43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
package Visual_DVM_2021.Passes.All;
|
||
import Common.Utils.CommonUtils;
|
||
import _VisualDVM.Utils;
|
||
import _VisualDVM.GlobalData.GlobalDatabase;
|
||
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
|
||
import Common.Passes.Pass;
|
||
|
||
import java.util.Vector;
|
||
public class DeleteSelectedRunTasks extends Pass<Vector<RunTask>> {
|
||
@Override
|
||
public String getIconPath() {
|
||
return "/icons/Delete.png";
|
||
}
|
||
@Override
|
||
public String getButtonText() {
|
||
return "";
|
||
}
|
||
@Override
|
||
protected boolean canStart(Object... args) throws Exception {
|
||
target = new Vector<>();
|
||
((GlobalDatabase)CommonUtils.db).runTasks.Data.values().stream().filter(task -> task.isVisible() && task.isSelected() && task.isPassive()).forEach(task -> target.add(task));
|
||
if (target.isEmpty()) {
|
||
Log.Writeln_("Не отмечено ни одной задачи для удаления.");
|
||
return false;
|
||
} else return true;
|
||
}
|
||
@Override
|
||
protected void showPreparation() throws Exception {
|
||
((GlobalDatabase)CommonUtils.db).runTasks.ClearUI();
|
||
}
|
||
@Override
|
||
protected void body() throws Exception {
|
||
for (RunTask task : target) {
|
||
CommonUtils.db.Delete(task);
|
||
Utils.forceDeleteWithCheck(task.getLocalWorkspace());
|
||
}
|
||
}
|
||
@Override
|
||
protected void showFinish() throws Exception {
|
||
((GlobalDatabase)CommonUtils.db).runTasks.ShowUI();
|
||
}
|
||
}
|