Fire selection change events on every selection change 71/2471/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 19 Nov 2018 10:23:10 +0000 (12:23 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 20 Nov 2018 06:43:13 +0000 (08:43 +0200)
Also added trace-level logging for selection firing for debugging
purposes.

gitlab #184

Change-Id: Ic499e83b87cc0939c45976ca1f7bda03d428ebd6

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

index df4860d42145551c2fd59c428ae7c749763a5a3d..e90ae5eeecf78dee9d9bd0f6a74084e116d83af9 100644 (file)
@@ -173,6 +173,8 @@ 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;
@@ -185,6 +187,8 @@ 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;
@@ -1553,10 +1557,14 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
 
         OpenStrategy os = new OpenStrategy(tree);
         os.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
-            resetSelectionFromWidget();
+            ISelection s = resetSelectionFromWidget();
+            if (s != null) {
+                LOGGER.trace("Fire selection change: {}", s);
+                selectionProvider.fireSelection(s);
+            }
         }));
         os.addPostSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
-            //System.out.println("OPENSTRATEGY: post selection changed: " + e);
+            LOGGER.trace("Fire post-selection change: {}", selectionProvider.getSelection());
             resetSelectionFromWidgetAndFirePostSelection(true);
         }));