Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt70
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt181
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt105
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt79
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt174
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt72
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt427
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt748
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DomainModelElementTester.xpt50
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Editor.xpt404
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ElementChooser.xpt414
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/GenDiagram.qvto29
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/InitDiagramFileAction.xpt145
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/MatchingStrategy.xpt49
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ModelElementSelectionPage.xpt167
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/NewDiagramFileWizard.xpt200
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetInfo.xpt331
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt89
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutCreationWizard.xpt156
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutPropertyTester.xpt53
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/UriEditorInputTester.xpt40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Utils.qvto255
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidateAction.xpt351
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidationMarker.xpt112
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt388
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/diagram.gifbin0 -> 339 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/extensions.xpt86
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt278
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/Utils.qvto49
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/shortcut.gifbin0 -> 93 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/wizban.gifbin0 -> 2466 bytes
31 files changed, 5502 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt
new file mode 100644
index 000000000..4caf0da89
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt
@@ -0,0 +1,70 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::GenEditorGenerator»
+
+«DEFINE ActionBarContributor FOR gmfgen::GenEditorView-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «actionBarContributorClassName»«EXPAND extendsList» {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected Class getEditorClass() {
+ return «getQualifiedClassName()».class;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getEditorId() {
+ return «getQualifiedClassName()».ID;
+ }
+ «EXPAND initMethod-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenEditorView» extends org.eclipse.gmf.runtime.diagram.ui.parts.DiagramActionBarContributor«ENDDEFINE»
+
+«DEFINE initMethod FOR gmfgen::GenEditorView»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void init(org.eclipse.ui.IActionBars bars, org.eclipse.ui.IWorkbenchPage page) {
+ super.init(bars, page);
+ // print preview
+ org.eclipse.jface.action.IMenuManager fileMenu = bars.getMenuManager().findMenuUsingPath(org.eclipse.ui.IWorkbenchActionConstants.M_FILE);
+ «EXPAND xpt::Common::_assert('fileMenu != null')-»
+«IF editorGen.plugin.printingEnabled-»
+ org.eclipse.jface.action.IAction printPreviewAction = new org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.RenderedPrintPreviewAction(new org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.EnhancedPrintActionHelper());
+ fileMenu.insertBefore("print", printPreviewAction);«EXPAND xpt::Common::nonNLS»
+«ELSE-»
+ fileMenu.remove("pageSetupAction");«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+«IF /*hasAudits || hasMetrics */editorGen.diagram.validationEnabled or hasAudits(editorGen) or (editorGen.metrics <> null and editorGen.metrics.metrics->size() > 0)-»
+ org.eclipse.jface.action.IMenuManager editMenu = bars.getMenuManager().findMenuUsingPath(org.eclipse.ui.IWorkbenchActionConstants.M_EDIT);
+ «EXPAND xpt::Common::_assert('editMenu != null')-»
+ if (editMenu.find("validationGroup") == null) {«EXPAND xpt::Common::nonNLS»
+ editMenu.add(new org.eclipse.jface.action.GroupMarker("validationGroup"));«EXPAND xpt::Common::nonNLS»
+ }
+«IF editorGen.diagram.validationEnabled or hasAudits(editorGen)-»
+ org.eclipse.jface.action.IAction validateAction = new «EXPAND xpt::editor::ValidateAction::qualifiedClassName FOR editorGen.diagram»(page);
+ editMenu.appendToGroup("validationGroup", validateAction);«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+«IF editorGen.metrics <> null and editorGen.metrics.metrics->size() > 0-»
+ org.eclipse.jface.action.IAction metricsAction = new «editorGen.diagram.getMetricProviderQualifiedClassName()».MetricsAction(page);
+ editMenu.appendToGroup("validationGroup", metricsAction);«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+«ENDIF /*hasAudits || hasMetrics */-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenEditorView»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt
new file mode 100644
index 000000000..c6af45b84
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt
@@ -0,0 +1,181 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE CreationWizard FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «creationWizardClassName»
+ extends org.eclipse.jface.wizard.Wizard implements org.eclipse.ui.INewWizard {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbench workbench;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.jface.viewers.IStructuredSelection selection;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «getCreationWizardPageQualifiedClassName()» diagramModelFilePage;
+ «IF isStandaloneDomainModel(self)-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «getCreationWizardPageQualifiedClassName()» domainModelFilePage;
+ «ENDIF-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.emf.ecore.resource.Resource diagram;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private boolean openNewlyCreatedDiagramEditor = true;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.ui.IWorkbench getWorkbench() {
+ return workbench;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.jface.viewers.IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final org.eclipse.emf.ecore.resource.Resource getDiagram() {
+ return diagram;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final boolean isOpenNewlyCreatedDiagramEditor() {
+ return openNewlyCreatedDiagramEditor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) {
+ this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void init(org.eclipse.ui.IWorkbench workbench, org.eclipse.jface.viewers.IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizard(self))) FOR editorGen»);
+ setDefaultPageImageDescriptor(«editorGen.plugin.getActivatorQualifiedClassName()».getBundledImageDescriptor(
+ "icons/wizban/New«IF domainDiagramElement <> null»«domainDiagramElement.genPackage.prefix»«ENDIF»Wizard.gif")); //$NON-NLS-1$
+ setNeedsProgressMonitor(true);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void addPages() {
+ diagramModelFilePage = new «getCreationWizardPageQualifiedClassName()»(
+ "DiagramModelFile", getSelection(), "«editorGen.diagramFileExtension»"); //$NON-NLS-1$ //$NON-NLS-2$
+ diagramModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizardDiagramPage(self))) FOR editorGen»);
+ diagramModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForCreationWizardDiagramPage(self))) FOR editorGen»);
+ addPage(diagramModelFilePage);
+ «IF isStandaloneDomainModel(self)-»
+
+ domainModelFilePage = new «getCreationWizardPageQualifiedClassName()»(
+ "DomainModelFile", getSelection(), "«editorGen.domainFileExtension»") { //$NON-NLS-1$ //$NON-NLS-2$
+
+ public void setVisible(boolean visible) {
+ if (visible) {
+ String fileName = diagramModelFilePage.getFileName();
+ fileName = fileName.substring(0, fileName.length() - ".«editorGen.diagramFileExtension»".length()); //$NON-NLS-1$
+ setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
+ getContainerFullPath(), fileName, "«editorGen.domainFileExtension»")); //$NON-NLS-1$
+ }
+ super.setVisible(visible);
+ }
+ };
+ domainModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»);
+ domainModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»);
+ addPage(domainModelFilePage);
+ «ENDIF-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean performFinish() {
+ org.eclipse.jface.operation.IRunnableWithProgress op =
+ «IF editorGen.application = null-»
+ new org.eclipse.ui.actions.WorkspaceModifyOperation(null) {
+
+ protected void execute(org.eclipse.core.runtime.IProgressMonitor monitor)
+ throws org.eclipse.core.runtime.CoreException, InterruptedException {
+ «ELSE-»
+ new org.eclipse.jface.operation.IRunnableWithProgress() {
+
+ public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ «ENDIF-»
+ diagram = «getDiagramEditorUtilQualifiedClassName()».createDiagram(diagramModelFilePage.getURI(),
+ «IF isStandaloneDomainModel(self)-»
+ domainModelFilePage.getURI(),
+ «ENDIF-»
+ monitor);
+ if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
+ try {
+ «getDiagramEditorUtilQualifiedClassName()».openDiagram(diagram);
+ } catch (org.eclipse.ui.PartInitException e) {
+ org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardOpenEditorError(self)) FOR editorGen», null, e.getStatus());
+ }
+ }
+ }
+ };
+ try {
+ getContainer().run(false, true, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ if (e.getTargetException() instanceof org.eclipse.core.runtime.CoreException) {
+ org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardCreationError(self)) FOR editorGen», null,
+ ((org.eclipse.core.runtime.CoreException) e.getTargetException()).getStatus());
+ } else {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
+ "Error creating diagram", e.getTargetException()); //$NON-NLS-1$
+ }
+ return false;
+ }
+ return diagram != null;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizard(self)), 'New ' + editorGen.modelID + ' Diagram')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizardDiagramPage(self)), 'Create ' + editorGen.modelID + ' Diagram')-»
+«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForCreationWizardDiagramPage(self)), (if isStandaloneDomainModel(self) then 'Select file that will contain diagram model.' else 'Select file that will contain diagram and domain models.' endif))-»
+«IF isStandaloneDomainModel(self)-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizardDomainPage(self)), 'Create ' + editorGen.modelID + ' Domain Model')-»
+«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForCreationWizardDomainPage(self)), 'Select file that will contain domain model.')-»
+«ENDIF-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardOpenEditorError(self), 'Error opening diagram editor')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardCreationError(self), 'Creation Problems')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizard(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizardDiagramPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForCreationWizardDiagramPage(self)))-»
+ «IF isStandaloneDomainModel(self)-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizardDomainPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForCreationWizardDomainPage(self)))-»
+ «ENDIF-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardOpenEditorError(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardCreationError(self))-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt
new file mode 100644
index 000000000..ef872708e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt
@@ -0,0 +1,105 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE CreationWizardPage FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «creationWizardPageClassName» extends
+ «IF editorGen.application = null-»
+ org.eclipse.ui.dialogs.WizardNewFileCreationPage
+ «ELSE-»
+ «editorGen.application.packageName».WizardNewFileCreationPage
+ «ENDIF-»
+ {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final String fileExtension;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «creationWizardPageClassName»(String pageName,
+ org.eclipse.jface.viewers.IStructuredSelection selection, String fileExtension) {
+ super(pageName, selection);
+ this.fileExtension = fileExtension;
+ }
+
+ /**
+ * Override to create files with this extension.
+ *
+ * @generated
+ */
+ protected String getExtension() {
+ return fileExtension;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.common.util.URI getURI() {
+ «IF editorGen.application = null-»
+ return org.eclipse.emf.common.util.URI.createPlatformResourceURI(getFilePath().toString(), false);
+ «ELSE-»
+ return org.eclipse.emf.common.util.URI.createFileURI(getFilePath().toString());
+ «ENDIF-»
+ }
+ «IF editorGen.application = null-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.core.runtime.IPath getFilePath() {
+ org.eclipse.core.runtime.IPath path = getContainerFullPath();
+ if (path == null) {
+ path = new org.eclipse.core.runtime.Path(""); //$NON-NLS-1$
+ }
+ String fileName = getFileName();
+ if (fileName != null) {
+ path = path.append(fileName);
+ }
+ return path;
+ }
+ «ENDIF-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void createControl(org.eclipse.swt.widgets.Composite parent) {
+ super.createControl(parent);
+ setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
+ getContainerFullPath(), getFileName(), getExtension()));
+ setPageComplete(validatePage());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean validatePage() {
+ if (!super.validatePage()) {
+ return false;
+ }
+ String extension = getExtension();
+ if (extension != null && !getFilePath().toString().endsWith("." + extension)) {
+ setErrorMessage(org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardPageExtensionError(self)) FOR editorGen», extension));
+ return false;
+ }
+ return true;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardPageExtensionError(self), 'File name should have {0} extension.')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardPageExtensionError(self))-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt
new file mode 100644
index 000000000..13b6490a3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE className FOR gmfgen::GenDiagram»DeleteElementAction«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE DeleteElementAction FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» extends org.eclipse.gmf.runtime.diagram.ui.actions.AbstractDeleteFromAction {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.ui.IWorkbenchPart part) {
+ super(part);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.ui.IWorkbenchPage workbenchPage) {
+ super(workbenchPage);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void init() {
+ super.init();
+ setId(org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds.ACTION_DELETE_FROM_MODEL);
+ setText(org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages.DiagramEditor_Delete_from_Model);
+ setToolTipText(org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages.DiagramEditor_Delete_from_ModelToolTip);
+ org.eclipse.ui.ISharedImages workbenchImages = org.eclipse.ui.PlatformUI.getWorkbench().getSharedImages();
+ setHoverImageDescriptor(workbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_TOOL_DELETE));
+ setImageDescriptor(workbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_TOOL_DELETE));
+ setDisabledImageDescriptor(workbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getCommandLabel() {
+ return org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages.DiagramEditor_Delete_from_Model;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.commands.Command getCommand(org.eclipse.gef.Request request) {
+ java.util.List operationSet = getOperationSet();
+ if (operationSet.isEmpty()) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ java.util.Iterator editParts = operationSet.iterator();
+ org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand command =
+ new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), getCommandLabel());
+ while (editParts.hasNext()) {
+ org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) editParts.next();
+ org.eclipse.gef.commands.Command curCommand = editPart.getCommand(request);
+ if (curCommand != null) {
+ command.compose(new org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy(curCommand));
+ }
+ }
+ if (command.isEmpty() || command.size() != operationSet.size()) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt
new file mode 100644
index 000000000..9397e3041
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt
@@ -0,0 +1,174 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::diagram::updater::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE DiagramContentInitializer FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «diagramContentInitializerClassName» {
+
+ «EXPAND attributes-»
+
+ «EXPAND initDiagramContent-»
+
+ «EXPAND createChildren FOREACH getAllContainers()->select(container | not container.sansDomain)-»
+
+ «EXPAND createNode-»
+
+ «EXPAND createLinks-»
+ «IF not (getAllContainers())[gmfgen::GenCompartment]->isEmpty()-»
+
+ «EXPAND getCompartment-»
+ «ENDIF-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Map myDomain2NotationMap = new java.util.HashMap();
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection myLinkDescriptors = new java.util.LinkedList();
+«ENDDEFINE»
+
+«DEFINE initDiagramContent FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void initDiagramContent(org.eclipse.gmf.runtime.notation.Diagram diagram) {
+ if (!«EXPAND xpt::editor::VisualIDRegistry::modelID».equals(diagram.getType())) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Incorrect diagram passed as a parameter: " + diagram.getType());
+ return;
+ }
+ if («EXPAND MetaModel::NotInstance('diagram.getElement()') FOR domainDiagramElement») {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Incorrect diagram element specified: " + diagram.getElement() + " instead of «domainDiagramElement.ecoreClass.name»");
+ return;
+ }
+ «EXPAND createChildrenMethodName»(diagram);
+ createLinks(diagram);
+}
+«ENDDEFINE»
+
+«DEFINE createChildrenMethodName FOR gmfgen::GenContainerBase»create«getUniqueIdentifier()»Children«ENDDEFINE»
+
+«DEFINE createChildren FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void «EXPAND createChildrenMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ «EXPAND collectContainedLinks-»
+ «IF hasSemanticChildren(self)-»
+ java.util.Collection childNodeDescriptors = «EXPAND xpt::diagram::updater::DiagramUpdater::getSemanticChildrenMethodCall»(view);
+ for (java.util.Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, («getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()») it.next());
+ }
+ «ENDIF-»
+ «EXPAND createCompartmentsChildren-»
+}
+«ENDDEFINE»
+
+«DEFINE collectContainedLinks FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE collectContainedLinks FOR gmfgen::GenNode-»
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(«EXPAND xpt::diagram::updater::DiagramUpdater::getOutgoingLinksMethodCall»(view));
+«ENDDEFINE»
+
+«DEFINE createCompartmentsChildren FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE createCompartmentsChildren FOR gmfgen::GenNode-»
+ «EXPAND callCreateCompartmentChildren FOREACH compartments»
+«ENDDEFINE»
+
+«REM»
+ Will be called for each compartment of GenNode for GenNode.isSansDomain() == false.
+ if !GenNode.isSansDomain() => !GenCompartment.isSansDomain() so should not check
+ !this.isSansDomain() here.
+«ENDREM»
+«DEFINE callCreateCompartmentChildren FOR gmfgen::GenCompartment-»
+ «EXPAND createChildrenMethodName»(getCompartment(view, «EXPAND xpt::editor::VisualIDRegistry::visualID»));
+«ENDDEFINE»
+
+«DEFINE createNode FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void createNode(org.eclipse.gmf.runtime.notation.View parentView, «editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()» nodeDescriptor) {
+ final String nodeType = «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall('nodeDescriptor.getVisualID()')»;
+ org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.diagram.core.services.ViewService.createNode(parentView, nodeDescriptor.getModelElement(), nodeType, «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ switch (nodeDescriptor.getVisualID()) {
+ «EXPAND createNodeCase FOREACH getAllNodes()->select(node | not node.sansDomain)-»
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createNodeCase FOR gmfgen::GenContainerBase-»
+«EXPAND xpt::Common::caseVisualID»
+ «EXPAND createChildrenMethodName»(node);
+ return;
+«ENDDEFINE»
+
+«REM»Adopt this code to work with links to links«ENDREM»
+«DEFINE createLinks FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void createLinks(org.eclipse.gmf.runtime.notation.Diagram diagram) {
+ for (boolean continueLinkCreation = true; continueLinkCreation;) {
+ continueLinkCreation = false;
+ java.util.Collection additionalDescriptors = new java.util.LinkedList();
+ for (java.util.Iterator it = myLinkDescriptors.iterator(); it.hasNext();) {
+ «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») it.next();
+ if (!myDomain2NotationMap.containsKey(nextLinkDescriptor.getSource()) || !myDomain2NotationMap.containsKey(nextLinkDescriptor.getDestination())) {
+ continue;
+ }
+ final String linkType = «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall('nextLinkDescriptor.getVisualID()')»;
+ org.eclipse.gmf.runtime.notation.Edge edge = org.eclipse.gmf.runtime.diagram.core.services.ViewService.getInstance().createEdge(nextLinkDescriptor.getSemanticAdapter(), diagram, linkType, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true, «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ if (edge != null) {
+ edge.setSource((org.eclipse.gmf.runtime.notation.View) myDomain2NotationMap.get(nextLinkDescriptor.getSource()));
+ edge.setTarget((org.eclipse.gmf.runtime.notation.View) myDomain2NotationMap.get(nextLinkDescriptor.getDestination()));
+ it.remove();
+ if (nextLinkDescriptor.getModelElement() != null) {
+ myDomain2NotationMap.put(nextLinkDescriptor.getModelElement(), edge);
+ }
+ continueLinkCreation = true;
+ switch (nextLinkDescriptor.getVisualID()) {
+ «EXPAND createLinksCase FOREACH links->select(link | null <> link.getMetaClass())-»
+ }
+ }
+ }
+ myLinkDescriptors.addAll(additionalDescriptors);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createLinksCase FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::caseVisualID»
+ additionalDescriptors.addAll(«EXPAND xpt::diagram::updater::DiagramUpdater::getOutgoingLinksMethodCall»(edge));
+ break;
+«ENDDEFINE»
+
+«DEFINE getCompartment FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gmf.runtime.notation.Node getCompartment(org.eclipse.gmf.runtime.notation.View node, int visualID) {
+ String type = «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall('visualID')»;
+ for (java.util.Iterator it = node.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (nextView instanceof org.eclipse.gmf.runtime.notation.Node && type.equals(nextView.getType())) {
+ return (org.eclipse.gmf.runtime.notation.Node) nextView;
+ }
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt
new file mode 100644
index 000000000..b60800bcc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE className FOR gmfgen::GenDiagram»DiagramEditorContextMenuProvider«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE DiagramEditorContextMenuProvider FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» extends org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbenchPart part;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName» deleteAction;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public DiagramEditorContextMenuProvider(org.eclipse.ui.IWorkbenchPart part, org.eclipse.gef.EditPartViewer viewer) {
+ super(part, viewer);
+ this.part = part;
+ deleteAction = new «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName»(part);
+ deleteAction.init();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void dispose() {
+ if (deleteAction != null) {
+ deleteAction.dispose();
+ deleteAction = null;
+ }
+ super.dispose();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void buildContextMenu(final org.eclipse.jface.action.IMenuManager menu) {
+ getViewer().flush();
+ try {
+ org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(
+ (org.eclipse.emf.ecore.EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {
+
+ public void run() {
+ org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService.getInstance().contributeToPopupMenu(
+ DiagramEditorContextMenuProvider.this, part);
+ menu.remove(org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds.ACTION_DELETE_FROM_MODEL);
+ menu.appendToGroup("editGroup", deleteAction);
+ }
+ });
+ } catch (Exception e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Error building context menu", e);
+ }
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
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»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt
new file mode 100644
index 000000000..c274dc9ac
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt
@@ -0,0 +1,748 @@
+/*
+ * 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'»
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE DocumentProvider FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «documentProviderClassName» extends org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider implements org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider {
+
+ «EXPAND createElementInfo-»
+
+ «EXPAND createDocument-»
+
+ «EXPAND setupDocument-»
+
+ «EXPAND computeModificationStamp-»
+
+ «EXPAND createEmptyDocument-»
+
+ «EXPAND createEditingDomain-»
+
+ «EXPAND setDocumentContent-»
+
+ «EXPAND getModificationStamp-»
+
+ «EXPAND isDeleted-»
+
+ «EXPAND getResourceSetInfo-»
+
+ «EXPAND disposeElementInfo-»
+ «IF null = editorGen.application-»
+
+ «EXPAND doValidateState-»
+ «ENDIF-»
+
+ «EXPAND isReadOnly-»
+
+ «EXPAND isModifiable-»
+
+ «EXPAND updateCache-»
+
+ «EXPAND doUpdateStateCache-»
+
+ «EXPAND isSynchronized-»
+ «IF null = editorGen.application-»
+
+ «EXPAND getResetRule-»
+
+ «EXPAND getSaveRule-»
+
+ «EXPAND getSynchronizeRule-»
+
+ «EXPAND getValidateStateRule-»
+
+ «EXPAND computeSchedulingRule-»
+ «ENDIF-»
+
+ «EXPAND doSynchronize-»
+
+ «EXPAND doSaveDocument-»
+
+ «EXPAND handleElementChanged-»
+
+ «EXPAND handleElementMoved-»
+
+ «EXPAND createInputWithEditingDomain-»
+
+ «EXPAND getDiagramDocument-»
+
+ «EXPAND getOperationRunner-»
+ «IF null <> editorGen.application-»
+
+ «EXPAND getFile-»
+ «ENDIF-»
+
+ «EXPAND xpt::editor::ResourceSetInfo::ResourceSetInfo-»
+
+ «EXPAND xpt::editor::ResourceSetModificationListener::ResourceSetModificationListener-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE createElementInfo FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected ElementInfo createElementInfo(Object element) throws org.eclipse.core.runtime.CoreException {
+ «EXPAND checkEditorInputInstance-»
+ org.eclipse.ui.IEditorInput editorInput = (org.eclipse.ui.IEditorInput) element;
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document = (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) createDocument(editorInput);
+
+ ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
+ info.setModificationStamp(computeModificationStamp(info));
+ info.fStatus = null;
+ return info;
+}
+«ENDDEFINE»
+
+«DEFINE checkEditorInputInstance FOR gmfgen::GenDiagram-»
+if («IF null = editorGen.application»false == element instanceof «EXPAND fileEditorInputClassFQName» && «ENDIF»false == element instanceof «EXPAND uriEditorInputClassFQName») {
+ «EXPAND throwIncorrectInputException-»
+}
+«ENDDEFINE»
+
+«DEFINE throwIncorrectInputException FOR gmfgen::GenDiagram-»
+throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, 0,
+ org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderIncorrectInputError(self)) FOR editorGen»,
+ new Object[] {element, «IF null = editorGen.application»"«EXPAND fileEditorInputClassFQName»", «ENDIF»"«EXPAND uriEditorInputClassFQName»"}),«EXPAND xpt::Common::nonNLS(1)»«IF null = editorGen.application»«EXPAND xpt::Common::nonNLS(2)»«ENDIF»
+ null));
+«ENDDEFINE»
+
+«DEFINE fileEditorInputClassFQName FOR gmfgen::GenDiagram»org.eclipse.ui.part.FileEditorInput«ENDDEFINE»
+
+«DEFINE uriEditorInputClassFQName FOR gmfgen::GenDiagram»org.eclipse.emf.common.ui.URIEditorInput«ENDDEFINE»
+
+«DEFINE createDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument createDocument(Object element) throws org.eclipse.core.runtime.CoreException {
+ «EXPAND checkEditorInputInstance-»
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document = createEmptyDocument();
+ setDocumentContent(document, (org.eclipse.ui.IEditorInput) element);
+ setupDocument(element, document);
+ return document;
+}
+«ENDDEFINE»
+
+«DEFINE setupDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Sets up the given document as it would be provided for the given element. The
+content of the document is not changed. This default implementation is empty.
+Subclasses may reimplement.
+
+@param element the blue-print element
+@param document the document to set up'
+ )»
+protected void setupDocument(Object element, org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document) {
+ // for subclasses
+}
+«ENDDEFINE»
+
+«DEFINE computeModificationStamp FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private long computeModificationStamp(ResourceSetInfo info) {
+ int result = 0;
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ if (file.getLocation() != null) {
+ result += file.getLocation().toFile().lastModified();
+ } else {
+ result += file.getModificationStamp();
+ }
+ }
+ «ELSE-»
+ java.io.File file = getFile(nextResource);
+ if (file != null && file.exists()) {
+ result += file.lastModified();
+ }
+ «ENDIF-»
+ }
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE createEmptyDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument createEmptyDocument() {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument document = new org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument();
+ document.setEditingDomain(createEditingDomain());
+ return document;
+}
+«ENDDEFINE»
+
+«DEFINE createEditingDomain FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.transaction.TransactionalEditingDomain createEditingDomain() {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory.getInstance().createEditingDomain();
+ editingDomain.setID("«editingDomainID»");«EXPAND xpt::Common::nonNLS»
+ final org.eclipse.emf.transaction.NotificationFilter diagramResourceModifiedFilter = org.eclipse.emf.transaction.NotificationFilter.createNotifierFilter(editingDomain.getResourceSet()).and(org.eclipse.emf.transaction.NotificationFilter.createEventTypeFilter(org.eclipse.emf.common.notify.Notification.ADD)).and(org.eclipse.emf.transaction.NotificationFilter.createFeatureFilter(org.eclipse.emf.ecore.resource.ResourceSet.class, org.eclipse.emf.ecore.resource.ResourceSet.RESOURCE_SET__RESOURCES));
+ editingDomain.getResourceSet().eAdapters().add(new org.eclipse.emf.common.notify.Adapter() {
+
+ private org.eclipse.emf.common.notify.Notifier myTarger;
+
+ public org.eclipse.emf.common.notify.Notifier getTarget() {
+ return myTarger;
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
+ if (diagramResourceModifiedFilter.matches(notification)) {
+ Object value = notification.getNewValue();
+ if (value instanceof org.eclipse.emf.ecore.resource.Resource) {
+ ((org.eclipse.emf.ecore.resource.Resource) value).setTrackingModification(true);
+ }
+ }
+ }
+
+ public void setTarget(org.eclipse.emf.common.notify.Notifier newTarget) {
+ myTarger = newTarget;
+ }
+
+ });
+
+ return editingDomain;
+}
+«ENDDEFINE»
+
+«DEFINE setDocumentContent FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void setDocumentContent(org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document, org.eclipse.ui.IEditorInput element) throws org.eclipse.core.runtime.CoreException {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument diagramDocument = (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) document;
+ org.eclipse.emf.transaction.TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
+ «IF null = editorGen.application»if (element instanceof «EXPAND fileEditorInputClassFQName») {
+ org.eclipse.core.resources.IStorage storage = ((«EXPAND fileEditorInputClassFQName») element).getStorage();
+ org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil.load(domain, storage, true, getProgressMonitor());
+ document.setContent(diagram);
+ } else «ENDIF»if(element instanceof «EXPAND uriEditorInputClassFQName») {
+ org.eclipse.emf.common.util.URI uri = ((«EXPAND uriEditorInputClassFQName») element).getURI();
+ org.eclipse.emf.ecore.resource.Resource resource = null;
+ try {
+ resource = domain.getResourceSet().getResource(uri.trimFragment(), false);
+ if (resource == null) {
+ resource = domain.getResourceSet().createResource(uri.trimFragment());
+ }
+ if (!resource.isLoaded()) {
+ try {
+ java.util.Map options = new java.util.HashMap(org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory.getDefaultLoadOptions());
+ // @see 171060
+ // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
+ resource.load(options);
+ } catch (java.io.IOException e) {
+ resource.unload();
+ throw e;
+ }
+ }
+ if (uri.fragment() != null) {
+ org.eclipse.emf.ecore.EObject rootElement = resource.getEObject(uri.fragment());
+ if (rootElement instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ document.setContent((org.eclipse.gmf.runtime.notation.Diagram) rootElement);
+ return;
+ }
+ } else {
+ for (java.util.Iterator it = resource.getContents().iterator(); it.hasNext();) {
+ Object rootElement = it.next();
+ if (rootElement instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ document.setContent((org.eclipse.gmf.runtime.notation.Diagram) rootElement);
+ return;
+ }
+ }
+ }
+ throw new RuntimeException(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderNoDiagramInResourceError(self)) FOR editorGen»);
+ } catch (Exception e) {
+ org.eclipse.core.runtime.CoreException thrownExcp = null;
+ if (e instanceof org.eclipse.core.runtime.CoreException) {
+ thrownExcp = (org.eclipse.core.runtime.CoreException) e;
+ } else {
+ String msg = e.getLocalizedMessage();
+ thrownExcp = new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, 0,
+ msg != null ? msg : «EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderDiagramLoadingError(self)) FOR editorGen», e));
+ }
+ throw thrownExcp;
+ }
+ } else {
+ «EXPAND throwIncorrectInputException-»
+ }
+}
+«ENDDEFINE»
+
+«DEFINE getModificationStamp FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public long getModificationStamp(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return computeModificationStamp(info);
+ }
+ return super.getModificationStamp(element);
+}
+«ENDDEFINE»
+
+«DEFINE isDeleted FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isDeleted(Object element) {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document = getDiagramDocument(element);
+ if (document != null) {
+ org.eclipse.emf.ecore.resource.Resource diagramResource = document.getDiagram().eResource();
+ if (diagramResource != null) {
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(diagramResource);
+ return file == null || file.getLocation() == null || !file.getLocation().toFile().exists();
+ «ELSE-»
+ java.io.File file = getFile(diagramResource);
+ return file != null && !file.exists();
+ «ENDIF-»
+ }
+ }
+ return super.isDeleted(element);
+}
+«ENDDEFINE»
+
+«DEFINE getResourceSetInfo FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public ResourceSetInfo getResourceSetInfo(Object editorInput) {
+ return (ResourceSetInfo) super.getElementInfo(editorInput);
+}
+«ENDDEFINE»
+
+«DEFINE disposeElementInfo FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void disposeElementInfo(Object element, ElementInfo info) {
+ if (info instanceof ResourceSetInfo) {
+ ResourceSetInfo resourceSetInfo = (ResourceSetInfo) info;
+ resourceSetInfo.dispose();
+ }
+ super.disposeElementInfo(element, info);
+}
+«ENDDEFINE»
+
+«DEFINE doValidateState FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void doValidateState(Object element, Object computationContext) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.resources.IFile>*/ files2Validate = new java.util.ArrayList/*<org.eclipse.core.resources.IFile>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ files2Validate.add(file);
+ }
+ }
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().validateEdit((org.eclipse.core.resources.IFile[]) files2Validate.toArray(new org.eclipse.core.resources.IFile[files2Validate.size()]), computationContext);
+ }
+
+ super.doValidateState(element, computationContext);
+}
+«ENDDEFINE»
+
+«DEFINE isReadOnly FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isReadOnly(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ «EXPAND callUpdateCache-»
+ return info.isReadOnly();
+ }
+ return super.isReadOnly(element);
+}
+«ENDDEFINE»
+
+«DEFINE isModifiable FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isModifiable(Object element) {
+ if (!isStateValidated(element)) {
+ if («IF null = editorGen.application»element instanceof «EXPAND fileEditorInputClassFQName» || «ENDIF»element instanceof «EXPAND uriEditorInputClassFQName») {
+ return true;
+ }
+ }
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ «EXPAND callUpdateCache-»
+ return info.isModifiable();
+ }
+ return super.isModifiable(element);
+}
+«ENDDEFINE»
+
+«DEFINE callUpdateCache FOR gmfgen::GenDiagram-»
+if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (org.eclipse.core.runtime.CoreException ex) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderIsModifiable(self)) FOR editorGen», ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
+ }
+}
+«ENDDEFINE»
+
+«DEFINE updateCache FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void updateCache(Object element) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ «ELSE-»
+ java.io.File file = getFile(nextResource);
+ if (file != null && file.exists() && !file.canWrite()) {
+ «ENDIF-»
+ info.setReadOnly(true);
+ info.setModifiable(false);
+ return;
+ }
+ }
+ info.setReadOnly(false);
+ info.setModifiable(true);
+ return;
+ }
+}
+«ENDDEFINE»
+
+«DEFINE doUpdateStateCache FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void doUpdateStateCache(Object element) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ info.setUpdateCache(true);
+ }
+ super.doUpdateStateCache(element);
+}
+«ENDDEFINE»
+
+«DEFINE isSynchronized FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isSynchronized(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return info.isSynchronized();
+ }
+ return super.isSynchronized(element);
+}
+«ENDDEFINE»
+
+«DEFINE getResetRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.core.runtime.jobs.ISchedulingRule getResetRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/ rules = new java.util.ArrayList/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file));
+ }
+ }
+ return new org.eclipse.core.runtime.jobs.MultiRule((org.eclipse.core.runtime.jobs.ISchedulingRule[]) rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getSaveRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.core.runtime.jobs.ISchedulingRule getSaveRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/ rules = new java.util.ArrayList/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(computeSchedulingRule(file));
+ }
+ }
+ return new org.eclipse.core.runtime.jobs.MultiRule((org.eclipse.core.runtime.jobs.ISchedulingRule[]) rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getSynchronizeRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.core.runtime.jobs.ISchedulingRule getSynchronizeRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/ rules = new java.util.ArrayList/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file));
+ }
+ }
+ return new org.eclipse.core.runtime.jobs.MultiRule((org.eclipse.core.runtime.jobs.ISchedulingRule[]) rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getValidateStateRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.core.runtime.jobs.ISchedulingRule getValidateStateRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/ files = new java.util.ArrayList/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ files.add(file);
+ }
+ }
+ return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule((org.eclipse.core.resources.IFile[]) files.toArray(new org.eclipse.core.resources.IFile[files.size()]));
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE computeSchedulingRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.core.runtime.jobs.ISchedulingRule computeSchedulingRule(org.eclipse.core.resources.IResource toCreateOrModify) {
+ if (toCreateOrModify.exists())
+ return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify);
+
+ org.eclipse.core.resources.IResource parent = toCreateOrModify;
+ do {
+ /*
+ * XXX This is a workaround for
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601
+ * IResourceRuleFactory.createRule should iterate the hierarchy
+ * itself.
+ */
+ toCreateOrModify = parent;
+ parent = toCreateOrModify.getParent();
+ } while (parent != null && !parent.exists());
+
+ return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify);
+}
+«ENDDEFINE»
+
+«DEFINE doSynchronize FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void doSynchronize(Object element, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ handleElementChanged(info, nextResource, monitor);
+ }
+ return;
+ }
+ super.doSynchronize(element, monitor);
+}
+«ENDDEFINE»
+
+«DEFINE handleElementChanged FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void handleElementChanged(ResourceSetInfo info, org.eclipse.emf.ecore.resource.Resource changedResource, org.eclipse.core.runtime.IProgressMonitor monitor) {
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(changedResource);
+ if (file != null) {
+ try {
+ file.refreshLocal(org.eclipse.core.resources.IResource.DEPTH_INFINITE, monitor);
+ } catch (org.eclipse.core.runtime.CoreException ex) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderHandleElementContentChanged(self)) FOR editorGen», ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged
+ }
+ }
+ «ENDIF-»
+ changedResource.unload();
+
+ fireElementContentAboutToBeReplaced(info.getEditorInput());
+ removeUnchangedElementListeners(info.getEditorInput(), info);
+ info.fStatus = null;
+ try {
+ setDocumentContent(info.fDocument, info.getEditorInput());
+ } catch (org.eclipse.core.runtime.CoreException e) {
+ info.fStatus = e.getStatus();
+ }
+«REM»TODO: Remove this if and call setModificationStamp only from doSaveDocument method«ENDREM»«-»
+ if (!info.fCanBeSaved) {
+ info.setModificationStamp(computeModificationStamp(info));
+ }
+ addUnchangedElementListeners(info.getEditorInput(), info);
+ fireElementContentReplaced(info.getEditorInput());
+}
+«ENDDEFINE»
+
+«DEFINE doSaveDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void doSaveDocument(org.eclipse.core.runtime.IProgressMonitor monitor, Object element, org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document, boolean overwrite) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ if (!overwrite && !info.isSynchronized()) {
+ throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID,
+ «IF null = editorGen.application»org.eclipse.core.resources.IResourceStatus.OUT_OF_SYNC_LOCAL«ELSE»org.eclipse.core.runtime.IStatus.ERROR«ENDIF»,
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentUnsynchronizedFileSaveError(self)) FOR editorGen»,
+ null));
+ }
+ «IF null = editorGen.application-»
+ info.stopResourceListening();
+ «ENDIF-»
+ fireElementStateChanging(element);
+ try {
+ monitor.beginTask(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentSaveDiagramTask(self)) FOR editorGen», info.getResourceSet().getResources().size() + 1); //"Saving diagram"
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ monitor.setTaskName(org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentSaveNextResourceTask(self)) FOR editorGen»,
+ nextResource.getURI()));
+ if (nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) {
+ try {
+ nextResource.save(«EXPAND xpt::Common::getSaveOptions»);
+ } catch (java.io.IOException e) {
+ fireElementStateChangeFailed(element);
+ throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null));
+ }
+ }
+ monitor.worked(1);
+ }
+ monitor.done();
+ info.setModificationStamp(computeModificationStamp(info));
+ } catch (RuntimeException x) {
+ fireElementStateChangeFailed(element);
+ throw x;
+ } «IF null = editorGen.application» finally {
+ info.startResourceListening();
+ } «ENDIF»
+ } else {
+ org.eclipse.emf.common.util.URI newResoruceURI;
+ java.util.List affectedFiles = null;
+ «IF null = editorGen.application»if (element instanceof «EXPAND fileEditorInputClassFQName») {
+ org.eclipse.core.resources.IFile newFile = ((«EXPAND fileEditorInputClassFQName») element).getFile();
+ affectedFiles = java.util.Collections.singletonList(newFile);
+ newResoruceURI = org.eclipse.emf.common.util.URI.createPlatformResourceURI(newFile.getFullPath().toString(), true);
+ } else «ENDIF»if(element instanceof «EXPAND uriEditorInputClassFQName») {
+ newResoruceURI = ((«EXPAND uriEditorInputClassFQName») element).getURI();
+ } else {
+ fireElementStateChangeFailed(element);
+ «EXPAND throwIncorrectInputException-»
+ }
+ if (false == document instanceof org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) {
+ fireElementStateChangeFailed(element);
+ throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, 0,
+ "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null));«EXPAND xpt::Common::nonNLS(1)»«EXPAND xpt::Common::nonNLS(2)»
+ }
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument diagramDocument = (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) document;
+ final org.eclipse.emf.ecore.resource.Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI);
+ final org.eclipse.gmf.runtime.notation.Diagram diagramCopy = (org.eclipse.gmf.runtime.notation.Diagram) org.eclipse.emf.ecore.util.EcoreUtil.copy(diagramDocument.getDiagram());
+ try {
+ new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(diagramDocument.getEditingDomain(), org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentSaveAs(self)) FOR editorGen», diagramCopy.getName()), affectedFiles) {
+ 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 {
+ newResource.getContents().add(diagramCopy);
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ }
+ }.execute(monitor, null);
+ newResource.save(«EXPAND xpt::Common::getSaveOptions»);
+ } catch (org.eclipse.core.commands.ExecutionException e) {
+ fireElementStateChangeFailed(element);
+ throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, 0, e.getLocalizedMessage(), null));
+ } catch (java.io.IOException e) {
+ fireElementStateChangeFailed(element);
+ throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, 0, e.getLocalizedMessage(), null));
+ }
+ newResource.unload();
+ }
+}
+«ENDDEFINE»
+
+«DEFINE handleElementMoved FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void handleElementMoved(org.eclipse.ui.IEditorInput input, org.eclipse.emf.common.util.URI uri) {
+ «IF null = editorGen.application»if (input instanceof «EXPAND fileEditorInputClassFQName») {
+ org.eclipse.core.resources.IFile newFile = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getFile(new org.eclipse.core.runtime.Path(org.eclipse.emf.common.util.URI.decode(uri.path())).removeFirstSegments(1));
+ fireElementMoved(input, newFile == null ? null : new org.eclipse.ui.part.FileEditorInput(newFile));
+ return;
+ }«ENDIF»
+ // TODO: append suffix to the URI! (use diagram as a parameter)
+ fireElementMoved(input, new org.eclipse.emf.common.ui.URIEditorInput(uri));
+}
+«ENDDEFINE»
+
+«DEFINE createInputWithEditingDomain FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.ui.IEditorInput createInputWithEditingDomain(org.eclipse.ui.IEditorInput editorInput, org.eclipse.emf.transaction.TransactionalEditingDomain domain) {
+ return editorInput;
+}
+«ENDDEFINE»
+
+«DEFINE getDiagramDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument getDiagramDocument(Object element) {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument doc = getDocument(element);
+ if (doc instanceof org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) {
+ return (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) doc;
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getOperationRunner FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.jface.operation.IRunnableContext getOperationRunner(org.eclipse.core.runtime.IProgressMonitor monitor) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getFile FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private static java.io.File getFile(org.eclipse.emf.ecore.resource.Resource resource) {
+ org.eclipse.emf.common.util.URI resourceUri = resource.getURI();
+ if (resourceUri != null && resourceUri.isFile()) {
+ java.io.File file = new java.io.File(resourceUri.toFileString());
+ if (!file.isDirectory()) {
+ return file;
+ }
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentProviderIsModifiable(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentProviderHandleElementContentChanged(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentProviderIncorrectInputError(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentProviderNoDiagramInResourceError(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentProviderDiagramLoadingError(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentUnsynchronizedFileSaveError(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentSaveDiagramTask(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentSaveNextResourceTask(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForDocumentSaveAs(self))-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentProviderIsModifiable(self), 'Updating cache failed')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentProviderHandleElementContentChanged(self), 'Failed to refresh hierarchy for changed resource')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentProviderIncorrectInputError(self), (if 'Incorrect element used: {0} instead of ' + editorGen.application.repr() = null then '{1} or {2}' else '{1}' endif))-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentProviderNoDiagramInResourceError(self), 'Diagram is not present in resource')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentProviderDiagramLoadingError(self), 'Error loading diagram')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentUnsynchronizedFileSaveError(self), 'The file has been changed on the file system')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentSaveDiagramTask(self), 'Saving diagram')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentSaveNextResourceTask(self), 'Saving {0}')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForDocumentSaveAs(self), 'Saving {0} diagram as')-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DomainModelElementTester.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DomainModelElementTester.xpt
new file mode 100644
index 000000000..ee08817d7
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DomainModelElementTester.xpt
@@ -0,0 +1,50 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE DomainModelElementTester FOR gmfgen::GenNavigator-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «domainModelElementTesterClassName» extends org.eclipse.core.expressions.PropertyTester {
+
+ «EXPAND test-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE test FOR gmfgen::GenNavigator-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
+ if (false == receiver instanceof org.eclipse.emf.ecore.EObject) {
+ return false;
+ }
+ org.eclipse.emf.ecore.EObject eObject = (org.eclipse.emf.ecore.EObject) receiver;
+ org.eclipse.emf.ecore.EClass eClass = eObject.eClass();
+ «EXPAND checkGenClass FOREACH editorGen.domainGenModel.genPackages.genClasses-»
+ return false;
+}
+«ENDDEFINE»
+
+«DEFINE checkGenClass FOR genmodel::GenClass-»
+if (eClass == «EXPAND MetaModel::MetaClass») {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNavigator-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Editor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Editor.xpt
new file mode 100644
index 000000000..2c04ce16c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Editor.xpt
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2006, 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE Editor FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «className» extends org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor«EXPAND implementsList FOR getEditorImplementsList(self)» {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND getContextID-»
+ «EXPAND createPaletteRoot FOR editorGen.diagram.palette-»
+
+ «EXPAND getPreferencesHint-»
+
+ «EXPAND getContributorId-»
+ «EXPAND getAdapter-»
+
+ «EXPAND getDocumentProvider-»
+
+ «EXPAND getEditingDomain-»
+
+ «EXPAND setDocumentProvider-»
+ «IF isIDEMode(self)-»
+
+ «EXPAND gotoMarker-»
+
+ «EXPAND isSaveAsAllowed-»
+
+ «EXPAND doSaveAs-»
+
+ «EXPAND performSaveAs-»
+
+ «EXPAND getShowInContext-»
+ «EXPAND getNavigatorSelection FOR editorGen.navigator-»
+ «ENDIF-»
+
+ «EXPAND configureGraphicalViewer-»
+
+ «IF editorGen.diagram.generateCreateShortcutAction()-»
+
+ «EXPAND initializeGraphicalViewer-»
+
+ «EXPAND DropTargetListener-»
+ «ENDIF-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static final String ID = "«iD»"; «EXPAND xpt::Common::nonNLS»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public static final String CONTEXT_ID = "«contextID»"; «EXPAND xpt::Common::nonNLS»
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «className»() {
+ super(«null <> editorGen.diagram.palette and editorGen.diagram.palette.flyout»);
+}
+«ENDDEFINE»
+
+«DEFINE getContextID FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected String getContextID() {
+ return CONTEXT_ID;
+}
+«ENDDEFINE»
+
+«DEFINE createPaletteRoot FOR gmfgen::Palette-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.palette.PaletteRoot createPaletteRoot(org.eclipse.gef.palette.PaletteRoot existingPaletteRoot) {
+ org.eclipse.gef.palette.PaletteRoot root = super.createPaletteRoot(existingPaletteRoot);
+ new «getFactoryQualifiedClassName()»().fillPalette(root);
+ return root;
+}
+«ENDDEFINE»
+
+«DEFINE getPreferencesHint FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint getPreferencesHint() {
+«REM»
+ XXX seems better we use preference store directly (in configureGraphicalViewer) instead all these indirect ids
+«ENDREM»«-»
+ return «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»;
+}
+«ENDDEFINE»
+
+«DEFINE getContributorId FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public String getContributorId() {
+ return «editorGen.plugin.getActivatorQualifiedClassName()».ID;
+}
+«ENDDEFINE»
+
+«DEFINE getAdapter FOR gmfgen::GenEditorView-»
+ «IF not hasPropertySheet(self) or hasNavigator(self)-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public Object getAdapter(Class type) {
+ «IF not hasPropertySheet(self)-»
+ if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) {
+ return null;
+ }
+ «ENDIF-»
+ «IF hasNavigator(self)-»
+ if (type == org.eclipse.ui.part.IShowInTargetList.class) {
+ return new org.eclipse.ui.part.IShowInTargetList() {
+ public String[] getShowInTargetIds() {
+ return new String[] { org.eclipse.ui.navigator.resources.ProjectExplorer.VIEW_ID };
+ }
+ };
+ }
+ «ENDIF-»
+ return super.getAdapter(type);
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getDocumentProvider FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider getDocumentProvider(org.eclipse.ui.IEditorInput input) {
+ if («EXPAND checkEditorInput») {
+ return «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getDocumentProvider();
+ }
+ return super.getDocumentProvider(input);
+}
+«ENDDEFINE»
+
+«DEFINE getEditingDomain FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain() {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document = getEditorInput() != null ? getDocumentProvider().getDocument(getEditorInput()) : null;
+ if (document instanceof org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) {
+ return ((org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) document).getEditingDomain();
+ }
+ return super.getEditingDomain();
+}
+«ENDDEFINE»
+
+«DEFINE setDocumentProvider FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void setDocumentProvider(org.eclipse.ui.IEditorInput input) {
+ if («EXPAND checkEditorInput») {
+ setDocumentProvider(«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getDocumentProvider());
+ } else {
+ super.setDocumentProvider(input);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE checkEditorInput FOR gmfgen::GenEditorView»«IF isIDEMode(self)»input instanceof org.eclipse.ui.IFileEditorInput || «ENDIF»input instanceof org.eclipse.emf.common.ui.URIEditorInput«ENDDEFINE»
+
+«DEFINE gotoMarker FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void gotoMarker(org.eclipse.core.resources.IMarker marker) {
+ org.eclipse.gmf.runtime.common.ui.services.marker.MarkerNavigationService.getInstance().gotoMarker(this, marker);
+}
+«ENDDEFINE»
+
+«DEFINE isSaveAsAllowed FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isSaveAsAllowed() {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE doSaveAs FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void doSaveAs() {
+ performSaveAs(new org.eclipse.core.runtime.NullProgressMonitor());
+}
+«ENDDEFINE»
+
+«DEFINE performSaveAs FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void performSaveAs(org.eclipse.core.runtime.IProgressMonitor progressMonitor) {
+ org.eclipse.swt.widgets.Shell shell = getSite().getShell();
+ org.eclipse.ui.IEditorInput input = getEditorInput();
+ org.eclipse.ui.dialogs.SaveAsDialog dialog = new org.eclipse.ui.dialogs.SaveAsDialog(shell);
+ org.eclipse.core.resources.IFile original = input instanceof org.eclipse.ui.IFileEditorInput ? ((org.eclipse.ui.IFileEditorInput) input).getFile() : null;
+ if (original != null) {
+ dialog.setOriginalFile(original);
+ }
+ dialog.create();
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider provider = getDocumentProvider();
+ if (provider == null) {
+ // editor has been programmatically closed while the dialog was open
+ return;
+ }
+ if (provider.isDeleted(input) && original != null) {
+ String message = org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForSavingDeletedFile(self)) FOR editorGen», original.getName());
+ dialog.setErrorMessage(null);
+ dialog.setMessage(message, org.eclipse.jface.dialogs.IMessageProvider.WARNING);
+ }
+ if (dialog.open() == org.eclipse.jface.window.Window.CANCEL) {
+ if (progressMonitor != null) {
+ progressMonitor.setCanceled(true);
+ }
+ return;
+ }
+ org.eclipse.core.runtime.IPath filePath = dialog.getResult();
+ if (filePath == null) {
+ if (progressMonitor != null) {
+ progressMonitor.setCanceled(true);
+ }
+ return;
+ }
+ org.eclipse.core.resources.IWorkspaceRoot workspaceRoot = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot();
+ org.eclipse.core.resources.IFile file = workspaceRoot.getFile(filePath);
+ final org.eclipse.ui.IEditorInput newInput = new org.eclipse.ui.part.FileEditorInput(file);
+ // Check if the editor is already open
+ org.eclipse.ui.IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
+ org.eclipse.ui.IEditorReference[] editorRefs = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
+ for (int i = 0; i < editorRefs.length; i++) {
+ if (matchingStrategy.matches(editorRefs[i], newInput)) {
+ org.eclipse.jface.dialogs.MessageDialog.openWarning(shell, «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForSaveAsProblems(self))) FOR editorGen», «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForSaveAsProblems(self))) FOR editorGen»);
+ return;
+ }
+ }
+ boolean success = false;
+ try {
+ provider.aboutToChange(newInput);
+ getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
+ success = true;
+ } catch (org.eclipse.core.runtime.CoreException x) {
+ org.eclipse.core.runtime.IStatus status = x.getStatus();
+ if (status == null || status.getSeverity() != org.eclipse.core.runtime.IStatus.CANCEL) {
+ org.eclipse.jface.dialogs.ErrorDialog.openError(shell, «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForSaveProblems(self))) FOR editorGen», «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForSaveProblems(self))) FOR editorGen», x.getStatus());
+ }
+ } finally {
+ provider.changed(newInput);
+ if (success) {
+ setInput(newInput);
+ }
+ }
+ if (progressMonitor != null) {
+ progressMonitor.setCanceled(!success);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE getShowInContext FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.ui.part.ShowInContext getShowInContext() {
+ return new org.eclipse.ui.part.ShowInContext(getEditorInput(), «IF hasNavigator(self)»getNavigatorSelection()«ELSE»getGraphicalViewer().getSelection()«ENDIF»);
+}
+«ENDDEFINE»
+
+«DEFINE getNavigatorSelection FOR gmfgen::GenNavigator-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.jface.viewers.ISelection getNavigatorSelection() {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document = getDiagramDocument();
+ «EXPAND xpt::navigator::NavigatorLinkHelper::findSelectionBody-»
+}
+«ENDDEFINE»
+
+«DEFINE configureGraphicalViewer FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void configureGraphicalViewer() {
+ super.configureGraphicalViewer();
+ «EXPAND xpt::editor::DiagramEditorContextMenuProvider::qualifiedClassName FOR editorGen.diagram» provider =
+ new «EXPAND xpt::editor::DiagramEditorContextMenuProvider::qualifiedClassName FOR editorGen.diagram»(this, getDiagramGraphicalViewer());
+ getDiagramGraphicalViewer().setContextMenu(provider);
+ getSite().registerContextMenu(org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer());
+ }
+«ENDDEFINE»
+
+«DEFINE initializeGraphicalViewer FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void initializeGraphicalViewer() {
+ super.initializeGraphicalViewer();
+ «EXPAND addDropTargetListener('org.eclipse.jface.util.LocalSelectionTransfer.getTransfer()')-»
+ «EXPAND addDropTargetListener('org.eclipse.emf.edit.ui.dnd.LocalTransfer.getInstance()')-»
+}
+«ENDDEFINE»
+
+«DEFINE addDropTargetListener(transferAccessor : String) FOR gmfgen::GenEditorView-»
+getDiagramGraphicalViewer().addDropTargetListener(new DropTargetListener(getDiagramGraphicalViewer(), «transferAccessor») {
+
+ protected Object getJavaObject(org.eclipse.swt.dnd.TransferData data) {
+ return «transferAccessor».nativeToJava(data);
+ }
+
+});
+«ENDDEFINE»
+
+«DEFINE DropTargetListener FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedClassComment»
+private abstract class DropTargetListener extends org.eclipse.gmf.runtime.diagram.ui.parts.DiagramDropTargetListener {
+
+ «EXPAND DTL_constructor-»
+
+ «EXPAND DTL_getObjectsBeingDropped-»
+
+ «EXPAND DTL_getJavaObject-»
+
+ «EXPAND DTL_additions-»
+}
+«ENDDEFINE»
+
+
+«DEFINE DTL_constructor FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public DropTargetListener(org.eclipse.gef.EditPartViewer viewer, org.eclipse.swt.dnd.Transfer xfer) {
+ super(viewer, xfer);
+}
+«ENDDEFINE»
+
+«DEFINE DTL_getObjectsBeingDropped FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected java.util.List getObjectsBeingDropped() {
+ org.eclipse.swt.dnd.TransferData data = getCurrentEvent().currentDataType;
+ java.util.Collection uris = new java.util.HashSet();
+
+ Object transferedObject = getJavaObject(data);
+ if (transferedObject instanceof org.eclipse.jface.viewers.IStructuredSelection) {
+ org.eclipse.jface.viewers.IStructuredSelection selection = (org.eclipse.jface.viewers.IStructuredSelection) transferedObject;
+ for (java.util.Iterator it = selection.iterator(); it.hasNext();) {
+ Object nextSelectedObject = it.next();
+«REM»
+ TODO: move NavigatorItem to some place available in runtime and remove
+ "genEditor.getEditorGen().getNavigator() != null" test
+«ENDREM»«-»
+ «IF hasNavigator(self)»if (nextSelectedObject instanceof «editorGen.navigator.getNavigatorItemQualifiedClassName()») {
+ org.eclipse.gmf.runtime.notation.View view = ((«editorGen.navigator.getNavigatorItemQualifiedClassName()») nextSelectedObject).getView();
+ nextSelectedObject = view.getElement();
+ } else «ENDIF»if (nextSelectedObject instanceof org.eclipse.core.runtime.IAdaptable) {
+ org.eclipse.core.runtime.IAdaptable adaptable = (org.eclipse.core.runtime.IAdaptable) nextSelectedObject;
+ nextSelectedObject = adaptable.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ }
+
+ if (nextSelectedObject instanceof org.eclipse.emf.ecore.EObject) {
+ org.eclipse.emf.ecore.EObject modelElement = (org.eclipse.emf.ecore.EObject) nextSelectedObject;
+ org.eclipse.emf.ecore.resource.Resource modelElementResource = modelElement.eResource();
+ uris.add(modelElementResource.getURI().appendFragment(modelElementResource.getURIFragment(modelElement)));
+ }
+ }
+ }
+
+ java.util.List result = new java.util.ArrayList();
+ for (java.util.Iterator it = uris.iterator(); it.hasNext();) {
+ org.eclipse.emf.common.util.URI nextURI = (org.eclipse.emf.common.util.URI) it.next();
+ org.eclipse.emf.ecore.EObject modelObject = getEditingDomain().getResourceSet().getEObject(nextURI, true);
+ result.add(modelObject);
+ }
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE DTL_getJavaObject FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected abstract Object getJavaObject(org.eclipse.swt.dnd.TransferData data);
+«ENDDEFINE»
+
+«DEFINE implementsList FOR Sequence(String)-»
+«IF not self->isEmpty()» implements «EXPAND implementsListEntry FOREACH self SEPARATOR ', '»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE implementsListEntry FOR String»«self»«ENDDEFINE»
+
+«DEFINE DTL_additions FOR gmfgen::GenEditorView-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenEditorView-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenEditorView-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForSavingDeletedFile(self), 'The original file "{0}" has been deleted.')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForSaveAsProblems(self)), 'Problem During Save As...')-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForSaveAsProblems(self)), 'Save could not be completed. Target file is already open in another editor.')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForSaveProblems(self)), 'Save Problems')-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForSaveProblems(self)), 'Could not save file.')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForSavingDeletedFile(self))-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForSaveAsProblems(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForSaveAsProblems(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForSaveProblems(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForSaveProblems(self)))-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ElementChooser.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ElementChooser.xpt
new file mode 100644
index 000000000..4481be47b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ElementChooser.xpt
@@ -0,0 +1,414 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE ElementChooser FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «elementChooserClassName» extends org.eclipse.jface.dialogs.Dialog {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND createDialogArea-»
+
+ «EXPAND createButtonBar-»
+
+ «EXPAND createModelBrowser-»
+
+ «EXPAND setOkButtonEnabled-»
+
+ «EXPAND isValidModelFile-»
+
+ «EXPAND getSelectedModelElementURI-»
+
+ «EXPAND open-»
+
+ «EXPAND ModelElementsTreeContentProvider-»
+
+ «EXPAND ModelElementsTreeLabelProvider-»
+
+ «EXPAND ModelFilesFilter-»
+
+ «EXPAND OkButtonEnabler-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.jface.viewers.TreeViewer myTreeViewer;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.common.util.URI mySelectedModelElementURI;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gmf.runtime.notation.View myView;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.transaction.TransactionalEditingDomain myEditingDomain = org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «elementChooserClassName»(org.eclipse.swt.widgets.Shell parentShell, org.eclipse.gmf.runtime.notation.View view) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | org.eclipse.swt.SWT.RESIZE);
+ myView = view;
+}
+«ENDDEFINE»
+
+«DEFINE createDialogArea FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent) {
+ org.eclipse.swt.widgets.Composite composite = (org.eclipse.swt.widgets.Composite) super.createDialogArea(parent);
+ getShell().setText(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForSelectModelElement(self))) FOR editorGen»);
+ createModelBrowser(composite);
+ return composite;
+}
+«ENDDEFINE»
+
+«DEFINE createButtonBar FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.swt.widgets.Control createButtonBar(org.eclipse.swt.widgets.Composite parent) {
+ org.eclipse.swt.widgets.Control buttonBar = super.createButtonBar(parent);
+ setOkButtonEnabled(false);
+ return buttonBar;
+}
+«ENDDEFINE»
+
+«DEFINE createModelBrowser FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void createModelBrowser(org.eclipse.swt.widgets.Composite composite) {
+ myTreeViewer = new org.eclipse.jface.viewers.TreeViewer(composite, org.eclipse.swt.SWT.SINGLE | org.eclipse.swt.SWT.H_SCROLL | org.eclipse.swt.SWT.V_SCROLL | org.eclipse.swt.SWT.BORDER);
+ org.eclipse.swt.layout.GridData layoutData = new org.eclipse.swt.layout.GridData(org.eclipse.swt.layout.GridData.FILL_BOTH);
+ layoutData.heightHint = 300;
+ layoutData.widthHint = 300;
+ myTreeViewer.getTree().setLayoutData(layoutData);
+ myTreeViewer.setContentProvider(new ModelElementsTreeContentProvider());
+ myTreeViewer.setLabelProvider(new ModelElementsTreeLabelProvider());
+ myTreeViewer.setInput(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot());
+ myTreeViewer.addFilter(new ModelFilesFilter());
+ myTreeViewer.addSelectionChangedListener(new OkButtonEnabler());
+}
+«ENDDEFINE»
+
+«DEFINE setOkButtonEnabled FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void setOkButtonEnabled(boolean enabled) {
+ getButton(org.eclipse.jface.dialogs.IDialogConstants.OK_ID).setEnabled(enabled);
+}
+«ENDDEFINE»
+
+«DEFINE isValidModelFile FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private boolean isValidModelFile(org.eclipse.core.resources.IFile file) {
+ String fileExtension = file.getFullPath().getFileExtension();
+ return «EXPAND compareModelFileExtension FOREACH containsShortcutsTo SEPARATOR ' || '»; «EXPAND xpt::Common::nonNLS FOR containsShortcutsTo->asSequence()»
+}
+«ENDDEFINE»
+
+«DEFINE compareModelFileExtension FOR String»"«self»".equals(fileExtension)«ENDDEFINE»
+
+«DEFINE getSelectedModelElementURI FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.common.util.URI getSelectedModelElementURI() {
+ return mySelectedModelElementURI;
+}
+«ENDDEFINE»
+
+«DEFINE open FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public int open() {
+ int result = super.open();
+ for (java.util.Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource resource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ resource.unload();
+ }
+ myEditingDomain.dispose();
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE ModelElementsTreeContentProvider FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private class ModelElementsTreeContentProvider implements org.eclipse.jface.viewers.ITreeContentProvider {
+
+ «EXPAND METCP_attributes-»
+
+ «EXPAND METCP_getChildren-»
+
+ «EXPAND METCP_getParent-»
+
+ «EXPAND METCP_hasChildren-»
+
+ «EXPAND METCP_getElements-»
+
+ «EXPAND METCP_dispose-»
+
+ «EXPAND METCP_inputChanged-»
+
+ «EXPAND METCP_additions-»
+}
+«ENDDEFINE»
+
+«DEFINE METCP_attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.jface.viewers.ITreeContentProvider myWorkbenchContentProvider = new «IF null = editorGen.application»org.eclipse.ui.model.WorkbenchContentProvider«ELSE»org.eclipse.ui.model.BaseWorkbenchContentProvider«ENDIF»();
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider myAdapterFctoryContentProvier = new org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider(«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory());
+«ENDDEFINE»
+
+«DEFINE METCP_getChildren FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public Object[] getChildren(Object parentElement) {
+ Object[] result = myWorkbenchContentProvider.getChildren(parentElement);
+ if (result != null && result.length > 0) {
+ return result;
+ }
+ if (parentElement instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.core.resources.IFile modelFile = (org.eclipse.core.resources.IFile) parentElement;
+ org.eclipse.core.runtime.IPath resourcePath = modelFile.getFullPath();
+ org.eclipse.emf.ecore.resource.ResourceSet resourceSet = myEditingDomain.getResourceSet();
+ try {
+ org.eclipse.emf.ecore.resource.Resource modelResource = resourceSet.getResource(org.eclipse.emf.common.util.URI.createPlatformResourceURI(resourcePath.toString(), true), true);
+ return myAdapterFctoryContentProvier.getChildren(modelResource);
+ } catch (org.eclipse.emf.common.util.WrappedException e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to load resource: " + resourcePath.toString(), e); «EXPAND xpt::Common::nonNLS»
+ }
+ return java.util.Collections.EMPTY_LIST.toArray();
+ }
+ return myAdapterFctoryContentProvier.getChildren(parentElement);
+}
+«ENDDEFINE»
+
+«DEFINE METCP_getParent FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public Object getParent(Object element) {
+ Object parent = myWorkbenchContentProvider.getParent(element);
+ if (parent != null) {
+ return parent;
+ }
+ if (element instanceof org.eclipse.emf.ecore.EObject) {
+ org.eclipse.emf.ecore.EObject eObject = (org.eclipse.emf.ecore.EObject) element;
+ if (eObject.eContainer() == null && eObject.eResource().getURI().isFile()) {
+ String path = eObject.eResource().getURI().path();
+ return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new org.eclipse.core.runtime.Path(path));
+ }
+ return myAdapterFctoryContentProvier.getParent(eObject);
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE METCP_hasChildren FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean hasChildren(Object element) {
+ if (element instanceof org.eclipse.core.resources.IFile) {
+ return isValidModelFile((org.eclipse.core.resources.IFile) element);
+ }
+ return myWorkbenchContentProvider.hasChildren(element) || myAdapterFctoryContentProvier.hasChildren(element);
+}
+«ENDDEFINE»
+
+«DEFINE METCP_getElements FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public Object[] getElements(Object inputElement) {
+ Object[] elements = myWorkbenchContentProvider.getElements(inputElement);
+ return elements;
+}
+«ENDDEFINE»
+
+«DEFINE METCP_dispose FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void dispose() {
+ myWorkbenchContentProvider.dispose();
+ myAdapterFctoryContentProvier.dispose();
+}
+«ENDDEFINE»
+
+«DEFINE METCP_inputChanged FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void inputChanged(org.eclipse.jface.viewers.Viewer viewer, Object oldInput, Object newInput) {
+ myWorkbenchContentProvider.inputChanged(viewer, oldInput, newInput);
+ myAdapterFctoryContentProvier.inputChanged(viewer, oldInput, newInput);
+}
+«ENDDEFINE»
+
+«DEFINE ModelElementsTreeLabelProvider FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private class ModelElementsTreeLabelProvider implements org.eclipse.jface.viewers.ILabelProvider {
+
+ «EXPAND METLP_attributes-»
+
+ «EXPAND METLP_getImage-»
+
+ «EXPAND METLP_getText-»
+
+ «EXPAND METLP_addListener-»
+
+ «EXPAND METLP_dispose-»
+
+ «EXPAND METLP_isLabelProperty-»
+
+ «EXPAND METLP_removeListener-»
+
+ «EXPAND METLP_additions-»
+}
+«ENDDEFINE»
+
+
+«DEFINE METLP_attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.model.WorkbenchLabelProvider myWorkbenchLabelProvider = new org.eclipse.ui.model.WorkbenchLabelProvider();
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider myAdapterFactoryLabelProvider = new org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider(«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory());
+«ENDDEFINE»
+
+«DEFINE METLP_getImage FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.swt.graphics.Image getImage(Object element) {
+ org.eclipse.swt.graphics.Image result = myWorkbenchLabelProvider.getImage(element);
+ return result != null ? result : myAdapterFactoryLabelProvider.getImage(element);
+}
+«ENDDEFINE»
+
+«DEFINE METLP_getText FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public String getText(Object element) {
+ String result = myWorkbenchLabelProvider.getText(element);
+ return result != null && result.length() > 0 ? result : myAdapterFactoryLabelProvider.getText(element);
+}
+«ENDDEFINE»
+
+«DEFINE METLP_addListener FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void addListener(org.eclipse.jface.viewers.ILabelProviderListener listener) {
+ myWorkbenchLabelProvider.addListener(listener);
+ myAdapterFactoryLabelProvider.addListener(listener);
+}
+«ENDDEFINE»
+
+«DEFINE METLP_dispose FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void dispose() {
+ myWorkbenchLabelProvider.dispose();
+ myAdapterFactoryLabelProvider.dispose();
+}
+«ENDDEFINE»
+
+«DEFINE METLP_isLabelProperty FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isLabelProperty(Object element, String property) {
+ return myWorkbenchLabelProvider.isLabelProperty(element, property) || myAdapterFactoryLabelProvider.isLabelProperty(element, property);
+}
+«ENDDEFINE»
+
+«DEFINE METLP_removeListener FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void removeListener(org.eclipse.jface.viewers.ILabelProviderListener listener) {
+ myWorkbenchLabelProvider.removeListener(listener);
+ myAdapterFactoryLabelProvider.removeListener(listener);
+}
+«ENDDEFINE»
+
+«DEFINE ModelFilesFilter FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private class ModelFilesFilter extends org.eclipse.jface.viewers.ViewerFilter {
+
+ «EXPAND MFF_select-»
+
+ «EXPAND MFF_additions-»
+}
+«ENDDEFINE»
+
+«DEFINE MFF_select FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean select(org.eclipse.jface.viewers.Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof org.eclipse.core.resources.IContainer) {
+ return true;
+ }
+ if (element instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.core.resources.IFile file = (org.eclipse.core.resources.IFile) element;
+ return isValidModelFile(file);
+ }
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE OkButtonEnabler FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private class OkButtonEnabler implements org.eclipse.jface.viewers.ISelectionChangedListener {
+
+ «EXPAND OBE_selectionChanged-»
+
+ «EXPAND OBE_additions-»
+}
+«ENDDEFINE»
+
+«DEFINE OBE_selectionChanged FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event) {
+ if (event.getSelection() instanceof org.eclipse.jface.viewers.IStructuredSelection) {
+ org.eclipse.jface.viewers.IStructuredSelection selection = (org.eclipse.jface.viewers.IStructuredSelection) event.getSelection();
+ if (selection.size() == 1) {
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof org.eclipse.emf.edit.provider.IWrapperItemProvider) {
+ selectedElement = ((org.eclipse.emf.edit.provider.IWrapperItemProvider) selectedElement).getValue();
+ }
+ if (selectedElement instanceof org.eclipse.emf.ecore.util.FeatureMap.Entry) {
+ selectedElement = ((org.eclipse.emf.ecore.util.FeatureMap.Entry) selectedElement).getValue();
+ }
+ if (selectedElement instanceof org.eclipse.emf.ecore.EObject) {
+ org.eclipse.emf.ecore.EObject selectedModelElement = (org.eclipse.emf.ecore.EObject) selectedElement;
+ setOkButtonEnabled(org.eclipse.gmf.runtime.diagram.core.services.ViewService.getInstance().provides(org.eclipse.gmf.runtime.notation.Node.class, new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(selectedModelElement), myView, null, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true, «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»));
+ mySelectedModelElementURI = org.eclipse.emf.ecore.util.EcoreUtil.getURI(selectedModelElement);
+ return;
+ }
+ }
+ }
+ mySelectedModelElementURI = null;
+ setOkButtonEnabled(false);
+}
+«ENDDEFINE»
+
+«DEFINE METCP_additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE METLP_additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE MFF_additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE OBE_additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForSelectModelElement(self)), 'Select model element')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForSelectModelElement(self)))-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/GenDiagram.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/GenDiagram.qvto
new file mode 100644
index 000000000..e6716d8b8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/GenDiagram.qvto
@@ -0,0 +1,29 @@
+import xpt.NativeGenModelUtils;
+
+import xpt.GenModelUtils;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
+modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
+
+library GenDiagram;
+
+helper standaloneDomainModel(genDiagram : genModel::GenDiagram) : Boolean {
+ return not genDiagram.editorGen.sameFileForDiagramAndModel and genDiagram.domainDiagramElement <> null
+}
+
+helper hasDocumentRoot(genDiagram : genModel::GenDiagram) : Boolean {
+ return getDocumentRoot(genDiagram) <> null
+}
+
+helper getDocumentRoot(genDiagram : genModel::GenDiagram) : genModel_1::GenClass {
+ return (if genDiagram.domainDiagramElement = null then null else getDocumentRoot(genDiagram.domainDiagramElement.genPackage) endif)
+}
+
+helper getDocumentRootSetFeature(genDiagram : genModel::GenDiagram) : genModel_1::GenFeature {
+ return getDocumentRoot(genDiagram).genFeatures->select(f | isDocRootSetFeature(f, genDiagram.domainDiagramElement.ecoreClass))->first()
+}
+
+helper isDocRootSetFeature(gf : genModel_1::GenFeature, eType : ecore::EClass) : Boolean {
+ return not isListType(gf) and gf.ecoreFeature.changeable and (-2 = gf.ecoreFeature.upperBound.oclAsType(Integer) and (gf.ecoreFeature.eClass().name = 'EReference' and gf.ecoreFeature.eType.oclAsType(ecore::EClass).isSuperTypeOf(eType)))
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/InitDiagramFileAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/InitDiagramFileAction.xpt
new file mode 100644
index 000000000..fa701d4b1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/InitDiagramFileAction.xpt
@@ -0,0 +1,145 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Dmitry Stadnik (Borland) - rewritten in xpand
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::editor::Utils»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE InitDiagramFileAction(editorGen : gmfgen::GenEditorGenerator) FOR gmfgen::InitDiagramAction-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+«EXPAND xpt::Common::packageStatement FOR qualifiedClassName»
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «qualifiedClassName.xpandSplit('\.')->last()»
+ «IF editorGen.application = null-»
+implements org.eclipse.ui.IObjectActionDelegate {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbenchPart targetPart;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.common.util.URI domainModelURI;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setActivePart(org.eclipse.jface.action.IAction action, org.eclipse.ui.IWorkbenchPart targetPart) {
+ this.targetPart = targetPart;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection) {
+ domainModelURI = null;
+ action.setEnabled(false);
+ if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection == false || selection.isEmpty()) {
+ return;
+ }
+ org.eclipse.core.resources.IFile file =
+ (org.eclipse.core.resources.IFile) ((org.eclipse.jface.viewers.IStructuredSelection) selection).getFirstElement();
+ domainModelURI = org.eclipse.emf.common.util.URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+ action.setEnabled(true);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.swt.widgets.Shell getShell() {
+ return targetPart.getSite().getShell();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void run(org.eclipse.jface.action.IAction action) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain =
+ org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ «IF editorGen.sameFileForDiagramAndModel-»
+ org.eclipse.emf.ecore.resource.ResourceSet resourceSet = new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
+ «ELSE-»
+ org.eclipse.emf.ecore.resource.ResourceSet resourceSet = editingDomain.getResourceSet();
+ «ENDIF-»
+ org.eclipse.emf.ecore.EObject diagramRoot = null;
+ try {
+ org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(domainModelURI, true);
+ diagramRoot = (org.eclipse.emf.ecore.EObject) resource.getContents().get(0);
+ } catch (org.eclipse.emf.common.util.WrappedException ex) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
+ "Unable to load resource: " + domainModelURI, ex);«EXPAND xpt::Common::nonNLS»
+ }
+ if (diagramRoot == null) {
+ org.eclipse.jface.dialogs.MessageDialog.openError(getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForInitDiagramFileResourceErrorDialog())) FOR editorGen»,
+ «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForInitDiagramFileResourceErrorDialog())) FOR editorGen»);
+ return;
+ }
+ org.eclipse.jface.wizard.Wizard wizard = new «editorGen.diagram.getNewDiagramFileWizardQualifiedClassName()»(domainModelURI, diagramRoot, editingDomain);
+ wizard.setWindowTitle(org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForInitDiagramFileWizardTitle()) FOR editorGen»,
+ «EXPAND xpt::editor::VisualIDRegistry::modelID FOR editorGen.diagram»));
+ «editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».runWizard(getShell(), wizard, "InitDiagramFile");«EXPAND xpt::Common::nonNLS»
+ }
+ «ELSE-»
+implements org.eclipse.ui.IWorkbenchWindowActionDelegate {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbenchWindow window;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void init(org.eclipse.ui.IWorkbenchWindow window) {
+ this.window = window;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void dispose() {
+ window = null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection) {
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.swt.widgets.Shell getShell() {
+ return window.getShell();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void run(org.eclipse.jface.action.IAction action) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain =
+ org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ org.eclipse.emf.ecore.resource.Resource resource =
+ «editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».openModel(getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForInitDiagramOpenFileDialogTitle()) FOR editorGen», editingDomain);
+ if (resource == null || resource.getContents().isEmpty()) {
+ return;
+ }
+ org.eclipse.emf.ecore.EObject diagramRoot = (org.eclipse.emf.ecore.EObject) resource.getContents().get(0);
+ org.eclipse.jface.wizard.Wizard wizard = new «editorGen.diagram.getNewDiagramFileWizardQualifiedClassName()»(resource.getURI(), diagramRoot, editingDomain);
+ wizard.setWindowTitle(org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForInitDiagramFileWizardTitle()) FOR editorGen»,
+ «EXPAND xpt::editor::VisualIDRegistry::modelID FOR editorGen.diagram»));
+ «editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».runWizard(getShell(), wizard, "InitDiagramFile");«EXPAND xpt::Common::nonNLS»
+ }
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForInitDiagramFileResourceErrorDialog()))-»
+«EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForInitDiagramFileResourceErrorDialog()))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForInitDiagramFileWizardTitle())-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForInitDiagramOpenFileDialogTitle())-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForInitDiagramFileResourceErrorDialog()), 'Error')-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForInitDiagramFileResourceErrorDialog()), 'Model file loading failed')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForInitDiagramFileWizardTitle(), 'Initialize new {0} diagram file')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForInitDiagramOpenFileDialogTitle(), 'Select domain model')-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/MatchingStrategy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/MatchingStrategy.xpt
new file mode 100644
index 000000000..6e7a81455
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/MatchingStrategy.xpt
@@ -0,0 +1,49 @@
+/*
+ * 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'»
+
+«DEFINE MatchingStrategy FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «matchingStrategyClassName» implements org.eclipse.ui.IEditorMatchingStrategy {
+
+ «EXPAND matches-»
+
+}
+«ENDDEFINE»
+
+«DEFINE matches FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean matches(org.eclipse.ui.IEditorReference editorRef, org.eclipse.ui.IEditorInput input) {
+ org.eclipse.ui.IEditorInput editorInput;
+ try {
+ editorInput = editorRef.getEditorInput();
+ } catch (org.eclipse.ui.PartInitException e) {
+ return false;
+ }
+
+ if (editorInput.equals(input)) {
+ return true;
+ }
+«REM»
+ Should be removed then https://bugs.eclipse.org/bugs/show_bug.cgi?id=175260 commited.
+ Problem is: URIEditorInput has no .equals() overriden
+«ENDREM-»
+ if (editorInput instanceof org.eclipse.emf.common.ui.URIEditorInput && input instanceof org.eclipse.emf.common.ui.URIEditorInput) {
+ return ((org.eclipse.emf.common.ui.URIEditorInput) editorInput).getURI().equals(((org.eclipse.emf.common.ui.URIEditorInput) input).getURI());
+ }
+ return false;
+}
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ModelElementSelectionPage.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ModelElementSelectionPage.xpt
new file mode 100644
index 000000000..397b50fa8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ModelElementSelectionPage.xpt
@@ -0,0 +1,167 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::editor::GenDiagram»
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE className FOR gmfgen::GenDiagram»«defaultModelElementSelectionPageClassName(self)»«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE ModelElementSelectionPage FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment('Wizard page that allows to select element from model.')»
+public class «EXPAND className» extends org.eclipse.jface.wizard.WizardPage {
+ «EXPAND attributes-»
+
+ «EXPAND ctor-»
+
+ «EXPAND getModelElement-»
+
+ «EXPAND setModelElement-»
+
+ «EXPAND createControl-»
+
+ «EXPAND getSelectionTitle-»
+
+ «EXPAND updateSelection-»
+
+ «EXPAND validatePage-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.emf.ecore.EObject selectedModelElement;
+
+«EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.jface.viewers.TreeViewer modelViewer;
+«ENDDEFINE»
+
+«DEFINE ctor FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+public «EXPAND className»(String pageName) {
+ super(pageName);
+}
+«ENDDEFINE»
+
+«DEFINE getModelElement FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.EObject getModelElement() {
+ return selectedModelElement;
+}
+«ENDDEFINE»
+
+«DEFINE setModelElement FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+public void setModelElement(org.eclipse.emf.ecore.EObject modelElement) {
+ selectedModelElement = modelElement;
+ if (modelViewer != null) {
+ if (selectedModelElement != null) {
+ modelViewer.setInput(selectedModelElement.eResource());
+ modelViewer.setSelection(new org.eclipse.jface.viewers.StructuredSelection(selectedModelElement));
+ } else {
+ modelViewer.setInput(null);
+ }
+ setPageComplete(validatePage());
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createControl FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+public void createControl(org.eclipse.swt.widgets.Composite parent) {
+ initializeDialogUnits(parent);
+
+ org.eclipse.swt.widgets.Composite plate = new org.eclipse.swt.widgets.Composite(parent, org.eclipse.swt.SWT.NONE);
+ plate.setLayoutData(new org.eclipse.swt.layout.GridData(org.eclipse.swt.layout.GridData.FILL_BOTH));
+ org.eclipse.swt.layout.GridLayout layout = new org.eclipse.swt.layout.GridLayout();
+ layout.marginWidth = 0;
+ plate.setLayout(layout);
+ setControl(plate);
+
+ org.eclipse.swt.widgets.Label label = new org.eclipse.swt.widgets.Label(plate, org.eclipse.swt.SWT.NONE);
+ label.setText(getSelectionTitle());
+ label.setLayoutData(new org.eclipse.swt.layout.GridData(org.eclipse.swt.layout.GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ modelViewer = new org.eclipse.jface.viewers.TreeViewer(
+ plate, org.eclipse.swt.SWT.SINGLE | org.eclipse.swt.SWT.H_SCROLL | org.eclipse.swt.SWT.V_SCROLL | org.eclipse.swt.SWT.BORDER);
+ org.eclipse.swt.layout.GridData layoutData = new org.eclipse.swt.layout.GridData(org.eclipse.swt.layout.GridData.FILL_BOTH);
+ layoutData.heightHint = 300;
+ layoutData.widthHint = 300;
+ modelViewer.getTree().setLayoutData(layoutData);
+ modelViewer.setContentProvider(new org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider(
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory()));
+ modelViewer.setLabelProvider(new org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider(
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory()));
+ if (selectedModelElement != null) {
+ modelViewer.setInput(selectedModelElement.eResource());
+ modelViewer.setSelection(new org.eclipse.jface.viewers.StructuredSelection(selectedModelElement));
+ }
+ modelViewer.addSelectionChangedListener(new org.eclipse.jface.viewers.ISelectionChangedListener() {
+ public void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event) {
+ «EXPAND className».this.updateSelection((org.eclipse.jface.viewers.IStructuredSelection) event.getSelection());
+ }
+ });
+
+ setPageComplete(validatePage());
+}
+«ENDDEFINE»
+
+«DEFINE getSelectionTitle FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment('Override to provide custom model element description.')»
+protected String getSelectionTitle() {
+ return «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForModelElementSelectionPage(self))) FOR editorGen»;
+}
+«ENDDEFINE»
+
+«DEFINE updateSelection FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected void updateSelection(org.eclipse.jface.viewers.IStructuredSelection selection) {
+ selectedModelElement = null;
+ if (selection.size() == 1) {
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof org.eclipse.emf.edit.provider.IWrapperItemProvider) {
+ selectedElement = ((org.eclipse.emf.edit.provider.IWrapperItemProvider) selectedElement).getValue();
+ }
+ if (selectedElement instanceof org.eclipse.emf.ecore.util.FeatureMap.Entry) {
+ selectedElement = ((org.eclipse.emf.ecore.util.FeatureMap.Entry) selectedElement).getValue();
+ }
+ if (selectedElement instanceof org.eclipse.emf.ecore.EObject) {
+ selectedModelElement = (org.eclipse.emf.ecore.EObject) selectedElement;
+ }
+ }
+ setPageComplete(validatePage());
+}
+«ENDDEFINE»
+
+«DEFINE validatePage FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment('Override to provide specific validation of the selected model element.')»
+protected boolean validatePage() {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForModelElementSelectionPage(self)), 'Select model element:')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForModelElementSelectionPage(self)))-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/NewDiagramFileWizard.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/NewDiagramFileWizard.xpt
new file mode 100644
index 000000000..be6fe7616
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/NewDiagramFileWizard.xpt
@@ -0,0 +1,200 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Dmitry Stadnik (Borland) - rewritten in xpand
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE className FOR gmfgen::GenDiagram»«newDiagramFileWizardClassName»«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE NewDiagramFileWizard FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» extends org.eclipse.jface.wizard.Wizard {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «EXPAND creationPage» myFileCreationPage;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «EXPAND xpt::editor::ModelElementSelectionPage::qualifiedClassName» diagramRootElementSelectionPage;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.transaction.TransactionalEditingDomain myEditingDomain;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.emf.common.util.URI domainModelURI,
+ org.eclipse.emf.ecore.EObject diagramRoot,
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) {
+ «EXPAND xpt::Common::_assert('domainModelURI != null : "Domain model uri must be specified"')-»
+ «EXPAND xpt::Common::_assert('diagramRoot != null : "Doagram root element must be specified"')-»
+ «EXPAND xpt::Common::_assert('editingDomain != null : "Editing domain must be specified"')-»
+
+ myFileCreationPage = new «EXPAND creationPage»(«EXPAND xpt::Externalizer::accessorCall(nameKey(i18nKeyForNewDiagramFileWizardCreationPage(self))) FOR editorGen», org.eclipse.jface.viewers.StructuredSelection.EMPTY);
+ myFileCreationPage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForNewDiagramFileWizardCreationPage(self))) FOR editorGen»);
+ myFileCreationPage.setDescription(org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForNewDiagramFileWizardCreationPage(self))) FOR editorGen»,
+ «EXPAND xpt::editor::VisualIDRegistry::modelID»));
+ org.eclipse.core.runtime.IPath filePath;
+ String fileName = org.eclipse.emf.common.util.URI.decode(domainModelURI.trimFileExtension().lastSegment());
+ if (domainModelURI.isPlatformResource()) {
+ filePath = new org.eclipse.core.runtime.Path(domainModelURI.trimSegments(1).toPlatformString(true));
+ } else if (domainModelURI.isFile()) {
+ filePath = new org.eclipse.core.runtime.Path(domainModelURI.trimSegments(1).toFileString());
+ } else {
+ // TODO : use some default path
+ throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); «EXPAND xpt::Common::nonNLS»
+ }
+ myFileCreationPage.setContainerFullPath(filePath);
+ myFileCreationPage.setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
+ filePath, fileName, "«editorGen.diagramFileExtension»")); «EXPAND xpt::Common::nonNLS»
+
+ diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(«EXPAND xpt::Externalizer::accessorCall(nameKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self))) FOR editorGen»);
+ diagramRootElementSelectionPage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self))) FOR editorGen»);
+ diagramRootElementSelectionPage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self))) FOR editorGen»);
+ diagramRootElementSelectionPage.setModelElement(diagramRoot);
+
+ myEditingDomain = editingDomain;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void addPages() {
+ addPage(myFileCreationPage);
+ addPage(diagramRootElementSelectionPage);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean performFinish() {
+ java.util.List affectedFiles = new java.util.LinkedList();
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile diagramFile = myFileCreationPage.createNewFile();
+ «EXPAND xpt::Common::setCharset('diagramFile')-»
+ affectedFiles.add(diagramFile);
+ org.eclipse.emf.common.util.URI diagramModelURI = org.eclipse.emf.common.util.URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
+ «ELSE-»
+ org.eclipse.core.runtime.IPath diagramModelPath = myFileCreationPage.getContainerFullPath().append(myFileCreationPage.getFileName());
+ org.eclipse.emf.common.util.URI diagramModelURI = org.eclipse.emf.common.util.URI.createFileURI(diagramModelPath.toString());
+ «ENDIF-»
+ org.eclipse.emf.ecore.resource.ResourceSet resourceSet = myEditingDomain.getResourceSet();
+ final org.eclipse.emf.ecore.resource.Resource diagramResource = resourceSet.createResource(diagramModelURI);
+ org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand command =
+ new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(
+ myEditingDomain, «EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardInitDiagramCommand(self)) FOR editorGen», affectedFiles) {
+
+ 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 {
+ int diagramVID = «EXPAND xpt::editor::VisualIDRegistry::getDiagramVisualIDMethodCall»(diagramRootElementSelectionPage.getModelElement());
+ if (diagramVID != «EXPAND xpt::editor::VisualIDRegistry::visualID») {
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardIncorrectRootError(self)) FOR editorGen»);
+ }
+ org.eclipse.gmf.runtime.notation.Diagram diagram =
+ org.eclipse.gmf.runtime.diagram.core.services.ViewService.createDiagram(
+ diagramRootElementSelectionPage.getModelElement(), «EXPAND xpt::editor::VisualIDRegistry::modelID»,
+ «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ diagramResource.getContents().add(diagram);
+ «IF editorGen.sameFileForDiagramAndModel-»
+ diagramResource.getContents().add(diagram.getElement());
+ «ENDIF-»
+ «IF not synchronized-»
+ new «getDiagramContentInitializerQualifiedClassName()»().initDiagramContent(diagram);
+ «ENDIF-»
+ 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.NullProgressMonitor(), null);
+ diagramResource.save(«EXPAND xpt::Common::getSaveOptions»);
+ «getDiagramEditorUtilQualifiedClassName()».openDiagram(diagramResource);
+ } catch (org.eclipse.core.commands.ExecutionException e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
+ "Unable to create model and diagram", e); «EXPAND xpt::Common::nonNLS»
+ } catch (java.io.IOException ex) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
+ "Save operation failed for: " + diagramModelURI, ex); «EXPAND xpt::Common::nonNLS»
+ } catch (org.eclipse.ui.PartInitException ex) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
+ "Unable to open editor", ex); «EXPAND xpt::Common::nonNLS»
+ }
+ return true;
+ }
+
+ «EXPAND xpt::Common::generatedClassComment»
+ private static class DiagramRootElementSelectionPage extends «EXPAND xpt::editor::ModelElementSelectionPage::qualifiedClassName» {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected DiagramRootElementSelectionPage(String pageName) {
+ super(pageName);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getSelectionTitle() {
+ return «EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPageSelectionTitle(self)) FOR editorGen»;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean validatePage() {
+ if (selectedModelElement == null) {
+ setErrorMessage(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPageNoSelectionMessage(self)) FOR editorGen»);
+ return false;
+ }
+ boolean result = org.eclipse.gmf.runtime.diagram.core.services.ViewService.getInstance().provides(
+ new org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation(
+ new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(selectedModelElement),
+ «EXPAND xpt::editor::VisualIDRegistry::modelID», «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»));
+ setErrorMessage(result ? null : «EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewDiagramFileWizardRootSelectionPageInvalidSelectionMessage(self)) FOR editorGen»);
+ return result;
+ }
+ }
+}
+«ENDDEFINE»
+
+«DEFINE creationPage FOR gmfgen::GenDiagram»
+«IF null = editorGen.application-»
+org.eclipse.ui.dialogs.WizardNewFileCreationPage«ELSE-»
+«editorGen.application.packageName».WizardNewFileCreationPage«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::accessorField(nameKey(i18nKeyForNewDiagramFileWizardCreationPage(self)))-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForNewDiagramFileWizardCreationPage(self)))-»
+«EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForNewDiagramFileWizardCreationPage(self)))-»
+«EXPAND xpt::Externalizer::accessorField(nameKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self)))-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self)))-»
+«EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self)))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForNewDiagramFileWizardRootSelectionPageSelectionTitle(self))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForNewDiagramFileWizardRootSelectionPageNoSelectionMessage(self))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForNewDiagramFileWizardRootSelectionPageInvalidSelectionMessage(self))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForNewDiagramFileWizardInitDiagramCommand(self))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForNewDiagramFileWizardIncorrectRootError(self))-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(nameKey(i18nKeyForNewDiagramFileWizardCreationPage(self)), 'Initialize new diagram file')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForNewDiagramFileWizardCreationPage(self)), 'Diagram file')-»
+«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForNewDiagramFileWizardCreationPage(self)), 'Create new diagram based on {0} model content')-»
+«EXPAND xpt::Externalizer::messageEntry(nameKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self)), 'Select diagram root element')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self)), 'Diagram root element')-»
+«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(self)), 'Select semantic model element to be depicted on diagram')-»"Select diagram root element:"
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewDiagramFileWizardRootSelectionPageSelectionTitle(self), 'Select diagram root element:')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewDiagramFileWizardRootSelectionPageNoSelectionMessage(self), 'Diagram root element is not selected')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewDiagramFileWizardRootSelectionPageInvalidSelectionMessage(self), 'Invalid diagram root element is selected')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewDiagramFileWizardInitDiagramCommand(self), 'Initializing diagram contents')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewDiagramFileWizardIncorrectRootError(self), 'Incorrect model object stored as a root resource object')-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetInfo.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetInfo.xpt
new file mode 100644
index 000000000..c5bb5b25d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetInfo.xpt
@@ -0,0 +1,331 @@
+/*
+ * 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'»
+
+«REM»Inner class of DocumentProvider«ENDREM»
+«DEFINE ResourceSetInfo FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+protected class ResourceSetInfo extends ElementInfo {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND getModificationStamp-»
+
+ «EXPAND setModificationStamp-»
+
+ «EXPAND getEditingDomain-»
+
+ «EXPAND getResourceSet-»
+
+ «EXPAND getLoadedResourcesIterator-»
+
+ «EXPAND getEditorInput-»
+
+ «EXPAND dispose-»
+
+ «EXPAND isSynchronized-»
+
+ «IF null = editorGen.application-»
+ «EXPAND setUnSynchronized-»
+
+ «EXPAND setSynchronized-»
+
+ «EXPAND stopResourceListening-»
+
+ «EXPAND startResourceListening-»
+
+ «ENDIF-»
+ «EXPAND isUpdateCache-»
+
+ «EXPAND setUpdateCache-»
+
+ «EXPAND isModifiable-»
+
+ «EXPAND setModifiable-»
+
+ «EXPAND isReadOnly-»
+
+ «EXPAND setReadOnly-»
+
+ «IF null = editorGen.application-»
+ «EXPAND SynchronizerDelegate-»
+
+ «ENDIF-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private long myModificationStamp = «IF null = editorGen.application»org.eclipse.core.resources.IResource.NULL_STAMP«ELSE»0«ENDIF»;
+
+ «IF null = editorGen.application-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.workspace.util.WorkspaceSynchronizer mySynchronizer;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.util.Collection myUnSynchronizedResources = new java.util.ArrayList();
+
+ «ENDIF-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument myDocument;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IEditorInput myEditorInput;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private boolean myUpdateCache = true;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private boolean myModifiable = false;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private boolean myReadOnly = true;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private ResourceSetModificationListener myResourceSetListener;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public ResourceSetInfo(org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document, org.eclipse.ui.IEditorInput editorInput) {
+ super(document);
+ myDocument = document;
+ myEditorInput = editorInput;
+ «IF null = editorGen.application-»
+ startResourceListening();
+ «ENDIF-»
+ myResourceSetListener = new ResourceSetModificationListener(this);
+ getResourceSet().eAdapters().add(myResourceSetListener);
+}
+«ENDDEFINE»
+
+«DEFINE getModificationStamp FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public long getModificationStamp() {
+ return myModificationStamp;
+}
+«ENDDEFINE»
+
+«DEFINE setModificationStamp FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void setModificationStamp(long modificationStamp) {
+ myModificationStamp = modificationStamp;
+}
+«ENDDEFINE»
+
+«DEFINE getEditingDomain FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain() {
+ return myDocument.getEditingDomain();
+}
+«ENDDEFINE»
+
+«DEFINE getResourceSet FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.resource.ResourceSet getResourceSet() {
+ return getEditingDomain().getResourceSet();
+}
+«ENDDEFINE»
+
+«DEFINE getLoadedResourcesIterator FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ getLoadedResourcesIterator() {
+ return new java.util.ArrayList/*<org.eclipse.emf.ecore.resource.Resource>*/(getResourceSet().getResources()).iterator();
+}
+«ENDDEFINE»
+
+«DEFINE getEditorInput FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.ui.IEditorInput getEditorInput() {
+ return myEditorInput;
+}
+«ENDDEFINE»
+
+«DEFINE dispose FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void dispose() {
+ «IF null = editorGen.application-»
+ stopResourceListening();
+ «ENDIF-»
+ getResourceSet().eAdapters().remove(myResourceSetListener);
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource resource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ resource.unload();
+ }
+}
+«ENDDEFINE»
+
+«DEFINE isSynchronized FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isSynchronized() {
+ «IF null = editorGen.application-»
+ return myUnSynchronizedResources.size() == 0;
+ «ELSE-»
+ return getModificationStamp() == computeModificationStamp(this);
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE setUnSynchronized FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void setUnSynchronized(org.eclipse.emf.ecore.resource.Resource resource) {
+ myUnSynchronizedResources.add(resource);
+}
+«ENDDEFINE»
+
+«DEFINE setSynchronized FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void setSynchronized(org.eclipse.emf.ecore.resource.Resource resource) {
+ myUnSynchronizedResources.remove(resource);
+}
+«ENDDEFINE»
+
+«DEFINE stopResourceListening FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public final void stopResourceListening() {
+ mySynchronizer.dispose();
+ mySynchronizer = null;
+}
+«ENDDEFINE»
+
+«DEFINE startResourceListening FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public final void startResourceListening() {
+ mySynchronizer = new org.eclipse.emf.workspace.util.WorkspaceSynchronizer(getEditingDomain(), new SynchronizerDelegate());
+}
+«ENDDEFINE»
+
+«DEFINE isUpdateCache FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isUpdateCache() {
+ return myUpdateCache;
+}
+«ENDDEFINE»
+
+«DEFINE setUpdateCache FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void setUpdateCache(boolean update) {
+ myUpdateCache = update;
+}
+«ENDDEFINE»
+
+«DEFINE isModifiable FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isModifiable() {
+ return myModifiable;
+}
+«ENDDEFINE»
+
+«DEFINE setModifiable FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void setModifiable(boolean modifiable) {
+ myModifiable = modifiable;
+}
+«ENDDEFINE»
+
+«DEFINE isReadOnly FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isReadOnly() {
+ return myReadOnly;
+}
+«ENDDEFINE»
+
+«DEFINE setReadOnly FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void setReadOnly(boolean readOnly) {
+ myReadOnly = readOnly;
+}
+«ENDDEFINE»
+
+«DEFINE SynchronizerDelegate FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private class SynchronizerDelegate implements org.eclipse.emf.workspace.util.WorkspaceSynchronizer.Delegate {
+
+ «EXPAND disposeSD-»
+
+ «EXPAND handleResourceChangedSD-»
+
+ «EXPAND handleResourceDeletedSD-»
+
+ «EXPAND handleResourceMovedSD-»
+
+ «EXPAND additionsSD-»
+}
+«ENDDEFINE»
+
+«DEFINE disposeSD FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void dispose() {
+}
+«ENDDEFINE»
+
+«DEFINE handleResourceChangedSD FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean handleResourceChanged(final org.eclipse.emf.ecore.resource.Resource resource) {
+ «EXPAND updateSynchStateSD-»
+ org.eclipse.swt.widgets.Display.getDefault().asyncExec(new java.lang.Runnable() {
+ public void run() {
+ handleElementChanged(ResourceSetInfo.this, resource, null);
+ }
+ });
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE handleResourceDeletedSD FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean handleResourceDeleted(org.eclipse.emf.ecore.resource.Resource resource) {
+ «EXPAND updateSynchStateSD-»
+ org.eclipse.swt.widgets.Display.getDefault().asyncExec(new java.lang.Runnable() {
+ public void run() {
+ fireElementDeleted(ResourceSetInfo.this.getEditorInput());
+ }
+ });
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE handleResourceMovedSD FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean handleResourceMoved(org.eclipse.emf.ecore.resource.Resource resource, final org.eclipse.emf.common.util.URI newURI) {
+ «EXPAND updateSynchStateSD-»
+ if (myDocument.getDiagram().eResource() == resource) {
+ org.eclipse.swt.widgets.Display.getDefault().asyncExec(new java.lang.Runnable() {
+ public void run() {
+ handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI);
+ }
+ });
+ } else {
+ handleResourceDeleted(resource);
+ }
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE updateSynchStateSD FOR gmfgen::GenDiagram-»
+synchronized (ResourceSetInfo.this) {
+ if (ResourceSetInfo.this.fCanBeSaved) {
+ ResourceSetInfo.this.setUnSynchronized(resource);
+ return true;
+ }
+}
+«ENDDEFINE»
+
+«DEFINE additionsSD FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt
new file mode 100644
index 000000000..673974d78
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt
@@ -0,0 +1,89 @@
+/*
+ * 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'»
+
+«REM»Inner class of DocumentProvider«ENDREM»
+«DEFINE ResourceSetModificationListener FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private class ResourceSetModificationListener extends org.eclipse.emf.ecore.util.EContentAdapter {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND notifyChanged-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.transaction.NotificationFilter myModifiedFilter;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private ResourceSetInfo myInfo;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public ResourceSetModificationListener(ResourceSetInfo info) {
+ myInfo = info;
+ myModifiedFilter = org.eclipse.emf.transaction.NotificationFilter.createEventTypeFilter(org.eclipse.emf.common.notify.Notification.SET).or(org.eclipse.emf.transaction.NotificationFilter.createEventTypeFilter(org.eclipse.emf.common.notify.Notification.UNSET)).and(org.eclipse.emf.transaction.NotificationFilter.createFeatureFilter(org.eclipse.emf.ecore.resource.Resource.class, org.eclipse.emf.ecore.resource.Resource.RESOURCE__IS_MODIFIED));
+}
+«ENDDEFINE»
+
+«DEFINE notifyChanged FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
+ if (notification.getNotifier() instanceof org.eclipse.emf.ecore.resource.ResourceSet) {
+ super.notifyChanged(notification);
+ }
+ if (!notification.isTouch() && myModifiedFilter.matches(notification)) {
+ if (notification.getNotifier() instanceof org.eclipse.emf.ecore.resource.Resource) {
+ org.eclipse.emf.ecore.resource.Resource resource = (org.eclipse.emf.ecore.resource.Resource) notification.getNotifier();
+ if (resource.isLoaded()) {
+ boolean modified = false;
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ if (nextResource.isLoaded()) {
+ modified = nextResource.isModified();
+ }
+ }
+ boolean dirtyStateChanged = false;
+ synchronized (myInfo) {
+ if (modified != myInfo.fCanBeSaved) {
+ myInfo.fCanBeSaved = modified;
+ dirtyStateChanged = true;
+ }
+ «IF null = editorGen.application-»
+ if (!resource.isModified()) {
+ myInfo.setSynchronized(resource);
+ }
+ «ENDIF-»
+ }
+ if (dirtyStateChanged) {
+ fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);
+
+ if (!modified) {
+ myInfo.setModificationStamp(computeModificationStamp(myInfo));
+ }
+ }
+ }
+ }
+ }
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutCreationWizard.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutCreationWizard.xpt
new file mode 100644
index 000000000..2eba54561
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutCreationWizard.xpt
@@ -0,0 +1,156 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::editor::GenDiagram»
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE className FOR gmfgen::GenDiagram»«defaultShortcutCreationWizardClassName(self)»«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE ShortcutCreationWizard FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+/**
+ * Allows to select foreign model element and add shortcut to the diagram.
+ *
+ * @generated
+ */
+public class «EXPAND className» extends org.eclipse.jface.wizard.Wizard {
+
+ /**
+ * @generated
+ */
+ private ReferencedElementSelectionPage referencedElementSelectionPage;
+
+ /**
+ * @generated
+ */
+ private org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain;
+
+ /**
+ * @generated
+ */
+ public «EXPAND className»(org.eclipse.emf.ecore.EObject modelElement, org.eclipse.gmf.runtime.notation.View view,
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) {
+ referencedElementSelectionPage = new ReferencedElementSelectionPage(«EXPAND xpt::Externalizer::accessorCall(nameKey(i18nKeyForShortcutWizardReferencedElementPage(self))) FOR editorGen», view);
+ referencedElementSelectionPage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForShortcutWizardReferencedElementPage(self))) FOR editorGen»);
+ referencedElementSelectionPage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForShortcutWizardReferencedElementPage(self))) FOR editorGen»);
+ referencedElementSelectionPage.setModelElement(modelElement);
+
+ this.editingDomain = editingDomain;
+ }
+
+ /**
+ * @generated
+ */
+ public void addPages() {
+ addPage(referencedElementSelectionPage);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean performFinish() {
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor viewDescriptor =
+ new org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor(
+ new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(referencedElementSelectionPage.getModelElement()),
+ org.eclipse.gmf.runtime.notation.Node.class, null, «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ org.eclipse.gmf.runtime.common.core.command.ICommand command =
+ new org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand(
+ editingDomain, viewDescriptor, referencedElementSelectionPage.getView());
+ command = command.compose(new «getCreateShortcutDecorationsCommandQualifiedClassName()»(
+ editingDomain, referencedElementSelectionPage.getView(), viewDescriptor));
+ try {
+ org.eclipse.core.commands.operations.OperationHistoryFactory.getOperationHistory().execute(
+ command, new org.eclipse.core.runtime.NullProgressMonitor(), null);
+ } catch (org.eclipse.core.commands.ExecutionException ee) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to create shortcut", ee);«EXPAND xpt::Common::nonNLS»
+ }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ private static class ReferencedElementSelectionPage extends «EXPAND xpt::editor::ModelElementSelectionPage::qualifiedClassName» {
+
+ /**
+ * @generated
+ */
+ private org.eclipse.gmf.runtime.notation.View view;
+
+ /**
+ * @generated
+ */
+ public ReferencedElementSelectionPage(String pageName, org.eclipse.gmf.runtime.notation.View view) {
+ super(pageName);
+ this.view = view;
+ }
+
+ /**
+ * @generated
+ */
+ public org.eclipse.gmf.runtime.notation.View getView() {
+ return view;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getSelectionTitle() {
+ return «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForShortcutWizardReferencedElementPage(self))) FOR editorGen»;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean validatePage() {
+ if (selectedModelElement == null) {
+ setErrorMessage(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForShortcutWizardReferencedElementPageEmptyError(self)) FOR editorGen»);
+ return false;
+ }
+ boolean result = org.eclipse.gmf.runtime.diagram.core.services.ViewService.getInstance().provides(
+ org.eclipse.gmf.runtime.notation.Node.class,
+ new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(selectedModelElement),
+ view, null, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true,
+ «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ setErrorMessage(result ? null : «EXPAND xpt::Externalizer::accessorCall(i18nKeyForShortcutWizardReferencedElementPageInvalidError(self)) FOR editorGen»);
+ return result;
+ }
+ }
+}
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«IF null <> editorGen.application-»
+«EXPAND xpt::Externalizer::messageEntry(nameKey(i18nKeyForShortcutWizardReferencedElementPage(self)), 'Select referenced element')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForShortcutWizardReferencedElementPage(self)), 'Referenced element')-»
+«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForShortcutWizardReferencedElementPage(self)), 'Select element that the new shortcut will refer to.')-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForShortcutWizardReferencedElementPage(self)), 'Select referenced element:')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForShortcutWizardReferencedElementPageEmptyError(self), 'Referenced element is not selected')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForShortcutWizardReferencedElementPageInvalidError(self), 'Invalid referenced element is selected')-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«IF null <> editorGen.application-»
+ «EXPAND xpt::Externalizer::accessorField(nameKey(i18nKeyForShortcutWizardReferencedElementPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForShortcutWizardReferencedElementPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForShortcutWizardReferencedElementPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForShortcutWizardReferencedElementPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForShortcutWizardReferencedElementPageEmptyError(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForShortcutWizardReferencedElementPageInvalidError(self))-»
+«ENDIF-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutPropertyTester.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutPropertyTester.xpt
new file mode 100644
index 000000000..a71ad737a
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutPropertyTester.xpt
@@ -0,0 +1,53 @@
+/*
+ * 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'»
+
+«DEFINE ShortcutPropertyTester FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «shortcutPropertyTesterClassName» extends org.eclipse.core.expressions.PropertyTester {
+
+ «EXPAND attributes-»
+
+ «EXPAND test-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected static final String SHORTCUT_PROPERTY = "isShortcut"; «EXPAND xpt::Common::nonNLS»
+«ENDDEFINE»
+
+«DEFINE test FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
+ if (false == receiver instanceof org.eclipse.gmf.runtime.notation.View) {
+ return false;
+ }
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) receiver;
+ if (SHORTCUT_PROPERTY.equals(method)) {
+ org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «EXPAND xpt::Common::nonNLS»
+ if (annotation != null) {
+ return «EXPAND xpt::editor::VisualIDRegistry::modelID».equals(annotation.getDetails().get("modelID")); «EXPAND xpt::Common::nonNLS»
+ }
+ }
+ return false;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/UriEditorInputTester.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/UriEditorInputTester.xpt
new file mode 100644
index 000000000..1501222c2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/UriEditorInputTester.xpt
@@ -0,0 +1,40 @@
+/*
+ * 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'»
+
+«DEFINE UriEditorInputTester FOR gmfgen::GenNavigator-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «uriInputTesterClassName» extends org.eclipse.core.expressions.PropertyTester {
+
+ «EXPAND test FOR editorGen-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE test FOR gmfgen::GenEditorGenerator-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
+ if (false == receiver instanceof org.eclipse.emf.common.ui.URIEditorInput) {
+ return false;
+ }
+ org.eclipse.emf.common.ui.URIEditorInput editorInput = (org.eclipse.emf.common.ui.URIEditorInput) receiver;
+ return "«diagramFileExtension»".equals(editorInput.getURI().fileExtension()); «EXPAND xpt::Common::nonNLS»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNavigator-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Utils.qvto
new file mode 100644
index 000000000..3891b3bfa
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Utils.qvto
@@ -0,0 +1,255 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Utils;
+
+helper isStandaloneDomainModel(diagram : genModel::GenDiagram) : Boolean {
+ return not diagram.editorGen.sameFileForDiagramAndModel and null <> diagram.domainDiagramElement
+}
+
+helper hasNavigator(editorView : genModel::GenEditorView) : Boolean {
+ return null <> editorView.editorGen.navigator
+}
+
+helper addGotoMarker(editorView : genModel::GenEditorView, implementsList : Sequence(String)) : Sequence(String) {
+ return (if isIDEMode(editorView) then implementsList->including('org.eclipse.ui.ide.IGotoMarker') else implementsList endif)
+}
+
+helper isIDEMode(editorView : genModel::GenEditorView) : Boolean {
+ return null = editorView.editorGen.application
+}
+
+helper addReadOnlyPropSheet(editorView : genModel::GenEditorView, implementsList : Sequence(String)) : Sequence(String) {
+ return (if hasPropertySheet(editorView) and editorView.editorGen.propertySheet.readOnly then implementsList->including('org.eclipse.gmf.runtime.diagram.ui.properties.views.IReadOnlyDiagramPropertySheetPageContributor') else implementsList endif)
+}
+
+helper hasPropertySheet(editorView : genModel::GenEditorView) : Boolean {
+ return null <> editorView.editorGen.propertySheet
+}
+
+helper getEditorImplementsList(editorView : genModel::GenEditorView) : Sequence(String) {
+ return addGotoMarker(editorView, addReadOnlyPropSheet(editorView, Sequence { }))
+}
+
+helper getContainedSemanticNodes(container : genModel::GenContainerBase) : Sequence(genModel::GenNode) {
+ return container.containedNodes->select(node | null <> node.modelFacet)->asSequence()
+}
+
+helper genModel::GenCommonBase::getEssentialVisualChildren() : Collection(genModel::GenCommonBase) {
+ return Sequence { }
+}
+
+helper genModel::GenLink::getEssentialVisualChildren() : Collection(genModel::GenCommonBase) {
+ return self.labels
+}
+
+helper genModel::GenContainerBase::getEssentialVisualChildren() : Collection(genModel::GenCommonBase) {
+ return self.containedNodes
+}
+
+helper genModel::GenNode::getEssentialVisualChildren() : Collection(genModel::GenCommonBase) {
+ return ((Sequence { })[genModel::GenNodeLabel]->union(self.labels->asSequence()))[genModel::GenCommonBase]->union(self.compartments->asSequence())->union(self.containedNodes->asSequence())
+}
+
+helper defaultShortcutCreationWizardClassName(diagram : genModel::GenDiagram) : String {
+ return 'ShortcutCreationWizard'
+}
+
+helper defaultModelElementSelectionPageClassName(diagram : genModel::GenDiagram) : String {
+ return 'ModelElementSelectionPage'
+}
+
+helper defaultValidateActionClassName(diagram : genModel::GenDiagram) : String {
+ return 'ValidateAction'
+}
+
+helper i18nKeyForDocumentProvider(diagram : genModel::GenDiagram) : String {
+ return diagram.documentProviderClassName
+}
+
+helper i18nKeyForDocumentProviderIsModifiable(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '_isModifiable'
+}
+
+helper i18nKeyForDocumentProviderHandleElementContentChanged(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '_handleElementContentChanged'
+}
+
+helper i18nKeyForDocumentProviderIncorrectInputError(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '.IncorrectInputError'
+}
+
+helper i18nKeyForDocumentProviderNoDiagramInResourceError(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '.NoDiagramInResourceError'
+}
+
+helper i18nKeyForDocumentProviderDiagramLoadingError(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '.DiagramLoadingError'
+}
+
+helper i18nKeyForDocumentUnsynchronizedFileSaveError(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '.UnsynchronizedFileSaveError'
+}
+
+helper i18nKeyForDocumentSaveDiagramTask(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '.SaveDiagramTask'
+}
+
+helper i18nKeyForDocumentSaveNextResourceTask(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '.SaveNextResourceTask'
+}
+
+helper i18nKeyForDocumentSaveAs(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDocumentProvider(diagram) + '.SaveAsOperation'
+}
+
+helper i18nKeyForDiagramEditorUtil(diagram : genModel::GenDiagram) : String {
+ return diagram.diagramEditorUtilClassName
+}
+
+helper i18nKeyForOpenModelResourceErrorDialog(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDiagramEditorUtil(diagram) + '.OpenModelResourceErrorDialog'
+}
+
+helper i18nKeyForCreateDiagramProgressTask(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDiagramEditorUtil(diagram) + '.CreateDiagramProgressTask'
+}
+
+helper i18nKeyForCreateDiagramCommandLabel(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForDiagramEditorUtil(diagram) + '.CreateDiagramCommandLabel'
+}
+
+helper i18nKeyForInitDiagramFileResourceErrorDialog() : String {
+ return 'InitDiagramFile.ResourceErrorDialog'
+}
+
+helper i18nKeyForInitDiagramFileWizardTitle() : String {
+ return 'InitDiagramFile.WizardTitle'
+}
+
+helper i18nKeyForInitDiagramOpenFileDialogTitle() : String {
+ return 'InitDiagramFile.OpenModelFileDialogTitle'
+}
+
+helper i18nKeyForNewDiagramFileWizard(diagram : genModel::GenDiagram) : String {
+ return diagram.newDiagramFileWizardClassName
+}
+
+helper i18nKeyForNewDiagramFileWizardCreationPage(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForNewDiagramFileWizard(diagram) + '.CreationPage'
+}
+
+helper i18nKeyForNewDiagramFileWizardRootSelectionPage(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForNewDiagramFileWizard(diagram) + '.RootSelectionPage'
+}
+
+helper i18nKeyForNewDiagramFileWizardRootSelectionPageSelectionTitle(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForNewDiagramFileWizardRootSelectionPage(diagram) + 'SelectionTitle'
+}
+
+helper i18nKeyForNewDiagramFileWizardRootSelectionPageNoSelectionMessage(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForNewDiagramFileWizardRootSelectionPage(diagram) + 'NoSelectionMessage'
+}
+
+helper i18nKeyForNewDiagramFileWizardRootSelectionPageInvalidSelectionMessage(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForNewDiagramFileWizardRootSelectionPage(diagram) + 'InvalidSelectionMessage'
+}
+
+helper i18nKeyForNewDiagramFileWizardInitDiagramCommand(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForNewDiagramFileWizard(diagram) + '.InitDiagramCommand'
+}
+
+helper i18nKeyForNewDiagramFileWizardIncorrectRootError(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForNewDiagramFileWizard(diagram) + '.IncorrectRootError'
+}
+
+helper i18nKeyForSavingDeletedFile(editor : genModel::GenEditorView) : String {
+ return i18nKeyForEditor(editor) + '.SavingDeletedFile'
+}
+
+helper i18nKeyForSaveAsProblems(editor : genModel::GenEditorView) : String {
+ return i18nKeyForEditor(editor) + '.SaveAsError'
+}
+
+helper i18nKeyForSaveProblems(editor : genModel::GenEditorView) : String {
+ return i18nKeyForEditor(editor) + '.SaveError'
+}
+
+helper i18nKeyForEditor(editor : genModel::GenEditorView) : String {
+ return editor.className
+}
+
+helper i18nKeyForSelectModelElement(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForElementChooser(diagram) + '.SelectModelElement'
+}
+
+helper i18nKeyForElementChooser(diagram : genModel::GenDiagram) : String {
+ return diagram.elementChooserClassName
+}
+
+helper i18nKeyForCreateShortcutOpenModel() : String {
+ return 'CreateShortcutAction.OpenModel'
+}
+
+helper i18nKeyForCreateShortcutWizard() : String {
+ return 'CreateShortcutAction.Wizard'
+}
+
+helper i18nKeyForShortcutWizardReferencedElementPage(diagram : genModel::GenDiagram) : String {
+ return defaultShortcutCreationWizardClassName(diagram) + '.ReferencedElementSelectionPage'
+}
+
+helper i18nKeyForModelElementSelectionPage(diagram : genModel::GenDiagram) : String {
+ return defaultModelElementSelectionPageClassName(diagram)
+}
+
+helper i18nKeyForValidateAction(diagram : genModel::GenDiagram) : String {
+ return defaultValidateActionClassName(diagram)
+}
+
+helper i18nKeyForShortcutWizardReferencedElementPageEmptyError(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForShortcutWizardReferencedElementPage(diagram) + 'EmptyError'
+}
+
+helper i18nKeyForShortcutWizardReferencedElementPageInvalidError(diagram : genModel::GenDiagram) : String {
+ return i18nKeyForShortcutWizardReferencedElementPage(diagram) + 'InvalidError'
+}
+
+helper i18nKeyForCreationWizard(diagram : genModel::GenDiagram) : String {
+ return diagram.creationWizardClassName
+}
+
+helper i18nKeyForCreationWizardDiagramPage(diagram : genModel::GenDiagram) : String {
+ return diagram.creationWizardClassName + '.DiagramModelFilePage'
+}
+
+helper i18nKeyForCreationWizardDomainPage(diagram : genModel::GenDiagram) : String {
+ return diagram.creationWizardClassName + '.DomainModelFilePage'
+}
+
+helper i18nKeyForCreationWizardOpenEditorError(diagram : genModel::GenDiagram) : String {
+ return diagram.creationWizardClassName + 'OpenEditorError'
+}
+
+helper i18nKeyForCreationWizardCreationError(diagram : genModel::GenDiagram) : String {
+ return diagram.creationWizardClassName + 'CreationError'
+}
+
+helper i18nKeyForCreationWizardPageExtensionError(diagram : genModel::GenDiagram) : String {
+ return diagram.creationWizardPageClassName + 'ExtensionError'
+}
+
+helper titleKey(dialogKey : String) : String {
+ return dialogKey + 'Title'
+}
+
+helper messageKey(dialogKey : String) : String {
+ return dialogKey + 'Message'
+}
+
+helper nameKey(dialogKey : String) : String {
+ return dialogKey + 'Name'
+}
+
+helper descriptionKey(dialogKey : String) : String {
+ return dialogKey + 'Description'
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidateAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidateAction.xpt
new file mode 100644
index 000000000..5914f7df0
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidateAction.xpt
@@ -0,0 +1,351 @@
+/*
+ * 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:
+ * Dmitry Stadnik (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::Utils»
+«EXTENSION xpt::GenAuditRoot»
+«EXTENSION xpt::GenEditorGenerator»
+
+«DEFINE className FOR gmfgen::GenDiagram»«defaultValidateActionClassName(self)»«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE ValidateAction FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» extends org.eclipse.jface.action.Action {
+ «EXPAND attributes-»
+ «EXPAND _constructor-»
+ «EXPAND run-»
+ «EXPAND runValidation-»
+ «EXPAND runNonUIValidation-»
+ «EXPAND runValidationWithEP-»
+ «EXPAND runEMFValidator-»
+ «EXPAND validate-»
+ «EXPAND createMarkersForStatus-»
+ «EXPAND createMarkersForDiagnostic-»
+ «EXPAND addMarker-»
+ «EXPAND diagnosticToStatusSeverity-»
+ «EXPAND collectTargetElementsFromStatus-»
+ «EXPAND collectTargetElementsFromDiagnostic-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbenchPage page;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.ui.IWorkbenchPage page) {
+ setText(«EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForValidateAction(self))) FOR editorGen»);
+ this.page = page;
+ }
+«ENDDEFINE»
+
+«DEFINE run FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void run() {
+ org.eclipse.ui.IWorkbenchPart workbenchPart = page.getActivePart();
+ if (workbenchPart instanceof org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart) {
+ final org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart part = (org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart) workbenchPart;
+ try {
+ «IF editorGen.application = null-»
+ new org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation(
+ «ENDIF-»
+ new org.eclipse.jface.operation.IRunnableWithProgress() {
+
+ public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
+ throws InterruptedException, java.lang.reflect.InvocationTargetException {
+ runValidation(part.getDiagramEditPart(), part.getDiagram());
+ }
+ }
+ «IF editorGen.application = null-»
+ )
+ «ENDIF-»
+ .run(new org.eclipse.core.runtime.NullProgressMonitor());
+ } catch (Exception e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Validation action failed", e);«EXPAND xpt::Common::nonNLS»
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE runValidation FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static void runValidation(org.eclipse.gmf.runtime.notation.View view) {
+ try {
+ if («getDiagramEditorUtilQualifiedClassName()».openDiagram(view.eResource())) {
+ org.eclipse.ui.IEditorPart editorPart = org.eclipse.ui.PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if (editorPart instanceof org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart) {
+ runValidation(((org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart) editorPart).
+ getDiagramEditPart(), view);
+ } else {
+ runNonUIValidation(view);
+ }
+ }
+ } catch (Exception e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
+ "Validation action failed", e); «EXPAND xpt::Common::nonNLS»
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE runNonUIValidation FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static void runNonUIValidation(org.eclipse.gmf.runtime.notation.View view) {
+ org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart =
+ org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory.getInstance().createDiagramEditPart(
+ view.getDiagram());
+ runValidation(diagramEditPart, view);
+ }
+«ENDDEFINE»
+
+«DEFINE runValidationWithEP FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static void runValidation(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart, org.eclipse.gmf.runtime.notation.View view) {
+ final org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart fpart = diagramEditPart;
+ final org.eclipse.gmf.runtime.notation.View fview = view;
+ org.eclipse.emf.transaction.TransactionalEditingDomain txDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(view);
+ «getValidationProviderQualifiedClassName()».runWithConstraints(txDomain, new Runnable() {
+
+ public void run() {
+ validate(fpart, fview);
+ }
+ });
+ }
+«ENDDEFINE»
+
+«DEFINE runEMFValidator FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static org.eclipse.emf.common.util.Diagnostic runEMFValidator(
+ org.eclipse.gmf.runtime.notation.View target) {
+ if (target.isSetElement() && target.getElement() != null) {
+ return new org.eclipse.emf.ecore.util.Diagnostician() {
+
+ public String getObjectLabel(org.eclipse.emf.ecore.EObject eObject) {
+ return org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getQualifiedName(eObject, true);
+ }
+ }.validate(target.getElement());
+ }
+ return org.eclipse.emf.common.util.Diagnostic.OK_INSTANCE;
+ }
+«ENDDEFINE»
+
+«DEFINE validate FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static void validate(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart,
+ org.eclipse.gmf.runtime.notation.View view) {
+ «IF editorGen.application = null-»
+ org.eclipse.core.resources.IFile target = view.eResource() != null ?
+ org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(view.eResource()) : null;
+ if (target != null) {
+ «getMarkerNavigationProviderQualifiedClassName()».deleteMarkers(target);
+ }
+ «ELSE-»
+ org.eclipse.gmf.runtime.notation.View target = view;
+ «EXPAND xpt::editor::ValidationMarker::qualifiedClassName».removeAllMarkers(diagramEditPart.getViewer());
+ «ENDIF-»
+ org.eclipse.emf.common.util.Diagnostic diagnostic = runEMFValidator(view);
+ createMarkers(target, diagnostic, diagramEditPart);
+ org.eclipse.emf.validation.service.IBatchValidator validator =
+ (org.eclipse.emf.validation.service.IBatchValidator)
+ org.eclipse.emf.validation.service.ModelValidationService.getInstance().newValidator(
+ org.eclipse.emf.validation.model.EvaluationMode.BATCH);
+ validator.setIncludeLiveConstraints(true);
+ if (view.isSetElement() && view.getElement() != null) {
+ org.eclipse.core.runtime.IStatus status = validator.validate(view.getElement());
+ createMarkers(target, status, diagramEditPart);
+ }
+«IF shouldRunValidateOnDiagram(editorGen.audits)-»
+«IF hasDiagramElementTargetRule(editorGen.audits)-»
+ validator.setTraversalStrategy(«getValidationProviderQualifiedClassName()».getNotationTraversalStrategy(validator));
+«ENDIF-»
+ org.eclipse.core.runtime.IStatus status = validator.validate(view);
+ createMarkers(target, status, diagramEditPart);
+«ENDIF-»
+ «IF editorGen.application <> null and validationDecorators-»
+ «getValidationDecoratorProviderQualifiedClassName()».refreshDecorators(view);
+ for (java.util.Iterator it = view.eAllContents(); it.hasNext();) {
+ org.eclipse.emf.ecore.EObject next = (org.eclipse.emf.ecore.EObject) it.next();
+ if (next instanceof org.eclipse.gmf.runtime.notation.View) {
+ «getValidationDecoratorProviderQualifiedClassName()».refreshDecorators(
+ (org.eclipse.gmf.runtime.notation.View) next);
+ }
+ }
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE createMarkersForStatus FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static void createMarkers(
+ «IF editorGen.application = null»org.eclipse.core.resources.IFile
+ «ELSE»org.eclipse.gmf.runtime.notation.View«ENDIF» target,
+ org.eclipse.core.runtime.IStatus validationStatus,
+ org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart) {
+ if (validationStatus.isOK()) {
+ return;
+ }
+ final org.eclipse.core.runtime.IStatus rootStatus = validationStatus;
+ java.util.List allStatuses = new java.util.ArrayList();
+ «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap element2ViewMap =
+ new «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap(
+ diagramEditPart.getDiagramView(),
+ collectTargetElements(rootStatus, new java.util.HashSet(), allStatuses));
+ for (java.util.Iterator it = allStatuses.iterator(); it.hasNext();) {
+ org.eclipse.emf.validation.model.IConstraintStatus nextStatus =
+ (org.eclipse.emf.validation.model.IConstraintStatus) it.next();
+ org.eclipse.gmf.runtime.notation.View view = «getDiagramEditorUtilQualifiedClassName()».findView(
+ diagramEditPart, nextStatus.getTarget(), element2ViewMap);
+ addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view),
+ org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getQualifiedName(nextStatus.getTarget(), true),
+ nextStatus.getMessage(), nextStatus.getSeverity());
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE createMarkersForDiagnostic FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static void createMarkers(
+ «IF editorGen.application = null»org.eclipse.core.resources.IFile
+ «ELSE»org.eclipse.gmf.runtime.notation.View«ENDIF» target,
+ org.eclipse.emf.common.util.Diagnostic emfValidationStatus,
+ org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart) {
+ if (emfValidationStatus.getSeverity() == org.eclipse.emf.common.util.Diagnostic.OK) {
+ return;
+ }
+ final org.eclipse.emf.common.util.Diagnostic rootStatus = emfValidationStatus;
+ java.util.List allDiagnostics = new java.util.ArrayList();
+ «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap element2ViewMap =
+ new «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap(
+ diagramEditPart.getDiagramView(),
+ collectTargetElements(rootStatus, new java.util.HashSet(), allDiagnostics));
+ for (java.util.Iterator it = emfValidationStatus.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.emf.common.util.Diagnostic nextDiagnostic = (org.eclipse.emf.common.util.Diagnostic) it.next();
+ java.util.List data = nextDiagnostic.getData();
+ if (data != null && !data.isEmpty() && data.get(0) instanceof org.eclipse.emf.ecore.EObject) {
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) data.get(0);
+ org.eclipse.gmf.runtime.notation.View view = «getDiagramEditorUtilQualifiedClassName()».findView(
+ diagramEditPart, element, element2ViewMap);
+ addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view),
+ org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getQualifiedName(element, true),
+ nextDiagnostic.getMessage(), diagnosticToStatusSeverity(nextDiagnostic.getSeverity()));
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE addMarker FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static void addMarker(org.eclipse.gef.EditPartViewer viewer,
+ «IF editorGen.application = null»org.eclipse.core.resources.IFile
+ «ELSE»org.eclipse.gmf.runtime.notation.View«ENDIF» target,
+ String elementId, String location, String message, int statusSeverity) {
+ if (target == null) {
+ return;
+ }
+ «IF editorGen.application = null-»
+ «getMarkerNavigationProviderQualifiedClassName()».addMarker(
+ target, elementId, location, message, statusSeverity);
+ «ELSE-»
+ new «EXPAND xpt::editor::ValidationMarker::qualifiedClassName»(
+ location, message, statusSeverity).add(viewer, elementId);
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE diagnosticToStatusSeverity FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static int diagnosticToStatusSeverity(int diagnosticSeverity) {
+ if (diagnosticSeverity == org.eclipse.emf.common.util.Diagnostic.OK) {
+ return org.eclipse.core.runtime.IStatus.OK;
+ } else if (diagnosticSeverity == org.eclipse.emf.common.util.Diagnostic.INFO) {
+ return org.eclipse.core.runtime.IStatus.INFO;
+ } else if (diagnosticSeverity == org.eclipse.emf.common.util.Diagnostic.WARNING) {
+ return org.eclipse.core.runtime.IStatus.WARNING;
+ } else if (diagnosticSeverity == org.eclipse.emf.common.util.Diagnostic.ERROR
+ || diagnosticSeverity == org.eclipse.emf.common.util.Diagnostic.CANCEL) {
+ return org.eclipse.core.runtime.IStatus.ERROR;
+ }
+ return org.eclipse.core.runtime.IStatus.INFO;
+ }
+«ENDDEFINE»
+
+«DEFINE collectTargetElementsFromStatus FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static java.util.Set collectTargetElements(org.eclipse.core.runtime.IStatus status,
+ java.util.Set targetElementCollector, java.util.List allConstraintStatuses) {
+ if (status instanceof org.eclipse.emf.validation.model.IConstraintStatus) {
+ targetElementCollector.add(((org.eclipse.emf.validation.model.IConstraintStatus) status).getTarget());
+ allConstraintStatuses.add(status);
+ }
+ if (status.isMultiStatus()) {
+ org.eclipse.core.runtime.IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ collectTargetElements(children[i], targetElementCollector, allConstraintStatuses);
+ }
+ }
+ return targetElementCollector;
+ }
+«ENDDEFINE»
+
+«DEFINE collectTargetElementsFromDiagnostic FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static java.util.Set collectTargetElements(org.eclipse.emf.common.util.Diagnostic diagnostic,
+ java.util.Set targetElementCollector, java.util.List allDiagnostics) {
+ java.util.List data = diagnostic.getData();
+ org.eclipse.emf.ecore.EObject target = null;
+ if (data != null && !data.isEmpty() && data.get(0) instanceof org.eclipse.emf.ecore.EObject) {
+ target = (org.eclipse.emf.ecore.EObject) data.get(0);
+ targetElementCollector.add(target);
+ allDiagnostics.add(diagnostic);
+ }
+ if (diagnostic.getChildren() != null && !diagnostic.getChildren().isEmpty()) {
+ for (java.util.Iterator it = diagnostic.getChildren().iterator(); it.hasNext();) {
+ collectTargetElements((org.eclipse.emf.common.util.Diagnostic) it.next(),
+ targetElementCollector, allDiagnostics);
+ }
+ }
+ return targetElementCollector;
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForValidateAction(self)), 'Validate')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForValidateAction(self)))-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidationMarker.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidationMarker.xpt
new file mode 100644
index 000000000..b2b938e16
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidationMarker.xpt
@@ -0,0 +1,112 @@
+/*
+ * 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:
+ * Dmitry Stadnik (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::Utils»
+
+«DEFINE className FOR gmfgen::GenDiagram»ValidationMarker«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE ValidationMarker FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static final String KEY = "validation_marker"; //$NON-NLS-1$
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final «EXPAND className»[] EMPTY_ARRAY = new «EXPAND className»[0];
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final String location;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final String message;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final int statusSeverity;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(String location, String message, int statusSeverity) {
+ this.location = location;
+ this.message = message;
+ this.statusSeverity = statusSeverity;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getLocation() {
+ return location;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getMessage() {
+ return message;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public int getStatusSeverity() {
+ return statusSeverity;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static java.util.Map getMarkers(org.eclipse.gef.EditPartViewer viewer) {
+ java.util.Map markers = (java.util.Map) viewer.getProperty(KEY);
+ if (markers == null) {
+ markers = new java.util.HashMap();
+ viewer.setProperty(KEY, markers);
+ }
+ return markers;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static java.util.Set getMarkers(org.eclipse.gef.EditPartViewer viewer, String viewId, boolean create) {
+ java.util.Set markers = (java.util.Set) getMarkers(viewer).get(viewId);
+ if (markers == null) {
+ if (!create) {
+ return java.util.Collections.EMPTY_SET;
+ }
+ markers = new java.util.HashSet();
+ getMarkers(viewer).put(viewId, markers);
+ }
+ return markers;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static «EXPAND className»[] getMarkers(org.eclipse.gef.EditPartViewer viewer, String viewId) {
+ java.util.Set markers = getMarkers(viewer, viewId, false);
+ if (markers.isEmpty()) {
+ return EMPTY_ARRAY;
+ }
+ return («EXPAND className»[]) markers.toArray(new «EXPAND className»[markers.size()]);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static void removeAllMarkers(org.eclipse.gef.EditPartViewer viewer) {
+ getMarkers(viewer).clear();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void add(org.eclipse.gef.EditPartViewer viewer, String viewId) {
+ getMarkers(viewer, viewId, true).add(this);
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt
new file mode 100644
index 000000000..f1a4a8a91
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt
@@ -0,0 +1,388 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::editor::Utils»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::editpolicies::LinkUtils»
+«EXTENSION xpt::expressions::ValueExpression»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE VisualIDRegistry FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment(
+ 'This registry is used to determine which type of visual object should be
+created for the corresponding Diagram, Node, ChildNode or Link represented
+by a domain model object.
+'
+ )»
+public class «visualIDRegistryClassName» {
+
+ «EXPAND attributes-»
+
+ «EXPAND getViewVisualID-»
+
+ «EXPAND getModelID-»
+
+ «EXPAND getVisualID-»
+
+ «EXPAND getType-»
+
+ «EXPAND getDiagramVisualID-»
+
+ «EXPAND getNodeVisualID-»
+
+ «EXPAND canCreateNode-»
+
+ «EXPAND getLinkWithClassVisualID-»
+
+ «EXPAND isDiagram-»
+
+ «EXPAND _constraintMethods-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«REM»
+ <Definitions of templates for outside usage>
+«ENDREM»
+
+«DEFINE visualID FOR gmfgen::GenCommonBase»«getEditPartQualifiedClassName()».VISUAL_ID«ENDDEFINE»
+
+«DEFINE modelID FOR gmfgen::GenDiagram»«getEditPartQualifiedClassName()».MODEL_ID«ENDDEFINE»
+
+«DEFINE getVisualIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND getVisualIdMethodName»«ENDDEFINE»
+
+«DEFINE getModelIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND getModelIDMethodName»«ENDDEFINE»
+
+«REM»
+ XXX looks like these methods would produce incorrect result for visualID of GenDiagram itself - ask Vano if
+ getType() method shouldn't be fixed similar to getVisualID, i.e. map diagram's visual id to MODEL_ID instead plain String.valueOf()
+«ENDREM»
+«DEFINE typeMethodCall(visualIdVar : String) FOR gmfgen::GenCommonBase»«getDiagram().getVisualIDRegistryQualifiedClassName()».«EXPAND getTypeMethodName FOR getDiagram()»(«visualIdVar»)«ENDDEFINE»
+«DEFINE typeMethodCall FOR gmfgen::GenCommonBase»«getDiagram().getVisualIDRegistryQualifiedClassName()».«EXPAND getTypeMethodName FOR getDiagram()»(«EXPAND visualID»)«ENDDEFINE»
+
+«DEFINE getDiagramVisualIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND getDiagramVisualIDMethodName»«ENDDEFINE»
+
+«DEFINE getNodeVisualIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND getNodeVisualIDMethodName»«ENDDEFINE»
+
+«DEFINE canCreateNodeMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND canCreateNodeMethodName»«ENDDEFINE»
+
+«DEFINE getLinkWithClassVisualIDMethodCall FOR gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName()».«EXPAND getLinkWithClassVisualIDMethodName»«ENDDEFINE»
+
+«REM»
+ </Definitions of templates for outside usage>
+«ENDREM»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static final String DEBUG_KEY = "«editorGen.plugin.iD»/debug/visualID"; «EXPAND xpt::Common::nonNLS»
+«IF null <> editorGen.expressionProviders-»
+ «EXPAND _constraintField FOREACH topLevelNodes-»
+ «EXPAND _constraintField FOREACH childNodes-»
+ «EXPAND _constraintField FOREACH links-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getViewVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static int «EXPAND getVisualIdMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ if (view instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ if («EXPAND modelID».equals(view.getType())) {
+ return «EXPAND visualID»;
+ } else {
+ «EXPAND unrecognizedVID-»
+ }
+ }
+ return «EXPAND getVisualIDMethodCall»(view.getType());
+}
+«ENDDEFINE»
+
+«DEFINE getVisualIdMethodName FOR gmfgen::GenDiagram»getVisualID«ENDDEFINE»
+
+«DEFINE getModelID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static String «EXPAND getModelIDMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ org.eclipse.gmf.runtime.notation.View diagram = view.getDiagram();
+ while (view != diagram) {
+ org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «EXPAND xpt::Common::nonNLS»
+ if (annotation != null) {
+ return (String) annotation.getDetails().get("modelID"); «EXPAND xpt::Common::nonNLS»
+ }
+ view = (org.eclipse.gmf.runtime.notation.View) view.eContainer();
+ }
+ return diagram != null ? diagram.getType() : null;
+}
+«ENDDEFINE»
+
+«DEFINE getModelIDMethodName FOR gmfgen::GenDiagram»getModelID«ENDDEFINE»
+
+«DEFINE getVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static int «EXPAND getVisualIdMethodName»(String type) {
+ try {
+ return Integer.parseInt(type);
+ } catch (NumberFormatException e) {
+ if (Boolean.TRUE.toString().equalsIgnoreCase(org.eclipse.core.runtime.Platform.getDebugOption(DEBUG_KEY))) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to parse view type as a visualID number: " + type);
+ }
+ }
+ «EXPAND unrecognizedVID-»
+}
+«ENDDEFINE»
+
+«DEFINE getType FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static String «EXPAND getTypeMethodName»(int visualID) {
+ return String.valueOf(visualID);
+}
+«ENDDEFINE»
+
+«DEFINE getTypeMethodName FOR gmfgen::GenDiagram»getType«ENDDEFINE»
+
+«DEFINE getDiagramVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static int «EXPAND getDiagramVisualIDMethodName»(org.eclipse.emf.ecore.EObject domainElement) {
+ if (domainElement == null) {
+ «EXPAND unrecognizedVID-»
+ }
+«IF null <> domainDiagramElement-»
+ «EXPAND returnVisualID-»
+«ENDIF-»
+ «EXPAND unrecognizedVID-»
+}
+«ENDDEFINE»
+
+«DEFINE getDiagramVisualIDMethodName FOR gmfgen::GenDiagram»getDiagramVisualID«ENDDEFINE»
+
+«DEFINE returnVisualID FOR gmfgen::GenCommonBase-»
+if («EXPAND checkSemanticElement») {
+ return «EXPAND visualID»;
+}
+«ENDDEFINE»
+
+«DEFINE checkSemanticElement FOR gmfgen::GenCommonBase-»
+ «ERROR 'checkSemanticElement not supported for: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE checkSemanticElement FOR gmfgen::GenDiagram»«EXPAND checkDomainElementMetaclass FOR domainDiagramElement» && isDiagram(«EXPAND MetaModel::CastEObject('domainElement') FOR domainDiagramElement»)«ENDDEFINE»
+«DEFINE checkSemanticElement FOR gmfgen::GenNode»«EXPAND checkDomainElementMetaclass FOR modelFacet.metaClass»«EXPAND checkDomainElementConstraints(self) FOR modelFacet»«ENDDEFINE»
+«DEFINE checkSemanticElement FOR gmfgen::GenLink»«EXPAND checkSemanticElement(self) FOR modelFacet»«ENDDEFINE»
+
+«DEFINE checkDomainElementMetaclass FOR genmodel::GenClass»«EXPAND MetaModel::MetaClass».isSuperTypeOf(domainElement.eClass())«ENDDEFINE»
+
+«DEFINE checkDomainElementConstraints(commonBase : gmfgen::GenCommonBase) FOR gmfgen::TypeModelFacet-»
+«IF null <> modelElementSelector» && «EXPAND _domainElementConstraintMethodName FOR commonBase»(«EXPAND MetaModel::CastEObject('domainElement') FOR metaClass»)«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkSemanticElement(genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet»«ERROR 'checkSemanticElement is supported only for TypeLinkModelFacet: ' + self.repr()»«ENDDEFINE»
+«DEFINE checkSemanticElement(genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet»«EXPAND checkDomainElementMetaclass FOR metaClass»«EXPAND checkDomainElementConstraints(genLink)»«ENDDEFINE»
+
+
+«DEFINE getNodeVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static int «EXPAND getNodeVisualIDMethodName»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
+ if (domainElement == null) {
+ «EXPAND unrecognizedVID-»
+ }
+ String containerModelID = «EXPAND getModelIDMethodCall»(containerView);
+ if (!«EXPAND modelID».equals(containerModelID)«EXPAND checkContainerModelID FOREACH shortcutsProvidedFor») { «EXPAND xpt::Common::nonNLS FOR shortcutsProvidedFor->asSequence()»
+ «EXPAND unrecognizedVID-»
+ }
+ int containerVisualID;
+ if («EXPAND modelID».equals(containerModelID)) {
+ containerVisualID = «EXPAND getVisualIDMethodCall»(containerView);
+ } else {
+ if (containerView instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ containerVisualID = «EXPAND visualID»;
+ } else {
+ «EXPAND unrecognizedVID-»
+ }
+ }
+ switch (containerVisualID) {
+ «EXPAND caseDomainContainerVisualID FOREACH getAllContainers()-»
+ }
+ «EXPAND unrecognizedVID-»
+}
+«ENDDEFINE»
+
+«DEFINE getNodeVisualIDMethodName FOR gmfgen::GenDiagram»getNodeVisualID«ENDDEFINE»
+
+«DEFINE caseDomainContainerVisualID FOR gmfgen::GenContainerBase-»
+ «IF getContainedSemanticNodes(self)->size() > 0-»
+«EXPAND xpt::Common::caseVisualID»
+ «EXPAND returnVisualID FOREACH getContainedSemanticNodes(self)-»
+ break;
+ «ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE canCreateNode FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static boolean «EXPAND canCreateNodeMethodName»(org.eclipse.gmf.runtime.notation.View containerView, int nodeVisualID) {
+ String containerModelID = «EXPAND getModelIDMethodCall»(containerView);
+ if (!«EXPAND modelID».equals(containerModelID)«EXPAND checkContainerModelID FOREACH shortcutsProvidedFor») { «EXPAND xpt::Common::nonNLS FOR shortcutsProvidedFor->asSequence()»
+ return false;
+ }
+ int containerVisualID;
+ if («EXPAND modelID».equals(containerModelID)) {
+ containerVisualID = «EXPAND getVisualIDMethodCall»(containerView);
+ } else {
+ if (containerView instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ containerVisualID = «EXPAND visualID»;
+ } else {
+ return false;
+ }
+ }
+ switch (containerVisualID) {
+ «EXPAND caseVisualID FOREACH getAllContainers()->select(e | not e.getEssentialVisualChildren()->isEmpty())-»
+ «EXPAND caseVisualID FOREACH links->select(e | not e.getEssentialVisualChildren()->isEmpty())-»
+ }
+ return false;
+}
+«ENDDEFINE»
+
+«DEFINE canCreateNodeMethodName FOR gmfgen::GenDiagram»canCreateNode«ENDDEFINE»
+
+«DEFINE checkContainerModelID FOR String» && !"«self»".equals(containerModelID)«ENDDEFINE»
+
+«DEFINE caseVisualID FOR gmfgen::GenCommonBase-»
+«EXPAND xpt::Common::caseVisualID»
+ «EXPAND checkEssentialChild FOREACH self.getEssentialVisualChildren()-»
+ break;
+«ENDDEFINE»
+
+«DEFINE checkEssentialChild FOR gmfgen::GenCommonBase-»
+if («EXPAND visualID» == nodeVisualID) {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE getLinkWithClassVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static int «EXPAND getLinkWithClassVisualIDMethodName»(org.eclipse.emf.ecore.EObject domainElement) {
+ if (domainElement == null) {
+ «EXPAND unrecognizedVID-»
+ }
+ «EXPAND returnVisualID FOREACH links->select(link | isTypeLink(link))-»
+ «EXPAND unrecognizedVID-»
+}
+«ENDDEFINE»
+
+«DEFINE getLinkWithClassVisualIDMethodName FOR gmfgen::GenDiagram»getLinkWithClassVisualID«ENDDEFINE»
+
+
+«DEFINE isDiagram FOR gmfgen::GenDiagram-»
+ «IF null <> domainDiagramElement-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'User can change implementation of this method to handle some specific
+situations not covered by default logic.
+'
+ )»
+private static boolean isDiagram(«EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» element) {
+ return true;
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+
+«REM»
+
+ Support for extra contstraints to check about model element.
+ Includes expression fields for interpreted constrains (like ocl or regexp).
+ For each model element that has an associated constraint, there's a method is<DomainElement>_<UID>()
+ that performs extra specification as defined by value expression
+
+ FIXME don't use static fields, replace with instance/separate cache (e.g. accessible from Activator)
+«ENDREM»
+
+«DEFINE _constraintMethods FOR gmfgen::GenDiagram-»
+«IF null <> editorGen.expressionProviders-»
+ «EXPAND _constraintMethod FOREACH topLevelNodes->select(n | n.modelFacet.modelElementSelector <> null)-»
+ «EXPAND _constraintMethod FOREACH childNodes->select(n | n.modelFacet.modelElementSelector <> null)-»
+ «FOREACH links->asSequence() AS l»«EXPAND _constraintMethod(l) FOR l.modelFacet»«ENDFOREACH»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _constraintMethod FOR gmfgen::GenNode-»
+«EXPAND _domainElementConstraintMethod(self, modelFacet.modelElementSelector, modelFacet.metaClass) FOR modelFacet.modelElementSelector.provider»
+«ENDDEFINE»
+
+«DEFINE _constraintMethod(l : gmfgen::GenLink) FOR gmfgen::LinkModelFacet»«ENDDEFINE» // no-op
+«DEFINE _constraintMethod(l : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+«IF modelElementSelector <> null»«EXPAND _domainElementConstraintMethod(l, modelElementSelector, metaClass) FOR modelElementSelector.provider»«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE _domainElementConstraintMethodName FOR gmfgen::GenCommonBase»is«getUniqueIdentifier()»«ENDDEFINE»
+
+«DEFINE _domainElementConstraintMethod(diagramElement : gmfgen::GenCommonBase, expression : gmfgen::ValueExpression, context : genmodel::GenClass) FOR gmfgen::GenExpressionProviderBase»«ERROR 'Constraint method is not supported for ' + self.repr()»«ENDDEFINE»
+
+«DEFINE _domainElementConstraintMethod(diagramElement : gmfgen::GenCommonBase, expression : gmfgen::ValueExpression, context : genmodel::GenClass) FOR gmfgen::GenJavaExpressionProvider-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static boolean «EXPAND _domainElementConstraintMethodName FOR diagramElement»(«EXPAND MetaModel::QualifiedClassName FOR context» domainElement) {
+«IF injectExpressionBody and (expression.body <> null and expression.body.xpandLength() <> 0)-»
+ «expression.body»
+«ELSEIF throwException or (injectExpressionBody and (expression.body = null or expression.body.xpandLength() = 0))-»
+ // FIXME: implement this method
+ // Ensure that you remove @generated or mark it @generated NOT
+ throw new java.lang.UnsupportedOperationException("No java implementation provided in '«EXPAND _domainElementConstraintMethodName FOR diagramElement»' operation");«EXPAND xpt::Common::nonNLS»
+«ELSE-»
+ return false;
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE _domainElementConstraintMethod(diagramElement : gmfgen::GenCommonBase, expression : gmfgen::ValueExpression, context : genmodel::GenClass) FOR gmfgen::GenExpressionInterpreter-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static boolean «EXPAND _domainElementConstraintMethodName FOR diagramElement»(«EXPAND MetaModel::QualifiedClassName FOR context» domainElement) {
+ if («constraintFieldName(diagramElement)» == null) { // lazy initialization
+ «constraintFieldName(diagramElement)» = «EXPAND xpt::expressions::getExpression::getExpression(expression, context)»; «EXPAND xpt::Common::nonNLS»
+ }
+ Object result = «constraintFieldName(diagramElement)».evaluate(domainElement);
+ return result instanceof Boolean && ((Boolean)result).booleanValue();
+ }
+«ENDDEFINE»
+
+
+«DEFINE _constraintField FOR gmfgen::GenNode»«EXPAND _constraintField(self) FOR modelFacet»«ENDDEFINE»
+«DEFINE _constraintField FOR gmfgen::GenLink»«EXPAND _constraintField(self) FOR modelFacet»«ENDDEFINE»
+
+«DEFINE _constraintField(diagramElement : gmfgen::GenCommonBase) FOR gmfgen::ModelFacet»«ENDDEFINE»
+«DEFINE _constraintField(diagramElement : gmfgen::GenCommonBase) FOR gmfgen::TypeModelFacet-»
+«IF modelElementSelector <> null»«EXPAND _constraintField(diagramElement) FOR modelElementSelector.provider»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _constraintField(diagramElement : gmfgen::GenCommonBase) FOR gmfgen::GenExpressionInterpreter»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static «container.getAbstractExpressionQualifiedClassName()» «constraintFieldName(diagramElement)»;
+«ENDDEFINE»
+
+«DEFINE _constraintField(diagramElement : gmfgen::GenCommonBase) FOR gmfgen::GenExpressionProviderBase»«ERROR 'Need to define approach to constraint fields for ' + self.repr()»«ENDDEFINE»
+«DEFINE _constraintField(diagramElement : gmfgen::GenCommonBase) FOR gmfgen::GenJavaExpressionProvider»«ENDDEFINE»// IOW, no fields for Java
+
+«REM»
+ Constraints support end.
+«ENDREM»
+
+
+«DEFINE unrecognizedVID FOR gmfgen::GenDiagram-»
+return -1;
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/diagram.gif b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/diagram.gif
new file mode 100644
index 000000000..bdc8ae9a0
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/diagram.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/extensions.xpt
new file mode 100644
index 000000000..a4c3889bf
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/extensions.xpt
@@ -0,0 +1,86 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«DEFINE extensions FOR gmfgen::GenEditorGenerator»
+ <extension point="org.eclipse.ui.editors" id="gmf-editor">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <editor
+ id="«editor.iD»"
+ name="%editorName"
+ icon="«editor.iconPathX»"
+ extensions="«diagramFileExtension»"
+ default="true"
+ class="«editor.getQualifiedClassName()»"
+ matchingStrategy="«diagram.getMatchingStrategyQualifiedClassName()»"
+ contributorClass="«editor.getActionBarContributorQualifiedClassName()»">
+ </editor>
+ </extension>
+
+ <extension point="org.eclipse.ui.contexts" id="ui-context">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <context
+ description="%context.description"
+ id="«editor.contextID»"
+ name="%context.name"
+ parentId="org.eclipse.gmf.runtime.diagram.ui.diagramContext">
+ </context>
+ </extension>
+
+ <extension point="org.eclipse.ui.newWizards" id="creation-wizard">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <wizard
+ name="%newWizardName"
+ icon="«diagram.creationWizardIconPathX»"
+ category="«diagram.creationWizardCategoryID»"
+ class="«diagram.getCreationWizardQualifiedClassName()»"
+ id="«diagram.getCreationWizardQualifiedClassName()»ID">
+ <description>%newWizardDesc</description>
+ </wizard>
+ </extension>
+
+«IF diagram.generateInitDiagramAction()-»
+ «IF null = application»<extension point="org.eclipse.ui.popupMenus" id="init-diagram-action">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <objectContribution
+ id="«plugin.iD».InitDiagram"
+ nameFilter="*.«domainFileExtension»"
+ objectClass="org.eclipse.core.resources.IFile">
+ <action
+ label="%initDiagramActionLabel"
+ class="«diagram.getInitDiagramFileActionQualifiedClassName()»"
+ menubarPath="additions"
+ enablesFor="1"
+ id="«plugin.iD».InitDiagramAction">
+ </action>
+ </objectContribution>
+ </extension>
+ «ELSE-»
+ <extension point="org.eclipse.ui.actionSets" id="init-diagram-action">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <actionSet
+ label="%initDiagramActionLabel"
+ visible="true"
+ id="«plugin.iD».InitDiagram">
+ <action
+ label="%initDiagramActionLabel"
+ class="«diagram.getInitDiagramFileActionQualifiedClassName()»"
+ menubarPath="file/additions"
+ id="«plugin.iD».InitDiagramAction">
+ </action>
+ </actionSet>
+ </extension>
+ «ENDIF-»
+«ENDIF-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt
new file mode 100644
index 000000000..70b2d2be3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2006, 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/Ecore'»
+«EXTENSION xpt::editor::palette::Utils»
+
+«DEFINE Factory FOR gmfgen::Palette»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «factoryClassName» {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void fillPalette(org.eclipse.gef.palette.PaletteRoot paletteRoot) {
+«IF definesStandardTools()-»
+ cleanStandardTools(paletteRoot);
+«ENDIF-»
+ «EXPAND addEntry('paletteRoot') FOREACH groups-»
+ }
+«IF definesStandardTools()»
+«EXPAND cleanStandardToolsHack-»
+«ENDIF-»
+
+«EXPAND createGroup FOREACH collectGroups(self)»
+«EXPAND createEntry FOREACH collectTools(self)»
+
+«IF needsNodeToolEntryClass(self)»«EXPAND nodeToolEntry»«ENDIF-»
+«IF needsLinkToolEntryClass(self)»«EXPAND linkToolEntry»«ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE createGroup FOR gmfgen::ToolGroup-»
+ «EXPAND xpt::Common::generatedMemberComment('Creates "' + title + '" palette tool group')»
+ private org.eclipse.gef.palette.PaletteContainer «createMethodName»() {
+ «EXPAND newContainer('paletteContainer')-»
+ «EXPAND setDescription('paletteContainer', self) FOR description-»
+ «EXPAND setSmallImage('paletteContainer', palette)-»
+ «EXPAND setLargeImage('paletteContainer', palette)-»
+ «EXPAND addEntry('paletteContainer') FOREACH entries-»
+ return paletteContainer;
+ }
+«ENDDEFINE»
+
+«DEFINE newContainer(varName : String) FOR gmfgen::ToolGroup-»
+«IF collapse and toolsOnly-»
+ org.eclipse.gef.palette.PaletteDrawer «varName» = new org.eclipse.gef.palette.PaletteDrawer(«EXPAND i18nTitle»);
+«ELSEIF stack-»
+ org.eclipse.gef.palette.PaletteStack «varName» = new org.eclipse.gef.palette.PaletteStack(«EXPAND i18nTitle», null, null);
+«ELSE-»
+ org.eclipse.gef.palette.PaletteGroup «varName» = new org.eclipse.gef.palette.PaletteGroup(«EXPAND i18nTitle»);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setDescription(varName : String, gr : gmfgen::ToolGroup) FOR String-»
+«varName».setDescription(«EXPAND i18nDesc FOR gr»);
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::ToolGroupItem»
+«ERROR 'abstract addEntry(ToolGroupItem,String) template'»
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::AbstractToolEntry-»
+«varName».add(«createMethodName»());
+«IF _default and group.stack-»
+«varName».setActiveEntry((org.eclipse.gef.palette.ToolEntry) paletteContainer.getChildren().get(paletteContainer.getChildren().size() - 1));
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::Separator-»
+«varName».add(new org.eclipse.gef.palette.PaletteSeparator());
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::ToolGroup-»
+«varName».add(«createMethodName»());
+«ENDDEFINE»
+
+«DEFINE createEntry FOR gmfgen::AbstractToolEntry-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gef.palette.ToolEntry «createMethodName»() {
+ «EXPAND newEntry('entry')-»
+ «EXPAND setSmallImage('entry', group.palette)-»
+ «EXPAND setLargeImage('entry', group.palette)-»
+ «EXPAND setToolClass('entry')-»
+ «EXPAND setToolProperty('entry') FOREACH properties-»
+ return entry;
+ }
+«ENDDEFINE»
+
+«DEFINE newEntry(toolVarName : String) FOR gmfgen::AbstractToolEntry-»
+«ERROR 'abstract newEntry(AbstractToolEntry,String) template'»
+«ENDDEFINE»
+
+«DEFINE newEntry(toolVarName : String) FOR gmfgen::ToolEntry-»
+«IF elements->isEmpty()-»
+org.eclipse.gef.palette.ToolEntry «toolVarName» = new org.eclipse.gef.palette.ToolEntry(«EXPAND i18nTitle», «EXPAND i18nDesc», null, null) {};
+«ELSE-»
+«LET (if genNodes->isEmpty() then 'LinkToolEntry' else 'NodeToolEntry' endif) AS toolEntryClass-»
+java.util.List/*<IElementType>*/ types = new java.util.ArrayList/*<IElementType>*/(«elements->size()»);
+«FOREACH elements->asSequence() AS e-»
+types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR e»);
+«ENDFOREACH-»
+«toolEntryClass» «toolVarName» = new «toolEntryClass»(«EXPAND i18nTitle», «EXPAND i18nDesc», types);
+«ENDLET-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE newEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+«IF gmfgen::StandardEntryKind::SELECT = kind -»
+«EXPAND newStdSelectEntry(toolVarName)-»
+«ELSEIF kind = gmfgen::StandardEntryKind::MARQUEE-»
+«EXPAND newStdMarqueeEntry(toolVarName)-»
+«ELSEIF kind = gmfgen::StandardEntryKind::ZOOM-»
+«EXPAND newStdZoomEntry(toolVarName)-»
+«ELSE-»
+«EXPAND newStdOtherEntry(toolVarName)-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE newStdSelectEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+org.eclipse.gef.palette.PanningSelectionToolEntry «toolVarName» = new org.eclipse.gef.palette.PanningSelectionToolEntry();
+«ENDDEFINE»
+
+«DEFINE newStdMarqueeEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+org.eclipse.gef.palette.MarqueeToolEntry «toolVarName» = new org.eclipse.gef.palette.MarqueeToolEntry();
+«ENDDEFINE»
+
+«DEFINE newStdZoomEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+FIXME
+«ENDDEFINE»
+
+«DEFINE newStdOtherEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+«ERROR 'override newStdOtherEntry(StandardEntry, String) for kind ' + kind.repr()»
+«ENDDEFINE»
+
+// FIXME: odd code - FOR EntryBase, while most of the template is valid for ToolEntry only!!!
+«DEFINE setSmallImage(toolVarName : String, palette : gmfgen::Palette) FOR gmfgen::EntryBase-»
+«IF null <> smallIconPath-»
+«toolVarName».setSmallIcon(«palette.activatorFQN()».findImageDescriptor("«smallIconPath»"));«EXPAND xpt::Common::nonNLS»
+«ELSEIF not (Sequence { self })[gmfgen::ToolEntry].elements->isEmpty()-»
+«LET self.oclAsType(gmfgen::ToolEntry) AS toolEntry-»
+«toolVarName».setSmallIcon(«palette.diagram.getElementTypesQualifiedClassName()».getImageDescriptor(«EXPAND xpt::providers::ElementTypes::accessElementType FOR toolEntry.elements->first().oclAsType(gmfgen::GenCommonBase)»));
+«ENDLET-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setLargeImage(toolVarName : String, palette : gmfgen::Palette) FOR gmfgen::EntryBase-»
+«IF null <> largeIconPath-»
+«toolVarName».setLargeIcon(«palette.activatorFQN()».findImageDescriptor("«largeIconPath»")); «EXPAND xpt::Common::nonNLS»
+«ELSEIF not (Sequence { self })[gmfgen::ToolEntry].elements->isEmpty()-»
+«toolVarName».setLargeIcon(«toolVarName».getSmallIcon());
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setToolClass(toolVarName : String) FOR gmfgen::AbstractToolEntry-»
+«IF null <> qualifiedToolName-»
+«toolVarName».setToolClass(«qualifiedToolName».class);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setToolProperty(toolVarName : String) FOR ecore::EStringToStringMapEntry-»
+«toolVarName».setToolProperty(«key», «value»);
+«ENDDEFINE»
+
+«DEFINE i18nTitle FOR gmfgen::ToolEntry-»
+«IF title = null»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nTitleKey(self)) FOR group.palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nTitle FOR gmfgen::ToolGroup-»
+«IF title = null»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nTitleKey(self)) FOR palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nDesc FOR gmfgen::ToolEntry-»
+«IF null = description»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nDescKey(self)) FOR group.palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nDesc FOR gmfgen::ToolGroup-»
+«IF null = description»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nDescKey(self)) FOR palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::Palette-»
+«EXPAND internal_i18n_accessors FOREACH collectGroups(self)-»
+«EXPAND internal_i18n_accessors FOREACH collectTools(self)-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::Palette-»
+«EXPAND internal_i18n_values FOREACH collectGroups(self)-»
+«EXPAND internal_i18n_values FOREACH collectTools(self)-»
+«ENDDEFINE»
+
+«DEFINE internal_i18n_accessors FOR gmfgen::EntryBase-»
+«IF null <> title»«EXPAND xpt::Externalizer::accessorField(i18nTitleKey(self))»«ENDIF-»
+«IF null <> description»«EXPAND xpt::Externalizer::accessorField(i18nDescKey(self))»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE internal_i18n_values FOR gmfgen::EntryBase-»
+«IF null <> title»«EXPAND xpt::Externalizer::messageEntry(i18nTitleKey(self), title)»«ENDIF-»
+«IF null <> description»«EXPAND xpt::Externalizer::messageEntry(i18nDescKey(self), description)»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE cleanStandardToolsHack FOR gmfgen::Palette»
+ «EXPAND xpt::Common::generatedMemberComment('Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=159289')»
+ private void cleanStandardTools(org.eclipse.gef.palette.PaletteRoot paletteRoot) {
+ for (java.util.Iterator it = paletteRoot.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gef.palette.PaletteEntry entry = (org.eclipse.gef.palette.PaletteEntry) it.next();
+ if (!"standardGroup".equals(entry.getId())) { «EXPAND xpt::Common::nonNLS»
+ continue;
+ }
+ for (java.util.Iterator it2 = ((org.eclipse.gef.palette.PaletteContainer) entry).getChildren().iterator(); it2.hasNext();) {
+ org.eclipse.gef.palette.PaletteEntry entry2 = (org.eclipse.gef.palette.PaletteEntry) it2.next();
+ if ("zoomTool".equals(entry2.getId())) { «EXPAND xpt::Common::nonNLS»
+ it2.remove();
+ } else if ("noteStack".equals(entry2.getId())) { «EXPAND xpt::Common::nonNLS»
+ it2.remove();
+ } else if ("selectionTool".equals(entry2.getId())) { «EXPAND xpt::Common::nonNLS»
+ it2.remove();
+ }
+ if (paletteRoot.getDefaultEntry() == entry2) {
+ paletteRoot.setDefaultEntry(null);
+ }
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE nodeToolEntry FOR OclAny»
+ «EXPAND xpt::Common::generatedClassComment»
+ private static class NodeToolEntry extends org.eclipse.gef.palette.ToolEntry {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final java.util.List elementTypes;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private NodeToolEntry(String title, String description, java.util.List elementTypes) {
+ super(title, description, null, null);
+ this.elementTypes = elementTypes;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.Tool createTool() {
+ org.eclipse.gef.Tool tool = new org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool(elementTypes);
+ tool.setProperties(getToolProperties());
+ return tool;
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE linkToolEntry FOR OclAny»
+ «EXPAND xpt::Common::generatedClassComment»
+ private static class LinkToolEntry extends org.eclipse.gef.palette.ToolEntry {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final java.util.List relationshipTypes;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private LinkToolEntry(String title, String description, java.util.List relationshipTypes) {
+ super(title, description, null, null);
+ this.relationshipTypes = relationshipTypes;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.Tool createTool() {
+ org.eclipse.gef.Tool tool = new org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool(relationshipTypes);
+ tool.setProperties(getToolProperties());
+ return tool;
+ }
+ }
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/Utils.qvto
new file mode 100644
index 000000000..b7f133e41
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/Utils.qvto
@@ -0,0 +1,49 @@
+import xpt.StringOperations;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Utils;
+
+helper genModel::Palette::activatorFQN() : String {
+ return self.diagram.editorGen.plugin.getActivatorQualifiedClassName()
+}
+
+helper genModel::AbstractToolEntry::activatorFQN() : String {
+ return self.group.palette.activatorFQN()
+}
+
+helper genModel::ToolGroup::activatorFQN() : String {
+ return self.palette.activatorFQN()
+}
+
+helper i18nKey(group : genModel::EntryBase) : String {
+ return let rv = group.createMethodName in (if rv.xpandStartsWith('get') then rv.xpandSubstring(3) else (if rv.xpandStartsWith('create') then rv.xpandSubstring(6) else rv endif) endif)
+}
+
+helper i18nTitleKey(group : genModel::EntryBase) : String {
+ return i18nKey(group) + '_title'
+}
+
+helper i18nDescKey(group : genModel::EntryBase) : String {
+ return i18nKey(group) + '_desc'
+}
+
+helper collectGroups(palette : genModel::Palette) : Sequence(genModel::ToolGroup) {
+ return palette.groups->asSequence()->union(palette.groups->collect(it | collectSubGroups(it)))->asOrderedSet()->asSequence()
+}
+
+helper collectSubGroups(group : genModel::ToolGroup) : Sequence(genModel::ToolGroup) {
+ return let rv = (group.entries)[genModel::ToolGroup] in rv->union(rv->collect(g | collectSubGroups(g))->flatten()->asSet())->asSequence()
+}
+
+helper collectTools(palette : genModel::Palette) : Sequence(genModel::AbstractToolEntry) {
+ return collectGroups(palette)->collect(g | (g.entries)[genModel::AbstractToolEntry])->flatten()
+}
+
+helper needsNodeToolEntryClass(palette : genModel::Palette) : Boolean {
+ return (collectTools(palette))[genModel::ToolEntry]->exists(e | not e.genNodes->isEmpty())
+}
+
+helper needsLinkToolEntryClass(palette : genModel::Palette) : Boolean {
+ return (collectTools(palette))[genModel::ToolEntry]->exists(e | not e.genLinks->isEmpty())
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/shortcut.gif b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/shortcut.gif
new file mode 100644
index 000000000..c8ebb3156
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/shortcut.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/wizban.gif b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/wizban.gif
new file mode 100644
index 000000000..cc3848e15
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/wizban.gif
Binary files differ

Back to the top