]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/ExpandNodeHandler.java
DefaultMouseListener was added twice in GraphExplorerComposite
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / ExpandNodeHandler.java
index b0e75e538d79af65483881b0c9133d2adc4144cd..9ad34737ebed0bbd4c87de96eea83b139f5367cb 100644 (file)
@@ -1,14 +1,12 @@
 package org.simantics.modeling.ui;
 
 import java.util.Arrays;
-import java.util.Comparator;
 
 import org.simantics.browsing.ui.BuiltinKeys;
 import org.simantics.browsing.ui.GraphExplorer;
 import org.simantics.browsing.ui.NodeContext;
 import org.simantics.browsing.ui.PrimitiveQueryProcessor;
 import org.simantics.browsing.ui.common.processors.IsExpandedProcessor;
-import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.SelectionHints;
 import org.simantics.ui.DoubleClickEvent;
@@ -27,25 +25,20 @@ public class ExpandNodeHandler implements IDoubleClickAction {
 
     @Override
     public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {
-        ReadGraph g = e.getGraph();
-        final NodeContext node = ISelectionUtils.getSinglePossibleKey(e.getResource(), SelectionHints.KEY_MAIN, NodeContext.class);
+        Object selection = e.getResource();
+        NodeContext node = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, NodeContext.class);
         if (node == null)
             return;
 
         Object widget = e.getHintContext().getHint(IWorkbenchActionHints.KEY_WIDGET);
         if (!(widget instanceof GraphExplorer))
             return;
-        final GraphExplorer explorer = (GraphExplorer) widget;
+        GraphExplorer explorer = (GraphExplorer) widget;
 
-        EditorAdapter[] editorAdapters = EditorRegistry.getInstance().getAdaptersFor(g, node);
-
-        Arrays.sort(editorAdapters, new Comparator<EditorAdapter>() {
-            @Override
-            public int compare(EditorAdapter o1, EditorAdapter o2) {
-                // Sort in descending priority order
-                return -(o1.getPriority() - o2.getPriority());
-            }
-        });
+        // Get adapters in descending priority order
+        EditorAdapter[] editorAdapters = EditorRegistry.getInstance().getAdaptersFor(e.getGraph(), selection);
+        if (editorAdapters.length > 1)
+            Arrays.sort(editorAdapters, (o1,o2) -> -(o1.getPriority() - o2.getPriority()));
 
         // If editor selection is unanimous, use the editor. Otherwise just expand/collapse the clicked node.
         if (editorAdapters.length == 0) {
@@ -57,7 +50,7 @@ public class ExpandNodeHandler implements IDoubleClickAction {
         }
     }
 
-    private IPriorityAction expandAction(final GraphExplorer explorer, final NodeContext node) {
+    private IPriorityAction expandAction(GraphExplorer explorer, NodeContext node) {
         return new PriorityAction(100) {
             @Override
             public void run() {