* @param selectedObjects
* @throws DatabaseException
*/
- public static boolean openEditor(ReadGraph g, Resource r, final String editorId, final Collection<Object> selectedObjects) throws DatabaseException {
-
- final Resource diagram = getDiagram(g, r, selectedObjects);
- if (diagram == null)
- return false;
-
- final Resource configurationComposite = ComponentUtils.getPossibleDiagramComposite(g, diagram);
- if (configurationComposite == null)
- return false;
-
- Pair<Resource, RVI> modelAndRVI = getModelAndRVI(g, configurationComposite);
+ public static boolean openEditor(ReadGraph g, Resource r, String editorId, Collection<Object> selectedObjects) throws DatabaseException {
+ Resource diagram = getDiagram(g, r, selectedObjects);
+ Resource configurationComposite = diagram != null ? ComponentUtils.getPossibleDiagramComposite(g, diagram) : null;
+ Pair<Resource, RVI> modelAndRVI = configurationComposite != null ? getModelAndRVI(g, configurationComposite) : null;
//System.out.println("modelAndRVI: " + modelAndRVI);
if (modelAndRVI == null)
return false;
+ scheduleOpenEditor(editorId, diagram, modelAndRVI.first, modelAndRVI.second, selectedObjects);
+ return true;
+ }
+
+ /**
+ * @param g
+ * @param configurationComposite
+ * @param editorId
+ * @param selectedObjects
+ * @throws DatabaseException
+ */
+ public static boolean openEditor(ReadGraph g, Resource r, String editorId, Collection<Object> selectedObjects, Resource model, RVI rvi) throws DatabaseException {
+ Resource diagram = getDiagram(g, r, selectedObjects);
+ if (diagram == null)
+ return false;
+ scheduleOpenEditor(editorId, diagram, model, rvi, selectedObjects);
+ return true;
+ }
- final Runnable editorActivator = NavigateToTarget.editorActivator(editorId, diagram, modelAndRVI.first, modelAndRVI.second, part -> {
+ /**
+ * @param g
+ * @param configurationComposite
+ * @param editorId
+ * @param selectedObjects
+ * @throws DatabaseException
+ */
+ private static void scheduleOpenEditor(String editorId, Resource diagram, Resource model, RVI rvi, Collection<Object> selectedObjects) throws DatabaseException {
+ Runnable editorActivator = NavigateToTarget.editorActivator(editorId, diagram, model, rvi, part -> {
if (selectedObjects.isEmpty())
return;
-
- final ICanvasContext openedCanvas = (ICanvasContext) part.getAdapter(ICanvasContext.class);
+ ICanvasContext openedCanvas = (ICanvasContext) part.getAdapter(ICanvasContext.class);
assert openedCanvas != null;
// CanvasContext-wide denial of initial zoom-to-fit on diagram open.
openedCanvas.getDefaultHintContext().setHint(DiagramHints.KEY_INITIAL_ZOOM_TO_FIT, Boolean.FALSE);
- //System.out.println("ASDF: " + element);
ThreadUtils.asyncExec(openedCanvas.getThreadAccess(),
NavigateToTarget.elementSelectorZoomer(openedCanvas, selectedObjects, false));
});
-
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- editorActivator.run();
- }
- });
-
- return true;
+ PlatformUI.getWorkbench().getDisplay().asyncExec(editorActivator);
}
}