Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 17db5997a99ff19a00aef3e0ec464fb1b13c5f07 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/*
 * Copyright (c) 2007, 2008 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:
 *    Artem Tikhomirov (Borland) - initial API and implementation
 */
«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
«EXTENSION xpt::editor::GenDiagram»
«EXTENSION xpt::GenModelUtils»
«EXTENSION xpt::editor::Utils»

«DEFINE DiagramEditorUtil FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::copyright FOR editorGen-»
package «editorGen.editor.packageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «diagramEditorUtilClassName» {

«EXPAND saveOptions-»

«EXPAND openDiagramMethod-»
«IF editorGen.application = null-»

	«EXPAND setCharsetMethods-»
«ENDIF-»

«EXPAND getUniqueFileNameMethod-»

«IF editorGen.application <> null»
	/**
	 * Allows user to select file and loads it as a model.
	 * 
	 * @generated
	 */
	public static org.eclipse.emf.ecore.resource.Resource openModel(
			org.eclipse.swt.widgets.Shell shell, String description, org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) {
		org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell, org.eclipse.swt.SWT.OPEN);
		if (description != null) {
			fileDialog.setText(description);
		}
		fileDialog.open();
		String fileName = fileDialog.getFileName();
		if (fileName == null || fileName.length() == 0) {
			return null;
		}
		if (fileDialog.getFilterPath() != null) {
			fileName = fileDialog.getFilterPath() + java.io.File.separator + fileName;
		}
		org.eclipse.emf.common.util.URI uri = org.eclipse.emf.common.util.URI.createFileURI(fileName);
		org.eclipse.emf.ecore.resource.Resource resource = null;
		try {
			resource = editingDomain.getResourceSet().getResource(uri, true);
		} catch (org.eclipse.emf.common.util.WrappedException we) {
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to load resource: " + uri, we); «EXPAND xpt::Common::nonNLS»
			org.eclipse.jface.dialogs.MessageDialog.openError(shell, 
                «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForOpenModelResourceErrorDialog(self))) FOR editorGen»,
				org.eclipse.osgi.util.NLS.bind(
				    «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForOpenModelResourceErrorDialog(self))) FOR editorGen»,
				    fileName));
		}
		return resource;
	}
«ENDIF»

	/**
	 * Runs the wizard in a dialog.
	 * 
	 * @generated
	 */
	public static void runWizard(org.eclipse.swt.widgets.Shell shell, org.eclipse.jface.wizard.Wizard wizard, String settingsKey) {
		org.eclipse.jface.dialogs.IDialogSettings pluginDialogSettings = «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getDialogSettings();
		org.eclipse.jface.dialogs.IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
		if (wizardDialogSettings == null) {
			wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
		}
		wizard.setDialogSettings(wizardDialogSettings);
		org.eclipse.jface.wizard.WizardDialog dialog = new org.eclipse.jface.wizard.WizardDialog(shell, wizard);
		dialog.create();
		dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
		dialog.open();
	}

«EXPAND createDiagramMethod-»
«IF domainDiagramElement <> null»
	«EXPAND createInitialModelMethod»
	«EXPAND attachModelMethod»
	«IF hasDocumentRoot(self)»«EXPAND createDocumentRootMethod»«ENDIF»
«ENDIF»

«EXPAND selectElementsMethod»
«EXPAND findElementsMethod»
«EXPAND findViewMethod»

«EXPAND additions»
}
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»

«DEFINE saveOptions FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public static java.util.Map getSaveOptions() {
		java.util.Map saveOptions = new java.util.HashMap();
		saveOptions.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_ENCODING, "UTF-8"); «EXPAND xpt::Common::nonNLS»
		saveOptions.put(org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED, org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
		return saveOptions;
	}
«ENDDEFINE»

«DEFINE openDiagramMethod FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public static boolean openDiagram(org.eclipse.emf.ecore.resource.Resource diagram) throws org.eclipse.ui.PartInitException {
«IF editorGen.application = null-»
		String path = diagram.getURI().toPlatformString(true);
		org.eclipse.core.resources.IResource workspaceResource = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(new org.eclipse.core.runtime.Path(path));
		if (workspaceResource instanceof org.eclipse.core.resources.IFile) {
			org.eclipse.ui.IWorkbenchPage page = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
			return null != page.openEditor(new org.eclipse.ui.part.FileEditorInput((org.eclipse.core.resources.IFile) workspaceResource), «editorGen.editor.getQualifiedClassName()».ID);
		}
		return false;
«ELSE-»
		org.eclipse.ui.IWorkbenchPage page = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		page.openEditor(new org.eclipse.emf.common.ui.URIEditorInput(diagram.getURI()), «editorGen.editor.getQualifiedClassName()».ID);
		return true;
«ENDIF-»
	}
«ENDDEFINE»

«DEFINE setCharsetMethods FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public static void setCharset(org.eclipse.core.resources.IFile file) {
		if (file == null) {
			return;
		}
		try {
			file.setCharset("UTF-8", new org.eclipse.core.runtime.NullProgressMonitor()); «EXPAND xpt::Common::nonNLS»
		} catch (org.eclipse.core.runtime.CoreException e) {
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to set charset for file " + file.getFullPath(), e); «EXPAND xpt::Common::nonNLS»
		}
	}	
«ENDDEFINE»

«DEFINE getUniqueFileNameMethod FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public static String getUniqueFileName(org.eclipse.core.runtime.IPath containerFullPath, String fileName, String extension) {
		if (containerFullPath == null) {
			containerFullPath = new org.eclipse.core.runtime.Path(""); «EXPAND xpt::Common::nonNLS»
		}
		if (fileName == null || fileName.trim().length() == 0) {
			fileName = "default"; «EXPAND xpt::Common::nonNLS»
		}
		org.eclipse.core.runtime.IPath filePath = containerFullPath.append(fileName);
		if (extension != null && !extension.equals(filePath.getFileExtension())) {
			filePath = filePath.addFileExtension(extension);
		}
		extension = filePath.getFileExtension();
		fileName = filePath.removeFileExtension().lastSegment();
		int i = 1;
		while (
		«IF editorGen.application = null-»
			org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().exists(filePath)
		«ELSE-»
			filePath.toFile().exists()
		«ENDIF-»
		) {
			i++;
			filePath = containerFullPath.append(fileName + i);
			if (extension != null) {
				filePath = filePath.addFileExtension(extension);
			}
		}
		return filePath.lastSegment();
	}
«ENDDEFINE»

«DEFINE createDiagramMethod FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment((if editorGen.application = null then 'This method should be called within a workspace modify operation since it creates resources.' else '' endif))»
	public static org.eclipse.emf.ecore.resource.Resource createDiagram(org.eclipse.emf.common.util.URI diagramURI,«IF standaloneDomainModel(self)» org.eclipse.emf.common.util.URI modelURI,«ENDIF» org.eclipse.core.runtime.IProgressMonitor progressMonitor) {
		org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain();
		progressMonitor.beginTask(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreateDiagramProgressTask(self)) FOR editorGen», 3);
		final org.eclipse.emf.ecore.resource.Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI);
«IF standaloneDomainModel(self)-»
		final org.eclipse.emf.ecore.resource.Resource modelResource = editingDomain.getResourceSet().createResource(modelURI);
«ELSEIF domainDiagramElement <> null and hasDocumentRoot(self) /*for standalone models, we assume its resourcefactory would be able to set extendedMetaData option*/-»
		((org.eclipse.emf.ecore.xmi.XMLResource) diagramResource).getDefaultSaveOptions().put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
		((org.eclipse.emf.ecore.xmi.XMLResource) diagramResource).getDefaultLoadOptions().put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
«ENDIF-»
		final String diagramName = diagramURI.lastSegment();
		org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand command = new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(editingDomain, «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreateDiagramCommandLabel(self)) FOR editorGen», java.util.Collections.EMPTY_LIST) {
			protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
«IF domainDiagramElement <> null-»
				«EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» model = createInitialModel();
				attachModelToResource(model, «IF standaloneDomainModel(self)»model«ELSE»diagram«ENDIF»Resource);
«ENDIF»
				org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.diagram.core.services.ViewService.createDiagram(
«IF domainDiagramElement <> null-»
				«EXPAND MetaModel::DowncastToEObject('model') FOR domainDiagramElement», 
«ENDIF-»
					«EXPAND xpt::editor::VisualIDRegistry::modelID», «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
				if (diagram != null) {
					diagramResource.getContents().add(diagram);
					diagram.setName(diagramName);
«IF domainDiagramElement <> null-»
					diagram.setElement(«EXPAND MetaModel::DowncastToEObject('model') FOR domainDiagramElement»);
«ENDIF-»
				}
				
				try {
					«IF standaloneDomainModel(self)»modelResource.save(«EXPAND xpt::Common::getSaveOptions»);«ENDIF»
					diagramResource.save(«EXPAND xpt::Common::getSaveOptions»);
				} catch (java.io.IOException e) {
					«/* TODO CommandResult.newErrorCommandResult(e) would be better? Or even throw ExecutionEx?*/»
					«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to store model and diagram resources", e); «EXPAND xpt::Common::nonNLS»
				}
				return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
			}
		};
		try {
			org.eclipse.core.commands.operations.OperationHistoryFactory.getOperationHistory().execute(command, new org.eclipse.core.runtime.SubProgressMonitor(progressMonitor, 1), null);
		} catch (org.eclipse.core.commands.ExecutionException e) {
			«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to create model and diagram", e); «EXPAND xpt::Common::nonNLS»
		}
«IF editorGen.application = null-»
		«IF standaloneDomainModel(self)»setCharset(org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(modelResource));«ENDIF»
		setCharset(org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(diagramResource));
«ENDIF-»
		return diagramResource;
	}
«ENDDEFINE»

«DEFINE createInitialModelMethod FOR gmfgen::GenDiagram»
	«EXPAND xpt::Common::generatedMemberComment('Create a new instance of domain element associated with canvas.
<!-- begin-user-doc -->
<!-- end-user-doc -->')»
	private static «EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» createInitialModel() {
		return «EXPAND MetaModel::NewInstance FOR domainDiagramElement»;
	}
«ENDDEFINE»

«DEFINE attachModelMethod FOR gmfgen::GenDiagram»
	«EXPAND xpt::Common::generatedMemberComment('Store model element in the resource.
<!-- begin-user-doc -->
<!-- end-user-doc -->')»
	private static void attachModelToResource(«EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» model, org.eclipse.emf.ecore.resource.Resource resource) {
		resource.getContents().add(«IF hasDocumentRoot(self)»createDocumentRoot(model)«ELSE»«EXPAND MetaModel::DowncastToEObject('model') FOR domainDiagramElement»«ENDIF»);
	}
«ENDDEFINE»

// invoke only when there's DocumentRoot in the domain model
«DEFINE createDocumentRootMethod FOR gmfgen::GenDiagram»
	«EXPAND xpt::Common::generatedMemberComment»
	private static «EXPAND MetaModel::QualifiedClassName FOR getDocumentRoot(self)» createDocumentRoot(«EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» model) {
		«EXPAND MetaModel::NewInstance('docRoot') FOR getDocumentRoot(self)»
«LET getDocumentRootSetFeature(self) AS f»«IF f = null-»
		docRoot.set«domainDiagramElement.ecoreClass.name»(model); // FIXME name of the set method is pure guess«ELSE-»
		«EXPAND MetaModel::modifyFeature('docRoot', getDocumentRoot(self), 'model') FOR f»;«ENDIF»
«ENDLET-»
		return docRoot;
	}
«ENDDEFINE»

«DEFINE selectElementsMethod FOR gmfgen::GenDiagram»
	«EXPAND xpt::Common::generatedMemberComment»
	public static void selectElementsInDiagram(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart, java.util.List/*EditPart*/ editParts) {
		diagramPart.getDiagramGraphicalViewer().deselectAll();

		org.eclipse.gef.EditPart firstPrimary = null;
		for (java.util.Iterator it = editParts.iterator(); it.hasNext();) {
			org.eclipse.gef.EditPart nextPart = (org.eclipse.gef.EditPart) it.next();
			diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
			if(firstPrimary == null && nextPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart) {
				firstPrimary = nextPart;
			}
		}

		if(!editParts.isEmpty()) {
			diagramPart.getDiagramGraphicalViewer().reveal(firstPrimary != null ? firstPrimary : (org.eclipse.gef.EditPart)editParts.get(0));
		}
	}
«ENDDEFINE»

«DEFINE findElementsMethod FOR gmfgen::GenDiagram»
	«EXPAND xpt::Common::generatedMemberComment»
	private static int findElementsInDiagramByID(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramPart, org.eclipse.emf.ecore.EObject element, java.util.List editPartCollector) {
		org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer viewer = (org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) diagramPart.getViewer();
		final int intialNumOfEditParts = editPartCollector.size();
		
		if (element instanceof org.eclipse.gmf.runtime.notation.View) { // support notation element lookup
			org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) viewer.getEditPartRegistry().get(element);
			if (editPart != null) {
				editPartCollector.add(editPart);
				return 1;
			}
		}

		String elementID = org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getProxyID(element);
		java.util.List associatedParts = viewer.findEditPartsForElement(elementID, org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
		// perform the possible hierarchy disjoint -> take the top-most parts only
		for (java.util.Iterator editPartIt = associatedParts.iterator(); editPartIt.hasNext();) {
			org.eclipse.gef.EditPart nextPart = (org.eclipse.gef.EditPart) editPartIt.next();
			org.eclipse.gef.EditPart parentPart = nextPart.getParent();
			while (parentPart != null && !associatedParts.contains(parentPart)) {
				parentPart = parentPart.getParent();
			}
			if (parentPart == null) {
				editPartCollector.add(nextPart);
			}
		}

		if (intialNumOfEditParts == editPartCollector.size()) {
			if (!associatedParts.isEmpty()) {
				editPartCollector.add(associatedParts.iterator().next());
			} else {
				if (element.eContainer() != null) {
					return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector);
				}
			}
		}
		return editPartCollector.size() - intialNumOfEditParts;
	}
«ENDDEFINE»

«DEFINE findViewMethod FOR gmfgen::GenDiagram»
	«EXPAND xpt::Common::generatedMemberComment»
	public static org.eclipse.gmf.runtime.notation.View findView(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart, org.eclipse.emf.ecore.EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) {
		boolean hasStructuralURI = false;						
		if(targetElement.eResource() instanceof org.eclipse.emf.ecore.xmi.XMLResource) {
			hasStructuralURI = ((org.eclipse.emf.ecore.xmi.XMLResource)targetElement.eResource()).getID(targetElement) == null;
		}
		
		org.eclipse.gmf.runtime.notation.View view = null;
		if(hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) {
			view = (org.eclipse.gmf.runtime.notation.View)lazyElement2ViewMap.getElement2ViewMap().get(targetElement);
		} else if (findElementsInDiagramByID(diagramEditPart, targetElement, lazyElement2ViewMap.editPartTmpHolder) > 0) {
			org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) lazyElement2ViewMap.editPartTmpHolder.get(0);
			lazyElement2ViewMap.editPartTmpHolder.clear();
			view = editPart.getModel() instanceof org.eclipse.gmf.runtime.notation.View ? (org.eclipse.gmf.runtime.notation.View) editPart.getModel() : null;
		}
	
		return (view == null) ? diagramEditPart.getDiagramView() : view;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public static class LazyElement2ViewMap {
		«EXPAND xpt::Common::generatedMemberComment»
		private java.util.Map element2ViewMap;

		«EXPAND xpt::Common::generatedMemberComment»
		private org.eclipse.gmf.runtime.notation.View scope;

		«EXPAND xpt::Common::generatedMemberComment»
		private java.util.Set elementSet;

		«EXPAND xpt::Common::generatedMemberComment»
		public final java.util.List editPartTmpHolder = new java.util.ArrayList();

		«EXPAND xpt::Common::generatedMemberComment»
		public LazyElement2ViewMap(org.eclipse.gmf.runtime.notation.View scope, java.util.Set elements) {
			this.scope = scope;
			this.elementSet = elements;
		}

		«EXPAND xpt::Common::generatedMemberComment»
		public final java.util.Map getElement2ViewMap() {
			if(element2ViewMap == null) {
				element2ViewMap = new java.util.HashMap();
				// map possible notation elements to itself as these can't be found by view.getElement()
				for (java.util.Iterator it = elementSet.iterator(); it.hasNext();) {
					org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) it.next();
					if(element instanceof org.eclipse.gmf.runtime.notation.View) {
						org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) element;
						if(view.getDiagram() == scope.getDiagram()) {
							element2ViewMap.put(element, element); // take only those that part of our diagram
						}
					}
				}
				
				buildElement2ViewMap(scope, element2ViewMap, elementSet);					
			}
			return element2ViewMap;
		}
		«EXPAND xpt::Common::generatedMemberComment»
		static java.util.Map buildElement2ViewMap(org.eclipse.gmf.runtime.notation.View parentView, java.util.Map element2ViewMap, java.util.Set elements) {
			if(elements.size() == element2ViewMap.size()) return element2ViewMap;

			if(parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) && elements.contains(parentView.getElement())) {
				element2ViewMap.put(parentView.getElement(), parentView);
				if(elements.size() == element2ViewMap.size()) return element2ViewMap;
			}
			
			for (java.util.Iterator it = parentView.getChildren().iterator(); it.hasNext();) {
				buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);			
				if(elements.size() == element2ViewMap.size()) return element2ViewMap;
			}
			for (java.util.Iterator it = parentView.getSourceEdges().iterator(); it.hasNext();) {
				buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);			
				if(elements.size() == element2ViewMap.size()) return element2ViewMap;
			}
			for (java.util.Iterator it = parentView.getSourceEdges().iterator(); it.hasNext();) {
				buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);			
				if(elements.size() == element2ViewMap.size()) return element2ViewMap;
			}	
			return element2ViewMap;
		}
	} //LazyElement2ViewMap	
«ENDDEFINE»

«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForOpenModelResourceErrorDialog(self)))-»
«EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForOpenModelResourceErrorDialog(self)))-»
«EXPAND xpt::Externalizer::accessorField(i18nKeyForCreateDiagramProgressTask(self))-»
«EXPAND xpt::Externalizer::accessorField(i18nKeyForCreateDiagramCommandLabel(self))-»
«ENDDEFINE»

«DEFINE i18nValues FOR gmfgen::GenDiagram-»
«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForOpenModelResourceErrorDialog(self)), 'Error')-»
«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForOpenModelResourceErrorDialog(self)), 'Failed to load model file {0}')-»
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreateDiagramProgressTask(self), 'Creating diagram and model files')-»
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreateDiagramCommandLabel(self), 'Creating diagram and model')-»
«ENDDEFINE»

Back to the top