|
a/tool/src/GUI/TreeNodeSPDX.java |
|
b/tool/src/GUI/TreeNodeSPDX.java |
|
... |
|
... |
19 |
*/
|
19 |
*/
|
20 |
|
20 |
|
21 |
package GUI;
|
21 |
package GUI;
|
22 |
|
22 |
|
23 |
import java.io.File;
|
23 |
import java.io.File;
|
|
|
24 |
import java.util.ArrayList;
|
24 |
import javax.swing.Icon;
|
25 |
import javax.swing.Icon;
|
25 |
import javax.swing.ImageIcon;
|
26 |
import javax.swing.ImageIcon;
|
26 |
import javax.swing.tree.DefaultMutableTreeNode;
|
27 |
import javax.swing.tree.DefaultMutableTreeNode;
|
27 |
import main.core;
|
28 |
import main.core;
|
28 |
|
29 |
|
|
... |
|
... |
33 |
nodeType = NodeType.none;
|
34 |
nodeType = NodeType.none;
|
34 |
|
35 |
|
35 |
public String
|
36 |
public String
|
36 |
id = "";
|
37 |
id = "";
|
37 |
|
38 |
|
|
|
39 |
private String
|
|
|
40 |
title = "";
|
|
|
41 |
|
|
|
42 |
private int
|
|
|
43 |
// counts the number of relevant childs
|
|
|
44 |
counter = 0;
|
|
|
45 |
|
38 |
// in case we want to run a file with a script
|
46 |
// in case we want to run a file with a script
|
39 |
public File
|
47 |
public File
|
40 |
scriptFile = null,
|
48 |
scriptFile = null,
|
41 |
scriptFolder = null;
|
49 |
scriptFolder = null;
|
42 |
// if a file with a script was added, which method should be run?
|
50 |
// if a file with a script was added, which method should be run?
|
43 |
public String scriptMethod;
|
51 |
public String scriptMethod;
|
|
|
52 |
public ArrayList<String[]> scriptParameters = new ArrayList();
|
44 |
|
53 |
|
45 |
public Icon icon = null;
|
54 |
public Icon
|
|
|
55 |
icon = null,
|
|
|
56 |
iconWhenSelected = null;
|
|
|
57 |
|
46 |
|
58 |
|
47 |
public TreeNodeSPDX(String library) {
|
59 |
public TreeNodeSPDX(String library) {
|
48 |
super(library);
|
60 |
super(library);
|
|
|
61 |
title = library;
|
49 |
}
|
62 |
}
|
50 |
|
63 |
|
51 |
// @Override
|
64 |
// @Override
|
52 |
// public String toString(){
|
65 |
// public String toString(){
|
53 |
// return "";
|
66 |
// return "";
|
54 |
// }
|
67 |
// }
|
55 |
|
68 |
|
56 |
public TreeNodeSPDX(TreeNodeSPDX root) {
|
69 |
public TreeNodeSPDX(TreeNodeSPDX root) {
|
57 |
super(root);
|
70 |
super(root);
|
|
|
71 |
title = root.toString();
|
58 |
}
|
72 |
}
|
|
|
73 |
|
|
|
74 |
@Override
|
|
|
75 |
public String toString(){
|
|
|
76 |
String result = getTitle();
|
|
|
77 |
if(counter > 0){
|
|
|
78 |
result += " (" + counter + ")";
|
|
|
79 |
}
|
|
|
80 |
return result;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public String getTitle() {
|
|
|
84 |
if(title == null){
|
|
|
85 |
title = id;
|
|
|
86 |
}
|
|
|
87 |
if(title.isEmpty()){
|
|
|
88 |
title = id;
|
|
|
89 |
}
|
|
|
90 |
return title;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
public void setTitle(String title) {
|
|
|
94 |
this.title = title;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
|
59 |
|
98 |
|
60 |
/**
|
99 |
/**
|
61 |
* Given a specific tree node, generate a unique ID
|
100 |
* Given a specific tree node, generate a unique ID
|
62 |
* @param node the node from where start to calculate the ID string
|
101 |
* @param node the node from where start to calculate the ID string
|
63 |
* @return a unique ID based on the parent nodes of this entry
|
102 |
* @return a unique ID based on the parent nodes of this entry
|
|
... |
|
... |
79 |
* @param what the icon file name that is located under the "icons" folder
|
118 |
* @param what the icon file name that is located under the "icons" folder
|
80 |
*/
|
119 |
*/
|
81 |
public void setIcon(String what){
|
120 |
public void setIcon(String what){
|
82 |
icon = new ImageIcon(core.getIcon(what).getAbsolutePath());
|
121 |
icon = new ImageIcon(core.getIcon(what).getAbsolutePath());
|
83 |
}
|
122 |
}
|
|
|
123 |
|
|
|
124 |
/**
|
|
|
125 |
* Defines a new Icon for this node
|
|
|
126 |
* @param what the icon file name that is located under the "icons" folder
|
|
|
127 |
*/
|
|
|
128 |
public void setIconWhenSelected(String what){
|
|
|
129 |
iconWhenSelected = new ImageIcon(core.getIcon(what).getAbsolutePath());
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
/**
|
|
|
133 |
* Sets the number of relevant children on this node
|
|
|
134 |
* @param counter a positive, decimal value
|
|
|
135 |
*/
|
|
|
136 |
public void setCounter(int counter) {
|
|
|
137 |
this.counter = counter;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
84 |
}
|
142 |
}
|