промежуточный. небольшой рефакторинг. наследие DBProjectFile от ProjectFile.
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
package SapforTestingSystem.Json;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.Files.FileType;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Vector;
|
||||
public class SapforVersion_json implements Serializable {
|
||||
@Expose
|
||||
public String version = "";
|
||||
@Expose
|
||||
public String description = "";
|
||||
//поля для отображения деревьев.
|
||||
public File Home = null;
|
||||
public Vector<DBProjectFile> files = null;
|
||||
//-
|
||||
public SapforVersion_json(String version_in, String description_in) {
|
||||
version = version_in;
|
||||
description = description_in;
|
||||
@@ -21,11 +28,25 @@ public class SapforVersion_json implements Serializable {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return Home.getName()+ " : "+ Utils.Brackets(description);
|
||||
return Home.getName() + " : " + Utils.Brackets(description);
|
||||
}
|
||||
public File Home = null;
|
||||
public void initHome(File configurationRoot) {
|
||||
public void init(File configurationRoot) {
|
||||
String relativePath = Global.isWindows ? Utils.toW(version) : version;
|
||||
Home = Paths.get(configurationRoot.getAbsolutePath(), relativePath).toFile();
|
||||
files = new Vector<>();
|
||||
//--
|
||||
File[] files_ = Home.listFiles();
|
||||
if (files_ != null) {
|
||||
for (File file: files_){
|
||||
if (file.isFile()) {
|
||||
DBProjectFile dbProjectFile = new DBProjectFile();
|
||||
dbProjectFile.file = file;
|
||||
dbProjectFile.AutoDetectProperties();
|
||||
if (dbProjectFile.fileType.equals(FileType.forbidden)) {
|
||||
files.add(dbProjectFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
public class SapforTask extends DBObject {
|
||||
//------------------------------------>>
|
||||
@@ -50,6 +52,45 @@ public class SapforTask extends DBObject {
|
||||
//-----------
|
||||
public SapforTask() {
|
||||
}
|
||||
/*
|
||||
public static Vector<DefaultMutableTreeNode> getTaskConfigurationDescription(SapforTask task) {
|
||||
Vector<DefaultMutableTreeNode> res = new Vector<>();
|
||||
DefaultMutableTreeNode codesNode = new DefaultMutableTreeNode("Проходы");
|
||||
Vector<String> codes = new Vector<>(Arrays.asList(task.codes.split(" ")));
|
||||
for (String code_s : codes)
|
||||
codesNode.add(new DefaultMutableTreeNode(PassCode_2021.valueOf(code_s).getDescription()));
|
||||
res.add(codesNode);
|
||||
DefaultMutableTreeNode flagsNode = new DefaultMutableTreeNode("Флаги");
|
||||
flagsNode.add(new DefaultMutableTreeNode(task.flags));
|
||||
res.add(flagsNode);
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
public DefaultMutableTreeNode getVersionsTree(File configurationRoot) {
|
||||
DefaultMutableTreeNode root = null;
|
||||
DefaultMutableTreeNode child = null;
|
||||
DefaultMutableTreeNode parent = null;
|
||||
//--
|
||||
for (SapforVersion_json version_json : versions) {
|
||||
version_json.init(configurationRoot);
|
||||
child = new DefaultMutableTreeNode(version_json);
|
||||
if (parent == null) {
|
||||
root = child;
|
||||
parent = child;
|
||||
} else {
|
||||
parent.add(child);
|
||||
parent = child;
|
||||
}
|
||||
}
|
||||
if (parent != null) {
|
||||
for (SapforVersion_json version_json : variants) {
|
||||
version_json.init(configurationRoot);
|
||||
parent.add(new DefaultMutableTreeNode(version_json));
|
||||
}
|
||||
}
|
||||
//--
|
||||
return root;
|
||||
}
|
||||
public void Reset() {
|
||||
state = TaskState.Inactive;
|
||||
versions.clear();
|
||||
|
||||
@@ -2,81 +2,18 @@ package SapforTestingSystem.SapforTasksPackage;
|
||||
import Common.Constants;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.Files.FileType;
|
||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||
import SapforTestingSystem.Json.SapforVersion_json;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class SapforTasksPackageInterface {
|
||||
public static File getPackageArchive(SapforTasksPackage package_in) {
|
||||
return new File(Global.SapforPackagesDirectory, package_in.id + ".zip");
|
||||
}
|
||||
public static Vector<DBProjectFile> getProjectFiles(String dir_in) {
|
||||
Vector<DBProjectFile> res = new Vector<>();
|
||||
//получить список файлов которые могут быть файлами проекта в заданной папке
|
||||
//гарантированно нет вложенных.
|
||||
File dir = new File(dir_in);
|
||||
File[] files = dir.listFiles();
|
||||
//-
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
DBProjectFile projectFile = new DBProjectFile();
|
||||
projectFile.file = file;
|
||||
projectFile.AutoDetectProperties();
|
||||
if (!projectFile.fileType.equals(FileType.forbidden)) {
|
||||
res.add(projectFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public static Vector<DefaultMutableTreeNode> getTaskConfigurationDescription(SapforTask task) {
|
||||
Vector<DefaultMutableTreeNode> res = new Vector<>();
|
||||
DefaultMutableTreeNode codesNode = new DefaultMutableTreeNode("Проходы");
|
||||
Vector<String> codes = new Vector<>(Arrays.asList(task.codes.split(" ")));
|
||||
for (String code_s : codes)
|
||||
codesNode.add(new DefaultMutableTreeNode(PassCode_2021.valueOf(code_s).getDescription()));
|
||||
res.add(codesNode);
|
||||
DefaultMutableTreeNode flagsNode = new DefaultMutableTreeNode("Флаги");
|
||||
flagsNode.add(new DefaultMutableTreeNode(task.flags));
|
||||
res.add(flagsNode);
|
||||
return res;
|
||||
}
|
||||
public static DefaultMutableTreeNode getTaskVersionsTree(File configurationRoot, SapforTask task) {
|
||||
DefaultMutableTreeNode root = null;
|
||||
DefaultMutableTreeNode child = null;
|
||||
DefaultMutableTreeNode parent = null;
|
||||
//--
|
||||
for (SapforVersion_json version_json : task.versions) {
|
||||
version_json.initHome(configurationRoot);
|
||||
child = new DefaultMutableTreeNode(version_json);
|
||||
if (parent == null) {
|
||||
root = child;
|
||||
parent = child;
|
||||
} else {
|
||||
parent.add(child);
|
||||
parent = child;
|
||||
}
|
||||
}
|
||||
if (parent != null) {
|
||||
for (SapforVersion_json version_json : task.variants) {
|
||||
version_json.initHome(configurationRoot);
|
||||
parent.add(new DefaultMutableTreeNode(version_json));
|
||||
}
|
||||
}
|
||||
//--
|
||||
return root;
|
||||
}
|
||||
public static DefaultMutableTreeNode getTreeRoot(SapforTasksPackage package_in) {
|
||||
|
||||
SapforTasksResults_json results_json = getLocalResults(package_in);
|
||||
@@ -100,8 +37,7 @@ public class SapforTasksPackageInterface {
|
||||
*/
|
||||
DefaultMutableTreeNode taskNode = new DefaultMutableTreeNode(task.test_description);
|
||||
//--
|
||||
taskNode.add(getTaskVersionsTree(
|
||||
new File(getLocalWorkspace(package_in), configuration_id), task));
|
||||
taskNode.add(task.getVersionsTree(new File(getLocalWorkspace(package_in), configuration_id)));
|
||||
//--
|
||||
groupNode.add(taskNode);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package SapforTestingSystem.SapforTasksPackage;
|
||||
import Common.Current;
|
||||
import Common.UI.Trees.DataTree;
|
||||
import Common.UI.UI;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import SapforTestingSystem.Json.SapforVersion_json;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.io.File;
|
||||
public class SapforTasksPackageTree extends DataTree {
|
||||
Current current;
|
||||
public SapforTasksPackageTree(DefaultMutableTreeNode root_in, Current current_in) {
|
||||
@@ -30,18 +28,11 @@ public class SapforTasksPackageTree extends DataTree {
|
||||
public void SelectionAction(TreePath e) {
|
||||
System.out.println("Select");
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastPathComponent();
|
||||
Current.set(Current.ProjectNode, node);
|
||||
// Current.set(Current.ProjectNode, node);
|
||||
Object o = node.getUserObject();
|
||||
if (o instanceof File) {
|
||||
Current.set(Current.SelectedDirectory, o);
|
||||
Current.set(Current.SelectedFile, null);
|
||||
UI.getMainWindow().getProjectWindow().ShowNoSelectedFile();
|
||||
} else if (o instanceof DBProjectFile) {
|
||||
Current.set(Current.SelectedFile, o);
|
||||
File file = ((DBProjectFile) o).file;
|
||||
Current.set(Current.SelectedDirectory, file.getParentFile());
|
||||
UI.getMainWindow().getProjectWindow().ShowSelectedFile();
|
||||
if (o instanceof SapforVersion_json) {
|
||||
Current.set(current, o);
|
||||
System.out.println(((SapforVersion_json)o).Home);
|
||||
}
|
||||
UI.getMainWindow().getProjectWindow().ShowSelectedDirectory();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user