From: Jussi Koskela Date: Tue, 3 Sep 2019 10:28:13 +0000 (+0300) Subject: Use PreferredDiagramEditorID in OpenDiagramEditorFromComponentAdapter X-Git-Tag: v1.43.0~136^2~83 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=28a84e15fa3fff6b52e21071dea142ba9cd6fe5a;p=simantics%2Fplatform.git Use PreferredDiagramEditorID in OpenDiagramEditorFromComponentAdapter gitlab #371 Change-Id: Ia2b39d03f346a47c45b3982ec882b9facc9e28eb --- diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromComponentAdapter.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromComponentAdapter.java index d5071303e..6be9f72f9 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromComponentAdapter.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromComponentAdapter.java @@ -63,6 +63,15 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt super(Messages.OpenDiagramFromComponentAdapter_OpenDiagramContainingComponent, Activator.SYMBOL_ICON); } + protected String getEditorId(ReadGraph g, Resource diagram) throws DatabaseException { + ModelingResources MOD = ModelingResources.getInstance(g); + String preferredEditorId = g.getPossibleRelatedValue(diagram, MOD.PreferredDiagramEditorID); + if(preferredEditorId != null) + return preferredEditorId; + else + return EDITOR_ID; + } + @Override public boolean canHandle(ReadGraph graph, Object input) throws DatabaseException { Pair p = tryGetResource(graph, input); @@ -153,6 +162,8 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt Resource composite = g.getSingleObject(component, l0.PartOf); Resource diagram = ComponentUtils.getPossibleCompositeDiagram(g, composite); + String editorId = getEditorId(g, composite); + if (LOGGER.isDebugEnabled()) { LOGGER.debug(getClass().getSimpleName() + ".findDiagram: component: " + NameUtils.getURIOrSafeNameInternal(g, component)); //$NON-NLS-1$ LOGGER.debug(getClass().getSimpleName() + ".findDiagram: composite: " + NameUtils.getURIOrSafeNameInternal(g, composite)); //$NON-NLS-1$ @@ -213,7 +224,7 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt // Prevent diagram from opening if there's nothing to select // on the diagram based on the received input. if (!selectedObjects.isEmpty()) - result.add( NavigateToTarget.editorActivator(EDITOR_ID, diagram, indexRoot, rvi, editorActivationCallback(selectedObjects)) ); + result.add( NavigateToTarget.editorActivator(editorId, diagram, indexRoot, rvi, editorActivationCallback(selectedObjects)) ); } else { final MapSet referencingDiagrams = listReferenceDiagrams(g, referenceElements); final Set diagrams = referencingDiagrams.getKeys(); @@ -238,7 +249,7 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt RVI rvi = getDiagramCompositeRvi(g, singleDiagram.getResource()); if (rvi != null) { Collection selectedObjects = referencingDiagrams.getValues(singleDiagram); - result.add( NavigateToTarget.editorActivator(EDITOR_ID, singleDiagram.getResource(), indexRoot, rvi, editorActivationCallback(selectedObjects)) ); + result.add( NavigateToTarget.editorActivator(editorId, singleDiagram.getResource(), indexRoot, rvi, editorActivationCallback(selectedObjects)) ); } break; @@ -254,7 +265,7 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt if (selected != null) { Collection selectedObjects = referencingDiagrams.getValues(selected); RVI drvi = diagramToRvi.get(selected); - NavigateToTarget.editorActivator(EDITOR_ID, selected.getResource(), indexRoot, drvi, editorActivationCallback(selectedObjects)).run(); + NavigateToTarget.editorActivator(editorId, selected.getResource(), indexRoot, drvi, editorActivationCallback(selectedObjects)).run(); } }); break;