Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/impl')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CreateShortcutAction.xpt98
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CustomAction.xpt32
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/LoadResourceAction.xpt44
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/MenuAction.qvto11
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/PredefinedAction.xpt22
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/extensions.xpt156
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ChildNodeLabelEditPart.xpt43
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/CompartmentEditPart.xpt128
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt96
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ExternalNodeLabelEditPart.xpt68
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkEditPart.xpt145
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkLabelEditPart.xpt61
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt581
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeLabelEditPart.xpt70
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt537
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/AbstractParser.xpt396
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/ParserProvider.xpt223
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/i18n.qvto21
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/CustomPage.xpt84
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/StandardPage.xpt46
20 files changed, 2862 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CreateShortcutAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CreateShortcutAction.xpt
new file mode 100644
index 000000000..3684ac32f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CreateShortcutAction.xpt
@@ -0,0 +1,98 @@
+/*
+ * 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
+ * Artem Tikhomirov (Borland) - [174961] migration to Commands/Handlers
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::editor::Utils»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE Main FOR gmfgen::CreateShortcutAction-»
+«EXPAND xpt::Common::copyright FOR owner.editorGen-»
+«EXPAND xpt::Common::packageStatement FOR qualifiedClassName»
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «qualifiedClassName.xpandSplit('\.')->last()»«EXPAND extendsList»«EXPAND implementsList» {
+«EXPAND executeMethod»
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::CreateShortcutAction» extends org.eclipse.core.commands.AbstractHandler«ENDDEFINE»
+«DEFINE implementsList FOR gmfgen::CreateShortcutAction»«ENDDEFINE»
+
+«DEFINE executeMethod FOR gmfgen::CreateShortcutAction-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public Object execute(org.eclipse.core.commands.ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.ui.IEditorPart diagramEditor = org.eclipse.ui.handlers.HandlerUtil.getActiveEditorChecked(event);
+ org.eclipse.swt.widgets.Shell shell = diagramEditor.getEditorSite().getShell();
+ «EXPAND xpt::Common::_assert('diagramEditor instanceof org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor')-»
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor) diagramEditor).getEditingDomain();
+ org.eclipse.jface.viewers.ISelection selection = org.eclipse.ui.handlers.HandlerUtil.getCurrentSelectionChecked(event);
+ «EXPAND xpt::Common::_assert('selection instanceof org.eclipse.jface.viewers.IStructuredSelection')-»
+ «EXPAND xpt::Common::_assert('((org.eclipse.jface.viewers.IStructuredSelection) selection).size() == 1')-»
+ «EXPAND xpt::Common::_assert('((org.eclipse.jface.viewers.IStructuredSelection) selection).getFirstElement() instanceof org.eclipse.gef.EditPart')-»
+ org.eclipse.gef.EditPart selectedDiagramPart = (org.eclipse.gef.EditPart) ((org.eclipse.jface.viewers.IStructuredSelection) selection).getFirstElement();
+ final org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) selectedDiagramPart.getModel();
+«IF null = owner.editorGen.application-»
+ «owner.editorGen.diagram.getElementChooserQualifiedClassName()» elementChooser = new «owner.editorGen.diagram.getElementChooserQualifiedClassName()»(shell, view);
+ int result = elementChooser.open();
+ if (result != org.eclipse.jface.window.Window.OK) {
+ return null;
+ }
+ org.eclipse.emf.common.util.URI selectedModelElementURI = elementChooser.getSelectedModelElementURI();
+ final org.eclipse.emf.ecore.EObject selectedElement;
+ try {
+ selectedElement = editingDomain.getResourceSet().getEObject(selectedModelElementURI, true);
+ } catch (org.eclipse.emf.common.util.WrappedException e) {
+ «owner.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Exception while loading object: " + selectedModelElementURI.toString(), e);«EXPAND xpt::Common::nonNLS»
+ return null;
+ }
+
+ if (selectedElement == null) {
+ return null;
+ }
+ 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(selectedElement), org.eclipse.gmf.runtime.notation.Node.class, null, «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR owner.editorGen»);
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = new org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand(editingDomain, viewDescriptor, view);
+ command = command.compose(new «owner.editorGen.diagram.getCreateShortcutDecorationsCommandQualifiedClassName()»(editingDomain, view, viewDescriptor));
+ try {
+ org.eclipse.core.commands.operations.OperationHistoryFactory.getOperationHistory().execute(command, new org.eclipse.core.runtime.NullProgressMonitor(), null);
+ } catch (org.eclipse.core.commands.ExecutionException e) {
+ «owner.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to create shortcut", e);«EXPAND xpt::Common::nonNLS»
+ }
+«ELSE-»
+ org.eclipse.emf.ecore.resource.Resource resource = «owner.editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».openModel(shell, «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreateShortcutOpenModel())) FOR owner.editorGen», editingDomain);
+ if (resource == null || resource.getContents().isEmpty()) {
+ return null;
+ }
+ «EXPAND xpt::editor::ShortcutCreationWizard::qualifiedClassName FOR owner.editorGen.diagram» wizard = new «EXPAND xpt::editor::ShortcutCreationWizard::qualifiedClassName FOR owner.editorGen.diagram»((org.eclipse.emf.ecore.EObject) resource.getContents().get(0), view, editingDomain);
+ wizard.setWindowTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreateShortcutWizard())) FOR owner.editorGen»);
+ «owner.editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».runWizard(myShell, wizard, "CreateShortcut");«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::CreateShortcutAction»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«IF null <> editorGen.application-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreateShortcutOpenModel()), 'Select model to reference')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreateShortcutWizard()), 'Create shortcut')-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«IF null <> editorGen.application-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreateShortcutOpenModel()))-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreateShortcutWizard()))-»
+«ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CustomAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CustomAction.xpt
new file mode 100644
index 000000000..b469170ab
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/CustomAction.xpt
@@ -0,0 +1,32 @@
+/*
+ * 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:
+ * 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::StringOperations»
+
+«DEFINE Main FOR gmfgen::GenCustomAction-»
+«EXPAND xpt::Common::copyright FOR owner.editorGen-»
+«EXPAND xpt::Common::packageStatement FOR qualifiedClassName»
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «qualifiedClassName.xpandSplit('\.')->last()» extends org.eclipse.core.commands.AbstractHandler {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public Object execute(org.eclipse.core.commands.ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.ui.IEditorPart diagramEditor = org.eclipse.ui.handlers.HandlerUtil.getActiveEditorChecked(event);
+ org.eclipse.jface.viewers.ISelection selection = org.eclipse.ui.handlers.HandlerUtil.getCurrentSelectionChecked(event);
+ // FIXME implement required behavior
+ throw new UnsupportedOperationException();
+ }
+}
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/LoadResourceAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/LoadResourceAction.xpt
new file mode 100644
index 000000000..260811374
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/LoadResourceAction.xpt
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * Artem Tikhomirov (Borland) - [174961] migration to Commands/Handlers
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE Main FOR gmfgen::LoadResourceAction-»
+«EXPAND xpt::Common::copyright FOR owner.editorGen-»
+«EXPAND xpt::Common::packageStatement FOR qualifiedClassName»
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «qualifiedClassName.xpandSplit('\.')->last()»«EXPAND extendsList»«EXPAND implementsList» {
+«EXPAND executeMethod»
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::LoadResourceAction» extends org.eclipse.core.commands.AbstractHandler«ENDDEFINE»
+«DEFINE implementsList FOR gmfgen::LoadResourceAction»«ENDDEFINE»
+
+«DEFINE executeMethod FOR gmfgen::LoadResourceAction-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public Object execute(org.eclipse.core.commands.ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.ui.IEditorPart diagramEditor = org.eclipse.ui.handlers.HandlerUtil.getActiveEditorChecked(event);
+ org.eclipse.swt.widgets.Shell shell = diagramEditor.getEditorSite().getShell();
+ «EXPAND xpt::Common::_assert('diagramEditor instanceof org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor')-»
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor) diagramEditor).getEditingDomain();
+ org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(shell, editingDomain);
+ loadResourceDialog.open();
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::LoadResourceAction»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/MenuAction.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/MenuAction.qvto
new file mode 100644
index 000000000..ac0840e3b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/MenuAction.qvto
@@ -0,0 +1,11 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library MenuAction;
+
+helper hasCommandsToContribute(editorGen : genModel::GenEditorGenerator) : Boolean {
+ return not editorGen.contextMenus->isEmpty()
+}
+
+helper hasHandlersToContribute(editorGen : genModel::GenEditorGenerator) : Boolean {
+ return hasCommandsToContribute(editorGen)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/PredefinedAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/PredefinedAction.xpt
new file mode 100644
index 000000000..c2f00496c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/PredefinedAction.xpt
@@ -0,0 +1,22 @@
+/*
+ * 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:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«DEFINE Main FOR gmfgen::GenAction»«ERROR 'Asbtract template for ' + self.repr()»«ENDDEFINE»
+
+«DEFINE Main FOR gmfgen::LoadResourceAction»«EXPAND LoadResourceAction::Main»«ENDDEFINE»
+
+«DEFINE Main(editorGen : gmfgen::GenEditorGenerator) FOR gmfgen::InitDiagramAction»«EXPAND xpt::editor::InitDiagramFileAction::InitDiagramFileAction(editorGen)»«ENDDEFINE»
+
+«DEFINE Main FOR gmfgen::CreateShortcutAction»«EXPAND CreateShortcutAction::Main»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/extensions.xpt
new file mode 100644
index 000000000..1f34cbd20
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/actions/extensions.xpt
@@ -0,0 +1,156 @@
+/*
+ * 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:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION impl::actions::MenuAction»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE Main FOR gmfgen::GenEditorGenerator»
+ <extension point="org.eclipse.ui.menus" id="context-menus">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <!-- menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=«»">
+ </menuContribution>
+ <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=«»">
+ </menuContribution -->
+«EXPAND menuContribution FOREACH contextMenus-»
+ </extension>
+
+«IF hasCommandsToContribute(self)-»
+ <extension point="org.eclipse.ui.commands" id="menu-commands">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <category id="«editor.iD»" name="%cmdcategory.name" description="%cmdcategory.desc"/>
+«EXPAND commandContribution FOREACH contextMenus-»
+ </extension>
+«ENDIF-»
+
+«IF hasHandlersToContribute(self)-»
+ <extension point="org.eclipse.ui.handlers" id="menu-handlers">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+«EXPAND handlerContribution FOREACH contextMenus-»
+ </extension>
+«ENDIF-»
+
+ <!-- optionally, specify keybindings -->
+«ENDDEFINE»
+
+«DEFINE menuContribution FOR gmfgen::GenContextMenu-»
+«EXPAND _menuContribution(self, 'popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu')-»
+«ENDDEFINE»
+
+«DEFINE menuContribution(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenContributionManager»«ERROR 'Abstract menuContribution for ' + self.repr()»«ENDDEFINE»
+«DEFINE menuContribution(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenMenuManager»«EXPAND _menuContribution(contextMenu, 'popup:' + iD)»«ENDDEFINE»
+«DEFINE menuContribution(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenToolBarManager»«EXPAND _menuContribution(contextMenu, 'toolbar:' + iD)»«ENDDEFINE»
+
+«DEFINE _menuContribution(contextMenu : gmfgen::GenContextMenu, locationURI : String) FOR gmfgen::GenContributionManager-»
+ <menuContribution locationURI="«locationURI»">
+«EXPAND menuEntry(contextMenu) FOREACH items-»
+ </menuContribution>
+«EXPAND menuContribution(contextMenu) FOREACH (items)[gmfgen::GenContributionManager]-»
+«ENDDEFINE»
+
+
+«DEFINE commandContribution FOR gmfgen::GenContributionManager-»
+«EXPAND commandContribution FOREACH (items)[gmfgen::GenCustomAction]-»
+«EXPAND commandContribution FOREACH (items)[gmfgen::GenAction]-»
+«EXPAND commandContribution FOREACH (items)[gmfgen::GenContributionManager]-»
+«ENDDEFINE»
+
+«DEFINE handlerContribution FOR gmfgen::GenContributionManager-»
+«EXPAND handlerContribution FOREACH (items)[gmfgen::GenCustomAction]->select(a | a.generateBoilerplate)-»
+«EXPAND handlerContribution FOREACH (items)[gmfgen::GenContributionManager]-»
+«ENDDEFINE»
+
+«DEFINE commandContribution FOR gmfgen::GenCustomAction-»
+ <command id="«EXPAND commandIdentifier»"
+ name="«name»"
+ categoryId="«owner.editorGen.editor.iD»"
+ defaultHandler="«qualifiedClassName»"/>
+«ENDDEFINE»
+
+«DEFINE commandContribution FOR gmfgen::GenAction-»
+ <command id="«EXPAND commandIdentifier»"
+ name="«name/*FIXME: into i18n keys*/»"
+ categoryId="«owner.editorGen.editor.iD»"
+ defaultHandler="«qualifiedClassName»"/>
+«ENDDEFINE»
+
+«DEFINE handlerContribution FOR gmfgen::GenCustomAction-»
+ <handler
+ commandId="«EXPAND commandIdentifier»"
+ class="«qualifiedClassName»">
+ <enabledWhen>
+ <with variable="activePartId"><equals value="«owner.editorGen.editor.iD»"/></with>
+ </enabledWhen>
+ </handler>
+«ENDDEFINE»
+
+«DEFINE commandIdentifier FOR gmfgen::GenCustomAction»«owner.editorGen.plugin.iD».«qualifiedClassName.xpandSplit('\.')->last()»«ENDDEFINE»
+«DEFINE commandIdentifier FOR gmfgen::GenAction»«owner.editorGen.plugin.iD».«qualifiedClassName.xpandSplit('\.')->last()»«ENDDEFINE»
+
+«DEFINE menuEntry(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenContributionItem»«REM»NO-OP XXX or ERROR?«ENDREM»«ENDDEFINE»
+«DEFINE menuEntry(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenSeparator-»
+ <separator «IF groupName <> null»name="«groupName»" «ENDIF»visible="true"/>
+«ENDDEFINE»
+«DEFINE menuEntry(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenGroupMarker-»
+ <separator name="«groupName»"/>
+«ENDDEFINE»
+«DEFINE menuEntry(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenCommandAction-»
+ <command commandId="«commandIdentifier»">
+ <visibleWhen>
+«EXPAND menuCondition FOR contextMenu-»
+ </visibleWhen>
+ </command>
+«ENDDEFINE»
+«DEFINE menuEntry(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenCustomAction-»
+ <command commandId="«EXPAND commandIdentifier»">
+ <visibleWhen>
+«EXPAND menuCondition FOR contextMenu-»
+ </visibleWhen>
+ </command>
+«ENDDEFINE»
+«DEFINE menuEntry(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenAction-»
+ <command commandId="«EXPAND commandIdentifier»">
+ <visibleWhen>
+«EXPAND menuCondition FOR contextMenu-»
+ </visibleWhen>
+ </command>
+«ENDDEFINE»
+
+«DEFINE menuEntry(contextMenu : gmfgen::GenContextMenu) FOR gmfgen::GenMenuManager»
+ <menu id="«iD»" label="«name»">
+ <visibleWhen>
+«EXPAND menuCondition FOR contextMenu-»
+ </visibleWhen>
+ </menu>
+«ENDDEFINE»
+
+«DEFINE menuCondition FOR gmfgen::GenContextMenu-»
+ <and>
+ <with variable="activePartId"><equals value="«editorGen.editor.iD»"/></with>
+ <with variable="selection"><iterate«IF context->size() > 1» operator="or"«ENDIF» ifEmpty="false">
+«REM»XXX, perhaps, <adapt type="EditPart">?«ENDREM-»
+«FOREACH context->asSequence() AS de-»
+ <instanceof value="«de.getEditPartQualifiedClassName()»"/>
+«ENDFOREACH-»
+ </iterate></with>
+ </and>
+«ENDDEFINE»
+
+«DEFINE i18n FOR gmfgen::GenEditorGenerator-»
+«IF hasCommandsToContribute(self)-»
+# Commands and menu actions
+cmdcategory.name=«modelID» Editor Commands
+cmdcategory.desc=«modelID» Editor Commands
+«ENDIF»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ChildNodeLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ChildNodeLabelEditPart.xpt
new file mode 100644
index 000000000..a1c0d643f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ChildNodeLabelEditPart.xpt
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2006, 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
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE contsructor FOR gmfgen::GenChildLabelNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE getDragTrackerBody FOR gmfgen::GenChildLabelNode-»
+ if (request instanceof org.eclipse.gef.requests.SelectionRequest && ((org.eclipse.gef.requests.SelectionRequest) request).getLastButtonPressed() == 3) {
+ return null;
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx(this);
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenChildLabelNode-»
+ super.createDefaultEditPolicies();
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE, new «getItemSemanticEditPolicyQualifiedClassName()»());
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new «getDiagram().getTextNonResizableEditPolicyQualifiedClassName()»());
+ installEditPolicy(org.eclipse.gef.EditPolicy.COMPONENT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy());
+ installEditPolicy(org.eclipse.gef.EditPolicy.DIRECT_EDIT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy());
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+«ENDDEFINE»
+
+«DEFINE handleNotificationEventBody FOR gmfgen::GenChildLabelNode-»
+ Object feature = event.getFeature();
+ «EXPAND xpt::diagram::editparts::Common::handleText FOR self-»
+ super.handleNotificationEvent(event);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/CompartmentEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/CompartmentEditPart.xpt
new file mode 100644
index 000000000..e1bec33bb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/CompartmentEditPart.xpt
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2006, 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
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::editparts::Utils»
+
+«DEFINE contsructor FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE hasModelChildrenChanged FOR gmfgen::GenCompartment-»
+ «IF listLayout-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean hasModelChildrenChanged(org.eclipse.emf.common.notify.Notification evt) {
+ return false;
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getCompartmentName FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getCompartmentName() {
+ return «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCompartmentTitle(self)) FOR getDiagram().editorGen»;
+ }
+«ENDDEFINE»
+
+«DEFINE createFigure FOR gmfgen::GenCompartment-»
+ «IF not needsTitle-»
+ «REM»By default titles are shown even if there are no TitleStyle, we need to switch it off«ENDREM»«-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.draw2d.IFigure createFigure() {
+ org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure result = (org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure) super.createFigure();
+ result.setTitleVisibility(false);
+ return result;
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenCompartment-»
+ super.createDefaultEditPolicies();
+ «IF canCollapse-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableCompartmentEditPolicy());
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
+ «IF childNodes->size() > 0-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy());
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
+ «EXPAND xpt::diagram::editparts::Common::behaviour-»
+«ENDDEFINE»
+
+«DEFINE refreshVisuals FOR gmfgen::GenCompartment-»
+ «IF isStoringChildPositions(node)-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE handleNotificationEventBody FOR gmfgen::GenCompartment-»
+ super.handleNotificationEvent(notification);
+ Object feature = notification.getFeature();
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width().equals(feature)
+ || org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height().equals(feature)
+ || org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X().equals(feature)
+ || org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) {
+ refreshBounds();
+ }
+«ENDDEFINE»
+
+«DEFINE refreshBounds FOR gmfgen::GenCompartment-»
+ «IF isStoringChildPositions(node)-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshBounds() {
+ int x = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ int width = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ ((org.eclipse.gef.GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new org.eclipse.draw2d.geometry.Rectangle(x, y, width, height));
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setRatio FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setRatio(Double ratio) {
+ «IF gmfgen::ViewmapLayoutType::UNKNOWN = node.getLayoutType()-»
+ if (getFigure().getParent().getLayoutManager() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ «ELSE-»
+ // nothing to do -- parent layout does not accept Double constraints as ratio
+ // super.setRatio(ratio);
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«EXPAND internal_i18nAccessors FOREACH compartments»
+«ENDDEFINE»
+
+«DEFINE internal_i18nAccessors FOR gmfgen::GenCompartment-»
+«IF null <> title»«EXPAND xpt::Externalizer::accessorField(i18nKeyForCompartmentTitle(self))»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND internal_i18nValues FOREACH compartments»
+«ENDDEFINE»
+
+«DEFINE internal_i18nValues FOR gmfgen::GenCompartment-»
+«IF null <> title»«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCompartmentTitle(self), title)»«ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt
new file mode 100644
index 000000000..f3db47549
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/DiagramEditPart.xpt
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2006, 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
+ * 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::diagram::editparts::Utils»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenDiagram-»
+ super.createDefaultEditPolicies();
+ «EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
+ «EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
+ «IF generateCreateShortcutAction() and null = editorGen.application-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy() {
+ public org.eclipse.gef.commands.Command getDropObjectsCommand(org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest dropRequest) {
+ java.util.List viewDescriptors = new java.util.ArrayList();
+ for (java.util.Iterator it = dropRequest.getObjects().iterator(); it.hasNext();) {
+ Object nextObject = it.next();
+ if (false == nextObject instanceof org.eclipse.emf.ecore.EObject) {
+ continue;
+ }
+ viewDescriptors.add(new org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor(new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter((org.eclipse.emf.ecore.EObject) nextObject), org.eclipse.gmf.runtime.notation.Node.class, null, getDiagramPreferencesHint()));
+ }
+ return createShortcutsCommand(dropRequest, viewDescriptors);
+ }
+
+ private org.eclipse.gef.commands.Command createShortcutsCommand(org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest dropRequest, java.util.List viewDescriptors) {
+ org.eclipse.gef.commands.Command command = createViewsAndArrangeCommand(dropRequest, viewDescriptors);
+ if (command != null) {
+ return command.chain(new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(new «getCreateShortcutDecorationsCommandQualifiedClassName()»(getEditingDomain(), (org.eclipse.gmf.runtime.notation.View) getModel(), viewDescriptors)));
+ }
+ return null;
+ }
+ });
+ «ENDIF-»
+ «IF shouldGenerateDiagramViewmap(self)-»
+ // diagram figure does layout; need to install child editpolicy to show selection feedback
+ installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, new org.eclipse.gef.editpolicies.LayoutEditPolicy() {
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ final org.eclipse.gef.editpolicies.NonResizableEditPolicy p = new org.eclipse.gef.editpolicies.NonResizableEditPolicy();
+ p.setDragAllowed(false);
+ return p;
+ }
+ protected org.eclipse.gef.commands.Command getMoveChildrenCommand(org.eclipse.gef.Request request) {
+ return null;
+ }
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
+ return null;
+ }
+ });
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
+«ENDDEFINE»
+
+«DEFINE createFigure FOR gmfgen::GenDiagram-»
+ «IF shouldGenerateDiagramViewmap(self)-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createFigure() {
+ org.eclipse.draw2d.FreeformLayer l = new org.eclipse.draw2d.FreeformLayer();
+ l.setBorder(new org.eclipse.draw2d.MarginBorder(50));
+ «EXPAND initLayout('lm') FOR viewmap.layoutType-»
+ l.setLayoutManager(lm);
+ return l;
+ }
+ «ENDIF»
+«ENDDEFINE»
+
+«DEFINE initLayout(varName : String) FOR gmfgen::ViewmapLayoutType-»
+ «IF self = gmfgen::ViewmapLayoutType::TOOLBAR_LAYOUT-»
+ org.eclipse.draw2d.ToolbarLayout «varName» = new org.eclipse.draw2d.ToolbarLayout();
+ «varName».setSpacing(10);
+ «ELSEIF self = gmfgen::ViewmapLayoutType::FLOW_LAYOUT-»
+ org.eclipse.draw2d.FlowLayout «varName» = new org.eclipse.draw2d.FlowLayout();
+ «varName».setMajorSpacing(10);
+ «varName».setMinorSpacing(10);
+ «ELSE-»
+ org.eclipse.draw2d.LayoutManager «varName» = null; /*FIXME - unknown layout type*/
+ «ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ExternalNodeLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ExternalNodeLabelEditPart.xpt
new file mode 100644
index 000000000..e11749519
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/ExternalNodeLabelEditPart.xpt
@@ -0,0 +1,68 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE initializer FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ static {
+ registerSnapBackPosition(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall», new org.eclipse.draw2d.geometry.Point(0, 0));
+ }
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenExternalNodeLabel-»
+ super.createDefaultEditPolicies();
+ installEditPolicy(org.eclipse.gef.EditPolicy.DIRECT_EDIT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy());
+ installEditPolicy(org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE, new «getDiagram().getTextSelectionEditPolicyQualifiedClassName()»());
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+«ENDDEFINE»
+
+«DEFINE getBorderItemLocator FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator getBorderItemLocator() {
+ org.eclipse.draw2d.IFigure parentFigure = getFigure().getParent();
+ if (parentFigure != null && parentFigure.getLayoutManager() != null) {
+ Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure());
+ return (org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator) constraint;
+ }
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE refreshBounds FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void refreshBounds() {
+ int x = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ int width = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ getBorderItemLocator().setConstraint(new org.eclipse.draw2d.geometry.Rectangle(x, y, width, height));
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEventBody FOR gmfgen::GenExternalNodeLabel-»
+ Object feature = event.getFeature();
+ «EXPAND xpt::diagram::editparts::Common::handleText FOR self-»
+ super.handleNotificationEvent(event);
+«ENDDEFINE»
+
+«DEFINE createFigure FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::diagram::editparts::Common::labelFigure FOR viewmap-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkEditPart.xpt
new file mode 100644
index 000000000..38c9fdd8e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkEditPart.xpt
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2006, 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
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE _constructor FOR gmfgen::GenLink-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenLink-»
+ super.createDefaultEditPolicies();
+ «IF null = modelFacet-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.COMPONENT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ViewComponentEditPolicy());
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+«ENDDEFINE»
+
+«DEFINE addFixedChild FOR gmfgen::GenLink-»
+ «IF labels->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) {
+ «FOREACH labels->asSequence() AS label-»
+ «EXPAND addLabel(label) FOR label.viewmap-»
+ «ENDFOREACH-»
+ return false;
+ }
+ «ENDIF»
+«ENDDEFINE»
+
+«DEFINE addLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::Viewmap-»
+«ENDDEFINE»
+
+«DEFINE addLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::ParentAssignedViewmap-»
+ if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
+ ((«label.getEditPartQualifiedClassName()») childEditPart).«EXPAND impl::diagram::editparts::TextAware::labelSetterName»(
+ getPrimaryShape().«getterName»());
+ return true;
+ }
+«ENDDEFINE»
+
+«DEFINE removeFixedChild FOR gmfgen::GenLink-»
+ «IF labels->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) {
+ «FOREACH labels->asSequence() AS label-»
+ «EXPAND removeLabel(label) FOR label.viewmap-»
+ «ENDFOREACH-»
+ return false;
+ }
+ «ENDIF»
+«ENDDEFINE»
+
+«DEFINE removeLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::Viewmap-»
+«ENDDEFINE»
+
+«DEFINE removeLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::ParentAssignedViewmap-»
+ if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
+ return true;
+ }
+«ENDDEFINE»
+
+«DEFINE addChildVisual FOR gmfgen::GenLink-»
+ «IF labels->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+ «ENDIF»
+«ENDDEFINE»
+
+«DEFINE removeChildVisual FOR gmfgen::GenLink-»
+ «IF labels->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+ «ENDIF»
+«ENDDEFINE»
+
+«DEFINE createLinkFigure FOR gmfgen::GenLink-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Creates figure for this edit part.
+
+Body of this method does not depend on settings in generation model
+so you may safely remove <i>generated</i> tag and modify it.
+'
+ )»
+ «EXPAND createLinkFigure(self) FOR viewmap-»
+«ENDDEFINE»
+
+«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::Viewmap-»
+ «ERROR 'Unknown viewmap: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::FigureViewmap-»
+ «LET (if figureQualifiedClassName = null then 'org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx' else figureQualifiedClassName endif) AS fqn-»
+ protected org.eclipse.draw2d.Connection createConnectionFigure() {
+ return new «fqn»();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «fqn» getPrimaryShape() {
+ return («fqn») getFigure();
+ }
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::SnippetViewmap»
+ protected org.eclipse.draw2d.Connection createConnectionFigure() {
+ return «body»;
+ }
+«ENDDEFINE»
+
+«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::InnerClassViewmap»
+ protected org.eclipse.draw2d.Connection createConnectionFigure() {
+ return new «className»();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «className» getPrimaryShape() {
+ return («className») getFigure();
+ }
+
+ «classBody»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkLabelEditPart.xpt
new file mode 100644
index 000000000..a5502e08e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/LinkLabelEditPart.xpt
@@ -0,0 +1,61 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+
+«DEFINE initializer FOR gmfgen::GenLinkLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ static {
+ registerSnapBackPosition(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall»,
+ new org.eclipse.draw2d.geometry.Point(«labelOffsetX(viewmap, 0)», «labelOffsetY(viewmap, 0)»));
+ }
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenLinkLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenLinkLabel-»
+ super.createDefaultEditPolicies();
+ installEditPolicy(org.eclipse.gef.EditPolicy.DIRECT_EDIT_ROLE,
+ new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy());
+ installEditPolicy(org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE,
+ new «getDiagram().getTextSelectionEditPolicyQualifiedClassName()»());
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE,
+ new org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy() {
+
+ protected java.util.List createSelectionHandles() {
+ org.eclipse.gef.handles.MoveHandle mh = new org.eclipse.gef.handles.MoveHandle((org.eclipse.gef.GraphicalEditPart) getHost());
+ mh.setBorder(null);
+ return java.util.Collections.singletonList(mh);
+ }
+ });
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+«ENDDEFINE»
+
+«DEFINE getKeyPoint FOR gmfgen::GenLinkLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public int getKeyPoint() {
+ return org.eclipse.draw2d.ConnectionLocator.«alignment»;
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEventBody FOR gmfgen::GenLinkLabel-»
+ Object feature = event.getFeature();
+ «EXPAND xpt::diagram::editparts::Common::handleText FOR self-»
+ super.handleNotificationEvent(event);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt
new file mode 100644
index 000000000..a204dfc6b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeEditPart.xpt
@@ -0,0 +1,581 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * 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::diagram::ViewmapAttributesUtils»
+«EXTENSION xpt::diagram::editparts::Utils»
+
+«DEFINE extendsListContents FOR gmfgen::GenNode-»
+«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE extendsListContents FOR gmfgen::GenChildSideAffixedNode-»
+«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenNode-»
+ «EXPAND installCreationRolePolicy-»
+ super.createDefaultEditPolicies();
+ «EXPAND installPrimaryDragEditPolicy-»
+ «EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
+ «IF needsGraphicalNodeEditPolicy(self)-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE, new «getGraphicalNodeEditPolicyQualifiedClassName()»());
+ «ENDIF-»
+ «IF not childNodes->isEmpty()-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+«ENDDEFINE»
+
+«DEFINE installCreationRolePolicy FOR gmfgen::GenNode-»
+«IF hasChildren(self) or hasChildrenInListCompartments(self)-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, «EXPAND _creationEditPolicyNewInstance»);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _creationEditPolicyNewInstance FOR gmfgen::GenNode»new org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy()«ENDDEFINE»
+
+«DEFINE installPrimaryDragEditPolicy FOR gmfgen::GenNode»«ENDDEFINE»
+
+«DEFINE installPrimaryDragEditPolicy FOR gmfgen::GenChildSideAffixedNode-»
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy());
+«ENDDEFINE»
+
+«DEFINE createLayoutEditPolicy FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.editpolicies.LayoutEditPolicy createLayoutEditPolicy() {
+ «EXPAND createLayoutEditPolicyBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE createLayoutEditPolicyBody FOR gmfgen::GenNode-»
+ «IF gmfgen::ViewmapLayoutType::XY_LAYOUT = getLayoutType()-»
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy() {
+
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ org.eclipse.gef.EditPolicy result = super.createChildEditPolicy(child);
+ if (result == null) {
+ return new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy();
+ }
+ return result;
+ }
+ };
+ return lep;
+ «ELSEIF gmfgen::ViewmapLayoutType::TOOLBAR_LAYOUT = getLayoutType()»
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy() {
+
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ if (child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE) == null) {
+ if (child instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart) {
+ return new «getDiagram().getTextSelectionEditPolicyQualifiedClassName()»();
+ }
+ }
+ return super.createChildEditPolicy(child);
+ }
+ };
+ return lep;
+ «ELSEIF gmfgen::ViewmapLayoutType::FLOW_LAYOUT = getLayoutType()»
+ org.eclipse.gef.editpolicies.FlowLayoutEditPolicy lep = new org.eclipse.gef.editpolicies.FlowLayoutEditPolicy() {
+
+ «IF hasBorderItems(self)-»
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ return super.createChildEditPolicy(child);
+ }
+ «ENDIF-»
+
+ protected org.eclipse.gef.commands.Command createAddCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
+ return null;
+ }
+
+ protected org.eclipse.gef.commands.Command createMoveChildCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
+ return null;
+ }
+
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ «ELSE-»
+ org.eclipse.gef.editpolicies.LayoutEditPolicy lep = new org.eclipse.gef.editpolicies.LayoutEditPolicy() {
+
+ protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
+ «EXPAND borderItemSelectionEditPolicy-»
+ org.eclipse.gef.EditPolicy result = child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new org.eclipse.gef.editpolicies.NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected org.eclipse.gef.commands.Command getMoveChildrenCommand(org.eclipse.gef.Request request) {
+ return null;
+ }
+
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE borderItemSelectionEditPolicy FOR gmfgen::GenNode-»
+«IF hasBorderItems(self)-»
+org.eclipse.gmf.runtime.notation.View childView = (org.eclipse.gmf.runtime.notation.View) child.getModel();
+switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(childView)) {
+«IF getExternalLabels(self)->size() > 0-»
+«FOREACH getExternalLabels(self) AS nextLabel-»
+«EXPAND xpt::Common::caseVisualID FOR nextLabel-»
+«ENDFOREACH-»
+ return «EXPAND borderItemSelectionEP»;
+«ENDIF-»
+«IF getSideAffixedChildren(self)->size() > 0-»
+«FOREACH getSideAffixedChildren(self) AS nextBorderItem-»
+«EXPAND xpt::Common::caseVisualID FOR nextBorderItem-»
+«ENDFOREACH-»
+ return new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy();
+«ENDIF-»
+}
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE borderItemSelectionEP FOR gmfgen::GenNode-»
+new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy() {
+
+ protected java.util.List createSelectionHandles() {
+ org.eclipse.gef.handles.MoveHandle mh = new org.eclipse.gef.handles.MoveHandle((org.eclipse.gef.GraphicalEditPart) getHost());
+ mh.setBorder(null);
+ return java.util.Collections.singletonList(mh);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::Viewmap-»
+ «ERROR 'Unknown viewmap: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::FigureViewmap-»
+ «LET (if figureQualifiedClassName = null then 'org.eclipse.draw2d.RectangleFigure' else figureQualifiedClassName endif) AS fqn-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createNodeShape() {
+ return primaryShape = new «fqn»()«IF node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT»{
+ protected boolean useLocalCoordinates() {
+ return true;
+ }
+ }«ENDIF»;
+ }
+
+ «EXPAND getPrimaryShapeMethod FOR fqn-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::SnippetViewmap-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createNodeShape() {
+ return «body»;
+ }
+«ENDDEFINE»
+
+«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::InnerClassViewmap-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createNodeShape() {
+ «className» figure = new «className»();
+ «IF node.childNodes->size() > 0 and node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT-»
+ figure.setUseLocalCoordinates(true);
+ «ENDIF-»
+ return primaryShape = figure;
+ }
+
+ «EXPAND getPrimaryShapeMethod FOR className-»
+«ENDDEFINE»
+
+«DEFINE getPrimaryShapeMethod FOR String-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «self» getPrimaryShape() {
+ return («self») primaryShape;
+ }
+«ENDDEFINE»
+
+«DEFINE addFixedChild FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) {
+«FOREACH getInnerFixedLabels(self) AS label»«LET label.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
+ ((«label.getEditPartQualifiedClassName()») childEditPart).«EXPAND impl::diagram::editparts::TextAware::labelSetterName FOR childViewmap»(getPrimaryShape().«childViewmap.getterName»());
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «compartment.getEditPartQualifiedClassName()») {
+ org.eclipse.draw2d.IFigure pane = getPrimaryShape().«childViewmap.getterName»();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((«compartment.getEditPartQualifiedClassName()») childEditPart).getFigure());
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getSideAffixedChildren(self) AS child-»
+ if (childEditPart instanceof «child.getEditPartQualifiedClassName()») {
+ org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator locator = new org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator(getMainFigure(), org.eclipse.draw2d.PositionConstants.«child.preferredSideName»);
+ getBorderedFigure().getBorderItemContainer().add(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure(), locator);
+ return true;
+ }
+«ENDFOREACH-»
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE removeFixedChild FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) {
+«FOREACH getInnerFixedLabels(self) AS label»«LET label.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (childEditPart instanceof «compartment.getEditPartQualifiedClassName()») {
+ org.eclipse.draw2d.IFigure pane = getPrimaryShape().«childViewmap.getterName»();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.remove(((«compartment.getEditPartQualifiedClassName()») childEditPart).getFigure());
+ return true;
+ }
+«ENDLET»«ENDFOREACH-»
+«FOREACH getSideAffixedChildren(self) AS child-»
+ if (childEditPart instanceof «child.getEditPartQualifiedClassName()») {
+ getBorderedFigure().getBorderItemContainer().remove(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure());
+ return true;
+ }
+«ENDFOREACH-»
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE addChildVisual FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+«ENDDEFINE»
+
+«DEFINE removeChildVisual FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)){
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+«ENDDEFINE»
+
+«DEFINE getContentPaneFor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure getContentPaneFor(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart) {
+ «REM»it is unclear what we should return for labels here«ENDREM-»
+«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
+ if (editPart instanceof «compartment.getEditPartQualifiedClassName()») {
+ return getPrimaryShape().«childViewmap.getterName»();
+ }
+«ENDLET»«ENDFOREACH-»
+«IF hasBorderItems(self)-»
+ if (editPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart) {
+ return getBorderedFigure().getBorderItemContainer();
+ }
+«ENDIF-»
+ return getContentPane();
+ }
+«ENDDEFINE»
+
+«DEFINE addBorderItem FOR gmfgen::GenNode-»
+ «IF getExternalLabels(self)->size() > 0-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addBorderItem(org.eclipse.draw2d.IFigure borderItemContainer, org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart borderItemEditPart) {
+ if («FOREACH getExternalLabels(self) AS label SEPARATOR ' || '»borderItemEditPart instanceof «label.getEditPartQualifiedClassName()»«ENDFOREACH») {
+ org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator locator = new org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator(getMainFigure(), org.eclipse.draw2d.PositionConstants.SOUTH);
+ locator.setBorderItemOffset(new org.eclipse.draw2d.geometry.Dimension(-20, -20));
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else {
+ super.addBorderItem(borderItemContainer, borderItemEditPart);
+ }
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE createNodePlate FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodePlate() {
+ org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure result =
+ new org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure(getMapMode().DPtoLP(«defaultSizeWidth(viewmap, 40)»), getMapMode().DPtoLP(«defaultSizeHeight(viewmap, 40)»));
+ «EXPAND setupNodePlate-»
+ return result;
+ }
+«ENDDEFINE»
+
+«DEFINE setupNodePlate FOR gmfgen::GenNode»«ENDDEFINE»
+
+«DEFINE setupNodePlate FOR gmfgen::GenChildSideAffixedNode»
+ //FIXME: workaround for #154536
+ result.getBounds().setSize(result.getPreferredSize());
+«ENDDEFINE»
+
+«DEFINE getPrimaryDragEditPolicy FOR gmfgen::GenNode-»
+ «LET getResizeConstraints(viewmap) AS rc-»
+ «IF null <> primaryDragEditPolicyQualifiedClassName or null <> rc-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.EditPolicy getPrimaryDragEditPolicy() {
+ «IF null <> primaryDragEditPolicyQualifiedClassName-»
+ return new «primaryDragEditPolicyQualifiedClassName»();
+ «ELSE-»
+ org.eclipse.gef.EditPolicy result = super.getPrimaryDragEditPolicy();
+ if (result instanceof org.eclipse.gef.editpolicies.ResizableEditPolicy) {
+ org.eclipse.gef.editpolicies.ResizableEditPolicy ep = (org.eclipse.gef.editpolicies.ResizableEditPolicy) result;
+ ep.setResizeDirections(
+ «IF rc.resizeHandleNames->size() > 0-»
+ «FOREACH rc.resizeHandleNames->asSequence() AS name SEPARATOR ' | '»org.eclipse.draw2d.PositionConstants.«name»«ENDFOREACH-»
+ «ELSE»org.eclipse.draw2d.PositionConstants.NONE«ENDIF»);
+ }
+ return result;
+ «ENDIF-»
+ }
+ «ENDIF-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE createFigure FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Creates figure for this edit part.
+
+Body of this method does not depend on settings in generation model
+so you may safely remove <i>generated</i> tag and modify it.
+'
+ )»
+ protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure create«IF hasBorderItems(self)»Main«ELSE»Node«ENDIF»Figure() {
+ org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new org.eclipse.draw2d.StackLayout());
+ org.eclipse.draw2d.IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+«ENDDEFINE»
+
+«DEFINE setupContentPane FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Default implementation treats passed figure as content pane.
+Respects layout one may have set for generated figure.
+@param nodeShape instance of generated figure class'
+ )»
+ protected org.eclipse.draw2d.IFigure setupContentPane(org.eclipse.draw2d.IFigure nodeShape) {
+ «IF not childNodes->isEmpty() or (not compartments->isEmpty() or not labels->-((labels)[gmfgen::GenExternalNodeLabel])->isEmpty())-»
+ if (nodeShape.getLayoutManager() == null) {
+ «IF getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT-»
+ nodeShape.setLayoutManager(new org.eclipse.draw2d.FreeformLayout() {
+
+ public Object getConstraint(org.eclipse.draw2d.IFigure figure) {
+ Object result = constraints.get(figure);
+ if (result == null) {
+ result = new org.eclipse.draw2d.geometry.Rectangle(0, 0, -1, -1);
+ }
+ return result;
+ }
+ });
+ «ELSE-»
+ org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout layout =new org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout();
+ layout.setSpacing(getMapMode().DPtoLP(5));
+ nodeShape.setLayoutManager(layout);
+ «ENDIF-»
+ }
+ «ENDIF-»
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+«ENDDEFINE»
+
+«DEFINE getContentPane FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.draw2d.IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+«ENDDEFINE»
+
+«DEFINE setForegroundColor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setForegroundColor(org.eclipse.swt.graphics.Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setBackgroundColor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setBackgroundColor(org.eclipse.swt.graphics.Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setLineWidth FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof org.eclipse.draw2d.Shape) {
+ ((org.eclipse.draw2d.Shape) primaryShape).setLineWidth(getMapMode().DPtoLP(width));
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setLineStyle FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setLineType(int style) {
+ if (primaryShape instanceof org.eclipse.draw2d.Shape) {
+ ((org.eclipse.draw2d.Shape) primaryShape).setLineStyle(style);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE getPrimaryChildEditPart FOR gmfgen::GenNode-»
+ «IF not labels->isEmpty()-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR labels->first().oclAsType(gmfgen::GenLabel)»);
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE getMARelTypesOnSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnSource() {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantIncomingLinks(this).size() > 0
+«DEFINE getMARelTypesOnTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnTarget() {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantIncomingLinks(self) AS link-»
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE getMARelTypesOnSourceAndTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnSourceAndTarget(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart) {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ «FOREACH selectGenNodes(link.targets->asSequence()) AS target-»
+ if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
+ }
+ «ENDFOREACH-»
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantIncomingLinks(this).size() > 0
+«DEFINE getMATypesForSource FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMATypesForSource(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantIncomingLinks(self) AS link-»
+ «FOREACH selectGenNodes(link.sources->asSequence()) AS source-»
+ if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR source»);
+ }
+ «ENDFOREACH-»
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+// pre: getAssistantOutgoingLinks(this).size() > 0
+«DEFINE getMATypesForTarget FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMATypesForTarget(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
+ java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
+ «FOREACH getAssistantOutgoingLinks(self) AS link-»
+ «FOREACH (link.targets)[gmfgen::GenNode]->asSequence() AS target-»
+ if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
+ types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR target»);
+ }
+ «ENDFOREACH-»
+ «ENDFOREACH-»
+ return types;
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEventBody FOR gmfgen::GenTopLevelNode-»
+ if (event.getNotifier() == getModel() && org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getEModelElement_EAnnotations().equals(event.getFeature())) {
+ handleMajorSemanticChange();
+ } else {
+ super.handleNotificationEvent(event);
+ }
+«ENDDEFINE»
+
+«DEFINE innerClassDeclaration FOR gmfgen::Viewmap»
+«ENDDEFINE»
+
+«DEFINE innerClassDeclaration FOR gmfgen::InnerClassViewmap»
+ «classBody»
+«ENDDEFINE»
+
+«DEFINE getTargetEditPartMethod FOR gmfgen::GenNode»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.EditPart getTargetEditPart(org.eclipse.gef.Request request) {
+ if (request instanceof org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) {
+ org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter adapter = ((org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
+ org.eclipse.gmf.runtime.emf.type.core.IElementType type = (org.eclipse.gmf.runtime.emf.type.core.IElementType) adapter.getAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
+«FOREACH compartments->asSequence() AS compartment-»
+ «IF listCompartmentHasChildren(compartment)-»
+ «FOREACH compartment.childNodes->asSequence() AS childNode-»
+ if (type == «EXPAND xpt::providers::ElementTypes::accessElementType FOR childNode») {
+ return getChildBySemanticHint(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR compartment»);
+ }
+ «ENDFOREACH-»
+ «ENDIF-»
+«ENDFOREACH-»
+ }
+ return super.getTargetEditPart(request);
+ }
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeLabelEditPart.xpt
new file mode 100644
index 000000000..1fa3d0160
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/NodeLabelEditPart.xpt
@@ -0,0 +1,70 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::editparts::Utils»
+
+«DEFINE _constructor FOR gmfgen::GenNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
+ super(view);
+ }
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenNodeLabel-»
+ super.createDefaultEditPolicies();
+ installEditPolicy(org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE, new «getDiagram().getTextSelectionEditPolicyQualifiedClassName()»());
+ installEditPolicy(org.eclipse.gef.EditPolicy.DIRECT_EDIT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy());
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.gef.editpolicies.NonResizableEditPolicy() {
+
+ protected java.util.List createSelectionHandles() {
+ java.util.List handles = new java.util.ArrayList();
+ org.eclipse.gef.handles.NonResizableHandleKit.addMoveHandle((org.eclipse.gef.GraphicalEditPart) getHost(), handles);
+ ((org.eclipse.gef.handles.MoveHandle) handles.get(0)).setBorder(null);
+ return handles;
+ }
+
+ public org.eclipse.gef.commands.Command getCommand(org.eclipse.gef.Request request) {
+ return null;
+ }
+
+ public boolean understandsRequest(org.eclipse.gef.Request request) {
+ return false;
+ }
+ });
+ «EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
+«ENDDEFINE»
+
+«DEFINE refreshBounds FOR gmfgen::GenNodeLabel-»
+ «IF isStoringChildPositions(node)-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshBounds() {
+ int width = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ org.eclipse.draw2d.geometry.Dimension size = new org.eclipse.draw2d.geometry.Dimension(width, height);
+ int x = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ org.eclipse.draw2d.geometry.Point loc = new org.eclipse.draw2d.geometry.Point(x, y);
+ ((org.eclipse.gef.GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new org.eclipse.draw2d.geometry.Rectangle(loc, size));
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE handleNotificationEventBody FOR gmfgen::GenNodeLabel-»
+ Object feature = event.getFeature();
+ «IF isStoringChildPositions(node)-»
+ «EXPAND xpt::diagram::editparts::Common::handleBounds FOR self-»
+ «ENDIF-»
+ «EXPAND xpt::diagram::editparts::Common::handleText FOR self-»
+ super.handleNotificationEvent(event);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt
new file mode 100644
index 000000000..ce1172f91
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/editparts/TextAware.xpt
@@ -0,0 +1,537 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * 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::diagram::ViewmapAttributesUtils»
+
+«DEFINE fields FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gef.tools.DirectEditManager manager;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.common.ui.services.parser.IParser parser;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.util.List parserElements;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String defaultText;
+«ENDDEFINE»
+
+«DEFINE methods(needsRefreshBounds : Boolean, readOnly : Boolean, useElementIcon : Boolean, viewmap : gmfgen::Viewmap,
+ modelFacet : gmfgen::LabelModelFacet, host : gmfgen::GenCommonBase, diagram : gmfgen::GenDiagram) FOR gmfgen::GenCommonBase-»
+ «EXPAND getLabelTextHelper-»
+
+ «EXPAND setLabelTextHelper-»
+
+ «EXPAND getLabelIconHelper-»
+
+ «EXPAND setLabelIconHelper-»
+
+ «EXPAND labelSetter-»
+
+ «EXPAND getModelChildren-»
+
+ «EXPAND getChildBySemanticHint-»
+
+ «EXPAND getParserElement(modelFacet)-»
+
+ «EXPAND getLabelIcon(useElementIcon, diagram)-»
+
+ «EXPAND getLabelText-»
+
+ «EXPAND setLabelText(diagram)-»
+
+ «EXPAND getEditText-»
+
+ «EXPAND isEditable(readOnly)-»
+
+ «EXPAND getEditTextValidator-»
+
+ «EXPAND getCompletionProcessor-»
+
+ «EXPAND getParserOptions-»
+
+ «EXPAND getParser(modelFacet, diagram, host)-»
+
+ «EXPAND getManager(diagram)-»
+
+ «EXPAND setManager-»
+
+ «EXPAND performDirectEdit-»
+
+ «EXPAND performDirectEditAtPoint-»
+
+ «EXPAND performDirectEditWithInitialChar-»
+
+ «EXPAND performDirectEditRequest-»
+
+ «EXPAND refreshVisuals(needsRefreshBounds)-»
+
+ «EXPAND refreshLabel(diagram)-»
+
+ «EXPAND refreshUnderline-»
+
+ «EXPAND refreshStrikeThrough-»
+
+ «EXPAND refreshFont-»
+
+ «EXPAND setFontColor-»
+
+ «EXPAND addSemanticListeners-»
+
+ «EXPAND removeSemanticListeners-»
+
+ «EXPAND getAccessibleEditPart-»
+
+ «EXPAND getFontStyleOwnerView(viewmap)-»
+«ENDDEFINE»
+
+«DEFINE labelSetterName FOR gmfgen::ParentAssignedViewmap-»
+«IF setterName <> null»«setterName»«ELSE»setLabel«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE labelSetterName FOR gmfgen::Viewmap»setLabel«ENDDEFINE»
+
+«DEFINE getLabelTextHelper FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getLabelTextHelper(org.eclipse.draw2d.IFigure figure) {
+ if (figure instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ return ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) figure).getText();
+ } else {
+ return ((org.eclipse.draw2d.Label) figure).getText();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setLabelTextHelper FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setLabelTextHelper(org.eclipse.draw2d.IFigure figure, String text) {
+ if (figure instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) figure).setText(text);
+ } else {
+ ((org.eclipse.draw2d.Label) figure).setText(text);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE getLabelIconHelper FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.swt.graphics.Image getLabelIconHelper(org.eclipse.draw2d.IFigure figure) {
+ if (figure instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ return ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) figure).getIcon();
+ } else {
+ return ((org.eclipse.draw2d.Label) figure).getIcon();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setLabelIconHelper FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setLabelIconHelper(org.eclipse.draw2d.IFigure figure, org.eclipse.swt.graphics.Image icon) {
+ if (figure instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((org.eclipse.draw2d.Label) figure).setIcon(icon);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE labelSetter FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void «EXPAND labelSetterName FOR viewmap»(«EXPAND labelSetterFigureClassName FOR viewmap» figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+«ENDDEFINE»
+
+«DEFINE labelSetterFigureClassName FOR gmfgen::ParentAssignedViewmap-»
+ «IF figureQualifiedClassName <> null-»
+ «figureQualifiedClassName»
+ «ELSE-»
+ org.eclipse.draw2d.IFigure
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE labelSetterFigureClassName FOR gmfgen::Viewmap-»
+ org.eclipse.draw2d.IFigure
+«ENDDEFINE»
+
+«DEFINE getModelChildren FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List getModelChildren() {
+ return java.util.Collections.EMPTY_LIST;
+ }
+«ENDDEFINE»
+
+«DEFINE getChildBySemanticHint FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE getParserElement(modelFacet : gmfgen::LabelModelFacet) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.emf.ecore.EObject getParserElement() {
+«IF modelFacet = null»
+ org.eclipse.emf.ecore.EObject element = resolveSemanticElement();
+ return element != null ? element : (org.eclipse.gmf.runtime.notation.View) getModel();
+«ELSE»«EXPAND getParserElement FOR modelFacet»«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE getParserElement FOR gmfgen::LabelModelFacet-»
+ return resolveSemanticElement();
+«ENDDEFINE»
+
+«DEFINE getParserElement FOR gmfgen::DesignLabelModelFacet-»
+ return (org.eclipse.gmf.runtime.notation.View) getModel();
+«ENDDEFINE»
+
+«DEFINE getLabelIcon(useElementIcon : Boolean, diagram : gmfgen::GenDiagram) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.swt.graphics.Image getLabelIcon() {
+ «IF useElementIcon-»
+ org.eclipse.emf.ecore.EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return «diagram.getElementTypesQualifiedClassName()».getImage(parserElement.eClass());
+ «ELSE-»
+ return null;
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE getLabelText FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getLabelText() {
+ String text = null;
+ org.eclipse.emf.ecore.EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(
+ new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(parserElement),
+ getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+«ENDDEFINE»
+
+«DEFINE setLabelText(diagram : gmfgen::GenDiagram) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof «diagram.getTextSelectionEditPolicyQualifiedClassName()») {
+ ((«diagram.getTextSelectionEditPolicyQualifiedClassName()») pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof «diagram.getTextSelectionEditPolicyQualifiedClassName()») {
+ ((«diagram.getTextSelectionEditPolicyQualifiedClassName()») sfEditPolicy).refreshFeedback();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE getEditText FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; «EXPAND xpt::Common::nonNLS»
+ }
+ return getParser().getEditString(
+ new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(getParserElement()),
+ getParserOptions().intValue());
+ }
+«ENDDEFINE»
+
+«DEFINE isEditable(readOnly : Boolean) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean isEditable() {
+ «IF readOnly-»
+ return false;
+ «ELSE-»
+ return getParser() != null;
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE getEditTextValidator FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.jface.viewers.ICellEditorValidator getEditTextValidator() {
+ return new org.eclipse.jface.viewers.ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final org.eclipse.emf.ecore.EObject element = getParserElement();
+ final org.eclipse.gmf.runtime.common.ui.services.parser.IParser parser = getParser();
+ try {
+ org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus valid =
+ (org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus) getEditingDomain().runExclusive(
+ new org.eclipse.emf.transaction.RunnableWithResult.Impl() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+«ENDDEFINE»
+
+«DEFINE getCompletionProcessor FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.jface.text.contentassist.IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(getParserElement()));
+ }
+«ENDDEFINE»
+
+«DEFINE getParserOptions FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions getParserOptions() {
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions.NONE;
+ }
+«ENDDEFINE»
+
+«DEFINE getParser(modelFacet : gmfgen::LabelModelFacet, diagram : gmfgen::GenDiagram, host : gmfgen::GenCommonBase) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser() {
+ if (parser == null) {
+ parser = «EXPAND parsers::ParserProvider::accessorCall(host, modelFacet, 'getParserElement()')»;
+ }
+ return parser;
+ }
+«ENDDEFINE»
+
+«DEFINE getManager(diagram : gmfgen::GenDiagram) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.tools.DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager(this,
+ org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager.getTextCellEditorClass(this),
+ «diagram.getEditPartFactoryQualifiedClassName()».getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+«ENDDEFINE»
+
+«DEFINE setManager FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setManager(org.eclipse.gef.tools.DirectEditManager manager) {
+ this.manager = manager;
+ }
+«ENDDEFINE»
+
+«DEFINE performDirectEdit FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+«ENDDEFINE»
+
+«DEFINE performDirectEditAtPoint FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void performDirectEdit(org.eclipse.draw2d.geometry.Point eventLocation) {
+ if (getManager().getClass() == org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager.class) {
+ ((org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE performDirectEditWithInitialChar FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) {
+ ((org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE performDirectEditRequest FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void performDirectEditRequest(org.eclipse.gef.Request request) {
+ final org.eclipse.gef.Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof org.eclipse.gef.requests.DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ org.eclipse.gef.requests.DirectEditRequest editRequest = (org.eclipse.gef.requests.DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE refreshVisuals(needsRefreshBounds : Boolean) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ «IF needsRefreshBounds-»
+ refreshBounds();
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE refreshLabel(diagram : gmfgen::GenDiagram) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof «diagram.getTextSelectionEditPolicyQualifiedClassName()») {
+ ((«diagram.getTextSelectionEditPolicyQualifiedClassName()») pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof «diagram.getTextSelectionEditPolicyQualifiedClassName()») {
+ ((«diagram.getTextSelectionEditPolicyQualifiedClassName()») sfEditPolicy).refreshFeedback();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE refreshUnderline FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshUnderline() {
+ org.eclipse.gmf.runtime.notation.FontStyle style =
+ (org.eclipse.gmf.runtime.notation.FontStyle) getFontStyleOwnerView().getStyle(
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE refreshStrikeThrough FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshStrikeThrough() {
+ org.eclipse.gmf.runtime.notation.FontStyle style =
+ (org.eclipse.gmf.runtime.notation.FontStyle) getFontStyleOwnerView().getStyle(
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE refreshFont FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshFont() {
+ org.eclipse.gmf.runtime.notation.FontStyle style =
+ (org.eclipse.gmf.runtime.notation.FontStyle) getFontStyleOwnerView().getStyle(
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ org.eclipse.swt.graphics.FontData fontData = new org.eclipse.swt.graphics.FontData(
+ style.getFontName(), style.getFontHeight(),
+ (style.isBold() ? org.eclipse.swt.SWT.BOLD : org.eclipse.swt.SWT.NORMAL) |
+ (style.isItalic() ? org.eclipse.swt.SWT.ITALIC : org.eclipse.swt.SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setFontColor FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setFontColor(org.eclipse.swt.graphics.Color color) {
+ getFigure().setForegroundColor(color);
+ }
+«ENDDEFINE»
+
+«DEFINE addSemanticListeners FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addSemanticListeners() {
+ if (getParser() instanceof org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) {
+ org.eclipse.emf.ecore.EObject element = resolveSemanticElement();
+ parserElements = ((org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (org.eclipse.emf.ecore.EObject) parserElements.get(i)); «EXPAND xpt::Common::nonNLS»
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE removeSemanticListeners FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); «EXPAND xpt::Common::nonNLS»
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE getAccessibleEditPart FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(org.eclipse.swt.accessibility.AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+«ENDDEFINE»
+
+«DEFINE getFontStyleOwnerView(viewmap : gmfgen::Viewmap) FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.notation.View getFontStyleOwnerView() {
+ «IF isFixedFont(viewmap)-»
+ return (org.eclipse.gmf.runtime.notation.View) getModel();
+ «ELSE-»
+ return getPrimaryView();
+ «ENDIF-»
+ }
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/AbstractParser.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/AbstractParser.xpt
new file mode 100644
index 000000000..78202abc1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/AbstractParser.xpt
@@ -0,0 +1,396 @@
+/*
+ * 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
+ * Artem Tikhomirov (Borland) - [235113] alternative parser access
+ * [244419] custom parsers
+ */
+
+«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 impl::parsers::i18n»
+
+«DEFINE className FOR gmfgen::GenParsers»«defaultAbstractParserClassName()»«ENDDEFINE»
+«DEFINE qualifiedClassName FOR gmfgen::GenParsers»«implPackageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE Main FOR gmfgen::GenParsers-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «implPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public abstract class «EXPAND className» implements org.eclipse.gmf.runtime.common.ui.services.parser.IParser {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected final org.eclipse.emf.ecore.EAttribute[] features;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected final org.eclipse.emf.ecore.EAttribute[] editableFeatures;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String viewPattern;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String editorPattern;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String editPattern;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.emf.ecore.EAttribute[] features) {
+ if (features == null || java.util.Arrays.asList(features).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ this.editableFeatures = this.features = features;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.emf.ecore.EAttribute[] features,
+ org.eclipse.emf.ecore.EAttribute[] editableFeatures) {
+ if (features == null || java.util.Arrays.asList(features).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ this.features = features;
+ if (editableFeatures == null || java.util.Arrays.asList(editableFeatures).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ this.editableFeatures = editableFeatures;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getViewPattern() {
+ return viewPattern;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setViewPattern(String viewPattern) {
+ this.viewPattern = viewPattern;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getEditorPattern() {
+ return editorPattern;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setEditorPattern(String editorPattern) {
+ this.editorPattern = editorPattern;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getEditPattern() {
+ return editPattern;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setEditPattern(String editPattern) {
+ this.editPattern = editPattern;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean isAffectingEvent(Object event, int flags) {
+ if (event instanceof org.eclipse.emf.common.notify.Notification) {
+ return isAffectingFeature(((org.eclipse.emf.common.notify.Notification) event).getFeature());
+ }
+ return false;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean isAffectingFeature(Object feature) {
+ for (int i = 0; i < features.length; i++) {
+ if (features[i] == feature) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.jface.text.contentassist.IContentAssistProcessor getCompletionProcessor(
+ org.eclipse.core.runtime.IAdaptable element) {
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected Object[] getValues(org.eclipse.emf.ecore.EObject element) {
+ Object[] values = new Object[features.length];
+ for (int i = 0; i < features.length; i++) {
+ values[i] = getValue(element, features[i]);
+ }
+ return values;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected Object[] getEditableValues(org.eclipse.emf.ecore.EObject element) {
+ Object[] values = new Object[editableFeatures.length];
+ for (int i = 0; i < editableFeatures.length; i++) {
+ values[i] = getValue(element, editableFeatures[i]);
+ }
+ return values;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected Object getValue(org.eclipse.emf.ecore.EObject element, org.eclipse.emf.ecore.EAttribute feature) {
+ Object value = element.eGet(feature);
+ Class iClass = feature.getEAttributeType().getInstanceClass();
+ if (String.class.equals(iClass)) {
+ if (value == null) {
+ value = ""; «EXPAND xpt::Common::nonNLS»
+ }
+ }
+ return value;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getParseCommand(
+ org.eclipse.core.runtime.IAdaptable adapter, Object[] values, int flags) {
+ if (values == null || validateNewValues(values).getCode() !=
+ org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus.EDITABLE) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+ org.eclipse.emf.ecore.EObject element =
+ (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain =
+ org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(element);
+ if (editingDomain == null) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+ org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand command =
+ new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(
+ editingDomain, "Set Values"); «EXPAND xpt::Common::nonNLS»
+ for (int i = 0; i < values.length; i++) {
+ command.compose(getModificationCommand(element, editableFeatures[i], values[i]));
+ }
+ return command;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getModificationCommand(
+ org.eclipse.emf.ecore.EObject element, org.eclipse.emf.ecore.EAttribute feature, Object value) {
+ value = getValidNewValue(feature, value);
+ if (value instanceof InvalidValue) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+ org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest request =
+ new org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest(element, feature, value);
+ return new org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand(request);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus validateNewValues(Object[] values) {
+ if (values.length != editableFeatures.length) {
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.UNEDITABLE_STATUS;
+ }
+ for (int i = 0; i < values.length; i++) {
+ Object value = getValidNewValue(editableFeatures[i], values[i]);
+ if (value instanceof InvalidValue) {
+ return new org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus(
+ «editorGen.plugin.getActivatorQualifiedClassName()».ID,
+ org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus.UNEDITABLE,
+ value.toString());
+ }
+ }
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.EDITABLE_STATUS;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected Object getValidNewValue(org.eclipse.emf.ecore.EAttribute feature, Object value) {
+ org.eclipse.emf.ecore.EClassifier type = feature.getEType();
+ if (type instanceof org.eclipse.emf.ecore.EDataType) {
+ Class iClass = type.getInstanceClass();
+ if (Boolean.TYPE.equals(iClass)) {
+ if (value instanceof Boolean) {
+ // ok
+ } else if (value instanceof String) {
+ value = Boolean.valueOf((String) value);
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (Character.TYPE.equals(iClass)) {
+ if (value instanceof Character) {
+ // ok
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ value = new Character(s.charAt(0));
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (Byte.TYPE.equals(iClass)) {
+ if (value instanceof Byte) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Byte(((Number) value).byteValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Byte.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserWrongStringConversionMessage()) FOR editorGen», iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (Short.TYPE.equals(iClass)) {
+ if (value instanceof Short) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Short(((Number) value).shortValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Short.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserWrongStringConversionMessage()) FOR editorGen», iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (Integer.TYPE.equals(iClass)) {
+ if (value instanceof Integer) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Integer(((Number) value).intValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Integer.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserWrongStringConversionMessage()) FOR editorGen», iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (Long.TYPE.equals(iClass)) {
+ if (value instanceof Long) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Long(((Number) value).longValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Long.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserWrongStringConversionMessage()) FOR editorGen», iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (Float.TYPE.equals(iClass)) {
+ if (value instanceof Float) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Float(((Number) value).floatValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Float.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserWrongStringConversionMessage()) FOR editorGen», iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (Double.TYPE.equals(iClass)) {
+ if (value instanceof Double) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Double(((Number) value).doubleValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Double.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserWrongStringConversionMessage()) FOR editorGen», iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», iClass.getName()));
+ }
+ } else if (type instanceof org.eclipse.emf.ecore.EEnum) {
+ if (value instanceof String) {
+ org.eclipse.emf.ecore.EEnumLiteral literal =
+ ((org.eclipse.emf.ecore.EEnum) type).getEEnumLiteralByLiteral((String) value);
+ if (literal == null) {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnknownLiteralMessage()) FOR editorGen», value));
+ } else {
+ value = literal.getInstance();
+ }
+ } else {
+ value = new InvalidValue(org.eclipse.osgi.util.NLS.bind(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForAbstractParserUnexpectedValueTypeMessage()) FOR editorGen», String.class.getName()));
+ }
+ }
+ }
+ return value;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected class InvalidValue {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String description;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public InvalidValue(String description) {
+ this.description = description;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String toString() {
+ return description;
+ }
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenParsers»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenParsers-»
+«IF (implementations)[gmfgen::PredefinedParser]->size() > 0-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForAbstractParserUnexpectedValueTypeMessage(), 'Value of type {0} is expected')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForAbstractParserWrongStringConversionMessage(), 'String value does not convert to {0} value')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForAbstractParserUnknownLiteralMessage(), 'Unknown literal: {0}')-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenParsers-»
+«IF (implementations)[gmfgen::PredefinedParser]->size() > 0-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForAbstractParserUnexpectedValueTypeMessage())-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForAbstractParserWrongStringConversionMessage())-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForAbstractParserUnknownLiteralMessage())-»
+«ENDIF-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/ParserProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/ParserProvider.xpt
new file mode 100644
index 000000000..ef99f5736
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/ParserProvider.xpt
@@ -0,0 +1,223 @@
+/*
+ * 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
+ * Artem Tikhomirov (Borland) - [235113] alternative parser access
+ * [244419] custom parsers
+ */
+
+«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::providers::ParserUtils»
+
+«DEFINE accessorMethod_delegate2providers FOR gmfgen::GenParsers-»
+ «EXPAND xpt::Common::generatedMemberComment('Utility method that consults ParserService')»
+ public static org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser(org.eclipse.gmf.runtime.emf.type.core.IElementType type, org.eclipse.emf.ecore.EObject object, String parserHint) {
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserService.getInstance().getParser(new HintAdapter(type, object, parserHint));
+ }
+«ENDDEFINE»
+
+// invokes method generated with accessorMethod_delegate2providers template
+«DEFINE accessorCall_delegate2providers(elementTypeHolder : gmfgen::GenCommonBase, labelModelFacet : gmfgen::LabelModelFacet, parsedElement : String) FOR gmfgen::GenCommonBase-»
+«getDiagram().editorGen.labelParsers.getQualifiedClassName()».getParser(«EXPAND xpt::providers::ElementTypes::accessElementType FOR elementTypeHolder», «parsedElement», «IF labelModelFacet = null»«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall»«ELSE»«EXPAND _parserHint(labelModelFacet, self) FOR labelModelFacet.parser»«ENDIF»)«-»
+«ENDDEFINE»
+
+«DEFINE _parserHint(labelFacet : gmfgen::LabelModelFacet, hintHolder : gmfgen::GenCommonBase) FOR gmfgen::GenParserImplementation»«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR hintHolder»«ENDDEFINE»
+// ExternalParser may override hint
+«DEFINE _parserHint(labelFacet : gmfgen::LabelModelFacet, hintHolder : gmfgen::GenCommonBase) FOR gmfgen::ExternalParser-»
+«IF hint = null-»
+«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR hintHolder-»
+«ELSE»«hint»«ENDIF-»
+«ENDDEFINE»
+«DEFINE _parserHint(labelFacet : gmfgen::DesignLabelModelFacet, hintHolder : gmfgen::GenCommonBase) FOR gmfgen::ExternalParser-»
+«IF hint = null»org.eclipse.gmf.runtime.common.ui.services.parser.CommonParserHint.DESCRIPTION«ELSE»«hint»«ENDIF-»
+«ENDDEFINE»
+«DEFINE _parserHint(labelFacet : gmfgen::DesignLabelModelFacet, hintHolder : gmfgen::GenCommonBase) FOR gmfgen::GenParserImplementation»org.eclipse.gmf.runtime.common.ui.services.parser.CommonParserHint.DESCRIPTION«ENDDEFINE»
+
+// FIXME refactor static field to an instance registered within Activator
+«REM»Complementary method to accessorMethod_delegate2providers, although for direct access need an instance of this class«ENDREM»
+«DEFINE accessorMethod_direct FOR gmfgen::GenParsers-»
+ private static «getQualifiedClassName()» ourInstance;
+
+ public static «getQualifiedClassName()» get() {
+ if (ourInstance == null) {
+ ourInstance = new «getQualifiedClassName()»();
+ }
+ return ourInstance;
+ }
+«ENDDEFINE»
+
+// XXX consider adding #getDescriptionParser() method to control that kind of parser access?
+// XXX do I really need GenCommonBase elementTypeHolder, why not use elementType reference directly?
+«DEFINE accessorCall_direct(elementTypeHolder : gmfgen::GenCommonBase, labelModelFacet : gmfgen::LabelModelFacet, parsedElement : String) FOR gmfgen::GenCommonBase-»
+«IF labelModelFacet = null or (Sequence { labelModelFacet.parser })[gmfgen::ExternalParser]->size() = 1-»
+org.eclipse.gmf.runtime.common.ui.services.parser.ParserService.getInstance().getParser(new org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter(/*«EXPAND xpt::providers::ElementTypes::accessElementType FOR elementTypeHolder», */«parsedElement», «IF labelModelFacet = null»«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall»«ELSE»«EXPAND _parserHint(labelModelFacet, self) FOR labelModelFacet.parser»«ENDIF»))«-»
+«ELSE-»
+«getDiagram().editorGen.labelParsers.getQualifiedClassName()».get().«parserAccessorName(self)»()«-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE provider_getParserMethod FOR gmfgen::GenParsers-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser(
+ org.eclipse.core.runtime.IAdaptable hint) {
+ String vid = (String) hint.getAdapter(String.class);
+ if (vid != null) {
+ return getParser(«EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(vid));
+ }
+ org.eclipse.gmf.runtime.notation.View view =
+ (org.eclipse.gmf.runtime.notation.View) hint.getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null) {
+ return getParser(«EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view));
+ }
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE provider_providesMethod FOR gmfgen::GenParsers-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation) {
+ if (operation instanceof org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation) {
+ org.eclipse.core.runtime.IAdaptable hint =
+ ((org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation) operation).getHint();
+ if («editorGen.diagram.getElementTypesQualifiedClassName()».getElement(hint) == null) {
+ return false;
+ }
+ return getParser(hint) != null;
+ }
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE HintAdapterClass FOR gmfgen::GenParsers-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static class HintAdapter extends org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.gmf.runtime.emf.type.core.IElementType elementType;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public HintAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType type,
+ org.eclipse.emf.ecore.EObject object, String parserHint) {
+ super(object, parserHint);
+ «EXPAND xpt::Common::_assert('type != null')-»
+ elementType = type;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public Object getAdapter(Class adapter) {
+ if (org.eclipse.gmf.runtime.emf.type.core.IElementType.class.equals(adapter)) {
+ return elementType;
+ }
+ return super.getAdapter(adapter);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE getParserByVisualIdMethod FOR gmfgen::GenParsers-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser(int visualID) {
+ switch (visualID) {
+ «EXPAND _getParsers FOREACH editorGen.diagram.topLevelNodes-»
+ «EXPAND _getParsers FOREACH editorGen.diagram.childNodes-»
+ «EXPAND _getParsers FOREACH editorGen.diagram.links-»
+ }
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE _getParsers FOR gmfgen::GenNode»«EXPAND _getParser FOREACH labels»«ENDDEFINE»
+«DEFINE _getParsers FOR gmfgen::GenLink»«EXPAND _getParser FOREACH labels»«ENDDEFINE»
+«DEFINE _getParsers FOR gmfgen::GenChildLabelNode»«EXPAND _getParser(self) FOR labelModelFacet»«ENDDEFINE»
+«DEFINE _getParser FOR gmfgen::GenLabel»«EXPAND _getParser(self) FOR modelFacet»«ENDDEFINE»
+
+«DEFINE _getParser(element : gmfgen::GenCommonBase) FOR gmfgen::LabelModelFacet»«EXPAND _getParser(self, element) FOR parser»«ENDDEFINE»
+
+«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::GenParserImplementation»«ERROR 'Abstract template for ' + self.repr()»«ENDDEFINE»
+«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::ExternalParser»«REM»NOTHING TO DO«ENDREM»«ENDDEFINE»
+
+«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::PredefinedParser-»
+ «EXPAND xpt::Common::caseVisualID FOR element» return «parserAccessorName(element)»();
+«ENDDEFINE»
+
+«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::CustomParser-»
+ «EXPAND xpt::Common::caseVisualID FOR element» return «parserAccessorName(element)»();
+«ENDDEFINE»
+
+
+«DEFINE parsers FOR gmfgen::GenNode»«EXPAND _parser FOREACH labels»«ENDDEFINE»
+«DEFINE parsers FOR gmfgen::GenLink»«EXPAND _parser FOREACH labels»«ENDDEFINE»
+«DEFINE parsers FOR gmfgen::GenChildLabelNode»«EXPAND _parser(self) FOR labelModelFacet»«ENDDEFINE»
+
+«DEFINE _parser FOR gmfgen::GenLabel»«EXPAND _parser(self) FOR modelFacet»«ENDDEFINE»
+«DEFINE _parser(element : gmfgen::GenCommonBase) FOR gmfgen::LabelModelFacet»«EXPAND _parser(self, element) FOR parser»«ENDDEFINE»
+
+«DEFINE _parser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::GenParserImplementation»«ERROR 'Abstract template for ' + self.repr()»«ENDDEFINE»
+
+«DEFINE _parser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::CustomParser»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «qualifiedName» «parserFieldName(element)»;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ «IF holder.extensibleViaService»private«ELSE»public«ENDIF» org.eclipse.gmf.runtime.common.ui.services.parser.IParser «parserAccessorName(element)»() {
+ if («parserFieldName(element)» == null) {
+ «parserFieldName(element)» = new «qualifiedName»();
+ }
+ return «parserFieldName(element)»;
+ }
+«ENDDEFINE»
+
+«DEFINE _parser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::ExternalParser-»
+«REM»NO-OP«ENDREM-»
+«ENDDEFINE»
+
+«DEFINE _parser(modelFacet : gmfgen::FeatureLabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::PredefinedParser»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.common.ui.services.parser.IParser «parserFieldName(element)»;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ «IF holder.extensibleViaService»private«ELSE»public«ENDIF» org.eclipse.gmf.runtime.common.ui.services.parser.IParser «parserAccessorName(element)»() {
+ if («parserFieldName(element)» == null) {
+ org.eclipse.emf.ecore.EAttribute[] features = new org.eclipse.emf.ecore.EAttribute[] {
+ «EXPAND MetaModel::MetaFeature FOREACH modelFacet.metaFeatures SEPARATOR ', ' »
+ };
+ «IF modelFacet.editableMetaFeatures->size() > 0-»
+ org.eclipse.emf.ecore.EAttribute[] editableFeatures = new org.eclipse.emf.ecore.EAttribute[] {
+ «EXPAND MetaModel::MetaFeature FOREACH modelFacet.editableMetaFeatures SEPARATOR ', '»
+ };
+ «ENDIF-»
+ «getQualifiedClassName()» parser = new «getQualifiedClassName()»(features«IF modelFacet.editableMetaFeatures->size() > 0», editableFeatures«ENDIF»);
+ «EXPAND _setPatterns(viewMethod, editMethod, 'parser') FOR modelFacet-»
+ «parserFieldName(element)» = parser;
+ }
+ return «parserFieldName(element)»;
+ }
+«ENDDEFINE»
+
+«DEFINE _setPatterns(viewMethod : gmfgen::LabelTextAccessMethod, editMethod : gmfgen::LabelTextAccessMethod, parserVar : String) FOR gmfgen::FeatureLabelModelFacet-»
+«IF viewMethod <> gmfgen::LabelTextAccessMethod::NATIVE-»
+ «IF isPatternSpecified(viewPattern)-»
+ «parserVar».setViewPattern("«viewPattern»");«EXPAND xpt::Common::nonNLS(1)»
+ «ENDIF-»
+ «IF isPatternSpecified(editorPattern)-»
+ «parserVar».setEditorPattern("«editorPattern»");«EXPAND xpt::Common::nonNLS(1)»
+ «ELSEIF isPatternSpecified(viewPattern)-»
+ «parserVar».setEditorPattern("«viewPattern»");«EXPAND xpt::Common::nonNLS(1)»
+ «ENDIF-»
+«ENDIF-»
+«IF editMethod <> gmfgen::LabelTextAccessMethod::NATIVE-»
+ «IF isPatternSpecified(editPattern)-»
+ «parserVar».setEditPattern("«editPattern»");«EXPAND xpt::Common::nonNLS(1)»
+ «ELSEIF isPatternSpecified(viewPattern)-»
+ «parserVar».setEditPattern("«viewPattern»");«EXPAND xpt::Common::nonNLS(1)»
+ «ENDIF-»
+«ENDIF-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/i18n.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/i18n.qvto
new file mode 100644
index 000000000..028d254d8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/parsers/i18n.qvto
@@ -0,0 +1,21 @@
+library i18n;
+
+helper defaultAbstractParserClassName() : String {
+ return 'AbstractParser'
+}
+
+helper i18nKeyForAbstractParserUnexpectedValueTypeMessage() : String {
+ return defaultAbstractParserClassName() + '.UnexpectedValueType'
+}
+
+helper i18nKeyForAbstractParserWrongStringConversionMessage() : String {
+ return defaultAbstractParserClassName() + '.WrongStringConversion'
+}
+
+helper i18nKeyForAbstractParserUnknownLiteralMessage() : String {
+ return defaultAbstractParserClassName() + '.UnknownLiteral'
+}
+
+helper i18nKeyForMessageFormatParserInvalidInputError() : String {
+ return 'MessageFormatParser.InvalidInputError'
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/CustomPage.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/CustomPage.xpt
new file mode 100644
index 000000000..dea3c3246
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/CustomPage.xpt
@@ -0,0 +1,84 @@
+/*
+ * 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:
+ * 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::StringOperations»
+
+«DEFINE Main FOR gmfgen::GenCustomPreferencePage-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «(if qualifiedClassName = getClassName() then getDiagram().preferencesPackageName else qualifiedClassName.substring(1 + 0, qualifiedClassName.xpandLength() - getClassName().xpandLength() - 1) endif)»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «getClassName()»«EXPAND extendsList»«EXPAND implementsList» {
+
+«EXPAND _constant FOREACH preferences-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «getClassName()»() {
+ setPreferenceStore(«getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getPreferenceStore());
+ }
+«EXPAND methods»
+«EXPAND initDefaultsMethod»
+«EXPAND additions»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenCustomPreferencePage» extends org.eclipse.gmf.runtime.common.ui.preferences.AbstractPreferencePage«ENDDEFINE»
+«DEFINE implementsList FOR gmfgen::GenCustomPreferencePage»«REM»no-op«ENDREM»«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenCustomPreferencePage»«ENDDEFINE»
+
+// the reason I didn't split this template up into two distinct, addFieldsMethod and initHelpMethod, is that
+// using superclass other than oe.gmf...AbstractPreferencePage may require implementation of completely different
+// set of methods. Besides, there's not to much generated, anyway.
+«DEFINE methods FOR gmfgen::GenCustomPreferencePage»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addFields(org.eclipse.swt.widgets.Composite parent) {
+ // TODO Provide method implementation
+ throw new UnsupportedOperationException();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void initHelp() {
+ // TODO implement this method if needed, or leave as no-op
+ }
+«ENDDEFINE»
+
+
+«DEFINE initDefaultsMethod FOR gmfgen::GenCustomPreferencePage-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static void initDefaults(org.eclipse.jface.preference.IPreferenceStore store) {
+«IF preferences->isEmpty() or preferences->exists(p | p.defaultValue = null)-»
+ // TODO this code is invoked during preference store initialization, please fill
+ // the store passed with default preference values.
+«ENDIF-»
+«EXPAND _setDefaultValue('store') FOREACH preferences->select(p | p.defaultValue <> null)-»
+ }
+«ENDDEFINE»
+
+// pair template to initDefaultsMethod, allows external templates invoke generated initDefaults method
+// Note, CustomPage::Main is expected to be invoked only for templates with generateBoilerplate == true,
+// hence no extra check when generating with initDefaultsMethod,
+// however, call_initDefaults may get invoked for any CustomPreferencePage
+«DEFINE call_initDefaults(storeVarName : String) FOR gmfgen::GenCustomPreferencePage-»
+«IF generateBoilerplate»«qualifiedClassName».initDefaults(«storeVarName»);«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _constant FOR gmfgen::GenPreference-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final String «name» = "«key»";«EXPAND xpt::Common::nonNLS»
+«ENDDEFINE»
+
+«DEFINE _setDefaultValue(store : String) FOR gmfgen::GenPreference-»
+ «store».setDefault(«name», «defaultValue»);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/StandardPage.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/StandardPage.xpt
new file mode 100644
index 000000000..3a27cb938
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/preferences/StandardPage.xpt
@@ -0,0 +1,46 @@
+/*
+ * 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«DEFINE Main FOR gmfgen::GenStandardPreferencePage-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().preferencesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «getClassName()»«EXPAND extendsList»«EXPAND implementsList» {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «getClassName()»() {
+ setPreferenceStore(«getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getPreferenceStore());
+ }
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenStandardPreferencePage-»
+«IF gmfgen::StandardPreferencePages::General = kind-»
+ extends org.eclipse.gmf.runtime.diagram.ui.preferences.DiagramsPreferencePage«-»
+«ELSEIF gmfgen::StandardPreferencePages::Appearance = kind-»
+ extends org.eclipse.gmf.runtime.diagram.ui.preferences.AppearancePreferencePage«-»
+«ELSEIF gmfgen::StandardPreferencePages::Connections = kind-»
+ extends org.eclipse.gmf.runtime.diagram.ui.preferences.ConnectionsPreferencePage«-»
+«ELSEIF gmfgen::StandardPreferencePages::Printing = kind-»
+ extends org.eclipse.gmf.runtime.diagram.ui.preferences.PrintingPreferencePage«-»
+«ELSEIF gmfgen::StandardPreferencePages::RulersAndGrid = kind-»
+ extends org.eclipse.gmf.runtime.diagram.ui.preferences.RulerGridPreferencePage«-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenStandardPreferencePage»«REM»no-op«ENDREM»«ENDDEFINE»
+
+«DEFINE call_initDefaults(storeVarName : String) FOR gmfgen::GenStandardPreferencePage»«IF kind <> gmfgen::StandardPreferencePages::Pathmaps»«getQualifiedClassName()».initDefaults(«storeVarName»);«ENDIF»«ENDDEFINE» \ No newline at end of file

Back to the top