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=0168ad864ae5e98258498d76fef7f04f42ee4282;hp=e90ae5eeecf78dee9d9bd0f6a74084e116d83af9;hb=dfd710b04c7d7cdfab7747ba9a650b2cdc650092;hpb=9cfc6c61008c1b6b278bac6c8585df478dddf55f 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 e90ae5eee..0168ad864 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 @@ -173,8 +173,6 @@ import org.simantics.utils.ui.SWTUtils; import org.simantics.utils.ui.jface.BasePostSelectionProvider; import org.simantics.utils.ui.widgets.VetoingEventHandler; import org.simantics.utils.ui.workbench.WorkbenchUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; @@ -187,8 +185,6 @@ import gnu.trove.set.hash.THashSet; */ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, GraphExplorer /*, IPostSelectionProvider*/ { - private static final Logger LOGGER = LoggerFactory.getLogger(GraphExplorerImpl.class); - private static class GraphExplorerPostSelectionProvider implements IPostSelectionProvider { private GraphExplorerImpl ge; @@ -1556,16 +1552,10 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph }); OpenStrategy os = new OpenStrategy(tree); - os.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { - ISelection s = resetSelectionFromWidget(); - if (s != null) { - LOGGER.trace("Fire selection change: {}", s); - selectionProvider.fireSelection(s); - } - })); os.addPostSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { - LOGGER.trace("Fire post-selection change: {}", selectionProvider.getSelection()); - resetSelectionFromWidgetAndFirePostSelection(true); + //System.out.println("OPENSTRATEGY: post selection changed: " + e); + resetSelection(); + selectionProvider.firePostSelection(selectionProvider.getSelection()); })); // This listener takes care of updating the set of currently selected @@ -1588,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() { @@ -2330,7 +2300,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph // System.out.println("MODCOUNT: " + modCount + " vs. " + count); if (modCount != count) return; - resetSelectionFromWidgetAndFirePostSelection(false); + resetSelection(); } }); }