Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2008-12-29 07:41:38 -0500
committerashatalin2008-12-29 07:41:38 -0500
commitfc1dfb3b462e159eec1b6031bb41ab79c762474b (patch)
tree66acb7873f68640147106dcd919a5041ecbc918b /plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt
parent7f3bb1960b122d5d9c4edae8dc1c330032c9cf60 (diff)
downloadorg.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.gz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.xz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.zip
QVTO-based xpand implementation was merged to HEAD
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt427
1 files changed, 427 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt
new file mode 100644
index 000000000..17db5997a
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt
@@ -0,0 +1,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