--- a/tool/src/GUI/TreeNodeSPDX.java
+++ b/tool/src/GUI/TreeNodeSPDX.java
@@ -21,6 +21,7 @@
package GUI;
import java.io.File;
+import java.util.ArrayList;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -35,17 +36,29 @@
public String
id = "";
+ private String
+ title = "";
+
+ private int
+ // counts the number of relevant childs
+ counter = 0;
+
// in case we want to run a file with a script
public File
scriptFile = null,
scriptFolder = null;
// if a file with a script was added, which method should be run?
public String scriptMethod;
+ public ArrayList<String[]> scriptParameters = new ArrayList();
- public Icon icon = null;
+ public Icon
+ icon = null,
+ iconWhenSelected = null;
+
public TreeNodeSPDX(String library) {
super(library);
+ title = library;
}
// @Override
@@ -55,7 +68,33 @@
public TreeNodeSPDX(TreeNodeSPDX root) {
super(root);
+ title = root.toString();
}
+
+ @Override
+ public String toString(){
+ String result = getTitle();
+ if(counter > 0){
+ result += " (" + counter + ")";
+ }
+ return result;
+ }
+
+ public String getTitle() {
+ if(title == null){
+ title = id;
+ }
+ if(title.isEmpty()){
+ title = id;
+ }
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+
/**
* Given a specific tree node, generate a unique ID
@@ -81,4 +120,23 @@
public void setIcon(String what){
icon = new ImageIcon(core.getIcon(what).getAbsolutePath());
}
+
+ /**
+ * Defines a new Icon for this node
+ * @param what the icon file name that is located under the "icons" folder
+ */
+ public void setIconWhenSelected(String what){
+ iconWhenSelected = new ImageIcon(core.getIcon(what).getAbsolutePath());
+ }
+
+ /**
+ * Sets the number of relevant children on this node
+ * @param counter a positive, decimal value
+ */
+ public void setCounter(int counter) {
+ this.counter = counter;
+ }
+
+
+
}