Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/getEditorInput.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/getEditorInput.xpt44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/getEditorInput.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/getEditorInput.xpt
new file mode 100644
index 000000000..ccf0ec4e2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/getEditorInput.xpt
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«DEFINE getEditorInput FOR gmfgen::GenEditorGenerator-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private static org.eclipse.ui.IEditorInput getEditorInput(org.eclipse.gmf.runtime.notation.Diagram diagram) {
+ org.eclipse.emf.ecore.resource.Resource diagramResource = diagram.eResource();
+«IF null = application-»
+ for (java.util.Iterator it = diagramResource.getContents().iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.EObject nextEObject = (org.eclipse.emf.ecore.EObject) it.next();
+ if (nextEObject == diagram) {
+ return new org.eclipse.ui.part.FileEditorInput(org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(diagramResource));
+ }
+ if (nextEObject instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ break;
+ }
+ }
+«ENDIF-»
+ «EXPAND defineURIEditorInput('diagram') FOR diagram-»
+ return editorInput;
+}
+«ENDDEFINE»
+
+«DEFINE defineURIEditorInput(diagramVarName : String) FOR gmfgen::GenDiagram-»
+«EXPAND defineURIEditorInput(diagramVarName, 'editorInput')-»
+«ENDDEFINE»
+
+«DEFINE defineURIEditorInput(diagramVarName : String, editorInputVarName : String) FOR gmfgen::GenDiagram-»
+org.eclipse.emf.common.util.URI uri = org.eclipse.emf.ecore.util.EcoreUtil.getURI(«diagramVarName»);
+String editorName = uri.lastSegment() + "#" + «diagramVarName».eResource().getContents().indexOf(«diagramVarName»); «EXPAND xpt::Common::nonNLS»
+org.eclipse.ui.IEditorInput «editorInputVarName» = new org.eclipse.emf.common.ui.URIEditorInput(uri, editorName);
+«ENDDEFINE»

Back to the top