Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 963805bad87c7737522597399d9894f1d67738d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2007, 2009 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/2009/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