2023-11-19 02:12:44 +03:00
|
|
|
|
package Visual_DVM_2021.Passes.All;
|
2024-10-08 00:39:13 +03:00
|
|
|
|
import Common.CurrentAnchestor;
|
2024-10-07 14:22:52 +03:00
|
|
|
|
import Common.Utils.CommonUtils;
|
2024-10-09 22:01:19 +03:00
|
|
|
|
import _VisualDVM.Current;
|
2024-10-07 00:58:29 +03:00
|
|
|
|
import _VisualDVM.Global;
|
2024-10-09 22:21:57 +03:00
|
|
|
|
import _VisualDVM.Repository.BugReport.BugReport;
|
|
|
|
|
|
import _VisualDVM.Repository.BugReport.BugReportInterface;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.Pass_2021;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
public class OpenBugReportTestProject extends Pass_2021<BugReport> {
|
|
|
|
|
|
File root = null;
|
|
|
|
|
|
File project = null;
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
|
return "/icons/DownloadBugReport.png";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2024-10-08 00:39:13 +03:00
|
|
|
|
if (CurrentAnchestor.Check(Log, Current.BugReport) &&
|
2023-09-17 22:13:42 +03:00
|
|
|
|
(BugReportInterface.CheckNotDraft(target=Current.getBugReport(),Log))) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!target.project_version.isEmpty()) {
|
|
|
|
|
|
root = Paths.get(Global.visualiser.getWorkspace().getAbsolutePath(),
|
|
|
|
|
|
target.id).toFile();
|
|
|
|
|
|
project = Paths.get(root.getAbsolutePath(),
|
2024-10-08 22:33:49 +03:00
|
|
|
|
CommonUtils.isWindows() ? CommonUtils.toW(target.project_version)
|
2024-10-07 14:22:52 +03:00
|
|
|
|
: CommonUtils.toU(target.project_version)).toFile();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
return true;
|
|
|
|
|
|
}else {
|
|
|
|
|
|
Log.Writeln_("Отчёт об ошибке не содержит прикреплённого проекта!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void performPreparation() throws Exception {
|
|
|
|
|
|
passes.get(PassCode_2021.CloseCurrentProject).Do();
|
2024-10-08 00:39:13 +03:00
|
|
|
|
CurrentAnchestor.set(Current.Root, null); //чтобы гарантированно не существовало корня.
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
|
//попытка скачки. проверка существования архива уже там.
|
|
|
|
|
|
passes.get(PassCode_2021.DownloadBugReport).Do(target);
|
|
|
|
|
|
if (BugReportInterface.getArchiveFile(target).exists()) {
|
|
|
|
|
|
passes.get(PassCode_2021.UnzipFolderPass).Do(
|
|
|
|
|
|
BugReportInterface.getArchiveFile(target).getAbsolutePath(),
|
|
|
|
|
|
root.getAbsolutePath()
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean validate() {
|
|
|
|
|
|
if (!project.exists()) {
|
|
|
|
|
|
Log.Writeln_("Тестовый проект\n" + project.getAbsolutePath() +
|
|
|
|
|
|
"\nне был скачан.");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
|
if (passes.get(PassCode_2021.OpenCurrentProject).Do(project))
|
|
|
|
|
|
passes.get(PassCode_2021.ApplyBugReportSettings).Do();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|