--- a/tool/src/GUI/swingUtils.java
+++ b/tool/src/GUI/swingUtils.java
@@ -20,6 +20,7 @@
import javax.swing.*;
import javax.swing.text.Element;
import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import script.RunPlugins;
@@ -125,14 +126,16 @@
* The new node contains the details about a person
* @param root the parent of the new node
* @param person the object that will be used to populate the new node
- */
- static public void addNodePerson(TreeNodeSPDX root, Person person){
+ * @return The node with the person details
+ */
+ static public TreeNodeSPDX addNodePerson(TreeNodeSPDX root, Person person){
TreeNodeSPDX nodePerson =
createNodeChild(person.getTitle(),root);
// add the object
nodePerson.nodeType = NodeType.person;
nodePerson.id = person.getTitle();
nodePerson.setUserObject(person);
+ return nodePerson;
}
@@ -467,19 +470,30 @@
JTree m_tree = core.studio.getTree();
TreeSelectionModel model = m_tree.getSelectionModel();
TreePath path;
-// if(selectedNode.getChildCount()==0){
- path = new TreePath(selectedNode.getPath());
-// } else{
-// TreeNodeSPDX childNode = (TreeNodeSPDX) selectedNode.getChildAt(0);
-// path = new TreePath(childNode.getPath());
-// }
-
+
+ // we first select one of the children to ensure it gets expanded
+ TreeNodeSPDX child = (TreeNodeSPDX) selectedNode.getFirstChild();
+ if(child != null){
+ path = new TreePath(child.getPath());
+ // now out tree will expand the first child
model.addSelectionPath(path);
m_tree.setExpandsSelectedPaths(true);
m_tree.setSelectionPath(path);
- m_tree.scrollPathToVisible(path);
- }
- }
+ m_tree.scrollPathToVisible(path);
+ }
+
+ // second wave
+ path = new TreePath(selectedNode.getPath());
+ // what we really wanted is to highligh the father, so, go back!
+ model.addSelectionPath(path);
+ m_tree.setExpandsSelectedPaths(true);
+ m_tree.setSelectionPath(path);
+ m_tree.scrollPathToVisible(path);
+ }
+ }
+
+
+
/**
* Something changed on the disk, reload everything from start