--- a/tool/src/GUI/swingUtils.java
+++ b/tool/src/GUI/swingUtils.java
@@ -214,10 +214,27 @@
return node;
}
+
+
+ /**
+ * Add the basic root node to a treeview
+ * @param tree The treeview that we want to target
+ */
+ public static void nodeAddRoot(JTree tree){
+ // tree hook
+ tree.setCellRenderer(new TreeRenderer());
+ //Create the nodes.
+ TreeNodeSPDX nodeRoot =
+ new TreeNodeSPDX("root");
+ nodeRoot.id = "Root";
+ DefaultTreeModel treeModel = new DefaultTreeModel(nodeRoot);
+ tree.setModel(treeModel);
+ }
+
+
/**
* List all the indexed SPDX documents on the tree view
* @param tree where all items are listed
- * @param spdxList Array with all SPDXfile objects to be listed
*/
public static void populateTree(JTree tree){
// tree hook
@@ -471,8 +488,8 @@
public static void refreshAll(JTree tree, String UID){
// find all components inside our common library
File baseFolder = new File(".");
- core.components = actions.findSPDX(new File(baseFolder,
- is.library));
+// core.components = actions.findSPDX(new File(baseFolder,
+// is.library));
// now find our products
core.products = actions.findSPDX(new File(baseFolder,
is.products));
@@ -514,6 +531,8 @@
// All done, let's leave
log.write(is.INFO, Messages.TreeNodeChanged, node.getUID());
}
+
+
/////////////////////////////////////////////////////////////////////////
// Things related to show the SPDX text on the text area
@@ -717,5 +736,18 @@
return null;
}
+ /**
+ * Returns the node that is the root of a given treeview
+ * @param tree JTree object where all nodes are placed
+ * @return the root node or null if it does not exist
+ */
+ public static TreeNodeSPDX getRootNode(JTree tree){
+ // avoid empty null objects when there is nothing on the tree
+ if(tree.getModel().getRoot()==null){
+ return null;
+ }
+ TreeNodeSPDX nodeRoot = (TreeNodeSPDX) tree.getModel().getRoot();
+ return nodeRoot;
+ }
}