74 lines
2.5 KiB
Java
74 lines
2.5 KiB
Java
|
|
package Visual_DVM_2021.Passes;
|
|||
|
|
import Common.UI.UI;
|
|||
|
|
import Common.Utils.Utils;
|
|||
|
|
import Repository.Server.ServerCode;
|
|||
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
|||
|
|
import TestingSystem.Common.Group.Group;
|
|||
|
|
import TestingSystem.Common.Test.Test;
|
|||
|
|
import Visual_DVM_2021.Passes.All.CreateTestFromDirectory;
|
|||
|
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
|||
|
|
|
|||
|
|
import java.io.File;
|
|||
|
|
import java.util.Vector;
|
|||
|
|
public abstract class PublishTests extends TestingSystemPass<Vector<Test>> {
|
|||
|
|
@Override
|
|||
|
|
public String getButtonText() {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
protected boolean needsAnimation() {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
//---
|
|||
|
|
protected Group group;
|
|||
|
|
protected Vector<File> files;
|
|||
|
|
protected abstract boolean getGroup();
|
|||
|
|
protected abstract boolean findFiles();
|
|||
|
|
@Override
|
|||
|
|
protected boolean canStart(Object... args) throws Exception {
|
|||
|
|
target = new Vector<>();
|
|||
|
|
files = new Vector<>();
|
|||
|
|
//--------------------------
|
|||
|
|
group = null;
|
|||
|
|
if (!getGroup()) return false;
|
|||
|
|
if (group == null) {
|
|||
|
|
Log.Writeln_("Группа не выбрана.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
files = new Vector<>();
|
|||
|
|
if (!findFiles()) return false;
|
|||
|
|
if (files.isEmpty()) {
|
|||
|
|
Log.Writeln_("Не найдено ни одной папки для формирования теста.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
//---
|
|||
|
|
CreateTestFromDirectory createTestFromDirectory = (CreateTestFromDirectory) passes.get(PassCode_2021.CreateTestFromDirectory);
|
|||
|
|
//---
|
|||
|
|
for (File file : files) {
|
|||
|
|
if (createTestFromDirectory.Do(file, group))
|
|||
|
|
target.add(createTestFromDirectory.target);
|
|||
|
|
}
|
|||
|
|
//---
|
|||
|
|
if (target.isEmpty()) {
|
|||
|
|
Log.Writeln_("Не удалось создать ни одного теста.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
//---
|
|||
|
|
return UI.Question("В группу " + Utils.Brackets(group.description) +
|
|||
|
|
"\nбудет добавлено " + target.size() + " тестов.\nПродолжить");
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
protected void ServerAction() throws Exception {
|
|||
|
|
Command(new ServerExchangeUnit_2021(ServerCode.PublishObjects, null, target));
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
protected void performFinish() throws Exception {
|
|||
|
|
super.performFinish();
|
|||
|
|
passes.get(PassCode_2021.SynchronizeTests).Do();
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
protected void FocusResult() {
|
|||
|
|
UI.getMainWindow().FocusTests();
|
|||
|
|
}
|
|||
|
|
}
|