From: Jussi Koskela Date: Thu, 1 Aug 2019 10:42:45 +0000 (+0300) Subject: Support PreferredDiagramEditorID in OpenDiagramEditorFromConfiguration X-Git-Tag: v1.43.0~136^2~128 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=43355222d559c87975f7f39dce18d36f35ea9b94;p=simantics%2Fplatform.git Support PreferredDiagramEditorID in OpenDiagramEditorFromConfiguration gitlab #325 Change-Id: I95c7c075c3562410f5ba06c8785447f0cc53a860 --- diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromConfigurationAdapter.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromConfigurationAdapter.java index 0ca3b1b04..c446d1c3c 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromConfigurationAdapter.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromConfigurationAdapter.java @@ -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)); } }); }