Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/DeleteDownloadedBugReports.java
2023-11-19 02:12:44 +03:00

47 lines
1.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import java.io.File;
import java.util.Arrays;
import java.util.Vector;
public class DeleteDownloadedBugReports extends Pass_2021<Vector<File>> {
@Override
protected boolean needsAnimation() {
return true;
}
@Override
public boolean needsConfirmations() {
return true;
}
@Override
protected boolean canStart(Object... args) throws Exception {
target = null;
File workspace = Global.visualiser.getWorkspace();
File[] files = workspace.listFiles(pathname -> pathname.isDirectory() && pathname.getName().toLowerCase().startsWith("bugreport_"));
if (files != null) {
target = new Vector<>(Arrays.asList(files));
return UI.Warning("Будет удалено " + target.size() + " скачанных отчётов об ошибках." +
(Current.HasProject() ? "(Текущий проект будет закрыт)" : "")
);
}
return false;
}
@Override
protected void performPreparation() throws Exception {
if (Current.HasProject())
passes.get(PassCode_2021.CloseCurrentProject).Do();
}
@Override
protected void body() throws Exception {
for (File file : target) {
ShowMessage1(file.getAbsolutePath());
Utils.forceDeleteWithCheck(file);
}
}
}