добавление теста через папку.
This commit is contained in:
@@ -1,12 +1,25 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.Utils.Files.VDirectoryChooser;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.io.File;
|
||||
public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
db_project_info project = null;
|
||||
Group group= null;
|
||||
File dir;
|
||||
VDirectoryChooser directoryChooser = new VDirectoryChooser("Выбор домашней папки теста");
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/OpenProject.png";
|
||||
return "/icons/CreateProject.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
@@ -16,5 +29,58 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void restoreBrowserPath() {
|
||||
String last_dir_home =
|
||||
Global.db.settings.get(SettingName.ProjectsSearchDirectory).Value;
|
||||
if (!last_dir_home.isEmpty())
|
||||
directoryChooser.SetCurrentDirectory(last_dir_home);
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
group = null;
|
||||
project = null;
|
||||
dir = null;
|
||||
target = null;
|
||||
//-
|
||||
if (args.length == 0) {
|
||||
restoreBrowserPath();
|
||||
if (!Current.Check(Log, Current.Group))
|
||||
return false;
|
||||
group = Current.getGroup();
|
||||
dir = directoryChooser.ShowDialog();
|
||||
} else {
|
||||
dir = (File) args[0];
|
||||
group = (Group) args[1];
|
||||
}
|
||||
//-
|
||||
if (dir == null)
|
||||
return false;
|
||||
//--
|
||||
if (!dir.isDirectory()) {
|
||||
Log.Writeln_(Utils.Brackets(dir) + "\nне является папкой!");
|
||||
return false;
|
||||
}
|
||||
//-
|
||||
if (dir.getName().equals(Constants.data)) {
|
||||
Log.Writeln_(Utils.Brackets(dir) + "\nявляется служебной папкой визуализатора!");
|
||||
return false;
|
||||
}
|
||||
return Utils.validateProjectFolder(dir, Log) && Utils.containsSource(dir, true);
|
||||
}
|
||||
@Override
|
||||
protected void performPreparation() throws Exception {
|
||||
passes.get(PassCode_2021.CloseCurrentProject).Do();
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
project = new db_project_info(dir);
|
||||
project.CreateVersionsTree();
|
||||
project.Open();
|
||||
project.Close();
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
super.performDone();
|
||||
passes.get(PassCode_2021.PublishTest).Do(project,group);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user