From 43355222d559c87975f7f39dce18d36f35ea9b94 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Thu, 1 Aug 2019 13:42:45 +0300 Subject: [PATCH] Support PreferredDiagramEditorID in OpenDiagramEditorFromConfiguration gitlab #325 Change-Id: I95c7c075c3562410f5ba06c8785447f0cc53a860 --- .../OpenDiagramFromConfigurationAdapter.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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)); } }); } -- 2.47.1