]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Initial selection for diagram viewer should be the diagram itself 90/490/1
authorAntti Villberg <antti.villberg@semantum.fi>
Sun, 7 May 2017 06:45:57 +0000 (09:45 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Sun, 7 May 2017 06:45:57 +0000 (09:45 +0300)
refs #7194

Change-Id: I39696ee530cd04fb91562400f0b4937b30a121c7

bundles/org.simantics.diagram/src/org/simantics/diagram/ui/WorkbenchSelectionProvider.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerLoadJob.java

index 5f46a373b2ecefbf85192cbb5be8380c4bee79a9..6609ba24b155d1be1b508a566812274779432819 100644 (file)
@@ -99,10 +99,8 @@ public class WorkbenchSelectionProvider extends AbstractCanvasParticipant implem
         }
         super.removedFromContext(ctx);
     }
-
-    @HintListener(Class = Selection.class, Field = "SELECTION0")
-    public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
-        Iterable<?> selection = (Iterable<?>) newValue;
+    
+    public void fireSelection(Iterable<?> selection) {
         final ISelection s = constructAdaptableSelection(selection);
         swt.asyncExec(new Runnable() {
             @Override
@@ -114,18 +112,16 @@ public class WorkbenchSelectionProvider extends AbstractCanvasParticipant implem
         });
     }
 
+    @HintListener(Class = Selection.class, Field = "SELECTION0")
+    public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
+        Iterable<?> selection = (Iterable<?>) newValue;
+        fireSelection(selection);
+    }
+    
     @HintListener(Class = Selection.class, Field = "SELECTION0")
     public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {
         //System.out.println("selection removed: " + oldValue);
-        final ISelection s = constructAdaptableSelection(Collections.emptyList());
-        swt.asyncExec(new Runnable() {
-            @Override
-            public void run() {
-                currentSelection = s;
-                fireSelectionChanged(s);
-                schedulePostSelectionChanged(s);
-            }
-        });
+        fireSelection(Collections.emptyList());
     }
 
     // Post selection changed scheduling helper.
index dcadd4d9130cb872aca11a096066e46412f9a1fd..85f0dbbe7b432f35548a38488fa30491407036a9 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.modeling.ui.diagramEditor;
 
+import java.util.Collections;
+
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -74,6 +76,8 @@ public class DiagramViewerLoadJob extends DatabaseJob {
                         mon.worked(10);
                         END(task);
 
+                       viewer.selectionProvider.fireSelection(Collections.emptyList());
+                        
                         // Zoom to fit if no previous view transform is available
                         task = BEGIN("DV.scheduleZoomToFit");
                         viewer.scheduleZoomToFit(diagram);