]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Revert "Fixed GraphExplorerImpl to set selection upon keyboard-based selection"
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 13 Dec 2018 11:45:53 +0000 (13:45 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 13 Dec 2018 11:45:53 +0000 (13:45 +0200)
This reverts commit 75dc26dacf421e7027e959643963af1efdf10986.

bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java

index df4860d42145551c2fd59c428ae7c749763a5a3d..0168ad864ae5e98258498d76fef7f04f42ee4282 100644 (file)
@@ -1552,12 +1552,10 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
         });
 
         OpenStrategy os = new OpenStrategy(tree);
-        os.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
-            resetSelectionFromWidget();
-        }));
         os.addPostSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
             //System.out.println("OPENSTRATEGY: post selection changed: " + e);
-            resetSelectionFromWidgetAndFirePostSelection(true);
+            resetSelection();
+            selectionProvider.firePostSelection(selectionProvider.getSelection());
         }));
 
         // This listener takes care of updating the set of currently selected
@@ -1580,32 +1578,12 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
         });
     }
 
-    /**
-     * @return the new selection if it was different from the old selection in
-     *         {@link #selectionProvider}
-     */
-    private ISelection resetSelectionFromWidget() {
-        ISelection widgetSelection = getWidgetSelection();
+    private void resetSelection() {
+        final ISelection selection = getWidgetSelection();
 //        System.out.println("resetSelection()");
 //        System.out.println("    provider selection: " + selectionProvider.getSelection());
-//        System.out.println("    widget selection:   " + widgetSelection);
-        boolean equals = selectionProvider.selectionEquals(widgetSelection);
-        selectionProvider.setSelectionWithoutFiring(widgetSelection);
-        return equals ? null : widgetSelection;
-    }
-
-    /**
-     * @return the new selection if it was different from the old selection in
-     *         {@link #selectionProvider}
-     */
-    private boolean resetSelectionFromWidgetAndFirePostSelection(boolean force) {
-        ISelection s = resetSelectionFromWidget();
-        boolean fire = s != null || force;
-        if (fire) {
-            //System.out.println("FIRING POST-SELECTION: " + selectionProvider.getSelection());
-            selectionProvider.firePostSelection(selectionProvider.getSelection());
-        }
-        return fire;
+//        System.out.println("    widget selection:   " + selection);
+        selectionProvider.setAndFireNonEqualSelection(selection);
     }
 
     protected void setDefaultProcessors() {
@@ -2322,7 +2300,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
 //                    System.out.println("MODCOUNT: " + modCount + " vs. " + count);
                     if (modCount != count)
                         return;
-                    resetSelectionFromWidgetAndFirePostSelection(false);
+                    resetSelection();
                 }
             });
         }