Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/DownloadTest.java
2024-10-08 22:33:49 +03:00

61 lines
2.3 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.CurrentAnchestor;
import Common.Utils.CommonUtils;
import Common.Visual.CommonUI;
import Common_old.Current;
import _VisualDVM.Global;
import Common_old.Utils.Utils;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
public class DownloadTest extends TestingSystemPass<Test> {
@Override
public String getIconPath() {
return "/icons/DownloadBugReport.png";
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) throws Exception {
if (Current.getAccount().CheckRegistered(Log) && CurrentAnchestor.Check(Log, Current.Test)) {
target = Current.getTest();
return true;
}
return false;
}
@Override
protected void performPreparation() throws Exception {
passes.get(PassCode_2021.CloseCurrentProject).Do();
CurrentAnchestor.set(Current.Root, null); //чтобы гарантированно не существовало корня.
Utils.forceDeleteWithCheck(target.getArchive());
Utils.forceDeleteWithCheck(target.getHomePath());
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.DownloadTest, String.valueOf(target.id)));
response.Unpack(target.getArchive());
}
@Override
protected boolean validate() {
return target.getArchive().exists();
}
@Override
protected void performDone() throws Exception {
super.performDone();
if (passes.get(PassCode_2021.UnzipFolderPass).Do(
target.getArchive().getAbsolutePath(),
Global.visualiser.getWorkspace().getAbsolutePath(), false
))
if (CommonUI.Question("Тестовый проект успешно загружен под именем\n" +
CommonUtils.Brackets(target.getHomePath().getName()) +
"\nОткрыть его"))
passes.get(PassCode_2021.OpenCurrentProject).Do(target.getHomePath());
}
}