X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FGraphExplorerImpl.java;h=df4860d42145551c2fd59c428ae7c749763a5a3d;hp=0168ad864ae5e98258498d76fef7f04f42ee4282;hb=75dc26dacf421e7027e959643963af1efdf10986;hpb=b885083762a43ec97162a5f77df4fd5f85e28979 diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java index 0168ad864..df4860d42 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java @@ -1552,10 +1552,12 @@ 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); - resetSelection(); - selectionProvider.firePostSelection(selectionProvider.getSelection()); + resetSelectionFromWidgetAndFirePostSelection(true); })); // This listener takes care of updating the set of currently selected @@ -1578,12 +1580,32 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph }); } - private void resetSelection() { - final ISelection selection = getWidgetSelection(); + /** + * @return the new selection if it was different from the old selection in + * {@link #selectionProvider} + */ + private ISelection resetSelectionFromWidget() { + ISelection widgetSelection = getWidgetSelection(); // System.out.println("resetSelection()"); // System.out.println(" provider selection: " + selectionProvider.getSelection()); -// System.out.println(" widget selection: " + selection); - selectionProvider.setAndFireNonEqualSelection(selection); +// 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; } protected void setDefaultProcessors() { @@ -2300,7 +2322,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph // System.out.println("MODCOUNT: " + modCount + " vs. " + count); if (modCount != count) return; - resetSelection(); + resetSelectionFromWidgetAndFirePostSelection(false); } }); }