svn commit: r13567 - trunk/src_new/org/argouml/ui/explorer

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-09-17 16:36:43-0700
New Revision: 13567

Modified:
   trunk/src_new/org/argouml/ui/explorer/ExplorerTree.java
   trunk/src_new/org/argouml/ui/explorer/ExplorerTreeModel.java

Log:
Strengthen typing, eliminate duplicate code.

First pass at having tree expand to show current target.

Modified: trunk/src_new/org/argouml/ui/explorer/ExplorerTree.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/ExplorerTree.java?view=diff&rev=13567&p1=trunk/src_new/org/argouml/ui/explorer/ExplorerTree.java&p2=trunk/src_new/org/argouml/ui/explorer/ExplorerTree.java&r1=13566&r2=13567
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/ExplorerTree.java	(original)
+++ trunk/src_new/org/argouml/ui/explorer/ExplorerTree.java	2007-09-17 16:36:43-0700
@@ -26,11 +26,13 @@
 
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import javax.swing.JPopupMenu;
 import javax.swing.JTree;
@@ -40,7 +42,6 @@
 import javax.swing.event.TreeSelectionListener;
 import javax.swing.event.TreeWillExpandListener;
 import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeModel;
 import javax.swing.tree.TreePath;
 
 import org.argouml.kernel.Project;
@@ -72,7 +73,7 @@
     private boolean updatingSelection;
 
     /**
-     * Prevents target event cycles between this and the Targetmanager
+     * Prevents target event cycles between this and the TargetManager
      * for tree selection events.
      */
     private boolean updatingSelectionViaTreeSelection;
@@ -82,14 +83,6 @@
      */
     public ExplorerTree() {
         super();
-
-        // issue 2261: we must add this project property change first
-        // in order to receive the new project event after
-        // the ExplorerEventAdaptor
-        //(which is initialised in the ExplorerTreeModel).
-        ProjectManager.getManager()
-            .addPropertyChangeListener(new ProjectPropertyChangeListener());
-
         this.setModel(new ExplorerTreeModel(ProjectManager.getManager()
 			                    .getCurrentProject(), this));
         this.addMouseListener(new ExplorerMouseListener(this));
@@ -233,12 +226,12 @@
          * @see javax.swing.event.TreeWillExpandListener#treeWillExpand(javax.swing.event.TreeExpansionEvent)
          */
         public void treeWillExpand(TreeExpansionEvent tee) {
+            // TODO: This should not need to know about ProjectSettings - tfm
             Project p = ProjectManager.getManager().getCurrentProject();
             ProjectSettings ps = p.getProjectSettings();
             setShowStereotype(ps.getShowStereotypesValue());
 
             if (getModel() instanceof ExplorerTreeModel) {
-
                 ((ExplorerTreeModel) getModel()).updateChildren(tee.getPath());
             }
         }
@@ -287,28 +280,70 @@
      */
     private void setSelection(Object[] targets) {
         updatingSelectionViaTreeSelection = true;
-
         this.clearSelection();
-        int rows = getRowCount();
-        for (int i = 0; i < targets.length; i++) {
-            Object target = targets[i];
-            if (target instanceof Fig) {
-                target = ((Fig) target).getOwner();
-            }
-            for (int j = 0; j < rows; j++) {
-                Object rowItem =
-		    ((DefaultMutableTreeNode) getPathForRow(j)
-		            .getLastPathComponent()).getUserObject();
-                if (rowItem == target) {
-                    this.addSelectionRow(j);
+        addTargetsInternal(targets);
+        updatingSelectionViaTreeSelection = false;
+    }
+
+    private void addTargetsInternal(Object[] addedTargets) {
+        if (addedTargets.length < 1) {
+            return;
+        }
+        Set targets = new HashSet();
+        for (Object t : addedTargets) {
+            if (t instanceof Fig) {
+                targets.add(((Fig) t).getOwner());
+            } else {
+                targets.add(t);
+            }
+        }
+
+        ExplorerTreeModel model = (ExplorerTreeModel) getModel();
+        ExplorerTreeNode root = (ExplorerTreeNode) model.getRoot();
+        
+        
+        selectChildren(model, root, targets);
+    
+        int[] selectedRows = getSelectionRows();
+        if (selectedRows != null && selectedRows.length > 0) {
+            // TODO: This only works if the item is visible
+            // (all its parents are expanded)
+            // getExpandedDescendants, makeVisible
+            makeVisible(getPathForRow(selectedRows[0]));
+            scrollRowToVisible(selectedRows[0]);
+        }
+    }
+
+    /*
+     * Perform recursive search of subtree rooted at 'node', selecting all nodes which 
+     * have a userObject matching one of our targets.
+     */
+    private void selectChildren(ExplorerTreeModel model, ExplorerTreeNode node, Set targets) {
+        if (targets.isEmpty()) {
+            return;
+        }
+        Object nodeObject = node.getUserObject();
+        if (nodeObject != null) {
+            for (Object t : targets) {
+                if (t == nodeObject) {
+                    updatingSelectionViaTreeSelection = true;
+                    addSelectionPath(new TreePath(node.getPath()));
+                    updatingSelectionViaTreeSelection = false;
+                    // target may appear multiple places in the tree, so 
+                    // we don't stop here (but it's expensive to search
+                    // the whole tree) - tfm - 20070904
+//                  targets.remove(t);
+//                  break;
                 }
             }
         }
-        updatingSelectionViaTreeSelection = false;
 
-        if (this.getSelectionCount() > 0) {
-            scrollRowToVisible(this.getSelectionRows()[0]);
+        model.updateChildren(new TreePath(node.getPath()));
+        Enumeration e = node.children();
+        while (e.hasMoreElements()) {
+            selectChildren(model, (ExplorerTreeNode) e.nextElement(), targets);
         }
+
     }
 
     /**
@@ -438,30 +473,8 @@
         public void targetAdded(TargetEvent e) {
             if (!updatingSelection) {
                 updatingSelection = true;
-                Object[] targets = e.getAddedTargets();
-
-                int rows = getRowCount();
-                for (int i = 0; i < targets.length; i++) {
-                    Object target = targets[i];
-                    if (target instanceof Fig) {
-                        target = ((Fig) target).getOwner();
-                    }
-                    for (int j = 0; j < rows; j++) {
-                        Object rowItem =
-                            ((DefaultMutableTreeNode)
-                                    getPathForRow(j).getLastPathComponent())
-                            .getUserObject();
-                        if (rowItem == target) {
-                            updatingSelectionViaTreeSelection = true;
-                            addSelectionRow(j);
-                            updatingSelectionViaTreeSelection = false;
-                        }
-                    }
-                }
-
-                if (getSelectionCount() > 0) {
-                    scrollRowToVisible(getSelectionRows()[0]);
-                }
+                Object[] addedTargets = e.getAddedTargets();
+                addTargetsInternal(addedTargets);
                 updatingSelection = false;
             }
             // setTargets(e.getNewTargets());
@@ -514,33 +527,6 @@
         }
     }
 
-    class ProjectPropertyChangeListener implements PropertyChangeListener {
-
-        /**
-         * @see java.beans.PropertyChangeListener#propertyChange(
-         *         java.beans.PropertyChangeEvent)
-         *
-         * Listens to events coming from the project manager,
-         * i.e. when the current project changes,
-         * in order to expand the root node by default.
-         */
-        public void propertyChange(java.beans.PropertyChangeEvent pce) {
-
-            // project events
-            if (pce.getPropertyName()
-                    .equals(ProjectManager.CURRENT_PROJECT_PROPERTY_NAME)) {
-
-                TreeModel model = getModel();
-
-                if (model != null && model.getRoot() != null) {
-
-                    expandPath(getPathForRow(0));
-
-                }
-            }
-        }
-    }
-
 
     /**
      * The UID.

Modified: trunk/src_new/org/argouml/ui/explorer/ExplorerTreeModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/ExplorerTreeModel.java?view=diff&rev=13567&p1=trunk/src_new/org/argouml/ui/explorer/ExplorerTreeModel.java&p2=trunk/src_new/org/argouml/ui/explorer/ExplorerTreeModel.java&r1=13566&r2=13567
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/ExplorerTreeModel.java	(original)
+++ trunk/src_new/org/argouml/ui/explorer/ExplorerTreeModel.java	2007-09-17 16:36:43-0700
@@ -27,6 +27,7 @@
 import java.awt.EventQueue;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -38,7 +39,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Vector;
 
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
@@ -75,13 +75,13 @@
      * {@link org.argouml.ui.explorer.rules.PerspectiveRule PerspectiveRules},
      * that determine the tree view.
      */
-    private Object[] rules;
+    private List<PerspectiveRule> rules;
 
     /**
      * a map used to resolve model elements to tree nodes when determining
      * what effect a model event will have on the tree.
      */
-    private Map modelElementMap;
+    private Map<Object, Set<ExplorerTreeNode>> modelElementMap;
 
     /**
      * the global order for siblings in the tree.
@@ -91,7 +91,7 @@
     /**
      * The children currently being updated.
      */
-    private Vector updatingChildren = new Vector();
+    private List<ExplorerTreeNode> updatingChildren = new ArrayList<ExplorerTreeNode>();
 
     /**
      * A Runnable object that when executed does update some
@@ -109,7 +109,8 @@
 	/**
 	 * The set of nodes pending being updated.
 	 */
-	private LinkedList pendingUpdates = new LinkedList();
+	private LinkedList<ExplorerTreeNode> pendingUpdates = 
+	    new LinkedList<ExplorerTreeNode>();
 
 	/**
 	 * Is this object currently waiting to be run.
@@ -164,7 +165,7 @@
 		ExplorerTreeNode node = null;
 		synchronized (this) {
 		    if (!pendingUpdates.isEmpty()) {
-			node = (ExplorerTreeNode) pendingUpdates.removeFirst();
+			node = pendingUpdates.removeFirst();
 			node.setPending(false);
 		    } else {
 			done = true;
@@ -179,6 +180,9 @@
 	    if (!done) {
 		schedule();
             } else {
+                // TODO: This seems like a brute force workaround (and a very
+                // indirect one at that).  It appears to be needed though until
+                // we fix the problem properly. - tfm 20070904
                 /* This solves issue 2287. */
                 tree.refreshSelection();
             }
@@ -197,7 +201,7 @@
         tree = myTree;
 	setRoot(new ExplorerTreeNode(root, this));
 	setAsksAllowsChildren(false);
-	modelElementMap = new HashMap();
+	modelElementMap = new HashMap<Object, Set<ExplorerTreeNode>>();
 
 	ExplorerEventAdaptor.getInstance()
 	    .setTreeModelUMLEventListener(this);
@@ -242,12 +246,7 @@
      * @see org.argouml.ui.explorer.TreeModelUMLEventListener#modelElementRemoved(java.lang.Object)
      */
     public void modelElementRemoved(Object node) {
-        Collection nodes = this.findNodes(node);
-        Object[] nodesArray = nodes.toArray();
-
-        for (int x = 0; x < nodesArray.length; x++) {
-            ExplorerTreeNode changeNode = (ExplorerTreeNode) nodesArray[x];
-
+        for (ExplorerTreeNode changeNode : findNodes(node)) {
             if (changeNode.getParent() != null) {
                 removeNodeFromParent(changeNode);
             }
@@ -267,17 +266,15 @@
         }
 
 	// This should only be helpful for old garbage collectors.
-	Collection values = modelElementMap.values();
-	Iterator valuesIt = values.iterator();
-	while (valuesIt.hasNext()) {
-	    ((Collection) valuesIt.next()).clear();
+	for (Collection nodes : modelElementMap.values()) {
+	    nodes.clear();
 	}
 	modelElementMap.clear();
 
 	// This is somewhat inconsistent with the design of the constructor
 	// that receives the root object by argument. If this is okay
 	// then there may be no need for a constructor with that argument.
-	modelElementMap = new HashMap();
+	modelElementMap = new HashMap<Object, Set<ExplorerTreeNode>>();
 	Project proj = ProjectManager.getManager().getCurrentProject();
 	ExplorerTreeNode rootNode = new ExplorerTreeNode(proj, this);
 
@@ -307,9 +304,9 @@
 	}
 	updatingChildren.add(node);
 
-	Vector children = reorderChildren(node);
+	List children = reorderChildren(node);
 
-	Vector newChildren = new Vector();
+	List newChildren = new ArrayList();
 	Set deps = new HashSet();
 	collectChildren(modelElement, newChildren, deps);
 
@@ -334,9 +331,9 @@
      * @throws IllegalArgumentException if node has a child that is not a
      *         (descendant of) DefaultMutableTreeNode.
      */
-    private Vector reorderChildren(ExplorerTreeNode node) {
-	Vector children = new Vector();
-	Vector reordered = new Vector();
+    private List<Object> reorderChildren(ExplorerTreeNode node) {
+	List<Object> childUserObjects = new ArrayList<Object>();
+	List<ExplorerTreeNode> reordered = new ArrayList<ExplorerTreeNode>();
 
 	// Enumerate the current children of node to find out which now sorts
 	// in different order, since these must be moved
@@ -344,8 +341,8 @@
 	Object lastObj = null;
 	while (enChld.hasMoreElements()) {
 	    Object child = enChld.nextElement();
-	    if (child instanceof DefaultMutableTreeNode) {
-		Object obj = ((DefaultMutableTreeNode) child).getUserObject();
+	    if (child instanceof ExplorerTreeNode) {
+		Object obj = ((ExplorerTreeNode) child).getUserObject();
 		if (lastObj != null && order.compare(lastObj, obj) > 0) {
 		    /*
 		     * If a node to be moved is currently selected,
@@ -358,24 +355,24 @@
 		     * at a time - tfm
 		     */
 		    if (!tree.isPathSelected(new TreePath(
-                            getPathToRoot((DefaultMutableTreeNode) child)))) {
-			reordered.add(child);
+                            getPathToRoot((ExplorerTreeNode) child)))) {
+			reordered.add((ExplorerTreeNode) child);
 		    } else {
-			DefaultMutableTreeNode prev =
-                                ((DefaultMutableTreeNode) child)
-                                        .getPreviousSibling();
+		        ExplorerTreeNode prev = 
+		            (ExplorerTreeNode) ((ExplorerTreeNode) child)
+                                .getPreviousSibling();
 			while (prev != null
                                 && (order.compare(prev.getUserObject(), obj)
                                         >= 0)) {
 			    reordered.add(prev);
-			    children.removeElementAt(children.size() - 1);
-			    prev = prev.getPreviousSibling();
+			    childUserObjects.remove(childUserObjects.size() - 1);
+			    prev = (ExplorerTreeNode) prev.getPreviousSibling();
 			}
-			children.add(obj);
+			childUserObjects.add(obj);
 			lastObj = obj;
 		    }
 		} else {
-		    children.add(obj);
+		    childUserObjects.add(obj);
 		    lastObj = obj;
 		}
 	    } else {
@@ -384,10 +381,7 @@
 	    }
 	}
 
-        for (int x = 0; x < reordered.size(); x++) {
-	    DefaultMutableTreeNode child =
-		(DefaultMutableTreeNode) reordered.get(x);
-
+	for (ExplorerTreeNode child : reordered) {
 	    // Avoid our deinitialization here
 	    // The node will be added back to the tree again
 	    super.removeNodeFromParent(child);
@@ -395,11 +389,9 @@
 
 	// For each reordered node, find it's new position among the current
 	// children and move it there
-        for (int x = 0; x < reordered.size(); x++) {
-	    DefaultMutableTreeNode child =
-		(DefaultMutableTreeNode) reordered.get(x);
+        for (ExplorerTreeNode child : reordered) {
 	    Object obj = child.getUserObject();
-	    int ip = Collections.binarySearch(children, obj, order);
+	    int ip = Collections.binarySearch(childUserObjects, obj, order);
 
 	    if (ip < 0) {
 		ip = -(ip + 1);
@@ -407,10 +399,10 @@
 
 	    // Avoid our initialization here
 	    super.insertNodeInto(child, node, ip);
-	    children.add(ip, obj);
+	    childUserObjects.add(ip, obj);
 	}
 
-	return children;
+	return childUserObjects;
     }
 
     /**
@@ -441,10 +433,8 @@
 
 	// Collect the current set of objects that should be children to
 	// this node
-        for (int x = 0; x < rules.length; x++) {
-            Collection c = null;
-            Set c2 = null;
-            
+        for (PerspectiveRule rule : rules) {
+
             // TODO: A better implementation would be to batch events into
             // logical groups and update the tree one time for the entire
             // group, synchronizing access to the model repository so that
@@ -452,40 +442,35 @@
             // require doing the updates in a different thread than the
             // event delivery thread to prevent deadlocks, so for right now
             // we protect ourselves with try/catch blocks.
-
+            Collection children = null;
             try {
-                c =
-                    ((PerspectiveRule) rules[x])
-                        .getChildren(modelElement);
+                children = rule.getChildren(modelElement);
             } catch (InvalidElementException e) {
                 LOG.debug("InvalidElementException in ExplorerTree : " 
                         + e.getStackTrace());
             }
+
+	    if (children != null) {
+	        for (Object child : children) {
+		    if (child == null) {
+			LOG.warn("PerspectiveRule " + rule + " wanted to "
+				 + "add null to the explorer tree!");
+		    } else if (!newChildren.contains(child)) {
+			newChildren.add(child);
+		    }
+		}
+	    }
+
             try {
-                c2 =
-                    ((PerspectiveRule) rules[x])
-                        .getDependencies(modelElement);
+                Set dependencies = rule.getDependencies(modelElement);
+                if (dependencies != null) {
+                    deps.addAll(dependencies);
+                }
             } catch (InvalidElementException e) {
                 LOG.debug("InvalidElementException in ExplorerTree : " 
                         + e.getStackTrace());
             }
-            
-	    if (c != null) {
-		Iterator it = c.iterator();
-		while (it.hasNext()) {
-		    Object obj = it.next();
-		    if (obj == null) {
-			LOG.warn("PerspectiveRule " + rules[x] + " wanted to "
-				 + "add null to the explorer tree!");
-		    } else if (!newChildren.contains(obj)) {
-			newChildren.add(obj);
-		    }
-		}
-	    }
 
-	    if (c2 != null) {
-		deps.addAll(c2);
-	    }
         }
 
 	// Order the new children, the dependencies cannot and
@@ -581,10 +566,10 @@
 			       List newChildren) {
 	Set removeObjects = prepareAddRemoveSets(children, newChildren);
 	// Remember that children are not TreeNodes but UserObjects
-	Vector actualNodes = new Vector();
+	List<ExplorerTreeNode> actualNodes = new ArrayList<ExplorerTreeNode>();
 	Enumeration childrenEnum = node.children();
 	while (childrenEnum.hasMoreElements()) {
-	    actualNodes.add(childrenEnum.nextElement());
+	    actualNodes.add((ExplorerTreeNode) childrenEnum.nextElement());
 	}
 
 	int position = 0;
@@ -593,11 +578,11 @@
 	Object firstNew = newNodes.hasNext() ? newNodes.next() : null;
 	while (childNodes.hasNext()) {
 	    Object childObj = childNodes.next();
-	    if (!(childObj instanceof DefaultMutableTreeNode)) {
+	    if (!(childObj instanceof ExplorerTreeNode)) {
 		continue;
 	    }
 
-	    DefaultMutableTreeNode child = (DefaultMutableTreeNode) childObj;
+	    ExplorerTreeNode child = (ExplorerTreeNode) childObj;
 	    Object userObject = child.getUserObject();
 
 	    if (removeObjects.contains(userObject)) {
@@ -628,23 +613,24 @@
     /*
      * @see javax.swing.tree.DefaultTreeModel#insertNodeInto(javax.swing.tree.MutableTreeNode, javax.swing.tree.MutableTreeNode, int)
      */
+    @Override
     public void insertNodeInto(MutableTreeNode newChild,
 			       MutableTreeNode parent, int index) {
 	super.insertNodeInto(newChild, parent, index);
-
-	addNodesToMap(newChild);
+        if (newChild instanceof ExplorerTreeNode) {
+            addNodesToMap((ExplorerTreeNode) newChild);
+        }
     }
 
     /*
      * @see javax.swing.tree.DefaultTreeModel#removeNodeFromParent(javax.swing.tree.MutableTreeNode)
      */
+    @Override
     public void removeNodeFromParent(MutableTreeNode node) {
-	removeNodesFromMap(node);
-
 	if (node instanceof ExplorerTreeNode) {
+	    removeNodesFromMap((ExplorerTreeNode) node);
 	    ((ExplorerTreeNode) node).remove();
 	}
-
 	super.removeNodeFromParent(node);
     }
 
@@ -653,17 +639,13 @@
      *
      * @param node the node to be added
      */
-    private void addNodesToMap(TreeNode node) {
+    private void addNodesToMap(ExplorerTreeNode node) {
 	Enumeration children = node.children();
 	while (children.hasMoreElements()) {
-	    TreeNode child = (TreeNode) children.nextElement();
+	    ExplorerTreeNode child = (ExplorerTreeNode) children.nextElement();
 	    addNodesToMap(child);
 	}
-
-	if (node instanceof DefaultMutableTreeNode) {
-	    DefaultMutableTreeNode mtn = (DefaultMutableTreeNode) node;
-	    addToMap(mtn.getUserObject(), mtn);
-	}
+	addToMap(node.getUserObject(), node);
     }
 
     /**
@@ -671,17 +653,13 @@
      *
      * @param node the given node
      */
-    private void removeNodesFromMap(TreeNode node) {
+    private void removeNodesFromMap(ExplorerTreeNode node) {
 	Enumeration children = node.children();
 	while (children.hasMoreElements()) {
-	    TreeNode child = (TreeNode) children.nextElement();
+	    ExplorerTreeNode child = (ExplorerTreeNode) children.nextElement();
 	    removeNodesFromMap(child);
 	}
-
-	if (node instanceof DefaultMutableTreeNode) {
-	    DefaultMutableTreeNode mtn = (DefaultMutableTreeNode) node;
-	    removeFromMap(mtn.getUserObject(), mtn);
-	}
+	removeFromMap(node.getUserObject(), node);
     }
 
     /**
@@ -692,13 +670,13 @@
      * @param modelElement the modelelement to be added
      * @param node the node to be added
      */
-    private void addToMap(Object modelElement, TreeNode node) {
-	Object value = modelElementMap.get(modelElement);
+    private void addToMap(Object modelElement, ExplorerTreeNode node) {
+	Set<ExplorerTreeNode> nodes = modelElementMap.get(modelElement);
 
-	if (value != null) {
-	    ((Set) value).add(node);
+	if (nodes != null) {
+	    nodes.add(node);
 	} else {
-	    Set nodes = new HashSet();
+	    nodes = new HashSet<ExplorerTreeNode>();
 	    nodes.add(node);
 	    modelElementMap.put(modelElement, nodes);
 	}
@@ -710,13 +688,11 @@
      * @param modelElement the modelelement to be removed
      * @param node the node to be removed
      */
-    private void removeFromMap(Object modelElement, TreeNode node) {
-	Object value = modelElementMap.get(modelElement);
-
-	if (value != null) {
-	    Set nodeset = (Set) value;
-	    nodeset.remove(node);
-	    if (nodeset.isEmpty()) {
+    private void removeFromMap(Object modelElement, ExplorerTreeNode node) {
+	Collection<ExplorerTreeNode> nodes = modelElementMap.get(modelElement);
+	if (nodes != null) {
+	    nodes.remove(node);
+	    if (nodes.isEmpty()) {
                 modelElementMap.remove(modelElement);
             }
 	}
@@ -728,8 +704,8 @@
      * @param modelElement the given modelelement
      * @return the nodes sought
      */
-    private Collection findNodes(Object modelElement) {
-	Collection nodes = (Collection) modelElementMap.get(modelElement);
+    private Collection<ExplorerTreeNode> findNodes(Object modelElement) {
+	Collection<ExplorerTreeNode> nodes = modelElementMap.get(modelElement);
 
 	if (nodes == null) {
 	    return Collections.EMPTY_LIST;
@@ -744,12 +720,13 @@
      */
     public void itemStateChanged(ItemEvent e) {
 	if (e.getSource() instanceof PerspectiveComboBox) {
-            rules = ((ExplorerPerspective) e.getItem()).getRulesArray();
+            rules = ((ExplorerPerspective) e.getItem()).getList();
 	} else { // it is the combo for "order"
 	    order = (Comparator) e.getItem();
 	}
 	structureChanged();
-	tree.expandPath(tree.getPathForRow(0));
+	// TODO: temporary - let tree expand implicitly - tfm
+	tree.expandPath(tree.getPathForRow(1));
     }
 
     /**
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.