From: Antti Villberg Date: Sun, 7 May 2017 06:45:57 +0000 (+0300) Subject: Initial selection for diagram viewer should be the diagram itself X-Git-Tag: v1.29.0~70^2~4 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=f060a683d7907316ebb03c9fc95f7ba0ce52ee91;p=simantics%2Fplatform.git Initial selection for diagram viewer should be the diagram itself refs #7194 Change-Id: I39696ee530cd04fb91562400f0b4937b30a121c7 --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/ui/WorkbenchSelectionProvider.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/ui/WorkbenchSelectionProvider.java index 5f46a373b..6609ba24b 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/ui/WorkbenchSelectionProvider.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/ui/WorkbenchSelectionProvider.java @@ -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. diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerLoadJob.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerLoadJob.java index dcadd4d91..85f0dbbe7 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerLoadJob.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerLoadJob.java @@ -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);