]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Support PreferredDiagramEditorID in OpenDiagramEditorFromConfiguration 51/3051/1
authorJussi Koskela <jussi.koskela@semantum.fi>
Thu, 1 Aug 2019 10:42:45 +0000 (13:42 +0300)
committerJussi Koskela <jussi.koskela@semantum.fi>
Thu, 1 Aug 2019 10:42:45 +0000 (13:42 +0300)
gitlab #325

Change-Id: I95c7c075c3562410f5ba06c8785447f0cc53a860

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromConfigurationAdapter.java

index 0ca3b1b04406861467b845013717710ff5c45788..c446d1c3c057f15409192b182d3dba45d6c6c668 100644 (file)
@@ -32,6 +32,7 @@ import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.diagram.DiagramHints;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ComponentUtils;
+import org.simantics.modeling.ModelingResources;
 import org.simantics.modeling.actions.NavigateToTarget;
 import org.simantics.modeling.ui.Activator;
 import org.simantics.structural.stubs.StructuralResource2;
@@ -50,8 +51,13 @@ public class OpenDiagramFromConfigurationAdapter extends AbstractResourceEditorA
         super(Messages.OpenDiagramFromConfigurationAdapter_DiagramEditor, Activator.COMPOSITE_ICON);
     }
 
-    protected String getEditorId() {
-        return EDITOR_ID;
+    protected String getEditorId(ReadGraph g, Resource composite) throws DatabaseException {
+        ModelingResources MOD = ModelingResources.getInstance(g);
+        String preferredEditorId = g.getPossibleRelatedValue(composite, MOD.PreferredDiagramEditorID);
+        if(preferredEditorId != null)
+            return preferredEditorId;
+        else
+            return EDITOR_ID;
     }
 
     @Override
@@ -80,7 +86,7 @@ public class OpenDiagramFromConfigurationAdapter extends AbstractResourceEditorA
         Simantics.getSession().asyncRequest(new ReadRequest() {
             @Override
             public void run(ReadGraph g) throws DatabaseException {
-                openEditor(g, r, getEditorId());
+                openEditor(g, r, getEditorId(g, r));
             }
         });
     }