aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2008-12-29 07:41:38 -0500
committerashatalin2008-12-29 07:41:38 -0500
commitfc1dfb3b462e159eec1b6031bb41ab79c762474b (patch)
tree66acb7873f68640147106dcd919a5041ecbc918b
parent7f3bb1960b122d5d9c4edae8dc1c330032c9cf60 (diff)
downloadorg.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.gz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.xz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.zip
QVTO-based xpand implementation was merged to HEAD
-rw-r--r--plugins/org.eclipse.gmf.codegen/.classpath1
-rw-r--r--plugins/org.eclipse.gmf.codegen/.project12
-rw-r--r--plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.core.resources.prefs11
-rw-r--r--plugins/org.eclipse.gmf.codegen/.xpand-root4
-rw-r--r--plugins/org.eclipse.gmf.codegen/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.gmf.codegen/plugin.xml8
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java4
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto18
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt157
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt113
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.qvto131
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.xpt194
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ChildNodeLabelEditPart.xpt90
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/CompartmentEditPart.xpt74
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/DiagramEditPart.xpt65
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ExternalNodeLabelEditPart.xpt69
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkEditPart.xpt61
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkLabelEditPart.xpt68
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeEditPart.xpt131
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeLabelEditPart.xpt69
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/emf-merge.xml233
-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
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/CustomParser.xpt64
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/ParserProvider.xpt61
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/PredefinedParser.xpt322
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Common.xpt98
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ConstraintProviders.xpt101
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/EMFUtils.qvto3
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Externalizer.xpt102
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ExternalizerUtils.qvto21
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenAuditRoot.qvto35
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenEditorGenerator.qvto7
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenModelUtils.qvto40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/NonNLSUtils.qvto21
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/ActionBarAdvisor.xpt266
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Application.xpt51
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Perspective.xpt45
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WizardNewFileCreationPage.xpt206
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchAdvisor.xpt63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchWindowAdvisor.xpt63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/extensions.xpt94
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/i18n.qvto63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto31
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto47
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt126
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt148
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt161
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt18
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt60
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt46
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt302
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt50
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/BaseEditHelper.xpt99
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelper.xpt25
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelperAdvice.xpt25
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Common.xpt155
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/EditPartFactory.xpt129
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Utils.qvto67
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt547
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt28
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt38
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt240
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt72
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt68
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt112
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt165
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt203
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto90
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt33
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt146
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/PreferenceInitializer.xpt112
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/extensions.xpt49
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt488
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt120
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt64
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt93
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto150
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt166
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt34
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt91
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt70
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt44
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt34
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt54
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt70
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt111
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt70
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt181
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt105
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt79
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt174
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt72
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt427
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt748
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DomainModelElementTester.xpt50
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Editor.xpt404
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ElementChooser.xpt414
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/GenDiagram.qvto29
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/InitDiagramFileAction.xpt145
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/MatchingStrategy.xpt49
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ModelElementSelectionPage.xpt167
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/NewDiagramFileWizard.xpt200
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetInfo.xpt331
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ResourceSetModificationListener.xpt89
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutCreationWizard.xpt156
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ShortcutPropertyTester.xpt53
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/UriEditorInputTester.xpt40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/Utils.qvto255
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidateAction.xpt351
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ValidationMarker.xpt112
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/VisualIDRegistry.xpt388
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/diagram.gifbin0 -> 339 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/extensions.xpt86
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt278
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/Utils.qvto49
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/shortcut.gifbin0 -> 93 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/wizban.gifbin0 -> 2466 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/expressions/AbstractExpression.xpt145
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/expressions/OCLExpressionFactory.xpt148
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/expressions/RegexpExpressionFactory.xpt74
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/expressions/ValueExpression.qvto15
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/expressions/getExpression.xpt19
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/AbstractNavigatorItem.xpt81
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/DomainNavigatorContentProvider.xpt98
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/DomainNavigatorItem.xpt121
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/DomainNavigatorLabelProvider.xpt123
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/NavigatorActionProvider.xpt206
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/NavigatorContentProvider.xpt492
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/NavigatorGroup.xpt129
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/NavigatorItem.xpt109
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/NavigatorLabelProvider.xpt424
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/NavigatorLinkHelper.xpt132
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/NavigatorSorter.xpt58
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/Utils.qvto63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/extensions.xpt176
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/getEditorInput.xpt44
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/navigator/navigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/plugin/Activator.xpt218
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/plugin/build.xpt26
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/plugin/manifest.xpt74
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/plugin/options.xpt23
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/plugin/plugin.xpt158
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/plugin/properties.xpt53
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/LabelProvider.xpt94
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/PropertySection.xpt145
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/extensions.xpt144
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/EditPartProvider.xpt125
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ElementInitializers.qvto78
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ElementInitializers.xpt177
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ElementTypes.xpt258
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/IconProvider.xpt39
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/MarkerNavigationProvider.xpt86
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/MetricProvider.xpt436
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/Metrics.qvto26
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/MetricsResultView.xpt277
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ModelingAssistantProvider.xpt253
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ParserUtils.qvto17
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ShortcutsDecoratorProvider.xpt110
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ValidationDecoratorProvider.xpt393
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ValidationProvider.xpt322
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/ViewProvider.xpt226
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/extensions.xpt181
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/providers/i18n.qvto15
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.qvtlib/NativeMetaModel.java8
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.qvtlib/xpt/NativeEMFUtils.java9
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.qvtlib/xpt/NativeGenAuditRoot.java7
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.qvtlib/xpt/NativeGenModelUtils.java15
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.qvtlib/xpt/navigator/NativeUtils.java7
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.qvtlib/xpt/providers/NativeMetrics.java7
192 files changed, 23443 insertions, 13 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/.classpath b/plugins/org.eclipse.gmf.codegen/.classpath
index 472ee29b1..d32b70f21 100644
--- a/plugins/org.eclipse.gmf.codegen/.classpath
+++ b/plugins/org.eclipse.gmf.codegen/.classpath
@@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="src" path="templates.qvtlib"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.gmf.codegen/.project b/plugins/org.eclipse.gmf.codegen/.project
index f37c7417f..e249606d5 100644
--- a/plugins/org.eclipse.gmf.codegen/.project
+++ b/plugins/org.eclipse.gmf.codegen/.project
@@ -21,7 +21,16 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.gmf.xpand.oawBuilder</name>
+ <name>org.eclipse.m2m.qvt.oml.QvtBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>src_container</key>
+ <value>templates.migrated</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.gmf.xpand.xpandBuilder</name>
<arguments>
</arguments>
</buildCommand>
@@ -29,5 +38,6 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.m2m.qvt.oml.project.TransformationNature</nature>
</natures>
</projectDescription>
diff --git a/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.core.resources.prefs
index 009e4726a..06ca554cf 100644
--- a/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.gmf.codegen/.settings/org.eclipse.core.resources.prefs
@@ -1,9 +1,6 @@
-#Wed May 14 15:07:54 CEST 2008
+#Mon Dec 29 13:34:33 CET 2008
eclipse.preferences.version=1
-encoding//templates-dynmodel/MetaModel.xpt=ISO-8859-1
-encoding//templates/MetaModel.ext=ISO-8859-1
-encoding//templates/MetaModel.xpt=ISO-8859-1
-encoding//templates/diagram=ISO-8859-1
-encoding//templates/impl=ISO-8859-1
-encoding//templates/xpt=ISO-8859-1
+encoding/templates=ISO-8859-1
encoding/templates-dynmodel=ISO-8859-1
+encoding/templates-dynmodel.migrated=ISO-8859-1
+encoding/templates.migrated=ISO-8859-1
diff --git a/plugins/org.eclipse.gmf.codegen/.xpand-root b/plugins/org.eclipse.gmf.codegen/.xpand-root
index 4d842e88b..b80e35d95 100644
--- a/plugins/org.eclipse.gmf.codegen/.xpand-root
+++ b/plugins/org.eclipse.gmf.codegen/.xpand-root
@@ -1,2 +1,2 @@
-templates
-templates-dynmodel, templates/
+templates.migrated
+templates-dynmodel.migrated, templates.migrated/
diff --git a/plugins/org.eclipse.gmf.codegen/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.codegen/META-INF/MANIFEST.MF
index b85b1573f..06613bd28 100644
--- a/plugins/org.eclipse.gmf.codegen/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.gmf.codegen/META-INF/MANIFEST.MF
@@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.draw2d;bundle-version="[3.2.0,4.0.0)",
org.eclipse.gmf.common;bundle-version="[1.1.0,2.0.0)";visibility:=reexport,
org.eclipse.gmf.validate;bundle-version="[1.1.0,2.0.0)",
- org.eclipse.gmf.xpand;bundle-version="[1.0.0,2.0.0)"
+ org.eclipse.gmf.xpand;bundle-version="[2.0.0,3.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-BuddyPolicy: registered
diff --git a/plugins/org.eclipse.gmf.codegen/plugin.xml b/plugins/org.eclipse.gmf.codegen/plugin.xml
index 54b1bac9a..e0bf44ddb 100644
--- a/plugins/org.eclipse.gmf.codegen/plugin.xml
+++ b/plugins/org.eclipse.gmf.codegen/plugin.xml
@@ -103,4 +103,12 @@
</content-type>
</extension>
+ <extension point="org.eclipse.m2m.qvt.oml.javaBlackboxUnits">
+ <library class="xpt.providers.NativeMetrics"><metamodel nsURI="http://www.eclipse.org/gmf/2008/GenModel"/><metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/></library>
+ <library class="xpt.navigator.NativeUtils"><metamodel nsURI="http://www.eclipse.org/gmf/2008/GenModel"/><metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/><metamodel nsURI="http://www.eclipse.org/emf/2002/GenModel"/></library>
+ <library class="xpt.NativeGenModelUtils"><metamodel nsURI="http://www.eclipse.org/emf/2002/GenModel"/><metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/></library>
+ <library class="xpt.NativeGenAuditRoot"><metamodel nsURI="http://www.eclipse.org/gmf/2008/GenModel"/><metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/><metamodel nsURI="http://www.eclipse.org/emf/2002/GenModel"/></library>
+ <library class="xpt.NativeEMFUtils"><metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/></library>
+ <library class="NativeMetaModel"><metamodel nsURI="http://www.eclipse.org/emf/2002/GenModel"/><metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/></library>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
index 1a514fc6e..075e27232 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/CodegenEmitters.java
@@ -57,9 +57,9 @@ public class CodegenEmitters {
urls.add(getDynamicTemplatesURL(templateDirectory));
}
if (includeDynamicModelTemplates) {
- urls.add(getTemplatesBundle().getEntry("/templates-dynmodel/")); //$NON-NLS-1$
+ urls.add(getTemplatesBundle().getEntry("/templates-dynmodel.migrated/")); //$NON-NLS-1$
}
- urls.add(getTemplatesBundle().getEntry("/templates/")); //$NON-NLS-1$
+ urls.add(getTemplatesBundle().getEntry("/templates.migrated/")); //$NON-NLS-1$
myLocations = urls.toArray(new URL[urls.size()]);
myResourceManager = new BundleResourceManager(myLocations);
diff --git a/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto
new file mode 100644
index 000000000..cca3ed16f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto
@@ -0,0 +1,18 @@
+import xpt.GlobalVarOperations;
+
+modeltype genModel uses "http://www.eclipse.org/emf/2002/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Facility;
+
+helper getNameToken(gp : genModel::GenPackage) : String {
+ return gp.prefix
+}
+
+helper fieldName(gp : genModel::GenPackage) : String {
+ return 'instance' + getNameToken(gp)
+}
+
+helper getDMA() : genModel_1::DynamicModelAccess {
+ return xpandGetObjectGlobalVar('DynamicModelAccess').oclAsType(genModel_1::DynamicModelAccess)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt
new file mode 100644
index 000000000..6bb9db52e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt
@@ -0,0 +1,157 @@
+/*
+ * 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'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION Facility»
+
+«DEFINE Main FOR gmfgen::DynamicModelAccess-»
+package «packageName»;
+
+public class «className» {
+
+ «EXPAND field(self) FOREACH editorGen.getAllDomainGenPackages(false)-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EPackage ePackage;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «className»(org.eclipse.emf.ecore.EPackage ePackage) {
+ this.ePackage = ePackage;
+ }
+
+ «EXPAND getMethod(self) FOREACH editorGen.getAllDomainGenPackages(false)-»
+
+ «EXPAND getRegistryMethod»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean isInstance(Object obj, String metaClassName) {
+ org.eclipse.emf.ecore.EClass metaClass = getEClass(metaClassName);
+ return obj instanceof org.eclipse.emf.ecore.EObject && metaClass.isSuperTypeOf(((org.eclipse.emf.ecore.EObject) obj).eClass());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EObject newInstance(String metaClassName) {
+ return this.ePackage.getEFactoryInstance().create(getEClass(metaClassName));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EClass getEClass(String metaClassName) {
+ «EXPAND xpt::Common::_assert('metaClassName != null')-»
+ org.eclipse.emf.ecore.EClass metaClass = findMetaClass(metaClassName);
+ assertMetaClass(metaClass, metaClassName);
+ return metaClass;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EStructuralFeature getEFeature(String metaClassName, String metaFeatureName) {
+ «EXPAND xpt::Common::_assert('metaFeatureName != null')-»
+ org.eclipse.emf.ecore.EClass metaClass = getEClass(metaClassName);
+ org.eclipse.emf.ecore.EStructuralFeature f = metaClass.getEStructuralFeature(metaFeatureName);
+ assertMetaFeature(f, metaClass, metaFeatureName);
+ return f;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EAttribute getEAttribute(String metaClassName, String metaFeatureName) {
+ return (org.eclipse.emf.ecore.EAttribute) getEFeature(metaClassName, metaFeatureName);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EReference getEReference(String metaClassName, String metaFeatureName) {
+ return (org.eclipse.emf.ecore.EReference) getEFeature(metaClassName, metaFeatureName);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EDataType getEDataType(String metaClassName) {
+ «EXPAND xpt::Common::_assert('metaClassName != null')-»
+ org.eclipse.emf.ecore.EClassifier c = this.ePackage.getEClassifier(metaClassName);
+ if (false == c instanceof org.eclipse.emf.ecore.EDataType) {
+ return null;
+ }
+ return (org.eclipse.emf.ecore.EDataType) c;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EEnum getEEnum(String metaClassName) {
+ «EXPAND xpt::Common::_assert('metaClassName != null')-»
+ org.eclipse.emf.ecore.EClassifier c = this.ePackage.getEClassifier(metaClassName);
+ if (false == c instanceof org.eclipse.emf.ecore.EEnum) {
+ return null;
+ }
+ return (org.eclipse.emf.ecore.EEnum) c;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.ecore.EClass findMetaClass(String name) {
+ org.eclipse.emf.ecore.EClassifier c = this.ePackage.getEClassifier(name);
+ if (false == c instanceof org.eclipse.emf.ecore.EClass) {
+ return null;
+ }
+ return (org.eclipse.emf.ecore.EClass) c;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Default implementation throws IllegalStateException if metaclass is null')»
+ private void assertMetaClass(org.eclipse.emf.ecore.EClass metaClass, String metaClassName) {
+ if (metaClass == null) {
+ throw new IllegalStateException(java.text.MessageFormat.format("Can't find class {0} in the package {1}", new Object[] {metaClassName, this.ePackage.getName()}));
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Default implementation throws IllegalStateException if meta-feature is null')»
+ private void assertMetaFeature(org.eclipse.emf.ecore.EStructuralFeature metaFeature, org.eclipse.emf.ecore.EClass metaClass, String featureName) {
+ if (metaFeature == null) {
+ throw new IllegalStateException(java.text.MessageFormat.format("Can't find feature {0} of class {1} in the package {2}", new Object[] {featureName, metaClass.getName(), this.ePackage.getName()}));
+ }
+ }
+
+ «EXPAND initMethod FOREACH editorGen.getAllDomainGenPackages(false)-»
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::DynamicModelAccess»«ENDDEFINE»
+
+«DEFINE field(dma : gmfgen::DynamicModelAccess) FOR genmodel::GenPackage-»
+«EXPAND xpt::Common::generatedMemberComment»
+private static «dma.className» «fieldName(self)»;
+«ENDDEFINE»
+
+«DEFINE getMethod(dma : gmfgen::DynamicModelAccess) FOR genmodel::GenPackage-»
+ «EXPAND xpt::Common::generatedMemberComment('@throws IllegalStateException if no EPackage with given URI is registered.')»
+ public static «dma.className» get«getNameToken(self)»() {
+ if («fieldName(self)» == null) {
+ org.eclipse.emf.ecore.EPackage pkg = getRegistry().getEPackage("«ecorePackage.nsURI»");
+ if (pkg == null) {
+ throw new IllegalStateException("Package «ecorePackage.name»(«ecorePackage.nsURI») not found");
+ }
+ «fieldName(self)» = new «dma.className»(pkg);
+ «fieldName(self)».init«getNameToken(self)»();
+ }
+ return «fieldName(self)»;
+ }
+«ENDDEFINE»
+
+«DEFINE initMethod FOR genmodel::GenPackage-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private void init«getNameToken(self)»() {
+ }
+«ENDDEFINE»
+
+«DEFINE getRegistryMethod FOR gmfgen::DynamicModelAccess»
+ «EXPAND xpt::Common::generatedMemberComment('Default implementation returns global registry, clients that need another may redefine.')»
+ private static org.eclipse.emf.ecore.EPackage.Registry getRegistry() {
+ return org.eclipse.emf.ecore.EPackage.Registry.INSTANCE;
+ }
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt
new file mode 100644
index 000000000..820889ff3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt
@@ -0,0 +1,113 @@
+/*
+ * 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'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION Facility»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::NativeGenModelUtils»
+
+// XXX is isExternalInterface use valid here, won't all objects be just EObject?
+
+«DEFINE IsInstance(accessor : String) FOR genmodel::GenClass-»
+«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().isInstance(«accessor», "«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE NotInstance(accessor : String) FOR genmodel::GenClass»!«EXPAND IsInstance(accessor)»«ENDDEFINE»
+
+«DEFINE IsContainerInstance(_object : String, metaClass : genmodel::GenClass) FOR genmodel::GenClass-»
+«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().isInstance(«IF isExternalInterface(self)»((org.eclipse.emf.ecore.EObject) «_object»)«ELSE»«_object»«ENDIF».eContainer(), "«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE getFeatureValue(containerVar : String, containerClass : genmodel::GenClass) FOR genmodel::GenFeature-»
+((«EXPAND featureTargetType») «IF isExternalInterface(containerClass)-»
+((org.eclipse.emf.ecore.EObject) «containerVar»)«ELSE-»
+«containerVar»«ENDIF-»
+.eGet(«EXPAND MetaFeature»))«ENDDEFINE»
+
+«DEFINE featureTargetType FOR genmodel::GenFeature-»
+«EXPAND _featureTargetType(self) FOR ecoreFeature-»
+«ENDDEFINE»
+
+«DEFINE _featureTargetType(gf : genmodel::GenFeature) FOR ecore::EStructuralFeature»NO-OP«ENDDEFINE»
+«DEFINE _featureTargetType(gf : genmodel::GenFeature) FOR ecore::EReference-»
+«IF isListType(gf)»java.util.List«ELSE»org.eclipse.emf.ecore.EObject«ENDIF-»
+«ENDDEFINE»
+«DEFINE _featureTargetType(gf : genmodel::GenFeature) FOR ecore::EAttribute-»
+«IF isListType(gf)»java.util.List«ELSE»«getObjectCompatibleClassName(eAttributeType)»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getFeatureValue(containerVar : String, container : genmodel::GenClass, needsCastToResultType : Boolean) FOR genmodel::GenFeature-»
+// ??? FIXME
+«ENDDEFINE»
+
+«DEFINE setFeatureValue(containerVar : String, containerClass : genmodel::GenClass, valueVar : String) FOR genmodel::GenFeature-»
+«IF isExternalInterface(containerClass)-»
+((org.eclipse.emf.ecore.EObject) «containerVar»)«ELSE-»
+«containerVar»«ENDIF-»
+.eSet(«EXPAND MetaFeature», «valueVar»)«ENDDEFINE»
+
+«DEFINE setFeatureValue(containerVar : String, containerClass : genmodel::GenClass, valueVar : String, isPlainObjectValue : Boolean) FOR genmodel::GenFeature-»
+«EXPAND setFeatureValue(containerVar, containerClass, valueVar)»«ENDDEFINE»
+
+«DEFINE MetaClass FOR genmodel::GenDataType»«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().getEDataType("«ecoreDataType.name»")«ENDDEFINE»
+«DEFINE MetaClass FOR genmodel::GenEnum»«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().getEEnum("«ecoreEnum.name»")«ENDDEFINE»
+«DEFINE MetaClass FOR genmodel::GenClass»«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().getEClass("«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE MetaFeature FOR genmodel::GenFeature»«EXPAND _metaFeature(ecoreFeature)»«ENDDEFINE»
+
+«DEFINE _metaFeature(f : ecore::EStructuralFeature) FOR genmodel::GenFeature»no-op«ENDDEFINE»
+«DEFINE _metaFeature(eRef : ecore::EReference) FOR genmodel::GenFeature»«getDMA().getQualifiedClassName()».get«getNameToken(genClass.genPackage)»().getEReference("«genClass.ecoreClass.name»", "«ecoreFeature.name»")«ENDDEFINE»
+«DEFINE _metaFeature(eAttr : ecore::EAttribute) FOR genmodel::GenFeature»«getDMA().getQualifiedClassName()».get«getNameToken(genClass.genPackage)»().getEAttribute("«genClass.ecoreClass.name»", "«ecoreFeature.name»")«ENDDEFINE»
+
+«DEFINE NewInstance FOR genmodel::GenClass-»
+«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().newInstance("«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE NewInstance(varName : String) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «varName» = «EXPAND NewInstance»;«ENDDEFINE»
+
+«DEFINE DowncastToEObject(value : String) FOR genmodel::GenClass»«IF isExternalInterface(self)»(org.eclipse.emf.ecore.EObject) «ENDIF»«value»«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «value»;«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «IF isPlainObjectValue»(org.eclipse.emf.ecore.EObject)«ENDIF»«value»;«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenClassifier»NO-OP«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenDataType-»
+«EXPAND QualifiedClassName» «assignee» = («EXPAND QualifiedClassName») «value»;«ENDDEFINE»
+
+
+«DEFINE DeclareAndAssignContainer(assignee : String, _object : String, metaClass : genmodel::GenClass) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «IF isExternalInterface(metaClass)»((org.eclipse.emf.ecore.EObject) «_object»)«ELSE»«_object»«ENDIF».eContainer();«ENDDEFINE»
+
+// FIXME - feature value is not necessarily of EObject type
+«DEFINE DeclareAndAssign(assignee : String, src : String, srcMetaClass : genmodel::GenClass, srcFeature : genmodel::GenFeature) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «EXPAND getFeatureValue(src, srcMetaClass) FOR srcFeature»;«ENDDEFINE»
+
+«DEFINE DeclareAndAssign2(assignee : String, src : String, srcMetaClass : genmodel::GenClass, srcFeature : genmodel::GenFeature, srcExt : String, needCast : Boolean) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «EXPAND getFeatureValue(src, srcMetaClass) FOR srcFeature».«srcExt»;«ENDDEFINE»
+
+«DEFINE CastEObject(eObjectValue : String) FOR genmodel::GenClass»«eObjectValue»«ENDDEFINE»
+
+«DEFINE QualifiedClassName FOR genmodel::GenClassifier»NO-OP«ENDDEFINE»
+«DEFINE QualifiedClassName FOR genmodel::GenClass»org.eclipse.emf.ecore.EObject«ENDDEFINE»
+«DEFINE QualifiedClassName FOR genmodel::GenEnum»org.eclipse.emf.common.util.Enumerator«ENDDEFINE»
+«DEFINE QualifiedClassName FOR genmodel::GenDataType»«getObjectCompatibleClassName(ecoreDataType)»«ENDDEFINE»
+
+«DEFINE PopulateItemProviderFactories(factoryListVar : String) FOR gmfgen::GenEditorGenerator-»
+«REM»
+ NO-OP since ReflectiveItemProviderAdapterFactory should
+ get added anyway.
+«ENDREM»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.qvto
new file mode 100644
index 000000000..bd8aba806
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.qvto
@@ -0,0 +1,131 @@
+import xpt.StringOperations;
+import NativeMetaModel;
+
+import xpt.GenModelUtils;
+
+modeltype genModel uses "http://www.eclipse.org/emf/2002/GenModel";
+modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
+
+library MetaModel;
+
+helper getQualifiedPackageInterfaceName(gp : genModel::GenPackage) : String {
+ return (if gp.genModel.suppressEMFMetaData then getQualifiedPackageClassName(gp) else getReflectionPackageName(gp) + '.' + getPackageInterfaceName(gp) endif)
+}
+
+helper getQualifiedFactoryInterfaceName(gp : genModel::GenPackage) : String {
+ return getReflectionPackageName(gp) + '.' + getPrefixedName(gp, 'Factory')
+}
+
+helper getFactoryInstanceName(gp : genModel::GenPackage) : String {
+ return (if gp.genModel.suppressEMFMetaData then 'INSTANCE' else 'eINSTANCE' endif)
+}
+
+helper getQualifiedItemProviderAdapterFactoryClassName(gp : genModel::GenPackage) : String {
+ return getQualifiedPackageName(gp, gp.providerPackageSuffix) + '.' + getItemProviderAdapterFactoryClassName(gp)
+}
+
+helper getItemProviderAdapterFactoryClassName(gp : genModel::GenPackage) : String {
+ return getPrefixedName(gp, 'ItemProviderAdapterFactory')
+}
+
+helper getQualifiedInterfaceName(gc : genModel::GenClass) : String {
+ return (if null <> gc.ecoreClass.instanceClassName then gc.ecoreClass.instanceClassName.xpandReplaceAll('\$', '\.') else getInterfacePackageName(gc.genPackage) + '.' + gc.ecoreClass.name endif)
+}
+
+helper getInterfacePackageName(gp : genModel::GenPackage) : String {
+ return getQualifiedPackageName(gp, gp.interfacePackageSuffix)
+}
+
+helper genModel::GenClassifier::getQualifiedClassName() : String {
+ return null
+}
+
+helper genModel::GenDataType::getQualifiedClassName() : String {
+ return getObjectCompatibleClassName(self.ecoreDataType)
+}
+
+helper genModel::GenEnum::getQualifiedClassName() : String {
+ return getInterfacePackageName(self.genPackage) + '.' + self.ecoreEnum.name
+}
+
+helper getClassifierAccessorName(gc : genModel::GenClassifier) : String {
+ return switch { case (gc.getEcoreClassifier().name = 'Class') 'Class_'; case (gc.getEcoreClassifier().name = 'Name') 'Name_'; else gc.getEcoreClassifier().name; }
+}
+
+helper getFeatureAccessorName(gf : genModel::GenFeature) : String {
+ return gf.genClass.ecoreClass.name + '_' + gf.ecoreFeature.name.firstToUpper()
+}
+
+helper getAccessorName(gf : genModel::GenFeature) : String {
+ return (if isMapEntryFeature(gf) then 'Typed' + gf.ecoreFeature.name.firstToUpper() else gf.ecoreFeature.name.firstToUpper() endif)
+}
+
+
+helper isMapEntry(gc : genModel::GenClass) : Boolean {
+ return 'java.util.Map.Entry' = gc.ecoreClass.instanceClassName or 'java.util.Map$Entry' = gc.ecoreClass.instanceClassName and (gc.ecoreClass.getEStructuralFeature('key') <> null and gc.ecoreClass.getEStructuralFeature('value') <> null)
+}
+
+helper parenthesizedCast(what : String, source : genModel::GenClass, target : genModel::GenClass) : String {
+ return (if needsCast(source, target) then '(' + unparenthesizedCast(what, source, target) + ')' else what endif)
+}
+
+helper unparenthesizedCast(what : String, source : genModel::GenClass, target : genModel::GenClass) : String {
+ return (if needsCast(source, target) then (if target = null then '(org.eclipse.emf.ecore.EObject)' + what else '(' + getQualifiedInterfaceName(target) + ')' + what endif) else what endif)
+}
+
+helper needsCast(source : genModel::GenClass, target : genModel::GenClass) : Boolean {
+ return (if source = target then false else (if target = null then source <> null and isExternalInterface(source) else source = null or (isExternalInterface(target) or (isExternalInterface(source) or not target.ecoreClass.isSuperTypeOf(source.ecoreClass))) endif) endif)
+}
+
+helper genModel::GenClassifier::getEcoreClassifier() : ecore::EClassifier {
+ return null
+}
+
+helper genModel::GenClass::getEcoreClassifier() : ecore::EClassifier {
+ return self.ecoreClass
+}
+
+helper genModel::GenDataType::getEcoreClassifier() : ecore::EClassifier {
+ return self.ecoreDataType
+}
+
+helper getReflectionPackageName(gp : genModel::GenPackage) : String {
+ return getQualifiedPackageName(gp, gp.metaDataPackageSuffix)
+}
+
+helper getQualifiedPackageClassName(gp : genModel::GenPackage) : String {
+ return getReflectionClassPackageName(gp) + '.' + getPackageClassName(gp)
+}
+
+helper getReflectionClassPackageName(gp : genModel::GenPackage) : String {
+ return getQualifiedPackageName(gp, (if gp.genModel.suppressInterfaces then gp.metaDataPackageSuffix else gp.classPackageSuffix endif))
+}
+
+helper getPackageClassName(gp : genModel::GenPackage) : String {
+ return (if not gp.genModel.suppressEMFMetaData and not gp.genModel.suppressInterfaces then getPackageInterfaceName(gp) + 'Impl' else getPackageInterfaceName(gp) endif)
+}
+
+helper getPackageInterfaceName(gp : genModel::GenPackage) : String {
+ return (if gp.genModel.suppressEMFMetaData and not gp.genModel.suppressInterfaces then getPrefixedName(gp, 'PackageImpl') else getPrefixedName(gp, 'Package') endif)
+}
+
+helper getPrefixedName(gp : genModel::GenPackage, name : String) : String {
+ return (if null <> gp.prefix then gp.prefix + name else name endif)
+}
+
+helper getQualifiedPackageName(gp : genModel::GenPackage, suffix : String) : String {
+ return (if isBlank(suffix) then getQualifiedPackageName(gp) else getQualifiedPackageName(gp) + '.' + suffix endif)
+}
+
+helper getQualifiedPackageName(gp : genModel::GenPackage) : String {
+ return (if isBlank(gp.basePackage) then safeName(gp.ecorePackage.name) else gp.basePackage + '.' + safeName(gp.ecorePackage.name) endif)
+}
+
+helper isMapEntryFeature(gf : genModel::GenFeature) : Boolean {
+ return isMapEntry(gf.genClass) and ('key' = gf.ecoreFeature.name or 'value' = gf.ecoreFeature.name)
+}
+
+helper isBlank(s : String) : Boolean {
+ return null = s or s.xpandLength() = 0
+}
+
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.xpt
new file mode 100644
index 000000000..8602e7035
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/MetaModel.xpt
@@ -0,0 +1,194 @@
+/*
+ * 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'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION MetaModel»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION NativeMetaModel»
+«EXTENSION xpt::NativeGenModelUtils»
+
+/*
+ * Does instanceof check.
+ */
+«DEFINE IsInstance(accessor : String) FOR genmodel::GenClass-»
+«accessor» instanceof «getQualifiedInterfaceName(self)»«ENDDEFINE»
+
+// Shorthand, negates IsInstance - handy if you consider
+// different approaches for generated and dynamic models: false == instanceof
+// vs. !MetaModelFacility.isInstance
+«DEFINE NotInstance(accessor : String) FOR genmodel::GenClass-»
+false == «EXPAND IsInstance(accessor)»«ENDDEFINE»
+
+/**
+ * Special kind of instanceof check, that compares eContainer() of the object.
+ * Since metaClass may be an external interface, eContainer() might need cast to EObject
+ */
+«DEFINE IsContainerInstance(_object : String, metaClass : genmodel::GenClass) FOR genmodel::GenClass-»
+«EXPAND _getEObjectFeature(_object, 'eContainer()') FOR metaClass» instanceof «getQualifiedInterfaceName(self)»«ENDDEFINE»
+
+«DEFINE _getEObjectFeature(_object : String, feature : String) FOR genmodel::GenClass-»
+«IF isExternalInterface(self)»((org.eclipse.emf.ecore.EObject) «_object»).«feature»«ELSE»«_object».«feature»«ENDIF-»
+«ENDDEFINE»
+
+// Public/API-sort templates are named with first letter capitalized.
+// FIXME getFeatureValue* and setFeatureValue start with lowercase to indicate pending refactoring
+
+«DEFINE getFeatureValue(containerVar : String, containerClass : genmodel::GenClass) FOR genmodel::GenFeature-»
+«IF isExternalInterface(containerClass)-»
+((«EXPAND featureTargetType») ((org.eclipse.emf.ecore.EObject) «containerVar»).eGet(«EXPAND MetaFeature»))«-»
+«ELSE-»
+«containerVar».«getGetAccessor(self)»()«-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE featureTargetType FOR genmodel::GenFeature»«IF isListType(self)»java.util.List«ELSE»«EXPAND QualifiedClassName FOR findGenClassifier(genClass.genPackage.genModel, ecoreFeature.eType)»«ENDIF»«ENDDEFINE»
+
+/*
+ * FIXME leave only one version of these two getFeatureValue
+ *
+ * A slightly more sophisticated version of getFeatureValue().
+ * @param containerName the name of the container
+ * @param feature the feature whose value is in interest
+ * @param containerMetaClass the <code>GenClass</code> of the container, or <code>null</code>, if the container is declared as an <code>org.eclipse.emf.ecore.EObject</code>.
+ * @param needsCastToResultType whether the cast to the result type is required (this parameter is only used if the <code>org.eclipse.emf.ecore.EClass</code> this feature belongs to is an external interface).
+ */
+«DEFINE getFeatureValue(containerVar : String, container : genmodel::GenClass, needsCastToResultType : Boolean) FOR genmodel::GenFeature-»
+«IF isExternalInterface(genClass)-»
+«IF needsCastToResultType»((«EXPAND featureTargetType») «ENDIF»«parenthesizedCast(containerVar, container, null)».eGet(«EXPAND MetaFeature»)«IF needsCastToResultType»)«ENDIF-»
+«ELSE-»
+«parenthesizedCast(containerVar, container, genClass)».«getGetAccessor(self)»()«-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE modifyFeature(targetVar : String, targetType : genmodel::GenClass, value : String) FOR genmodel::GenFeature-»
+«IF isListType(self)-»
+«EXPAND getFeatureValue(targetVar, targetType)».add(«value»);«-»
+«ELSE-»
+«EXPAND setFeatureValue(targetVar, targetType, value)»;«-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE replaceFeatureValue(targetVar : String, targetType : genmodel::GenClass, oldValue : String, newValue : String) FOR genmodel::GenFeature-»
+«IF isListType(self)-»
+ «EXPAND getFeatureValue(targetVar, targetType)».remove(«oldValue»);
+«ENDIF-»
+ «EXPAND modifyFeature(targetVar, targetType, newValue)-»
+«ENDDEFINE»
+
+«DEFINE moveFeatureValue(oldTarget : String, newTarget : String, targetType : genmodel::GenClass, value : String) FOR genmodel::GenFeature-»
+«IF isListType(self)-»
+ «EXPAND getFeatureValue(oldTarget, targetType)».remove(«value»);
+«ELSE-»
+ «EXPAND setFeatureValue(oldTarget, targetType, 'null')»;
+«ENDIF-»
+ «EXPAND modifyFeature(newTarget, targetType, value)-»
+«ENDDEFINE»
+
+«DEFINE setFeatureValue(targetVar : String, targetType : genmodel::GenClass, valueVar : String) FOR genmodel::GenFeature-»
+«EXPAND setFeatureValue(targetVar, targetType, valueVar, false)»«ENDDEFINE»
+
+// FIXME support list features as well, i.e. do .add() instead of eSet
+«DEFINE setFeatureValue(targetVar : String, targetType : genmodel::GenClass, valueVar : String, isPlainObjectValue : Boolean) FOR genmodel::GenFeature-»
+«IF isExternalInterface(targetType)-»
+((org.eclipse.emf.ecore.EObject) «targetVar»).eSet(«EXPAND MetaFeature», «valueVar»)«-»
+«ELSE-»
+«targetVar».set«getAccessorName(self)»(«IF not isPlainObjectValue»«valueVar»«ELSE»«IF isPrimitiveType(self)»«EXPAND _unwrapObjectToPrimitiveValue(valueVar)»«ELSE»(«EXPAND featureTargetType») «valueVar»«ENDIF»«ENDIF»)«-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _unwrapObjectToPrimitiveValue(valueVar : String) FOR genmodel::GenFeature-»
+((«EXPAND featureTargetType») «valueVar»).«ecoreFeature.eType.instanceClassName»Value()«ENDDEFINE»
+
+«DEFINE MetaClass FOR genmodel::GenClassifier»«getQualifiedPackageInterfaceName(genPackage)».eINSTANCE.get«getClassifierAccessorName(self)»()«ENDDEFINE»
+
+«DEFINE MetaFeature FOR genmodel::GenFeature»«getQualifiedPackageInterfaceName(genClass.genPackage)».eINSTANCE.get«getFeatureAccessorName(self)»()«ENDDEFINE»
+
+// SomeFactory.eINSTANCE.createBlaBla();
+//NB: for map entries, the resulting type is EObject, not the qualified interface name. If cast is needed, use (un)parenthesizedCast() extension.
+//see GenClassImpl#hasFactoryInterfaceCreateMethod() for details why map entries should be treated differently
+«DEFINE NewInstance FOR genmodel::GenClass-»
+«IF isMapEntry(self)-»
+«getQualifiedFactoryInterfaceName(genPackage)».«getFactoryInstanceName(genPackage)».create(«EXPAND MetaClass»)«ELSE-»
+«getQualifiedFactoryInterfaceName(genPackage)».«getFactoryInstanceName(genPackage)».create«ecoreClass.name»()«ENDIF-»
+«ENDDEFINE»
+
+// XXX Need to take into account possible GenClass from generated and always available code
+// e.g. Notation or Ecore
+
+«DEFINE NewInstance(varName : String) FOR genmodel::GenClass-»
+«getQualifiedInterfaceName(self)» «varName» = «IF isMapEntry(self)»(«getQualifiedInterfaceName(self)») «ENDIF»«EXPAND NewInstance»;
+«ENDDEFINE»
+
+/*
+ * Ensures value is of type EObject, may be no-op if context GenClass is compatible with EObject.
+ * Note, injected value is not surrounded with parenthesis, may need to introduce another
+ * template to accomplish that if needed.
+ */
+«DEFINE DowncastToEObject(value : String) FOR genmodel::GenClass»«IF isExternalInterface(self)»(org.eclipse.emf.ecore.EObject) «ENDIF»«value»«ENDDEFINE»
+
+/*
+ * Declares new variable of appropriate type and assigns casted value to it.
+ */
+«DEFINE DeclareAndAssign(assignee : String, value : String) FOR genmodel::GenClass-»
+«getQualifiedInterfaceName(self)» «assignee» = («getQualifiedInterfaceName(self)») «value»;«ENDDEFINE»
+
+/*
+ * third boolean parameter is to indicate the value is not EObject, so may
+ * need extra cast in case dynamic model instances are in use.
+ */
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenClass-»
+«EXPAND DeclareAndAssign(assignee, value)»«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenClassifier-»
+«self.getQualifiedClassName()» «assignee» = («self.getQualifiedClassName()») «value»;«ENDDEFINE»
+
+// @see IsContainerInstance
+«DEFINE DeclareAndAssignContainer(assignee : String, _object : String, metaClass : genmodel::GenClass) FOR genmodel::GenClass-»
+«getQualifiedInterfaceName(self)» «assignee» = («getQualifiedInterfaceName(self)») «EXPAND _getEObjectFeature(_object, 'eContainer()') FOR metaClass»;«ENDDEFINE»
+
+/*
+ * Declares new variable of context type and assignes a value obtained from 'src',
+ * which is of type 'srcMetaClass', via 'srcFeature'
+ *
+ * XXX in certain scenarions may need extra cast of the feature value
+ */
+«DEFINE DeclareAndAssign(assignee : String, src : String, srcMetaClass : genmodel::GenClass, srcFeature : genmodel::GenFeature) FOR genmodel::GenClass-»
+«getQualifiedInterfaceName(self)» «assignee» = «EXPAND getFeatureValue(src, srcMetaClass) FOR srcFeature»;«ENDDEFINE»
+
+/*
+ * Same as DeclareAndAssign, with extra operation applied to source object
+ */
+«DEFINE DeclareAndAssign2(assignee : String, src : String, srcMetaClass : genmodel::GenClass, srcFeature : genmodel::GenFeature, srcExt : String, needCast : Boolean) FOR genmodel::GenClass-»
+«getQualifiedInterfaceName(self)» «assignee» = «IF needCast»(«getQualifiedInterfaceName(self)») «ENDIF»«EXPAND getFeatureValue(src, srcMetaClass) FOR srcFeature».«srcExt»;«ENDDEFINE»
+
+/*
+ * Cast value of type EObject to specific type. Would be no-op with dynamic model instances,
+ * therefore, the fact eObjectValue is actually EObject is essential
+ */
+«DEFINE CastEObject(eObjectValue : String) FOR genmodel::GenClass»(«getQualifiedInterfaceName(self)») «eObjectValue»«ENDDEFINE»
+
+/**
+ * Qualified interface name of the generated EClass, or EObject for dynamic models.
+ * Use whenever class name is inevitable (e.g. method arguments)
+ * SHOULD NEVER APPEAR in instanceof or any other similar comparison operation
+ */
+«DEFINE QualifiedClassName FOR genmodel::GenClass»«getQualifiedInterfaceName(self)»«ENDDEFINE»
+«DEFINE QualifiedClassName FOR genmodel::GenClassifier»«self.getQualifiedClassName()»«ENDDEFINE»
+
+«DEFINE PopulateItemProviderFactories(factoryListVar : String) FOR gmfgen::GenEditorGenerator-»
+«FOREACH getAllDomainGenPackages(true)->asSequence() AS genPackage-»
+ «factoryListVar».add(new «getQualifiedItemProviderAdapterFactoryClassName(genPackage)»());
+«ENDFOREACH-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ChildNodeLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ChildNodeLabelEditPart.xpt
new file mode 100644
index 000000000..77cdb1be3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ChildNodeLabelEditPart.xpt
@@ -0,0 +1,90 @@
+/*
+ * 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 Main FOR gmfgen::GenChildLabelNode-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::ChildNodeLabelEditPart::contsructor-»
+
+ «EXPAND getDragTracker-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::TextAware::methods(false, labelReadOnly, labelElementIcon, viewmap, labelModelFacet, self, getDiagram())-»
+
+ «EXPAND xpt::diagram::editparts::Common::notationalListeners-»
+
+«IF getAssistantOutgoingLinks(self)->size() > 0-»
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSource-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSourceAndTarget-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForTarget-»
+«ENDIF-»
+
+«IF getAssistantIncomingLinks(self)->size() > 0-»
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnTarget-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForSource-»
+«ENDIF-»
+
+ «EXPAND handleNotificationEvent-»
+
+ «EXPAND xpt::diagram::editparts::Common::labelFigure FOR viewmap-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenChildLabelNode»extends org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenChildLabelNode»implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenChildLabelNode-»
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant FOR self-»
+
+ «EXPAND impl::diagram::editparts::TextAware::fields FOR self-»
+«ENDDEFINE»
+
+«DEFINE getDragTracker FOR gmfgen::GenChildLabelNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.gef.DragTracker getDragTracker(org.eclipse.gef.Request request) {
+ «EXPAND impl::diagram::editparts::ChildNodeLabelEditPart::getDragTrackerBody-»
+}
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenChildLabelNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::ChildNodeLabelEditPart::createDefaultEditPoliciesBody-»
+}
+«ENDDEFINE»
+
+«DEFINE handleNotificationEvent FOR gmfgen::GenChildLabelNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
+ «EXPAND impl::diagram::editparts::ChildNodeLabelEditPart::handleNotificationEventBody-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenChildLabelNode»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/CompartmentEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/CompartmentEditPart.xpt
new file mode 100644
index 000000000..88cbef8c3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/CompartmentEditPart.xpt
@@ -0,0 +1,74 @@
+/*
+ * 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 Main FOR gmfgen::GenCompartment-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::contsructor-»
+
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::hasModelChildrenChanged-»
+
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::getCompartmentName-»
+
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::createFigure-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::refreshVisuals-»
+
+ «EXPAND handleNotificationEvent-»
+
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::refreshBounds-»
+
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::setRatio-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenCompartment-»
+extends «IF listLayout»org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenCompartment»«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant FOR self-»
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::createDefaultEditPoliciesBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEvent FOR gmfgen::GenCompartment-»
+ «IF isStoringChildPositions(node)-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification notification) {
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::handleNotificationEventBody-»
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenCompartment»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/DiagramEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/DiagramEditPart.xpt
new file mode 100644
index 000000000..a5bfee2c1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/DiagramEditPart.xpt
@@ -0,0 +1,65 @@
+/*
+ * 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 Main FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::DiagramEditPart::_constructor-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::DiagramEditPart::createFigure-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenDiagram»extends org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final static String MODEL_ID = "«editorGen.modelID»"; «EXPAND xpt::Common::nonNLS»
+
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant FOR self-»
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::DiagramEditPart::createDefaultEditPoliciesBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE definionName FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE definionName FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE definionName FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE definionName FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ExternalNodeLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ExternalNodeLabelEditPart.xpt
new file mode 100644
index 000000000..1ca07ce36
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/ExternalNodeLabelEditPart.xpt
@@ -0,0 +1,69 @@
+/*
+ * 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 Main FOR gmfgen::GenExternalNodeLabel-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::ExternalNodeLabelEditPart::initializer-»
+
+ «EXPAND impl::diagram::editparts::ExternalNodeLabelEditPart::_constructor-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::ExternalNodeLabelEditPart::getBorderItemLocator-»
+
+ «EXPAND impl::diagram::editparts::ExternalNodeLabelEditPart::refreshBounds-»
+
+ «EXPAND impl::diagram::editparts::TextAware::methods(false, readOnly, elementIcon, viewmap, modelFacet, node, getDiagram())-»
+
+ «EXPAND handleNotificationEvent-»
+
+ «EXPAND impl::diagram::editparts::ExternalNodeLabelEditPart::createFigure-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenExternalNodeLabel»extends org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenExternalNodeLabel»implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart, org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant FOR self-»
+
+ «EXPAND impl::diagram::editparts::TextAware::fields FOR self-»
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::ExternalNodeLabelEditPart::createDefaultEditPoliciesBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEvent FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
+ «EXPAND impl::diagram::editparts::ExternalNodeLabelEditPart::handleNotificationEventBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenExternalNodeLabel»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkEditPart.xpt
new file mode 100644
index 000000000..ea6902e16
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkEditPart.xpt
@@ -0,0 +1,61 @@
+/*
+ * 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 Main FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::LinkEditPart::_constructor-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::LinkEditPart::addFixedChild-»
+
+ «EXPAND impl::diagram::editparts::LinkEditPart::addChildVisual-»
+
+ «EXPAND impl::diagram::editparts::LinkEditPart::removeFixedChild-»
+
+ «EXPAND impl::diagram::editparts::LinkEditPart::removeChildVisual-»
+
+ «EXPAND impl::diagram::editparts::LinkEditPart::createLinkFigure-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenLink»extends org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenLink-»
+ «IF treeBranch»implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenLink-»
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant-»
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenLink-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::LinkEditPart::createDefaultEditPoliciesBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLink-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkLabelEditPart.xpt
new file mode 100644
index 000000000..930ca5b41
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/LinkLabelEditPart.xpt
@@ -0,0 +1,68 @@
+/*
+ * 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 Main FOR gmfgen::GenLinkLabel-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::LinkLabelEditPart::initializer-»
+
+ «EXPAND impl::diagram::editparts::LinkLabelEditPart::_constructor-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::LinkLabelEditPart::getKeyPoint-»
+
+ «EXPAND impl::diagram::editparts::TextAware::methods(false, readOnly, elementIcon, viewmap, modelFacet, link, getDiagram())-»
+
+ «EXPAND handleNotificationEvent-»
+
+ «EXPAND xpt::diagram::editparts::Common::labelFigure FOR viewmap-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenLinkLabel»extends org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenLinkLabel»implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenLinkLabel-»
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant-»
+
+ «EXPAND impl::diagram::editparts::TextAware::fields-»
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenLinkLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::LinkLabelEditPart::createDefaultEditPoliciesBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEvent FOR gmfgen::GenLinkLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
+ «EXPAND impl::diagram::editparts::LinkLabelEditPart::handleNotificationEventBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLinkLabel-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeEditPart.xpt
new file mode 100644
index 000000000..be08f7974
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeEditPart.xpt
@@ -0,0 +1,131 @@
+/*
+ * 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 Main FOR gmfgen::GenNode-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::_constructor-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::createLayoutEditPolicy-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::createNodeShape(self) FOR viewmap-»
+
+«IF hasFixedChildren(self)-»
+ «EXPAND impl::diagram::editparts::NodeEditPart::addFixedChild-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::removeFixedChild-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::addChildVisual-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::removeChildVisual-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getContentPaneFor-»
+«ENDIF-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::addBorderItem-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::createNodePlate-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getPrimaryDragEditPolicy-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::createFigure-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::setupContentPane-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getContentPane-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::setForegroundColor-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::setBackgroundColor-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::setLineWidth-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::setLineStyle-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getPrimaryChildEditPart-»
+
+«IF getAssistantOutgoingLinks(self)->size() > 0-»
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSource-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnSourceAndTarget-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForTarget-»
+«ENDIF-»
+
+«IF getAssistantIncomingLinks(self)->size() > 0-»
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMARelTypesOnTarget-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::getMATypesForSource-»
+«ENDIF-»
+
+«IF hasChildrenInListCompartments(self)-»
+ «EXPAND impl::diagram::editparts::NodeEditPart::getTargetEditPartMethod-»
+«ENDIF-»
+
+ «EXPAND handleNotificationEvent-»
+
+ «EXPAND impl::diagram::editparts::NodeEditPart::innerClassDeclaration FOR viewmap-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenNode»extends «EXPAND impl::diagram::editparts::NodeEditPart::extendsListContents»«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenNode»«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenNode-»
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant FOR self-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure contentPane;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure primaryShape;
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::NodeEditPart::createDefaultEditPoliciesBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEvent FOR gmfgen::GenNode-»
+«ENDDEFINE»
+
+«DEFINE handleNotificationEvent FOR gmfgen::GenTopLevelNode-»
+ «REM»This code is important for refreshing shortcut decoration
+ on adding corresponding annotation to the View instance.«ENDREM»
+ «IF getDiagram().generateShortcutIcon()-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
+ «EXPAND impl::diagram::editparts::NodeEditPart::handleNotificationEventBody-»
+ }
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNode-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeLabelEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeLabelEditPart.xpt
new file mode 100644
index 000000000..d38fc18ee
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/diagram/editparts/NodeLabelEditPart.xpt
@@ -0,0 +1,69 @@
+/*
+ * 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 Main FOR gmfgen::GenNodeLabel-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartClassName» «EXPAND extendsList» «EXPAND implementsList» {
+
+ «EXPAND attributes-»
+
+ «EXPAND impl::diagram::editparts::NodeLabelEditPart::_constructor-»
+
+ «EXPAND createDefaultEditPolicies-»
+
+ «EXPAND impl::diagram::editparts::TextAware::methods(isStoringChildPositions(node), readOnly, elementIcon, viewmap, modelFacet, node, getDiagram())-»
+
+ «EXPAND xpt::diagram::editparts::Common::notationalListeners-»
+
+ «EXPAND impl::diagram::editparts::NodeLabelEditPart::refreshBounds-»
+
+ «EXPAND handleNotificationEvent-»
+
+ «EXPAND xpt::diagram::editparts::Common::labelFigure FOR viewmap-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenNodeLabel»extends org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenNodeLabel»implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenNodeLabel-»
+ «EXPAND xpt::diagram::editparts::Common::visualIDConstant FOR self-»
+
+ «EXPAND impl::diagram::editparts::TextAware::fields FOR self-»
+«ENDDEFINE»
+
+«DEFINE createDefaultEditPolicies FOR gmfgen::GenNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void createDefaultEditPolicies() {
+ «EXPAND impl::diagram::editparts::NodeLabelEditPart::createDefaultEditPoliciesBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE handleNotificationEvent FOR gmfgen::GenNodeLabel-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
+ «EXPAND impl::diagram::editparts::NodeLabelEditPart::handleNotificationEventBody-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNodeLabel-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/emf-merge.xml b/plugins/org.eclipse.gmf.codegen/templates.migrated/emf-merge.xml
new file mode 100644
index 000000000..c6d592a52
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/emf-merge.xml
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<merge:options
+ indent=" "
+ braceStyle="matching"
+ redirect="Gen"
+ block="\s*@\s*generated\s*NOT\s*(?:\n\r?|\r\n?)"
+ noImport="\s*//\s*import\s+([\w.*]*)\s*;\s*(?:\n\r?|\r\n?)"
+ xmlns:merge="http://www.eclipse.org/org/eclipse/emf/codegen/jmerge/Options">
+
+<!-- Tabbed Standard
+
+ indent="&#x9;"
+ braceStyle="standard"
+
+-->
+
+ <!-- this accepts both new and old style markup. -->
+
+ <merge:dictionaryPattern
+ name="modelMembers"
+ select="Member/getComment"
+ match="@\s*(model)"/>
+
+ <merge:dictionaryPattern
+ name="generatedUnmodifiableMembers"
+ select="Member/getComment"
+ match="@\s*(gen)erated\s*(This field/method[^(?:\n\r?|\r\n?)]*)*(?:\n\r?|\r\n?)"/>
+
+ <merge:dictionaryPattern
+ name="generatedModifiableMembers"
+ select="Member/getComment"
+ match="@\s*generated\s*(modifiable)\s*(?:\n\r?|\r\n?)"/>
+
+ <!-- This is like the above, but for backward compatibility -->
+ <merge:dictionaryPattern
+ name="generatedLastGenMembers"
+ select="Member/getComment"
+ match="@\s*(lastgen).*(?:\n\r?|\r\n?)"/>
+
+ <merge:dictionaryPattern
+ name="orderedMembers"
+ select="Member/getComment"
+ match="@\s*(ordered)\s*(?:\n\r?|\r\n?)"/>
+
+ <!-- Only push Annotations for the Members marked by gen-->
+ <merge:push targetParentMarkup="^gen$" select="Annotation"/>
+
+ <merge:pull
+ sourceMarkup="^modifiable$"
+ sourceGet="Member/getComment"
+ sourceTransfer="(\s*&lt;!--\s*begin-user-doc.*?end-user-doc\s*-->\s*)(?:\n\r?|\r\n?)"
+ targetMarkup="^modifiable$"
+ targetPut="Member/setComment"/>
+ <merge:pull
+ sourceMarkup="^gen$"
+ sourceGet="Member/getComment"
+ sourceTransfer="(\s*&lt;!--\s*begin-user-doc.*?end-user-doc\s*-->\s*)(?:\n\r?|\r\n?)"
+ targetMarkup="^gen$"
+ targetPut="Member/setComment"/>
+ <merge:pull
+ sourceGet="Member/getFlags"
+ targetMarkup="^gen$"
+ equals="Member/getName"
+ targetPut="Member/setFlags"/>
+
+ <merge:pull
+ sourceMarkup="^gen$"
+ sourceGet="AbstractType/getComment"
+ sourceTransfer="(\s*&lt;!--\s*begin-user-doc.*?end-user-doc\s*-->\s*)(?:\n\r?|\r\n?)"
+ targetMarkup="^modifiable$"
+ targetPut="AbstractType/setComment"/>
+
+ <merge:pull
+ sourceGet="Type/getTypeParameters"
+ targetMarkup="^lastgen$|^gen$|^modifiable$|^model$"
+ targetPut="Type/setTypeParameters"/>
+ <merge:pull
+ sourceGet="Type/getSuperclass"
+ targetMarkup="^lastgen$|^gen$|^modifiable$|^model$"
+ targetPut="Type/setSuperclass"/>
+ <merge:pull
+ sourceGet="Type/getSuperInterfaces"
+ sourceTransfer="(\s*@\s*extends|\s*@\s*implements)(.*?)(?:&lt;!--|(?:\n\r?|\r\n?))"
+ targetMarkup="^lastgen$|^gen$|^modifiable$|^model$"
+ targetPut="Type/addSuperInterface"/>
+
+ <merge:pull
+ sourceGet="Enum/getSuperInterfaces"
+ sourceTransfer="(\s*@\s*extends|\s*@\s*implements)(.*?)(?:&lt;!--|(?:\n\r?|\r\n?))"
+ targetMarkup="^lastgen$|^gen$|^modifiable$|^model$"
+ targetPut="Enum/addSuperInterface"/>
+
+ <merge:pull
+ sourceGet="EnumConstant/getArguments"
+ targetMarkup="^lastgen$|^gen$|^modifiable$|^model$"
+ targetPut="EnumConstant/setArguments"/>
+ <merge:pull
+ sourceGet="EnumConstant/getBody"
+ targetMarkup="^lastgen$|^gen$|^modifiable$|^model$$"
+ targetPut="EnumConstant/setBody"/>
+
+ <merge:pull
+ sourceGet="AnnotationTypeMember/getType"
+ targetMarkup="^gen$"
+ targetPut="AnnotationTypeMember/setType"/>
+ <merge:pull
+ sourceGet="AnnotationTypeMember/getDefaultValue"
+ targetMarkup="^gen$"
+ targetPut="AnnotationTypeMember/setDefaultValue"/>
+
+ <merge:pull
+ sourceGet="Initializer/getBody"
+ targetMarkup="^gen$"
+ targetPut="Initializer/setBody"/>
+
+ <merge:pull
+ sourceGet="Field/getType"
+ targetMarkup="^gen$"
+ targetPut="Field/setType"/>
+ <merge:pull
+ sourceGet="Field/getInitializer"
+ targetMarkup="^gen$"
+ targetPut="Field/setInitializer"/>
+
+ <merge:pull
+ sourceGet="Method/getTypeParameters"
+ targetMarkup="^gen$"
+ targetPut="Method/setTypeParameters"/>
+ <merge:pull
+ sourceGet="Method/getReturnType"
+ targetMarkup="^gen$|^model$"
+ targetPut="Method/setReturnType"/>
+ <merge:pull
+ sourceGet="Method/getParameters"
+ targetMarkup="^gen$"
+ targetPut="Method/setParameters"/>
+ <merge:pull
+ sourceGet="Method/getBody"
+ targetMarkup="^gen$"
+ targetPut="Method/setBody"/>
+ <merge:pull
+ sourceGet="Method/getExceptions"
+ targetMarkup="^gen$"
+ targetPut="Method/addException"/>
+
+ <merge:sweep markup="^gen$" select="Member"/>
+ <merge:sweep markup="^org.eclipse.emf.ecore.EMetaObject$" select="Import"/>
+ <merge:sweep markup="^org.eclipse.emf.ecore.impl.EMetaObjectImpl$" select="Import"/>
+ <merge:sweep markup="^org.eclipse.emf.ecore.util.EObjectCompositeEList$" select="Import"/>
+ <merge:sweep markup="^org.eclipse.emf.ecore.util.EObjectCompositeWithInverseEList$" select="Import"/>
+ <merge:sweep markup="^org.eclipse.emf.common.util.AbstractEnumerator$" select="Import"/>
+
+ <merge:sort markup="^ordered$" select="Field"/>
+ <merge:sort markup="^ordered$" select="EnumConstant"/>
+
+<!-- Basic Rules
+
+ <merge:pull
+ sourceGet="CompilationUnit/getHeader"
+ targetPut="CompilationUnit/setHeader"/>
+
+ <merge:pull
+ sourceGet="Package/getName"
+ targetPut="Package/setName"/>
+
+ <merge:pull
+ sourceGet="Member/getFlags"
+ targetPut="Member/setFlags"/>
+ <merge:pull
+ sourceGet="Member/getComment"
+ targetPut="Member/setComment"/>
+
+ <merge:pull
+ sourceGet="Type/getSuperclass"
+ targetPut="Type/setSuperclass"/>
+ <merge:pull
+ sourceGet="Type/getSuperInterfaces"
+ targetPut="Type/addSuperInterface"/>
+
+ <merge:pull
+ sourceGet="Initializer/getBody"
+ targetPut="Initializer/setBody"/>
+
+ <merge:pull
+ sourceGet="Field/getType"
+ targetPut="Field/setType"/>
+ <merge:pull
+ sourceGet="Field/getInitializer"
+ targetPut="Field/setInitializer"/>
+
+ <merge:pull
+ sourceGet="Method/getBody"
+ targetPut="Method/setBody"/>
+ <merge:pull
+ sourceGet="Method/getReturnType"
+ targetPut="Method/setReturnType"/>
+ <merge:pull
+ sourceGet="Method/getExceptions"
+ targetPut="Method/addException"/>
+-->
+
+<!-- Push Enum Constants only for generated Enums -->
+<!--
+ <merge:push targetParentMarkup="^gen$" select="EnumConstant"/>
+-->
+
+<!-- Push Annotation Type Members only for generated Annotation Types -->
+<!--
+ <merge:push targetParentMarkup="^gen$" select="AnnotationTypeMember"/>
+-->
+
+<!-- Sets the content of annotations if the parent is marked with gen -->
+<!--
+ <merge:pull
+ sourceGet="Annotation/getContents"
+ targetParentMarkup="^gen$"
+ targetPut="Annotation/setContents"/>
+-->
+
+<!-- Remove annotations of generated target nodes if the annotation is not in the source -->
+<!--
+ <merge:sweep parentMarkup="^gen$" select="Annotation"/>
+-->
+
+<!--
+ <merge:pull
+ sourceMarkup="^modifiable$"
+ sourceGet="Member/getComment"
+ targetMarkup="^gen$"
+ targetPut="Member/setComment"/>
+-->
+
+</merge:options>
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
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/CustomParser.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/CustomParser.xpt
new file mode 100644
index 000000000..008477657
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/CustomParser.xpt
@@ -0,0 +1,64 @@
+/*
+ * 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) - [244419] custom parsers
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE Main FOR gmfgen::CustomParser»
+«EXPAND xpt::Common::copyright FOR holder.editorGen-»
+«EXPAND xpt::Common::packageStatement FOR qualifiedName»
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «qualifiedName.xpandSplit('\.')->last()»«EXPAND extendsList»«EXPAND implementsList» {
+«EXPAND body»
+«EXPAND additions»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::CustomParser»«ENDDEFINE»
+«DEFINE extendsList FOR gmfgen::CustomParser»«ENDDEFINE»
+«DEFINE implementsList FOR gmfgen::CustomParser» implements org.eclipse.gmf.runtime.common.ui.services.parser.IParser«ENDDEFINE»
+
+«DEFINE body FOR gmfgen::CustomParser»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getEditString(org.eclipse.core.runtime.IAdaptable element, int flags) {
+ return "";
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus isValidEditString(org.eclipse.core.runtime.IAdaptable element, String editString) {
+ // TODO change to EDITABLE_STATUS as appropriate
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.UNEDITABLE_STATUS;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.core.command.ICommand getParseCommand(org.eclipse.core.runtime.IAdaptable element, String newString, int flags) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getPrintString(org.eclipse.core.runtime.IAdaptable element, int flags) {
+ return "";
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean isAffectingEvent(Object event, int flags) {
+ return false;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.jface.text.contentassist.IContentAssistProcessor getCompletionProcessor(org.eclipse.core.runtime.IAdaptable element) {
+ return null;
+ }
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/ParserProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/ParserProvider.xpt
new file mode 100644
index 000000000..b1820c902
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/ParserProvider.xpt
@@ -0,0 +1,61 @@
+/*
+ * 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 Main FOR gmfgen::GenParsers-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «className»«EXPAND extendsList»«EXPAND implementsList» {
+ «EXPAND impl::parsers::ParserProvider::parsers FOREACH editorGen.diagram.topLevelNodes»
+ «EXPAND impl::parsers::ParserProvider::parsers FOREACH editorGen.diagram.childNodes»
+ «EXPAND impl::parsers::ParserProvider::parsers FOREACH editorGen.diagram.links»
+
+«IF extensibleViaService-»
+ «EXPAND impl::parsers::ParserProvider::getParserByVisualIdMethod-»
+ «EXPAND impl::parsers::ParserProvider::accessorMethod_delegate2providers-»
+ «EXPAND impl::parsers::ParserProvider::provider_getParserMethod»
+ «EXPAND impl::parsers::ParserProvider::provider_providesMethod»
+ «EXPAND impl::parsers::ParserProvider::HintAdapterClass»
+«ELSE-»
+ «EXPAND impl::parsers::ParserProvider::accessorMethod_direct-»
+«ENDIF-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenParsers»«IF extensibleViaService» extends org.eclipse.gmf.runtime.common.core.service.AbstractProvider«ENDIF»«ENDDEFINE»
+
+«DEFINE implementsList FOR gmfgen::GenParsers»«IF extensibleViaService» implements org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider«ENDIF»«ENDDEFINE»
+
+/*
+ * this/self - aka hintHolder, visual element to present a text (i.e. one of Node's labels)
+ * elementTypeHolder - model element being displayed
+ * modelFacet - may be null
+ * parsedElement - accessor to EObject being edited
+ */
+«DEFINE accessorCall(elementTypeHolder : gmfgen::GenCommonBase, labelModelFacet : gmfgen::LabelModelFacet, parsedElement : String) FOR gmfgen::GenCommonBase-»
+«IF getDiagram().editorGen.labelParsers.extensibleViaService-»
+«EXPAND impl::parsers::ParserProvider::accessorCall_delegate2providers(elementTypeHolder, labelModelFacet, parsedElement)-»
+«ELSE-»
+«EXPAND impl::parsers::ParserProvider::accessorCall_direct(elementTypeHolder, labelModelFacet, parsedElement)-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenParsers»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/PredefinedParser.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/PredefinedParser.xpt
new file mode 100644
index 000000000..5c8128b4e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/parsers/PredefinedParser.xpt
@@ -0,0 +1,322 @@
+/*
+ * 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 implementation
+ * Artem Tikhomirov (Borland) - [235113] alternative parser access
+ * [244419] custom parsers
+ * initial API
+ */
+
+«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 Main FOR gmfgen::PredefinedParser»
+«EXPAND xpt::Common::copyright FOR holder.editorGen-»
+package «holder.implPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «className» extends «EXPAND impl::parsers::AbstractParser::qualifiedClassName FOR holder» {
+
+«EXPAND fields»
+«EXPAND cons»
+«EXPAND aux_methods»
+«EXPAND parser_getEditStringMethod»
+«EXPAND parser_isValidEditStringMethod»
+«EXPAND parser_getParseCommandMethod»
+«EXPAND parser_getPrintStringMethod»
+«EXPAND parser_isAffectingEventMethod»
+«EXPAND parser_getCompletionProcessorMethod»
+«EXPAND additions»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::PredefinedParser»«ENDDEFINE»
+
+«DEFINE fields FOR gmfgen::PredefinedParser-»
+«IF viewMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT or viewMethod = gmfgen::LabelTextAccessMethod::PRINTF-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String defaultPattern;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String defaultEditablePattern;
+«ENDIF-»
+«IF viewMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.text.MessageFormat viewProcessor;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.text.MessageFormat editorProcessor;
+«ENDIF-»
+«IF editMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.text.MessageFormat editProcessor;
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE cons FOR gmfgen::PredefinedParser-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «className»(org.eclipse.emf.ecore.EAttribute[] features) {
+ super(features);
+«IF viewMethod = gmfgen::LabelTextAccessMethod::NATIVE or editMethod = gmfgen::LabelTextAccessMethod::NATIVE-»
+ if (features.length != 1) {
+ throw new IllegalArgumentException(java.util.Arrays.toString(features));
+ }
+«ENDIF-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «className»(org.eclipse.emf.ecore.EAttribute[] features, org.eclipse.emf.ecore.EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+«IF viewMethod = gmfgen::LabelTextAccessMethod::NATIVE or editMethod = gmfgen::LabelTextAccessMethod::NATIVE-»
+ if (features.length != 1) {
+ throw new IllegalArgumentException(java.util.Arrays.toString(features));
+ }
+ if (editableFeatures.length != 1) {
+ throw new IllegalArgumentException(java.util.Arrays.toString(editableFeatures));
+ }
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE aux_methods FOR gmfgen::PredefinedParser-»
+«IF viewMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getDefaultPattern() {
+ if (defaultPattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < features.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('{');
+ sb.append(i);
+ sb.append('}');
+ }
+ defaultPattern = sb.toString();
+ }
+ return defaultPattern;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setViewPattern(String viewPattern) {
+ super.setViewPattern(viewPattern);
+ viewProcessor = null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setEditorPattern(String editorPattern) {
+ super.setEditorPattern(editorPattern);
+ editorProcessor = null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.text.MessageFormat getViewProcessor() {
+ if (viewProcessor == null) {
+ viewProcessor = new java.text.MessageFormat(getViewPattern() == null ? getDefaultPattern() : getViewPattern());
+ }
+ return viewProcessor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.text.MessageFormat getEditorProcessor() {
+ if (editorProcessor == null) {
+ editorProcessor = new java.text.MessageFormat(getEditorPattern() == null ? getDefaultEditablePattern() : getEditorPattern());
+ }
+ return editorProcessor;
+ }
+«ELSEIF viewMethod = gmfgen::LabelTextAccessMethod::PRINTF-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getDefaultPattern() {
+ if (defaultPattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < features.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('%');
+ sb.append(i + 1);
+ sb.append('$');
+ sb.append('s');
+ }
+ defaultPattern = sb.toString();
+ }
+ return defaultPattern;
+ }
+«ENDIF-»
+«IF viewMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT or editMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getDefaultEditablePattern() {
+ if (defaultEditablePattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < editableFeatures.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('{');
+ sb.append(i);
+ sb.append('}');
+ }
+ defaultEditablePattern = sb.toString();
+ }
+ return defaultEditablePattern;
+ }
+«ENDIF-»
+«IF viewMethod = gmfgen::LabelTextAccessMethod::PRINTF or editMethod = gmfgen::LabelTextAccessMethod::PRINTF-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getDefaultEditablePattern() {
+ if (defaultEditablePattern == null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < editableFeatures.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append('%');
+ sb.append(i + 1);
+ sb.append('$');
+ sb.append('s');
+ }
+ defaultEditablePattern = sb.toString();
+ }
+ return defaultEditablePattern;
+ }
+«ENDIF-»
+«IF editMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setEditPattern(String editPattern) {
+ super.setEditPattern(editPattern);
+ editProcessor = null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.text.MessageFormat getEditProcessor() {
+ if (editProcessor == null) {
+ editProcessor = new java.text.MessageFormat(getEditPattern() == null ? getDefaultEditablePattern() : getEditPattern());
+ }
+ return editProcessor;
+ }
+«ELSEIF editMethod = gmfgen::LabelTextAccessMethod::REGEXP-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getEditPattern() {
+ String pattern = super.getEditPattern();
+ return pattern != null ? pattern : " ";«EXPAND xpt::Common::nonNLS»
+ }
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE parser_getEditStringMethod FOR gmfgen::PredefinedParser-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getEditString(org.eclipse.core.runtime.IAdaptable adapter, int flags) {
+«IF viewMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT-»
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new java.text.FieldPosition(0)).toString();
+«ELSEIF viewMethod = gmfgen::LabelTextAccessMethod::PRINTF-»
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ String pattern = getEditorPattern() == null ? getDefaultEditablePattern() : getEditorPattern();
+ return String.format(pattern, getEditableValues(element));
+«ELSEIF viewMethod = gmfgen::LabelTextAccessMethod::REGEXP-»
+ return "";«EXPAND xpt::Common::nonNLS»
+«ELSEIF viewMethod = gmfgen::LabelTextAccessMethod::NATIVE-»
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ String s = org.eclipse.emf.ecore.util.EcoreUtil.convertToString(editableFeatures[0].getEAttributeType(), element.eGet(editableFeatures[0]));
+ return s != null ? s : "";«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE parser_isValidEditStringMethod FOR gmfgen::PredefinedParser-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus isValidEditString(org.eclipse.core.runtime.IAdaptable adapter, String editString) {
+«IF editMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT-»
+ java.text.ParsePosition pos = new java.text.ParsePosition(0);
+ Object[] values = getEditProcessor().parse(editString, pos);
+ if (values == null) {
+ return new org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus(
+ «holder.editorGen.plugin.getActivatorQualifiedClassName()».ID,
+ org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus.UNEDITABLE,
+ org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForMessageFormatParserInvalidInputError()) FOR holder.editorGen»,
+ new Integer(pos.getErrorIndex())));
+ }
+ return validateNewValues(values);
+«ELSEIF editMethod = gmfgen::LabelTextAccessMethod::PRINTF-»
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.UNEDITABLE_STATUS;
+«ELSEIF editMethod = gmfgen::LabelTextAccessMethod::REGEXP-»
+ if (editString == null) {
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.UNEDITABLE_STATUS;
+ }
+ Object[] values = editString.split(getEditPattern());
+ return validateNewValues(values);
+«ELSEIF editMethod = gmfgen::LabelTextAccessMethod::NATIVE-»
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.EDITABLE_STATUS;
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE parser_getParseCommandMethod FOR gmfgen::PredefinedParser-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.core.command.ICommand getParseCommand(org.eclipse.core.runtime.IAdaptable adapter, String newString, int flags) {
+«IF editMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT-»
+ Object[] values = getEditProcessor().parse(newString, new java.text.ParsePosition(0));
+ return getParseCommand(adapter, values, flags);
+«ELSEIF editMethod = gmfgen::LabelTextAccessMethod::PRINTF-»
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+«ELSEIF editMethod = gmfgen::LabelTextAccessMethod::REGEXP-»
+ if (newString == null) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+ Object[] values = newString.split(getEditPattern());
+ return super.getParseCommand(adapter, values, flags);
+«ELSEIF editMethod = gmfgen::LabelTextAccessMethod::NATIVE-»
+ Object value = org.eclipse.emf.ecore.util.EcoreUtil.createFromString(editableFeatures[0].getEAttributeType(), newString);
+ return getParseCommand(adapter, new Object[] { value }, flags);
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE parser_getPrintStringMethod FOR gmfgen::PredefinedParser-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getPrintString(org.eclipse.core.runtime.IAdaptable adapter, int flags) {
+«IF viewMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT-»
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ return getViewProcessor().format(getValues(element), new StringBuffer(), new java.text.FieldPosition(0)).toString();
+«ELSEIF viewMethod = gmfgen::LabelTextAccessMethod::PRINTF-»
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ return String.format(getViewPattern() == null ? getDefaultPattern() : getViewPattern(), getValues(element));
+«ELSEIF viewMethod = gmfgen::LabelTextAccessMethod::REGEXP-»
+ return "";«EXPAND xpt::Common::nonNLS»
+«ELSEIF viewMethod = gmfgen::LabelTextAccessMethod::NATIVE-»
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ String s = org.eclipse.emf.ecore.util.EcoreUtil.convertToString(features[0].getEAttributeType(), element.eGet(features[0]));
+ return s != null ? s : "";«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE parser_isAffectingEventMethod FOR gmfgen::PredefinedParser-»
+«REM»NO-OP, rely on superclass for now«ENDREM-»
+«ENDDEFINE»
+
+«DEFINE parser_getCompletionProcessorMethod FOR gmfgen::PredefinedParser-»
+«REM»NO-OP, rely on superclass for now«ENDREM-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenParsers-»
+«IF (implementations)[gmfgen::PredefinedParser]->exists(p | p.editMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT)»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForMessageFormatParserInvalidInputError(), 'Invalid input at {0}')-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenParsers-»
+«IF (implementations)[gmfgen::PredefinedParser]->exists(p | p.editMethod = gmfgen::LabelTextAccessMethod::MESSAGE_FORMAT)»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForMessageFormatParserInvalidInputError())-»
+«ENDIF-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Common.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Common.xpt
new file mode 100644
index 000000000..421705dbd
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Common.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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::NonNLSUtils»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE copyright FOR gmfgen::GenEditorGenerator-»
+«IF copyrightText <> null-»
+/*
+ * «copyrightText.xpandReplaceAll('
+', '
+ * ')»
+ */
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE xcopyright FOR gmfgen::GenEditorGenerator-»
+«IF copyrightText <> null-»
+<!--
+«copyrightText»
+-->
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE generatedClassComment FOR OclAny»«EXPAND generatedClassComment('')»«ENDDEFINE»
+«DEFINE generatedClassComment(comment : String) FOR OclAny-»
+/**
+«IF comment.xpandLength() > 0-»
+ * «comment.xpandReplaceAll('
+', '
+ * ')»
+«ENDIF-»
+ * @generated
+ */«ENDDEFINE»
+
+«DEFINE generatedMemberComment FOR Collection(OclAny)»«EXPAND generatedMemberComment('') FOR ''»«ENDDEFINE»
+«DEFINE generatedMemberComment FOR OclAny»«EXPAND generatedMemberComment('')»«ENDDEFINE»
+«DEFINE generatedMemberComment(comment : String) FOR OclAny-»
+/**
+«IF comment.xpandLength() > 0-»
+ * «comment.xpandReplaceAll('
+', '
+ * ')»
+«ENDIF-»
+ * @generated
+ */«ENDDEFINE»
+
+«DEFINE xmlGeneratedTag FOR OclAny»<?gmfgen generated="true"?>«ENDDEFINE»
+
+«DEFINE getSaveOptions FOR gmfgen::GenDiagram»«getDiagramEditorUtilQualifiedClassName()».getSaveOptions()«ENDDEFINE»
+
+«DEFINE setCharset(varName : String) FOR gmfgen::GenDiagram-»
+«getDiagramEditorUtilQualifiedClassName()».setCharset(«varName»);
+«ENDDEFINE»
+
+«DEFINE nonNLS FOR OclAny»«EXPAND nonNLS(1)»«ENDDEFINE»
+
+«DEFINE nonNLS FOR Collection(OclAny)»«EXPAND nonNLS FOR getNonNLSCounter(self)»«ENDDEFINE»
+
+«DEFINE nonNLS FOR Collection(Integer)»«EXPAND nonNLS FOREACH self»«ENDDEFINE»
+
+«DEFINE nonNLS(i : Integer) FOR OclAny»«EXPAND nonNLS FOR i»«ENDDEFINE»
+
+«DEFINE nonNLS FOR Integer» //$NON-NLS-«self»$«ENDDEFINE»
+
+«DEFINE caseVisualID FOR gmfgen::GenCommonBase»case «EXPAND xpt::editor::VisualIDRegistry::visualID»:«ENDDEFINE»
+
+«DEFINE addShortcutAnnotation(viewVar : String) FOR gmfgen::GenDiagram-»
+ org.eclipse.emf.ecore.EAnnotation shortcutAnnotation = org.eclipse.emf.ecore.EcoreFactory.eINSTANCE.createEAnnotation();
+ shortcutAnnotation.setSource("Shortcut"); «EXPAND xpt::Common::nonNLS»
+ shortcutAnnotation.getDetails().put("modelID", «getEditPartQualifiedClassName()».MODEL_ID); «EXPAND xpt::Common::nonNLS»
+ «viewVar».getEAnnotations().add(shortcutAnnotation);
+«ENDDEFINE»
+
+
+«DEFINE packageStatement FOR String-»
+«IF self.xpandSplit('\.')->size() > 1-»
+package «FOREACH let tmpVar = self.xpandSplit('\.') in if tmpVar->size() < 2 then Sequence{}[String] else tmpVar->subSequence(1, tmpVar->size() - 1) endif AS s SEPARATOR '.'»«s»«ENDFOREACH»;«ENDIF-»
+«ENDDEFINE»
+
+// Provides handy single point to override generation of assert statements
+// TODO refactor this Common.xpt into different flavours - like CommonCodeStyle (nls, assert), CommonSnippets(pkgStmt, setCharset, getSaveOptions) and so on
+«DEFINE _assert(condition : String) FOR OclAny-»
+assert «condition»;«IF condition.xpandToCharList()->includes('"')»«EXPAND nonNLS»«ENDIF»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ConstraintProviders.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ConstraintProviders.xpt
new file mode 100644
index 000000000..9fd68e5ec
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ConstraintProviders.xpt
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::GenAuditRoot»
+«EXTENSION xpt::GenEditorGenerator»
+«EXTENSION xpt::NativeGenAuditRoot»
+
+«DEFINE extensions FOR gmfgen::GenEditorGenerator-»
+«IF hasAudits(self)»«EXPAND extensions FOR audits»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE extensions FOR gmfgen::GenAuditRoot-»
+«EXPAND extensions_emfv_constraintProviders»
+«EXPAND extensions_emfv_constraintBindings»
+«EXPAND extensions_emfv_uiContexts»
+«ENDDEFINE»
+
+//
+// Extension point: org.eclipse.emf.validation.constraintProviders
+//
+«DEFINE extensions_emfv_constraintProviders FOR gmfgen::GenAuditRoot-»
+ <extension point="org.eclipse.emf.validation.constraintProviders">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ «EXPAND declareCategory FOREACH categories-»
+ <constraintProvider cache="true">
+«FOREACH getAllTargetedModelPackages(self) AS p-»
+ <package namespaceUri="«p.ecorePackage.nsURI»"/>
+«ENDFOREACH-»
+ «EXPAND defineCategory FOREACH categories-»
+ </constraintProvider>
+ </extension>
+«ENDDEFINE»
+
+//
+// Extension point: org.eclipse.emf.validation.constraintBindings
+//
+«DEFINE extensions_emfv_constraintBindings FOR gmfgen::GenAuditRoot-»
+ <extension point="org.eclipse.emf.validation.constraintBindings">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+«FOREACH clientContexts->asSequence() AS ctx-»
+ <clientContext default="false" id="«getQualifiedIdentity(ctx)»">
+ <selector class="«ctx.getQualifiedClassName()»"/>
+ </clientContext>
+ <binding context="«getQualifiedIdentity(ctx)»">
+ «FOREACH rules->select(r | r.target <> null and r.target.contextSelector = ctx)->asSequence() /*alternative: ctx.ruleTargets.contains(r.target)*/ AS rule-»
+ <constraint ref="«editorGen.plugin.iD».«escapeXML(rule.id)»"/>
+ «ENDFOREACH-»
+ </binding>
+
+«ENDFOREACH-»
+ </extension>
+«ENDDEFINE»
+
+//
+// Extension point: org.eclipse.emf.validation.ui.UIRegisteredClientContext
+//
+«DEFINE extensions_emfv_uiContexts FOR gmfgen::GenAuditRoot-»
+«IF editorGen.diagram.liveValidationUIFeedback»
+ <extension point="org.eclipse.emf.validation.ui.UIRegisteredClientContext">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+«FOREACH clientContexts->asSequence() AS ctx-»
+ <clientContext id="«getQualifiedIdentity(ctx)»"/>
+«ENDFOREACH-»
+ </extension>
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE declareCategory FOR gmfgen::GenAuditContainer-»
+ <category id="«EXPAND _pathMap»" mandatory="false" name="«IF name <> null»«escapeXML(name)»«ELSE»«EXPAND _pathMap»«ENDIF»">
+ <![CDATA[«(if description <> null then description else '' endif)»]]>
+ </category>
+«ENDDEFINE»
+
+«DEFINE defineCategory FOR gmfgen::GenAuditContainer-»
+ <constraints categories="«EXPAND _pathMap»">
+ «FOREACH audits->select(a | a.target <> null and a.target.getTargetClass() <> null)->asSequence() AS audit-»
+ <constraint id="«escapeXML(audit.id)»"
+ «IF audit.requiresConstraintAdapter»lang="Java" class="«audit.getConstraintAdapterQualifiedClassName()»"«ELSE»lang="OCL"«ENDIF»
+ name="«escapeXML((if audit.name <> null then audit.name else audit.id endif))»"
+ mode="«IF audit.useInLiveMode»Live«ELSE»Batch«ENDIF»"
+ severity="«audit.severity.repr()»" statusCode="200">
+ «IF not audit.requiresConstraintAdapter»<![CDATA[«(if audit.rule <> null then audit.rule.body else '' endif)»]]>«ENDIF»
+ <description><![CDATA[«(if audit.description <> null then audit.description else '' endif)»]]></description>
+ <message><![CDATA[«IF audit.message <> null»«audit.message»«ELSE»«(if audit.name <> null then audit.name else audit.id endif)» audit violated«ENDIF»]]></message>
+ <target class="«audit.target.getTargetClassModelQualifiedName()»"/>
+ </constraint>
+ «ENDFOREACH-»
+ </constraints>
+«ENDDEFINE»
+
+«DEFINE _pathMap FOR gmfgen::GenAuditContainer»«FOREACH path->asSequence() AS p SEPARATOR '/' »«escapeXML(p.id)»«ENDFOREACH»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/EMFUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/EMFUtils.qvto
new file mode 100644
index 000000000..5c31c9afb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/EMFUtils.qvto
@@ -0,0 +1,3 @@
+library EMFUtils;
+
+
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Externalizer.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Externalizer.xpt
new file mode 100644
index 000000000..4e8ef19d1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/Externalizer.xpt
@@ -0,0 +1,102 @@
+/*
+ * 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:
+ * Anna Karjakina (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::ExternalizerUtils»
+
+«DEFINE Access FOR gmfgen::GenEditorGenerator-»
+«EXPAND xpt::Common::copyright-»
+package «getExternalizerPackageName(self)»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «getExternalizerClassName()» extends org.eclipse.osgi.util.NLS {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ static {
+ org.eclipse.osgi.util.NLS.initializeMessages("«getExternalizerClassName().toLower()»", «getExternalizerClassName()».class); «EXPAND xpt::Common::nonNLS»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «getExternalizerClassName()»() {
+ }
+
+ «EXPAND Fields»
+ //TODO: put accessor fields manually
+}
+«ENDDEFINE»
+
+«DEFINE Fields FOR gmfgen::GenEditorGenerator»
+ «EXPAND impl::actions::CreateShortcutAction::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::CreationWizard::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::CreationWizardPage::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::DiagramEditorUtil::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::DocumentProvider::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::InitDiagramFileAction::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::NewDiagramFileWizard::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::Editor::i18nAccessors FOR editor-»
+ «EXPAND xpt::editor::ElementChooser::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::ShortcutCreationWizard::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::ModelElementSelectionPage::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::ValidateAction::i18nAccessors FOR diagram-»
+ «EXPAND xpt::editor::palette::PaletteFactory::i18nAccessors FOR diagram.palette-»
+ «EXPAND xpt::application::ActionBarAdvisor::i18nAccessors FOR application-»
+ «EXPAND xpt::application::WorkbenchWindowAdvisor::i18nAccessors FOR application-»
+ «EXPAND xpt::application::WizardNewFileCreationPage::i18nAccessors FOR application-»
+ «EXPAND impl::diagram::editparts::CompartmentEditPart::i18nAccessors FOR diagram-»
+ «EXPAND xpt::diagram::editpolicies::OpenDiagram::i18nAccessors FOR diagram-»
+ «EXPAND xpt::navigator::NavigatorContentProvider::i18nAccessors FOR navigator-»
+ «EXPAND xpt::navigator::NavigatorActionProvider::i18nAccessors FOR navigator-»
+ «EXPAND impl::parsers::AbstractParser::i18nAccessors FOR labelParsers-»
+ «EXPAND parsers::PredefinedParser::i18nAccessors FOR labelParsers-»
+ «EXPAND xpt::providers::ModelingAssistantProvider::i18nAccessors FOR diagram-»
+«ENDDEFINE»
+
+«DEFINE Values FOR gmfgen::GenEditorGenerator»
+# TODO: manually put keys and values
+«EXPAND impl::actions::CreateShortcutAction::i18nValues FOR diagram-»
+«EXPAND xpt::editor::CreationWizard::i18nValues FOR diagram-»
+«EXPAND xpt::editor::CreationWizardPage::i18nValues FOR diagram-»
+«EXPAND xpt::editor::DiagramEditorUtil::i18nValues FOR diagram-»
+«EXPAND xpt::editor::DocumentProvider::i18nValues FOR diagram-»
+«EXPAND xpt::editor::InitDiagramFileAction::i18nValues FOR diagram-»
+«EXPAND xpt::editor::NewDiagramFileWizard::i18nValues FOR diagram-»
+«EXPAND xpt::editor::Editor::i18nValues FOR editor-»
+«EXPAND xpt::editor::ElementChooser::i18nValues FOR diagram-»
+«EXPAND xpt::editor::ShortcutCreationWizard::i18nValues FOR diagram-»
+«EXPAND xpt::editor::ModelElementSelectionPage::i18nValues FOR diagram-»
+«EXPAND xpt::editor::ValidateAction::i18nValues FOR diagram-»
+«EXPAND xpt::editor::palette::PaletteFactory::i18nValues FOR diagram.palette-»
+«EXPAND xpt::application::ActionBarAdvisor::i18nValues FOR application-»
+«EXPAND xpt::application::WorkbenchWindowAdvisor::i18nValues FOR application-»
+«EXPAND xpt::application::WizardNewFileCreationPage::i18nValues FOR application-»
+«EXPAND impl::diagram::editparts::CompartmentEditPart::i18nValues FOR diagram-»
+«EXPAND xpt::diagram::editpolicies::OpenDiagram::i18nValues FOR diagram-»
+«EXPAND xpt::navigator::NavigatorContentProvider::i18nValues FOR navigator-»
+«EXPAND xpt::navigator::NavigatorActionProvider::i18nValues FOR navigator-»
+«EXPAND impl::parsers::AbstractParser::i18nValues FOR labelParsers-»
+«EXPAND parsers::PredefinedParser::i18nValues FOR labelParsers-»
+«EXPAND xpt::providers::ModelingAssistantProvider::i18nValues FOR diagram-»
+«ENDDEFINE»
+
+«DEFINE accessorField(key : String) FOR OclAny»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static String «escapeIllegalKeySymbols(key)»;
+«ENDDEFINE»
+
+«DEFINE messageEntry(key : String, message : String) FOR OclAny-»
+«escapeIllegalKeySymbols(key)»=«escapeIllegalMessageSymbols(message)»
+«ENDDEFINE»
+
+«DEFINE accessorCall(key : String) FOR gmfgen::GenEditorGenerator-»
+«getExternalizerPackageName(self)».«getExternalizerClassName()».«escapeIllegalKeySymbols(key)»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ExternalizerUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ExternalizerUtils.qvto
new file mode 100644
index 000000000..32cae5298
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/ExternalizerUtils.qvto
@@ -0,0 +1,21 @@
+import xpt.StringOperations;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library ExternalizerUtils;
+
+helper getExternalizerPackageName(generator : genModel::GenEditorGenerator) : String {
+ return generator.editor.packageName
+}
+
+helper getExternalizerClassName() : String {
+ return 'Messages'
+}
+
+helper escapeIllegalKeySymbols(key : String) : String {
+ return key.xpandReplaceAll('[=&"]', '').xpandReplaceAll('[ .]', '_')
+}
+
+helper escapeIllegalMessageSymbols(message : String) : String {
+ return message.xpandReplaceAll('!', '\\!')
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenAuditRoot.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenAuditRoot.qvto
new file mode 100644
index 000000000..4c8839345
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenAuditRoot.qvto
@@ -0,0 +1,35 @@
+import xpt.GenEditorGenerator;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
+
+library GenAuditRoot;
+
+helper getAllTargetedModelPackages(root : genModel::GenAuditRoot) : Sequence(genModel_1::GenPackage) {
+ return root.rules->select(r | r.target <> null and r.target.getTargetClass() <> null)->collect(r | r.target.getTargetClass().genPackage)->asOrderedSet()->asSequence()
+}
+
+helper getQualifiedIdentity(ctx : genModel::GenAuditContext) : String {
+ return ctx.root.editorGen.plugin.iD + ctx.id
+}
+
+helper hasDiagramElementTargetRule(audits : genModel::GenAuditRoot) : Boolean {
+ return audits <> null and (audits.rules.target)[genModel::GenDiagramElementTarget]->size() > 0
+}
+
+helper hasAnyNotationElementTargetRule(audits : genModel::GenAuditRoot) : Boolean {
+ return audits <> null and (audits.rules.target)[genModel::GenNotationElementTarget]->size() > 0
+}
+
+helper shouldRunValidateOnDiagram(audits : genModel::GenAuditRoot) : Boolean {
+ return hasDiagramElementTargetRule(audits) or hasAnyNotationElementTargetRule(audits)
+}
+
+helper getTargetDiagramElements(ctx : genModel::GenAuditContext) : Sequence(genModel::GenCommonBase) {
+ return (ctx.ruleTargets)[genModel::GenDiagramElementTarget].element->asOrderedSet()->asSequence()
+}
+
+helper getAllTargetDiagramElements(root : genModel::GenAuditRoot) : Sequence(genModel::GenCommonBase) {
+ return root.clientContexts->collect(it | getTargetDiagramElements(it))->asOrderedSet()->asSequence()
+}
+
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenEditorGenerator.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenEditorGenerator.qvto
new file mode 100644
index 000000000..e2ca0489d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenEditorGenerator.qvto
@@ -0,0 +1,7 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library GenEditorGenerator;
+
+helper hasAudits(editorGen : genModel::GenEditorGenerator) : Boolean {
+ return editorGen.audits <> null and not editorGen.audits.rules->isEmpty()
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenModelUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenModelUtils.qvto
new file mode 100644
index 000000000..725ac349e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/GenModelUtils.qvto
@@ -0,0 +1,40 @@
+import xpt.NativeGenModelUtils;
+import xpt.StringOperations;
+
+modeltype genModel uses "http://www.eclipse.org/emf/2002/GenModel";
+modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
+
+library GenModelUtils;
+
+
+
+helper getReverse(feature : genModel::GenFeature) : genModel::GenFeature {
+ return (if isReferenceType(feature) then let eReverseFeature = feature.ecoreFeature.oclAsType(ecore::EReference).eOpposite in (if eReverseFeature <> null then let genClass = findGenClassifier(feature.genClass.genPackage.genModel, eReverseFeature.eContainingClass).oclAsType(genModel::GenClass) in (if genClass <> null then genClass.genFeatures->select(e | e.ecoreFeature = eReverseFeature)->first() else null endif) else null endif) else null endif)
+}
+
+helper getObjectCompatibleClassName(dt : ecore::EDataType) : String {
+ return (if dt.instanceClassName.xpandToCharList()->includes('.') then dt.instanceClassName else switch { case (dt.instanceClassName = 'boolean') 'java.lang.Boolean'; case (dt.instanceClassName = 'byte') 'java.lang.Byte'; case (dt.instanceClassName = 'char') 'java.lang.Character'; case (dt.instanceClassName = 'double') 'java.lang.Double'; case (dt.instanceClassName = 'float') 'java.lang.Float'; case (dt.instanceClassName = 'int') 'java.lang.Integer'; case (dt.instanceClassName = 'long') 'java.lang.Long'; case (dt.instanceClassName = 'short') 'java.lang.Short'; else 'java.lang.Object'; } endif)
+}
+
+
+
+
+helper getTypeGenClassifier(feature : genModel::GenFeature) : genModel::GenClassifier {
+ return findGenClassifier(feature.genClass.genPackage.genModel, feature.ecoreFeature.eType)
+}
+
+helper isExternalInterface(genClass : genModel::GenClass) : Boolean {
+ return null <> genClass.ecoreClass.instanceClassName
+}
+
+helper isContains(gf : genModel::GenFeature) : Boolean {
+ return isReferenceType(gf) and gf.ecoreFeature.oclAsType(ecore::EReference).containment
+}
+
+helper isPrimitiveType(gf : genModel::GenFeature) : Boolean {
+ return Sequence { 'boolean', 'byte', 'char', 'double', 'float', 'int', 'long', 'short' }->includes(gf.ecoreFeature.eType.instanceClassName)
+}
+
+helper isReferenceType(gf : genModel::GenFeature) : Boolean {
+ return not (Sequence { gf.ecoreFeature })[ecore::EReference]->isEmpty()
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/NonNLSUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/NonNLSUtils.qvto
new file mode 100644
index 000000000..cd397dc70
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/NonNLSUtils.qvto
@@ -0,0 +1,21 @@
+library NonNLSUtils;
+
+property counter : Sequence(Integer) = Sequence{};
+
+helper incrementNonNLSCounter() : OclVoid {
+ counter := counter->including(counter->size() + 1);
+ return null
+}
+
+helper resetNonNLSCounter() : OclVoid {
+ counter := Sequence { };
+ return null
+}
+
+helper getNonNLSCounter() : Sequence(Integer) {
+ return counter;
+}
+
+helper getNonNLSCounter(collection : Collection(OclAny)) : Sequence(Integer) {
+ return collection->iterate(element : OclAny; acc : Sequence(Integer) = Sequence{} | acc->including(acc->size() + 1))
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/ActionBarAdvisor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/ActionBarAdvisor.xpt
new file mode 100644
index 000000000..cb8567652
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/ActionBarAdvisor.xpt
@@ -0,0 +1,266 @@
+/*
+ * 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'»
+
+«EXTENSION xpt::application::i18n»
+
+«DEFINE ActionBarAdvisor FOR gmfgen::GenApplication-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «actionBarAdvisorClassName» extends org.eclipse.ui.application.ActionBarAdvisor {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.actions.ActionFactory.IWorkbenchAction lockToolBarAction;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.actions.ActionFactory.IWorkbenchAction toggleCoolbarAction;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «actionBarAdvisorClassName»(org.eclipse.ui.application.IActionBarConfigurer configurer) {
+ super(configurer);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbenchWindow getWindow() {
+ return getActionBarConfigurer().getWindowConfigurer().getWindow();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void makeActions(org.eclipse.ui.IWorkbenchWindow window) {
+ toggleCoolbarAction = org.eclipse.ui.actions.ActionFactory.TOGGLE_COOLBAR.create(window);
+ register(toggleCoolbarAction);
+ lockToolBarAction = org.eclipse.ui.actions.ActionFactory.LOCK_TOOL_BAR.create(window);
+ register(lockToolBarAction);
+ «EXPAND makeAction('window') FOREACH sharedContributionItems-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void fillMenuBar(org.eclipse.jface.action.IMenuManager menu) {
+ «EXPAND fill('menu') FOR mainMenu-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void fillCoolBar(org.eclipse.jface.action.ICoolBarManager toolBar) {
+ org.eclipse.jface.action.IMenuManager popUpMenu = new org.eclipse.jface.action.MenuManager();
+ popUpMenu.add(new org.eclipse.jface.action.ActionContributionItem(lockToolBarAction));
+ popUpMenu.add(new org.eclipse.jface.action.ActionContributionItem(toggleCoolbarAction));
+ toolBar.setContextMenuManager(popUpMenu);
+ «EXPAND fill('toolBar') FOR mainToolBar-»
+ }
+
+ «EXPAND openEditor FOR editorGen.editor-»
+
+ «EXPAND actions-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE openEditor FOR gmfgen::GenEditorView-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static boolean openEditor(org.eclipse.ui.IWorkbench workbench, org.eclipse.emf.common.util.URI fileURI) {
+ org.eclipse.ui.IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ org.eclipse.ui.IWorkbenchPage page = workbenchWindow.getActivePage();
+ org.eclipse.ui.IEditorDescriptor editorDescriptor =
+ workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());
+ if (editorDescriptor == null) {
+ org.eclipse.jface.dialogs.MessageDialog.openError(workbenchWindow.getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForDefaultFileEditorErrorDialog(editorGen.application))) FOR editorGen»,
+ org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForDefaultFileEditorErrorDialog(editorGen.application))) FOR editorGen»,
+ fileURI.toFileString()));
+ return false;
+ } else {
+ try {
+ page.openEditor(new org.eclipse.emf.common.ui.URIEditorInput(fileURI), editorDescriptor.getId());
+ } catch (org.eclipse.ui.PartInitException exception) {
+ org.eclipse.jface.dialogs.MessageDialog.openError(
+ workbenchWindow.getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForDefaultEditorOpenErrorDialog(editorGen.application))) FOR editorGen»,
+ exception.getMessage());
+ return false;
+ }
+ }
+ return true;
+ }
+«ENDDEFINE»
+
+«DEFINE makeAction(windowVar : String) FOR gmfgen::GenContributionItem»
+ «ERROR 'Can not make action for ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE makeAction(windowVar : String) FOR gmfgen::GenActionFactoryContributionItem»
+ register(org.eclipse.ui.actions.ActionFactory.«name».create(«windowVar»));
+«ENDDEFINE»
+
+«DEFINE fill(managerVar : String) FOR gmfgen::GenContributionManager»
+ «EXPAND contribute(managerVar) FOREACH items-»
+«ENDDEFINE»
+
+«DEFINE contribute(managerVar : String) FOR gmfgen::GenContributionItem»
+ «ERROR 'Can not contribute item: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE contribute(managerVar : String) FOR gmfgen::GenGroupMarker»
+ «managerVar».add(new org.eclipse.jface.action.GroupMarker(«groupName»));
+«ENDDEFINE»
+
+«DEFINE contribute(managerVar : String) FOR gmfgen::GenSeparator»
+ «managerVar».add(new org.eclipse.jface.action.Separator(«IF null <> groupName»«groupName»«ENDIF»));
+«ENDDEFINE»
+
+«DEFINE contribute(managerVar : String) FOR gmfgen::GenMenuManager»
+ «LET managerVar + 'X' AS menuVar-»
+ {
+ org.eclipse.jface.action.IMenuManager «menuVar» = new org.eclipse.jface.action.MenuManager(
+ «IF null <> name»«EXPAND xpt::Externalizer::accessorCall(i18nKeyForMenu(self)) FOR editorGen»«ELSE»null«ENDIF»«IF null <> iD», «iD»«ENDIF»);
+ «EXPAND contribute(menuVar) FOREACH items-»
+ «managerVar».add(«menuVar»);
+ }
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE contribute(managerVar : String) FOR gmfgen::GenToolBarManager»
+ «LET managerVar + 'X' AS toolBarVar-»
+ {
+ org.eclipse.jface.action.IToolBarManager «toolBarVar» = new org.eclipse.jface.action.ToolBarManager();
+ «EXPAND contribute(toolBarVar) FOREACH items-»
+ «managerVar».add(new org.eclipse.jface.action.ToolBarContributionItem(«toolBarVar»«IF null <> iD», «iD»«ENDIF»));
+ }
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE contribute(managerVar : String) FOR gmfgen::GenSharedContributionItem»
+ «EXPAND contributeShared(managerVar) FOR actualItem-»
+«ENDDEFINE»
+
+«DEFINE contributeShared(managerVar : String) FOR gmfgen::GenContributionItem»
+ «ERROR 'Can not contribute shared item: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE contributeShared(managerVar : String) FOR gmfgen::GenActionFactoryContributionItem»
+ «managerVar».add(getAction(org.eclipse.ui.actions.ActionFactory.«name».getId()));
+«ENDDEFINE»
+
+«DEFINE actions FOR gmfgen::GenApplication»
+«EXPAND NewDiagramAction-»
+«EXPAND OpenUriAction-»
+«EXPAND OpenAction-»
+«EXPAND AboutAction-»
+«ENDDEFINE»
+
+«DEFINE NewDiagramAction FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedClassComment»
+ public static class NewDiagramAction extends org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void run(org.eclipse.jface.action.IAction action) {
+ «editorGen.diagram.getCreationWizardQualifiedClassName()» wizard =
+ new «editorGen.diagram.getCreationWizardQualifiedClassName()»();
+ wizard.init(getWindow().getWorkbench(), org.eclipse.jface.viewers.StructuredSelection.EMPTY);
+ org.eclipse.jface.wizard.WizardDialog wizardDialog =
+ new org.eclipse.jface.wizard.WizardDialog(getWindow().getShell(), wizard);
+ wizardDialog.open();
+ }
+ }
+
+«ENDDEFINE»
+
+«DEFINE OpenUriAction FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedClassComment»
+ public static class OpenURIAction extends org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void run(org.eclipse.jface.action.IAction action) {
+ org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog =
+ new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(getWindow().getShell());
+ if (org.eclipse.jface.dialogs.Dialog.OK == loadResourceDialog.open()) {
+ for (java.util.Iterator i = loadResourceDialog.getURIs().iterator(); i.hasNext();) {
+ openEditor(getWindow().getWorkbench(), (org.eclipse.emf.common.util.URI) i.next());
+ }
+ }
+ }
+ }
+
+«ENDDEFINE»
+
+«DEFINE OpenAction FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedClassComment»
+ public static class OpenAction extends org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void run(org.eclipse.jface.action.IAction action) {
+ org.eclipse.swt.widgets.FileDialog fileDialog =
+ new org.eclipse.swt.widgets.FileDialog(getWindow().getShell(), org.eclipse.swt.SWT.OPEN);
+ fileDialog.open();
+ if (fileDialog.getFileName() != null && fileDialog.getFileName().length() > 0) {
+ openEditor(getWindow().getWorkbench(), org.eclipse.emf.common.util.URI.createFileURI(
+ fileDialog.getFilterPath() + java.io.File.separator + fileDialog.getFileName()));
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE AboutAction FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedClassComment»
+ public static class AboutAction extends org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void run(org.eclipse.jface.action.IAction action) {
+ org.eclipse.jface.dialogs.MessageDialog.openInformation(getWindow().getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForAboutDialog(self))) FOR editorGen»,
+ «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForAboutDialog(self))) FOR editorGen»
+ );
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenApplication-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenApplication-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForDefaultFileEditorErrorDialog(self)))-»
+«EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForDefaultFileEditorErrorDialog(self)))-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForDefaultEditorOpenErrorDialog(self)))-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForAboutDialog(self)))-»
+«EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForAboutDialog(self)))-»
+«IF null <> mainMenu-»
+«EXPAND internal_i18nAccessors FOR mainMenu-»
+«EXPAND internal_i18nAccessors FOREACH collectGenMenuManagers(mainMenu.items)-»
+«ENDIF»
+«EXPAND internal_i18nAccessors FOREACH collectGenMenuManagers(sharedContributionItems)-»
+«ENDDEFINE»
+
+«DEFINE internal_i18nAccessors FOR gmfgen::GenMenuManager-»
+«IF null <> name»«EXPAND xpt::Externalizer::accessorField(i18nKeyForMenu(self))»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenApplication-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForDefaultFileEditorErrorDialog(self)), 'Error')-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForDefaultFileEditorErrorDialog(self)), 'There is no editor registered for the file "{0}"')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForDefaultEditorOpenErrorDialog(self)), 'Open Editor')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForAboutDialog(self)), 'About')-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForAboutDialog(self)), editorGen.modelID + ' Diagram Editor')-»
+«IF null <> mainMenu-»
+«EXPAND internal_i18nValues FOR mainMenu-»
+«EXPAND internal_i18nValues FOREACH collectGenMenuManagers(mainMenu.items)-»
+«ENDIF»
+«EXPAND internal_i18nValues FOREACH collectGenMenuManagers(sharedContributionItems)-»
+«ENDDEFINE»
+
+«DEFINE internal_i18nValues FOR gmfgen::GenMenuManager-»
+«IF null <> name»«EXPAND xpt::Externalizer::messageEntry(i18nKeyForMenu(self), name)»«ENDIF-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Application.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Application.xpt
new file mode 100644
index 000000000..0543e7b46
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Application.xpt
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2006 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 Application FOR gmfgen::GenApplication-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «className» implements org.eclipse.equinox.app.IApplication {
+
+«EXPAND run-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void stop() {
+ }
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE run FOR gmfgen::GenApplication-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public Object start(org.eclipse.equinox.app.IApplicationContext context) throws Exception {
+ org.eclipse.swt.widgets.Display display = org.eclipse.ui.PlatformUI.createDisplay();
+ try {
+ int returnCode = org.eclipse.ui.PlatformUI.createAndRunWorkbench(display,
+ new «getWorkbenchAdvisorQualifiedClassName()»());
+ if (returnCode == org.eclipse.ui.PlatformUI.RETURN_RESTART) {
+ return org.eclipse.equinox.app.IApplication.EXIT_RESTART;
+ }
+ return org.eclipse.equinox.app.IApplication.EXIT_OK;
+ } finally {
+ display.dispose();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenApplication-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Perspective.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Perspective.xpt
new file mode 100644
index 000000000..3bdcfff58
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/Perspective.xpt
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2006 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 Perspective FOR gmfgen::GenApplication-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «perspectiveClassName» implements org.eclipse.ui.IPerspectiveFactory {
+ «EXPAND createInitialLayout-»
+ «EXPAND additions-»
+«ENDDEFINE»
+«DEFINE createInitialLayout FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void createInitialLayout(org.eclipse.ui.IPageLayout layout) {
+ layout.setEditorAreaVisible(true);
+ layout.addPerspectiveShortcut(«getWorkbenchAdvisorQualifiedClassName()».PERSPECTIVE_ID);
+ org.eclipse.ui.IFolderLayout right = layout.createFolder(
+ "right", org.eclipse.ui.IPageLayout.RIGHT, 0.6f, layout.getEditorArea()); «EXPAND xpt::Common::nonNLS»
+ right.addView(org.eclipse.ui.IPageLayout.ID_OUTLINE);
+ org.eclipse.ui.IFolderLayout bottomRight = layout.createFolder(
+ "bottomRight", org.eclipse.ui.IPageLayout.BOTTOM, 0.6f, "right"); «EXPAND xpt::Common::nonNLS» «EXPAND xpt::Common::nonNLS(2)»
+ bottomRight.addView(org.eclipse.ui.IPageLayout.ID_PROP_SHEET);
+ «EXPAND layoutAdditions-»
+ }
+}
+«ENDDEFINE»
+
+«DEFINE layoutAdditions FOR gmfgen::GenApplication-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenApplication-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WizardNewFileCreationPage.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WizardNewFileCreationPage.xpt
new file mode 100644
index 000000000..adec03972
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WizardNewFileCreationPage.xpt
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::application::i18n»
+
+«DEFINE WizardNewFileCreationPage FOR gmfgen::GenApplication-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class WizardNewFileCreationPage extends org.eclipse.jface.wizard.WizardPage {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.jface.viewers.IStructuredSelection currentSelection;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private String initialFileName;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.core.runtime.IPath initialContainerFullPath;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.swt.widgets.Text fileNameEditor;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public WizardNewFileCreationPage(String name, org.eclipse.jface.viewers.IStructuredSelection currentSelection) {
+ super(name);
+ this.currentSelection = currentSelection;
+ String home = System.getProperty("user.home"); //$NON-NLS-1$
+ if (home != null) {
+ initialContainerFullPath = new org.eclipse.core.runtime.Path(home);
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.jface.viewers.IStructuredSelection getSelection() {
+ return currentSelection;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getFileName() {
+ if (fileNameEditor == null) {
+ return initialFileName;
+ }
+ org.eclipse.core.runtime.IPath path = getFilePath();
+ if (path == null || path.isEmpty() || path.hasTrailingSeparator()) {
+ return null;
+ }
+ return path.lastSegment();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setFileName(String fileName) {
+ if (fileNameEditor == null) {
+ initialFileName = fileName;
+ return;
+ }
+ setFilePath(getContainerFullPath(), fileName);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.core.runtime.IPath getContainerFullPath() {
+ if (fileNameEditor == null) {
+ return initialContainerFullPath;
+ }
+ org.eclipse.core.runtime.IPath path = getFilePath();
+ if (path == null || path.isEmpty()) {
+ return null;
+ }
+ if (path.hasTrailingSeparator()) {
+ return path;
+ }
+ path = path.removeLastSegments(1);
+ if (path.isEmpty()) {
+ return null;
+ }
+ return path.addTrailingSeparator();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setContainerFullPath(org.eclipse.core.runtime.IPath containerPath) {
+ if (fileNameEditor == null) {
+ initialContainerFullPath = containerPath;
+ return;
+ }
+ setFilePath(containerPath, getFileName());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.core.runtime.IPath getFilePath() {
+ String fileName = fileNameEditor.getText().trim();
+ if (fileName.length() == 0) {
+ return null;
+ }
+ return new org.eclipse.core.runtime.Path(fileNameEditor.getText());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setFilePath(org.eclipse.core.runtime.IPath containerPath, String fileName) {
+ if (fileName == null) {
+ fileName = ""; //$NON-NLS-1$
+ } else {
+ fileName = fileName.trim();
+ }
+ if (containerPath == null) {
+ fileNameEditor.setText(fileName);
+ } else {
+ if (!containerPath.hasTrailingSeparator()) {
+ containerPath = containerPath.addTrailingSeparator();
+ }
+ org.eclipse.core.runtime.IPath path = fileName.length() == 0 ? containerPath : containerPath.append(fileName);
+ fileNameEditor.setText(path.toOSString());
+ }
+ setPageComplete(validatePage());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void createControl(org.eclipse.swt.widgets.Composite parent) {
+ org.eclipse.swt.widgets.Composite plate = new org.eclipse.swt.widgets.Composite(parent, org.eclipse.swt.SWT.NONE);
+ plate.setLayout(new org.eclipse.swt.layout.GridLayout(2, false));
+ org.eclipse.swt.widgets.Label label = new org.eclipse.swt.widgets.Label(plate, org.eclipse.swt.SWT.NONE);
+ label.setText(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewFileWizardFileLabel(self)) FOR editorGen»);
+ label.setLayoutData(new org.eclipse.swt.layout.GridData(org.eclipse.swt.SWT.BEGINNING, org.eclipse.swt.SWT.CENTER, false, false, 2, 1));
+ fileNameEditor = new org.eclipse.swt.widgets.Text(plate, org.eclipse.swt.SWT.SINGLE | org.eclipse.swt.SWT.BORDER);
+ fileNameEditor.setLayoutData(new org.eclipse.swt.layout.GridData(org.eclipse.swt.SWT.FILL, org.eclipse.swt.SWT.CENTER, true, false));
+ org.eclipse.swt.widgets.Button button = new org.eclipse.swt.widgets.Button(plate, org.eclipse.swt.SWT.PUSH);
+ button.setText(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewFileWizardBrowseButton(self)) FOR editorGen»);
+ button.setLayoutData(new org.eclipse.swt.layout.GridData(org.eclipse.swt.SWT.BEGINNING, org.eclipse.swt.SWT.CENTER, false, false));
+
+ // logic
+ fileNameEditor.addModifyListener(new org.eclipse.swt.events.ModifyListener() {
+
+ public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+ });
+ button.addSelectionListener(new org.eclipse.swt.events.SelectionListener() {
+
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ org.eclipse.swt.widgets.FileDialog dialog = new org.eclipse.swt.widgets.FileDialog(getShell(), org.eclipse.swt.SWT.SAVE);
+ dialog.setText(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewFileWizardSelectDialog(self)) FOR editorGen»);
+ dialog.setFileName(getFileName());
+ String fileName = dialog.open();
+ if (fileName != null) {
+ fileNameEditor.setText(fileName);
+ setPageComplete(validatePage());
+ }
+ }
+
+ public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
+ }
+ });
+
+ // init
+ setFilePath(initialContainerFullPath, initialFileName);
+ setControl(plate);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean validatePage() {
+ String fileName = fileNameEditor.getText().trim();
+ if (fileName.length() == 0) {
+ setErrorMessage(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewFileWizardEmpty(self)) FOR editorGen»);
+ return false;
+ }
+ if (!new org.eclipse.core.runtime.Path("").isValidPath(fileName)) { //$NON-NLS-1$
+ setErrorMessage(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForNewFileWizardInvalid(self)) FOR editorGen»);
+ return false;
+ }
+ setErrorMessage(null);
+ return true;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenApplication-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenApplication-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewFileWizardFileLabel(self), 'File:')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewFileWizardBrowseButton(self), 'Browse')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewFileWizardSelectDialog(self), 'Select new file')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewFileWizardEmpty(self), 'Specify file name')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForNewFileWizardInvalid(self), 'Invalid file name')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForNewFileWizardFileLabel(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForNewFileWizardBrowseButton(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForNewFileWizardSelectDialog(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForNewFileWizardEmpty(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForNewFileWizardInvalid(self))-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchAdvisor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchAdvisor.xpt
new file mode 100644
index 000000000..925ca847a
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchAdvisor.xpt
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2006 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 WorkbenchAdvisor FOR gmfgen::GenApplication-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «workbenchAdvisorClassName» extends org.eclipse.ui.application.WorkbenchAdvisor {
+«EXPAND perspectiveId-»
+
+«EXPAND getInitialWindowPerspectiveId-»
+
+«EXPAND initialize-»
+
+«EXPAND createWorkbenchWindowAdvisor-»
+
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE perspectiveId FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final String PERSPECTIVE_ID = "«perspectiveId»"; «EXPAND xpt::Common::nonNLS»
+«ENDDEFINE»
+
+«DEFINE getInitialWindowPerspectiveId FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public String getInitialWindowPerspectiveId() {
+ return PERSPECTIVE_ID;
+ }
+«ENDDEFINE»
+
+«DEFINE initialize FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void initialize(org.eclipse.ui.application.IWorkbenchConfigurer configurer) {
+ super.initialize(configurer);
+ configurer.setSaveAndRestore(true);
+ }
+«ENDDEFINE»
+
+«DEFINE createWorkbenchWindowAdvisor FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.ui.application.WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
+ org.eclipse.ui.application.IWorkbenchWindowConfigurer configurer) {
+ return new «getWorkbenchWindowAdvisorQualifiedClassName()»(configurer);
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenApplication-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchWindowAdvisor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchWindowAdvisor.xpt
new file mode 100644
index 000000000..0d3c81408
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/WorkbenchWindowAdvisor.xpt
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::application::i18n»
+
+«DEFINE WorkbenchWindowAdvisor FOR gmfgen::GenApplication-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «workbenchWindowAdvisorClassName» extends org.eclipse.ui.application.WorkbenchWindowAdvisor {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «workbenchWindowAdvisorClassName»(org.eclipse.ui.application.IWorkbenchWindowConfigurer configurer) {
+ super(configurer);
+ }
+
+ «EXPAND createActionBarAdvisor-»
+
+ «EXPAND preWindowOpen-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE createActionBarAdvisor FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.ui.application.ActionBarAdvisor createActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer configurer) {
+ return new «getActionBarAdvisorQualifiedClassName()»(configurer);
+ }
+«ENDDEFINE»
+
+«DEFINE preWindowOpen FOR gmfgen::GenApplication-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void preWindowOpen() {
+ org.eclipse.ui.application.IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ configurer.setInitialSize(new org.eclipse.swt.graphics.Point(1000, 700));
+ configurer.setTitle(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForWindowTitle(self)) FOR editorGen»);
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenApplication-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenApplication-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForWindowTitle(self))-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenApplication-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForWindowTitle(self), title)-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/extensions.xpt
new file mode 100644
index 000000000..ddd2eb7e2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/extensions.xpt
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«DEFINE extensions FOR gmfgen::GenApplication-»
+
+ <extension id="«iD»" point="org.eclipse.core.runtime.applications">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <application>
+ <run class="«getQualifiedClassName()»"/>
+ </application>
+ </extension>
+
+ <extension point="org.eclipse.ui.perspectives" id="rcp-perspective">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <perspective
+ id="«perspectiveId»"
+ name="%perspectiveName"
+ class="«getPerspectiveQualifiedClassName()»">
+ </perspective>
+ </extension>
+
+ <extension point="org.eclipse.ui.commands" id="rcp-menu-commands">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <command
+ name="%openURIActionLabel"
+ description="%openURIActionDescription"
+ categoryId="org.eclipse.ui.category.file"
+ id="«editorGen.plugin.iD».OpenURICommand"/>
+ <command
+ name="%openActionLabel"
+ description="%openActionDescription"
+ categoryId="org.eclipse.ui.category.file"
+ id="«editorGen.plugin.iD».OpenCommand"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.bindings" id="rcp-command-bindings">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <key
+ commandId="«editorGen.plugin.iD».OpenURICommand"
+ sequence="M1+U"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ <key
+ commandId="«editorGen.plugin.iD».OpenCommand"
+ sequence="M1+O"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.actionSets" id="rcp-actions">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <actionSet
+ label="%applicationActionSetLabel"
+ visible="true"
+ id="«editorGen.plugin.iD».ActionSet">
+ <action
+ label="%newDiagramActionLabel"
+ class="«getActionBarAdvisorQualifiedClassName()»$NewDiagramAction"
+ menubarPath="file/new/additions"
+ id="«editorGen.plugin.iD».NewDiagramAction">
+ </action>
+ <action
+ label="%aboutActionLabel"
+ class="«getActionBarAdvisorQualifiedClassName()»$AboutAction"
+ menubarPath="help/additions"
+ id="«editorGen.plugin.iD».AboutAction">
+ </action>
+ <action
+ label="%openURIActionLabel"
+ definitionId="«editorGen.plugin.iD».OpenURICommand"
+ class="«getActionBarAdvisorQualifiedClassName()»$OpenURIAction"
+ menubarPath="file/additions"
+ id="«editorGen.plugin.iD».OpenURIAction">
+ </action>
+ <action
+ label="%openActionLabel"
+ definitionId="«editorGen.plugin.iD».OpenCommand"
+ class="«getActionBarAdvisorQualifiedClassName()»$OpenAction"
+ menubarPath="file/additions"
+ id="«editorGen.plugin.iD».OpenAction">
+ </action>
+ </actionSet>
+ </extension>
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/i18n.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/i18n.qvto
new file mode 100644
index 000000000..db283db08
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/application/i18n.qvto
@@ -0,0 +1,63 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library i18n;
+
+helper i18nKeyForDefaultFileEditorErrorDialog(app : genModel::GenApplication) : String {
+ return app.actionBarAdvisorClassName + '.DefaultFileEditor'
+}
+
+helper i18nKeyForDefaultEditorOpenErrorDialog(app : genModel::GenApplication) : String {
+ return app.actionBarAdvisorClassName + '.DefaultEditorOpenError'
+}
+
+helper i18nKeyForWindowTitle(app : genModel::GenApplication) : String {
+ return app.workbenchWindowAdvisorClassName + '.Title'
+}
+
+helper i18nKeyForAboutDialog(app : genModel::GenApplication) : String {
+ return app.actionBarAdvisorClassName + '.AboutDialog'
+}
+
+helper titleKey(dialogKey : String) : String {
+ return dialogKey + 'Title'
+}
+
+helper messageKey(dialogKey : String) : String {
+ return dialogKey + 'Message'
+}
+
+helper i18nKeyForMenu(menuManager : genModel::GenMenuManager) : String {
+ return 'ApplicationMenuName.' + menuManager.name
+}
+
+helper collectGenMenuManagers(allItems : Collection(genModel::GenContributionItem)) : Sequence(genModel::GenMenuManager) {
+ return (collectAllContributionItems(allItems))[genModel::GenMenuManager]
+}
+
+helper collectAllContributionItems(allItems : Collection(genModel::GenContributionItem)) : Sequence(genModel::GenContributionManager) {
+ return let managers = (allItems->collect(it | it))[genModel::GenContributionManager]->asSequence() in managers->union(managers->collect(item | collectAllContributionItems(item.items))->flatten())
+}
+
+helper i18nKeyForNewFileWizardFileLabel(app : genModel::GenApplication) : String {
+ return wizardNewFileCreationPageClassName(app) + '.FileLabel'
+}
+
+helper i18nKeyForNewFileWizardBrowseButton(app : genModel::GenApplication) : String {
+ return wizardNewFileCreationPageClassName(app) + '.BrowseButton'
+}
+
+helper i18nKeyForNewFileWizardSelectDialog(app : genModel::GenApplication) : String {
+ return wizardNewFileCreationPageClassName(app) + '.SelectNewFileDialog'
+}
+
+helper i18nKeyForNewFileWizardEmpty(app : genModel::GenApplication) : String {
+ return wizardNewFileCreationPageClassName(app) + '.EmptyFileNameError'
+}
+
+helper i18nKeyForNewFileWizardInvalid(app : genModel::GenApplication) : String {
+ return wizardNewFileCreationPageClassName(app) + '.InvalidFileNameError'
+}
+
+helper wizardNewFileCreationPageClassName(app : genModel::GenApplication) : String {
+ return 'WizardNewFileCreationPage'
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto
new file mode 100644
index 000000000..551978384
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/Utils.qvto
@@ -0,0 +1,31 @@
+import xpt.NativeGenModelUtils;
+
+import xpt.GenModelUtils;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Utils;
+
+helper getNodes(diagram : genModel::GenDiagram) : Sequence(genModel::GenNode) {
+ return ((Sequence { })[genModel::GenTopLevelNode]->union(diagram.topLevelNodes->asSequence()))[genModel::GenNode]->union(diagram.childNodes->asSequence())
+}
+
+helper getElements(diagram : genModel::GenDiagram) : Sequence(genModel::GenCommonBase) {
+ return ((Sequence { diagram })[genModel::GenContainerBase]->union(diagram.topLevelNodes->asSequence())->union(diagram.childNodes->asSequence()))[genModel::GenCommonBase]->union(diagram.links->asSequence())
+}
+
+helper hasExplicitChildFeature(facet : genModel::TypeModelFacet) : Boolean {
+ return not isDerived(facet.childMetaFeature) and facet.childMetaFeature <> facet.containmentMetaFeature
+}
+
+helper hasContainerOtherThanSource(facet : genModel::TypeLinkModelFacet) : Boolean {
+ return facet.sourceMetaFeature <> null or facet.childMetaFeature <> facet.containmentMetaFeature
+}
+
+helper allPreferencePages(genDiagram : genModel::GenDiagram) : Sequence(genModel::GenPreferencePage) {
+ return recursePages(genDiagram.preferencePages->asSequence())
+}
+
+helper recursePages(pages : Sequence(genModel::GenPreferencePage)) : Sequence(genModel::GenPreferencePage) {
+ return (if pages->isEmpty() then pages else pages->union(recursePages(pages.children))->asOrderedSet()->asSequence() endif)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto
new file mode 100644
index 000000000..709579925
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/ViewmapAttributesUtils.qvto
@@ -0,0 +1,47 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library ViewmapAttributesUtils;
+
+helper isStoringChildPositions(layoutType : genModel::ViewmapLayoutType) : Boolean {
+ return genModel::ViewmapLayoutType::XY_LAYOUT = layoutType
+}
+
+helper isFixedFont(viewmap : genModel::Viewmap) : Boolean {
+ return null <> viewmap and (viewmap.attributes)[genModel::StyleAttributes]->exists(e | e.fixedFont)
+}
+
+helper isFixedForeground(viewmap : genModel::Viewmap) : Boolean {
+ return null <> viewmap and (viewmap.attributes)[genModel::StyleAttributes]->exists(e | e.fixedForeground)
+}
+
+helper isFixedBackground(viewmap : genModel::Viewmap) : Boolean {
+ return null <> viewmap and (viewmap.attributes)[genModel::StyleAttributes]->exists(e | e.fixedBackground)
+}
+
+helper getResizeConstraints(viewmap : genModel::Viewmap) : genModel::ResizeConstraints {
+ return (if null = viewmap then null else (viewmap.attributes)[genModel::ResizeConstraints]->first().oclAsType(genModel::ResizeConstraints) endif)
+}
+
+helper getDefaultSizeAttributes(viewmap : genModel::Viewmap) : genModel::DefaultSizeAttributes {
+ return (if null = viewmap then null else (viewmap.attributes)[genModel::DefaultSizeAttributes]->first().oclAsType(genModel::DefaultSizeAttributes) endif)
+}
+
+helper defaultSizeWidth(viewmap : genModel::Viewmap, defaultValue : Integer) : Integer {
+ return let a = getDefaultSizeAttributes(viewmap) in (if null = a then defaultValue else a.width endif)
+}
+
+helper defaultSizeHeight(viewmap : genModel::Viewmap, defaultValue : Integer) : Integer {
+ return let a = getDefaultSizeAttributes(viewmap) in (if null = a then defaultValue else a.height endif)
+}
+
+helper getLabelOffsetAttributes(viewmap : genModel::Viewmap) : genModel::LabelOffsetAttributes {
+ return (if null = viewmap then null else (viewmap.attributes)[genModel::LabelOffsetAttributes]->first().oclAsType(genModel::LabelOffsetAttributes) endif)
+}
+
+helper labelOffsetX(viewmap : genModel::Viewmap, defaultValue : Integer) : Integer {
+ return let a = getLabelOffsetAttributes(viewmap) in (if null = a then defaultValue else a.x endif)
+}
+
+helper labelOffsetY(viewmap : genModel::Viewmap, defaultValue : Integer) : Integer {
+ return let a = getLabelOffsetAttributes(viewmap) in (if null = a then defaultValue else a.y endif)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt
new file mode 100644
index 000000000..969764c76
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkCommand.xpt
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«DEFINE CreateLinkCommand FOR gmfgen::GenLink»«EXPAND Main»«ENDDEFINE»
+
+«DEFINE Main FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «diagram.editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::fields FOR modelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest request, org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject target) {
+ super(request.getLabel(), null, request);
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::_init FOR modelFacet-»
+ }
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::canCreate(self) FOR modelFacet-»
+
+ «EXPAND doExecuteWithResultMethod»
+
+ «EXPAND doConfigure(self) FOR modelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setElementToEdit(org.eclipse.emf.ecore.EObject element) {
+ throw new UnsupportedOperationException();
+ }
+ «EXPAND xpt::diagram::commands::CreateLinkUtils::accessors FOR modelFacet-»
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLink»«ENDDEFINE»
+
+«DEFINE doExecuteWithResultMethod FOR gmfgen::GenLink»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ if (!canExecute()) {
+ throw new org.eclipse.core.commands.ExecutionException("Invalid arguments in create link command");«EXPAND xpt::Common::nonNLS»
+ }
+ «EXPAND execute(self) FOR modelFacet»
+ }
+«ENDDEFINE»
+
+«DEFINE execute(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+«DEFINE execute(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet»
+«IF (if sourceMetaFeature = null then containmentMetaFeature.ecoreFeature.changeable else sourceMetaFeature.ecoreFeature.changeable endif) and targetMetaFeature.ecoreFeature.changeable-»
+ «EXPAND MetaModel::NewInstance('newElement') FOR metaClass-»
+ «EXPAND MetaModel::modifyFeature((if hasContainerOtherThanSource(self) then 'getContainer()' else 'getSource()' endif), containmentMetaFeature.genClass, 'newElement') FOR containmentMetaFeature-»
+ «IF sourceMetaFeature <> null-»
+ «EXPAND MetaModel::modifyFeature('newElement', metaClass, 'getSource()') FOR sourceMetaFeature-»
+ «ENDIF-»
+ «EXPAND MetaModel::modifyFeature('newElement', metaClass, 'getTarget()') FOR targetMetaFeature-»
+ «IF hasExplicitChildFeature(self)-»
+ «IF sourceMetaFeature <> null-»
+ «EXPAND MetaModel::modifyFeature('getContainer()', containmentMetaFeature.genClass, 'newElement') FOR childMetaFeature-»
+ «ELSE-»
+ «EXPAND MetaModel::modifyFeature('getSource()', getSourceType(), 'newElement') FOR childMetaFeature-»
+ «ENDIF-»
+ «ENDIF-»
+ «EXPAND initialize(link, 'newElement')-»
+ doConfigure(newElement, monitor, info);
+ ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«EXPAND MetaModel::DowncastToEObject('newElement') FOR metaClass»);
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement);
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE initialize(link : gmfgen::GenLink, newElementvVar : String) FOR gmfgen::TypeModelFacet»«IF modelElementInitializer <> null-»
+«link.diagram.getElementTypesQualifiedClassName()».init_«link.getUniqueIdentifier()»(«newElementvVar»);
+«ENDIF»«ENDDEFINE»
+
+
+«DEFINE execute(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet»
+«IF metaFeature.ecoreFeature.changeable-»
+ if (getSource() != null && getTarget() != null) {
+ «EXPAND MetaModel::modifyFeature('getSource()', getSourceType(), 'getTarget()') FOR metaFeature-»
+ }
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE doConfigure(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+/*
+ * TODO invocation of configure command should be optional, and better yet,
+ * configuration should rather happen from EditPolicy then from within creation command
+ */
+«DEFINE doConfigure(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void doConfigure(«EXPAND MetaModel::QualifiedClassName FOR metaClass» newElement, org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getElementType();
+ org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest configureRequest = new org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest(getEditingDomain(), «EXPAND MetaModel::DowncastToEObject('newElement') FOR metaClass», elementType);
+ configureRequest.setClientContext(((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ configureRequest.setParameter(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest.SOURCE, getSource());
+ configureRequest.setParameter(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest.TARGET, getTarget());
+ org.eclipse.gmf.runtime.common.core.command.ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt
new file mode 100644
index 000000000..f19cbc901
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateLinkUtils.xpt
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«REM»
+ Check whether link may be created.
+«ENDREM»
+«DEFINE canCreate(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && «EXPAND MetaModel::NotInstance('source') FOR getSourceType()») {
+ return false;
+ }
+ if (target != null && «EXPAND MetaModel::NotInstance('target') FOR getTargetType()») {
+ return false;
+ }
+ if (getSource() == null) {
+ return true; // link creation is in progress; source is not defined yet
+ }
+ // target may be null here but it's possible to check constraint
+ «EXPAND canCreateElement(link)-»
+ }
+«ENDDEFINE»
+
+«DEFINE canCreateElement(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE canCreateElement(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+«IF hasContainerOtherThanSource(self)-»
+ if (getContainer() == null) {
+ return false;
+ }
+«ENDIF-»
+ return «EXPAND validatorInvocation FOR link»(«IF hasContainerOtherThanSource(self)»getContainer(), «ENDIF»getSource(), getTarget());
+«ENDDEFINE»
+
+«DEFINE canCreateElement(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+ return «EXPAND validatorInvocation FOR link»(getSource(), getTarget());
+«ENDDEFINE»
+
+«DEFINE validatorInvocation FOR gmfgen::GenLink-»
+«diagram.getBaseItemSemanticEditPolicyQualifiedClassName()».«diagram.getLinkCreationConstraintsClassName()».canCreate«getUniqueIdentifier()-»
+«ENDDEFINE»
+
+«REM»
+ Fields of command that creates link.
+«ENDREM»
+«DEFINE fields FOR gmfgen::LinkModelFacet»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject source;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject target;
+«ENDDEFINE»
+
+«DEFINE fields FOR gmfgen::TypeLinkModelFacet»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject source;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject target;
+«IF hasContainerOtherThanSource(self)»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container;
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ Field accessors of command that creates link.
+«ENDREM»
+«DEFINE accessors FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getSource() {
+ return «EXPAND MetaModel::CastEObject('source') FOR getSourceType()»;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» getTarget() {
+ return «EXPAND MetaModel::CastEObject('target') FOR getTargetType()»;
+ }
+ «EXPAND containerAccessor-»
+«ENDDEFINE»
+
+«DEFINE containerAccessor FOR gmfgen::LinkModelFacet»«ENDDEFINE»
+
+«DEFINE containerAccessor FOR gmfgen::TypeLinkModelFacet-»
+«IF hasContainerOtherThanSource(self)-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» getContainer() {
+ return container;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Default approach is to traverse ancestors of the source to find instance of container.
+Modify with appropriate logic.'
+ )»
+ private static «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» deduceContainer(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject target) {
+ // Find container element for the new link.
+ // Climb up by containment hierarchy starting from the source
+ // and return the first element that is instance of the container class.
+ for (org.eclipse.emf.ecore.EObject element = source; element != null; element = element.eContainer()) {
+ if («EXPAND MetaModel::IsInstance('element') FOR containmentMetaFeature.genClass») {
+ return «EXPAND MetaModel::CastEObject('element') FOR containmentMetaFeature.genClass»;
+ }
+ }
+ return null;
+ }
+«ENDIF-»
+
+«ENDDEFINE»
+
+«REM»
+ Part of the constructor that performs initialization.
+«ENDREM»
+«DEFINE _init FOR gmfgen::LinkModelFacet-»
+ this.source = source;
+ this.target = target;
+«ENDDEFINE»
+
+«DEFINE _init FOR gmfgen::TypeLinkModelFacet-»
+ this.source = source;
+ this.target = target;
+«IF hasContainerOtherThanSource(self)-»
+ container = deduceContainer(source, target);
+«ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt
new file mode 100644
index 000000000..bd46cb821
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateNodeCommand.xpt
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«DEFINE CreateNodeCommand FOR gmfgen::GenNode-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+
+ «EXPAND _constructor-»
+
+ «EXPAND getElementToEdit-»
+
+ «EXPAND canExecuteMethod-»
+
+ «EXPAND doExecuteWithResultMethod»
+
+ «EXPAND doConfigureMethod»
+}
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+«ENDDEFINE»
+
+/*
+ * TODO: either use setElementToEdit, or generate downcasted version (which may be troublesome if containment and child features point to a different parent)
+ */
+«DEFINE getElementToEdit FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment('FIXME: replace with setElementToEdit()')»
+protected org.eclipse.emf.ecore.EObject getElementToEdit() {
+ org.eclipse.emf.ecore.EObject container = ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof org.eclipse.gmf.runtime.notation.View) {
+ container = ((org.eclipse.gmf.runtime.notation.View) container).getElement();
+ }
+ return container;
+}
+«ENDDEFINE»
+
+«DEFINE doExecuteWithResultMethod FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+«IF modelFacet.isPhantomElement()-»
+ «EXPAND phantomElementCreation(self, 'newElement') FOR modelFacet»
+«ELSE-»
+ «EXPAND normalElementCreation(self, 'newElement') FOR modelFacet»
+«ENDIF»
+ «EXPAND initialize(self, 'newElement') FOR modelFacet-»
+«IF true/*FIXME boolean needsExternalConfiguration*/»
+ doConfigure(newElement, monitor, info);
+«ENDIF»
+ ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass»);
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement);
+ }
+«ENDDEFINE»
+
+/*
+ * Unlike original CreateElementCommand, we don't keep track of IStatus from configureCommand.execute,
+ * nor allow status setting from doDefaultCreation. The reason is ICommandProxy#execute implementation,
+ * which ignores any status from wrapped ICommand. Besides, both CommandResult and IStatus seems too much to me.
+ */
+«DEFINE doConfigureMethod FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void doConfigure(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.metaClass» newElement, org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getElementType();
+ org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest configureRequest = new org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest(getEditingDomain(), «EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass», elementType);
+ configureRequest.setClientContext(((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ org.eclipse.gmf.runtime.common.core.command.ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE canExecuteMethod FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean canExecute() {
+«IF modelFacet.isPhantomElement()-»
+ return true;
+«ELSE-»
+ «EXPAND canExecute_Normal FOR modelFacet»
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE canExecute_Normal FOR gmfgen::TypeModelFacet-»
+«IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 or (childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0)-»
+ «EXPAND MetaModel::DeclareAndAssign('container', 'getElementToEdit()') FOR containmentMetaFeature.genClass-»
+ «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0-»
+ «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) = 1»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature» != null) {
+ «ELSE-»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature».size() >= «containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer)») {
+ «ENDIF-»
+ return false;
+ }
+ «ENDIF-»
+ «IF childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0-»
+ «IF childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) = 1-»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature» != null) {
+ «ELSE-»
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature».size() >= «childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer)») {
+ «ENDIF-»
+ return false;
+ }
+ «ENDIF-»
+«ENDIF-»
+ return true;
+«ENDDEFINE»
+
+«DEFINE phantomElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-»
+ // Uncomment to put "phantom" objects into the diagram file.
+ // org.eclipse.emf.ecore.resource.Resource resource =
+ // ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer().eResource();
+ // if (resource == null) {
+ // return null;
+ // }
+ org.eclipse.emf.ecore.resource.Resource resource = getElementToEdit().eResource();
+ «EXPAND MetaModel::NewInstance(varName) FOR metaClass»
+ resource.getContents().add(«EXPAND MetaModel::DowncastToEObject(varName) FOR metaClass»);
+«ENDDEFINE»
+
+«DEFINE normalElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-»
+ «EXPAND MetaModel::NewInstance(varName) FOR metaClass»
+«IF containmentMetaFeature <> null-»
+ «EXPAND MetaModel::DeclareAndAssign('owner', 'getElementToEdit()') FOR containmentMetaFeature.genClass»
+ «EXPAND MetaModel::modifyFeature('owner', containmentMetaFeature.genClass, varName) FOR containmentMetaFeature-»
+«ELSE-»
+ //
+ // FIXME no containment feature found in the genmodel, toolsmith need to manually write code here to add «varName» to a parent
+ //
+«ENDIF»
+«IF hasExplicitChildFeature(self)-»
+ «EXPAND MetaModel::DeclareAndAssign('childHolder', 'getElementToEdit()') FOR childMetaFeature.genClass»
+ «EXPAND MetaModel::modifyFeature('childHolder', childMetaFeature.genClass, varName) FOR childMetaFeature»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE initialize(node : gmfgen::GenNode, newElementVar : String) FOR gmfgen::TypeModelFacet»«IF modelElementInitializer <> null-»
+«node.getDiagram().getElementTypesQualifiedClassName()».init_«node.getUniqueIdentifier()»(«newElementVar»);
+«ENDIF»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt
new file mode 100644
index 000000000..67ca118a7
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateRefLinkCommand.xpt
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+/*
+ * TODO: remove the template, as it's no longer in use
+ */
+«DEFINE CreateRefLinkCommand FOR gmfgen::GenLink»«EXPAND CreateLinkCommand::Main»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt
new file mode 100644
index 000000000..e2609af6f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/CreateShortcutDecorationsCommand.xpt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE CreateShortcutDecorationsCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «createShortcutDecorationsCommandClassName»
+ extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.util.List myDescriptors;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «createShortcutDecorationsCommandClassName»(
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
+ org.eclipse.gmf.runtime.notation.View parentView,
+ java.util.List viewDescriptors) {
+ super(editingDomain, "Create Shortcuts", getWorkspaceFiles(parentView)); //$NON-NLS-1$
+ myDescriptors = viewDescriptors;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «createShortcutDecorationsCommandClassName»(
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
+ org.eclipse.gmf.runtime.notation.View parentView,
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor viewDescriptor) {
+ this(editingDomain, parentView, java.util.Collections.singletonList(viewDescriptor));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(
+ org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
+ throws org.eclipse.core.commands.ExecutionException {
+ for (java.util.Iterator it = myDescriptors.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor nextDescriptor =
+ (org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor) it.next();
+ org.eclipse.gmf.runtime.notation.View view =
+ (org.eclipse.gmf.runtime.notation.View) nextDescriptor.getAdapter(
+ org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null && view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ «EXPAND xpt::Common::addShortcutAnnotation('view')-»
+ }
+ }
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ }
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt
new file mode 100644
index 000000000..4772f23c9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkCommand.xpt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE ReorientLinkCommand FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «diagram.editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «reorientCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final int reorientDirection;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject oldEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject newEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «reorientCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::canReorient(self) FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::reorient FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::accessors-»
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt
new file mode 100644
index 000000000..7ff98dbfa
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkUtils.xpt
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::Utils»
+
+«REM»
+ Expands to all accessor methods for link and it's ends.
+«ENDREM»
+«DEFINE accessors FOR gmfgen::GenLink-»
+ «EXPAND linkAccessor FOR modelFacet-»
+ «EXPAND oldSourceAccessor FOR modelFacet-»
+ «EXPAND newSourceAccessor FOR modelFacet-»
+ «EXPAND oldTargetAccessor FOR modelFacet-»
+ «EXPAND newTargetAccessor FOR modelFacet-»
+«ENDDEFINE»
+
+«DEFINE linkAccessor FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE linkAccessor FOR gmfgen::TypeLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR metaClass» getLink() {
+ return «EXPAND MetaModel::CastEObject('getElementToEdit()') FOR metaClass»;
+ }
+«ENDDEFINE»
+
+«DEFINE oldSourceAccessor FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE oldSourceAccessor FOR gmfgen::TypeLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getOldSource() {
+ return «EXPAND MetaModel::CastEObject('oldEnd') FOR getSourceType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE oldSourceAccessor FOR gmfgen::FeatureLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getOldSource() {
+ return «EXPAND MetaModel::CastEObject('referenceOwner') FOR getSourceType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE newSourceAccessor FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getSourceType()» getNewSource() {
+ return «EXPAND MetaModel::CastEObject('newEnd') FOR getSourceType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE oldTargetAccessor FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» getOldTarget() {
+ return «EXPAND MetaModel::CastEObject('oldEnd') FOR getTargetType()»;
+ }
+«ENDDEFINE»
+
+«DEFINE newTargetAccessor FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» getNewTarget() {
+ return «EXPAND MetaModel::CastEObject('newEnd') FOR getTargetType()»;
+ }
+«ENDDEFINE»
+
+«REM»
+ Generates canExecute() method for the command that reorients link.
+ Implementation should perform all static checks that command can be executed.
+«ENDREM»
+«DEFINE canReorient(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean canExecute() {
+ «EXPAND checkLinkValidity-»
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return canReorientSource();
+ }
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_TARGET) {
+ return canReorientTarget();
+ }
+ return false;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean canReorientSource() {
+ «EXPAND checkSourceRequestValidity(link)-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean canReorientTarget() {
+ «EXPAND checkTargetRequestValidity(link)-»
+ }
+«ENDDEFINE»
+
+«DEFINE checkLinkValidity FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE checkLinkValidity FOR gmfgen::TypeLinkModelFacet-»
+ if («EXPAND MetaModel::NotInstance('getElementToEdit()') FOR metaClass») {
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE checkLinkValidity FOR gmfgen::FeatureLinkModelFacet-»
+ if («EXPAND MetaModel::NotInstance('referenceOwner') FOR getSourceType()») {
+ return false;
+ }
+«ENDDEFINE»
+
+«DEFINE checkSourceRequestValidity(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE checkSourceRequestValidity(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getSourceType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getSourceType()»)) {
+ return false;
+ }
+ «EXPAND extractFeatureWithCheck('getLink()', metaClass, 'target', getTargetType()) FOR targetMetaFeature-»
+ «EXPAND checkLinkConstraint(link, 'getNewSource()', 'target')-»
+«ENDDEFINE»
+
+«REM»
+ When feature source is being reoriented oldEnd is the link target.
+«ENDREM»
+«DEFINE checkSourceRequestValidity(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getTargetType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getSourceType()»)) {
+ return false;
+ }
+ return «EXPAND checkLinkConstraintInvocation FOR link»(getNewSource(), getOldTarget());
+«ENDDEFINE»
+
+«DEFINE checkTargetRequestValidity(link : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE checkTargetRequestValidity(link : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getTargetType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getTargetType()»)) {
+ return false;
+ }
+ «IF sourceMetaFeature <> null-»
+ «EXPAND extractFeatureWithCheck('getLink()', metaClass, 'source', getSourceType()) FOR sourceMetaFeature-»
+ «ELSE-»
+ if (!(«EXPAND MetaModel::IsContainerInstance('getLink()', metaClass) FOR getSourceType()»)) {
+ return false;
+ }
+ «EXPAND MetaModel::DeclareAndAssignContainer('source', 'getLink()', metaClass) FOR getSourceType()»
+ «ENDIF-»
+ «EXPAND checkLinkConstraint(link, 'source', 'getNewTarget()')-»
+«ENDDEFINE»
+
+«DEFINE checkTargetRequestValidity(link : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+ if (!(«EXPAND MetaModel::IsInstance('oldEnd') FOR getTargetType()» && «EXPAND MetaModel::IsInstance('newEnd') FOR getTargetType()»)) {
+ return false;
+ }
+ return «EXPAND checkLinkConstraintInvocation FOR link»(getOldSource(), getNewTarget());
+«ENDDEFINE»
+
+«DEFINE extractFeatureWithCheck(containerVar : String, containerMetaClass : genmodel::GenClass, _var : String, varMetaClass : genmodel::GenClass) FOR genmodel::GenFeature-»
+ «IF ecoreFeature.many-»
+ if («EXPAND MetaModel::getFeatureValue(containerVar, containerMetaClass)».size() != 1) {
+ return false;
+ }
+ «EXPAND MetaModel::DeclareAndAssign2(_var, containerVar, containerMetaClass, self, 'get(0)', true) FOR varMetaClass»
+ «ELSE-»
+ «EXPAND MetaModel::DeclareAndAssign(_var, containerVar, containerMetaClass, self) FOR varMetaClass»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkLinkConstraint(link : gmfgen::GenLink, sourceVar : String, targetVar : String) FOR gmfgen::TypeLinkModelFacet-»
+ «IF hasContainerOtherThanSource(self)-»
+ if (!(«EXPAND MetaModel::IsContainerInstance('getLink()', metaClass) FOR containmentMetaFeature.genClass»)) {
+ return false;
+ }
+ «EXPAND MetaModel::DeclareAndAssignContainer('container', 'getLink()', metaClass) FOR containmentMetaFeature.genClass»
+ return «EXPAND checkLinkConstraintInvocation FOR link»(container, «sourceVar», «targetVar»);
+ «ELSE-»
+ return «EXPAND checkLinkConstraintInvocation FOR link»(«sourceVar», «targetVar»);
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkLinkConstraintInvocation FOR gmfgen::GenLink-»
+ «diagram.getBaseItemSemanticEditPolicyQualifiedClassName()».«diagram.getLinkCreationConstraintsClassName()».canExist«getUniqueIdentifier()»
+«ENDDEFINE»
+
+«REM»
+ Generates doExecuteWithResult() method for the command that reorients link.
+ Implementation should throw ExecutionException if it can't execute the command.
+«ENDREM»
+«DEFINE reorient FOR gmfgen::LinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(
+ org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
+ throws org.eclipse.core.commands.ExecutionException {
+ if (!canExecute()) {
+ throw new org.eclipse.core.commands.ExecutionException("Invalid arguments in reorient link command"); «EXPAND xpt::Common::nonNLS»
+ }
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return reorientSource();
+ }
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_TARGET) {
+ return reorientTarget();
+ }
+ throw new IllegalStateException();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult reorientSource() throws org.eclipse.core.commands.ExecutionException {
+ «EXPAND reorientSource-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult reorientTarget() throws org.eclipse.core.commands.ExecutionException {
+ «EXPAND reorientTarget-»
+ }
+«ENDDEFINE»
+
+«DEFINE reorientSource FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«REM»
+ Shouldn't we change link container here?
+ [artem] especially when there's explicit childMetaFeature and
+ we changed source to another, but didn't change the container. Perhaps,
+ makes sense to deduceContainer() using new source?
+«ENDREM»
+«DEFINE reorientSource FOR gmfgen::TypeLinkModelFacet-»
+«IF (if sourceMetaFeature = null then containmentMetaFeature.ecoreFeature.changeable else sourceMetaFeature.ecoreFeature.changeable endif)-»
+«IF sourceMetaFeature <> null-»
+ «EXPAND changeTarget('getLink()', metaClass, 'getOldSource()', 'getNewSource()') FOR sourceMetaFeature-»
+«ELSE-»
+ «EXPAND changeSource('getLink()', 'getOldSource()', 'getNewSource()', getSourceType()) FOR (if hasExplicitChildFeature(self) then childMetaFeature else containmentMetaFeature endif)-»
+«ENDIF-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(getLink());
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ When feature source is being reoriented oldEnd is the link target.
+«ENDREM»
+«DEFINE reorientSource FOR gmfgen::FeatureLinkModelFacet-»
+«IF metaFeature.ecoreFeature.changeable-»
+ «EXPAND changeSource('getOldTarget()', 'getOldSource()', 'getNewSource()', getSourceType()) FOR metaFeature-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(referenceOwner);
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE reorientTarget FOR gmfgen::LinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE reorientTarget FOR gmfgen::TypeLinkModelFacet-»
+«IF targetMetaFeature.ecoreFeature.changeable-»
+ «EXPAND changeTarget('getLink()', metaClass, 'getOldTarget()', 'getNewTarget()') FOR targetMetaFeature-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(getLink());
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE reorientTarget FOR gmfgen::FeatureLinkModelFacet-»
+«IF metaFeature.ecoreFeature.changeable-»
+ «EXPAND changeTarget('getOldSource()', getSourceType(), 'getOldTarget()', 'getNewTarget()') FOR metaFeature-»
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(referenceOwner);
+«ELSE-»
+ throw new UnsupportedOperationException();
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ Replace old target with the new one in the source.
+«ENDREM»
+«DEFINE changeTarget(sourceVar : String, sourceVarGenClass : genmodel::GenClass, oldTargetVar : String, newTargetVar : String) FOR genmodel::GenFeature-»
+«EXPAND MetaModel::replaceFeatureValue(sourceVar, sourceVarGenClass, oldTargetVar, newTargetVar)»
+«ENDDEFINE»
+
+«REM»
+ Move target from old source to the new one.
+«ENDREM»
+«DEFINE changeSource(targetVar : String, oldSourceVar : String, newSourceVar : String, sourceVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature-»
+«EXPAND MetaModel::moveFeatureValue(oldSourceVar, newSourceVar, sourceVarGenClass, targetVar)»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt
new file mode 100644
index 000000000..0498a9209
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientLinkViewCommand.xpt
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE ReorientLinkViewCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «reorientConnectionViewCommandClassName»
+ extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.core.runtime.IAdaptable edgeAdaptor;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «reorientConnectionViewCommandClassName»(
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, String label) {
+ super(editingDomain, label, null);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public java.util.List getAffectedFiles() {
+ org.eclipse.gmf.runtime.notation.View view =
+ (org.eclipse.gmf.runtime.notation.View) edgeAdaptor.getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null) {
+ return getWorkspaceFiles(view);
+ }
+ return super.getAffectedFiles();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.core.runtime.IAdaptable getEdgeAdaptor() {
+ return edgeAdaptor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setEdgeAdaptor(org.eclipse.core.runtime.IAdaptable edgeAdaptor) {
+ this.edgeAdaptor = edgeAdaptor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) {
+ «EXPAND xpt::Common::_assert('null != edgeAdaptor : "Null child in ' + reorientConnectionViewCommandClassName + '"')-»
+ org.eclipse.gmf.runtime.notation.Edge edge = (org.eclipse.gmf.runtime.notation.Edge) getEdgeAdaptor().getAdapter(org.eclipse.gmf.runtime.notation.Edge.class);
+ «EXPAND xpt::Common::_assert('null != edge : "Null edge in ' + reorientConnectionViewCommandClassName + '"')-»
+ org.eclipse.gmf.runtime.notation.View tempView = edge.getSource();
+ edge.setSource(edge.getTarget());
+ edge.setTarget(tempView);
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ }
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt
new file mode 100644
index 000000000..60b348301
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/commands/ReorientRefLinkCommand.xpt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE ReorientRefLinkCommand FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «diagram.editCommandsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «reorientCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final int reorientDirection;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject referenceOwner;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject oldEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject newEnd;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «reorientCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest request) {
+ super(request.getLabel(), null, request);
+ reorientDirection = request.getDirection();
+ referenceOwner = request.getReferenceOwner();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::canReorient(self) FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::reorient FOR modelFacet-»
+ «EXPAND xpt::diagram::commands::ReorientLinkUtils::accessors-»
+}
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/BaseEditHelper.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/BaseEditHelper.xpt
new file mode 100644
index 000000000..71eeb0382
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/BaseEditHelper.xpt
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE BaseEditHelper FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editHelpersPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «baseEditHelperClassName» extends org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper {
+
+ «EXPAND attributes-»
+
+ «EXPAND getEditHelperAdvice-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getInsteadCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest req) {
+ org.eclipse.gmf.runtime.common.core.command.ICommand epCommand =
+ (org.eclipse.gmf.runtime.common.core.command.ICommand) req.getParameter(«EXPAND editPolicyCommand»);
+ req.setParameter(«EXPAND editPolicyCommand», null);
+ org.eclipse.gmf.runtime.common.core.command.ICommand ehCommand = super.getInsteadCommand(req);
+ if (epCommand == null) {
+ return ehCommand;
+ }
+ if (ehCommand == null) {
+ return epCommand;
+ }
+ org.eclipse.gmf.runtime.common.core.command.CompositeCommand command =
+ new org.eclipse.gmf.runtime.common.core.command.CompositeCommand(null);
+ command.add(epCommand);
+ command.add(ehCommand);
+ return command;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getCreateCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getCreateRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getDestroyElementCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getDestroyReferenceCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
+ return null;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final String «EXPAND editPolicyCommand» = "edit policy command"; //$NON-NLS-1$
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final String «EXPAND contextElementType» = "context element type"; //$NON-NLS-1$
+«ENDDEFINE»
+
+«DEFINE editPolicyCommand FOR gmfgen::GenDiagram»EDIT_POLICY_COMMAND«ENDDEFINE»
+
+«DEFINE contextElementType FOR gmfgen::GenDiagram»CONTEXT_ELEMENT_TYPE«ENDDEFINE»
+
+«DEFINE editPolicyCommandConstant FOR gmfgen::GenDiagram»«getBaseEditHelperQualifiedClassName()».«EXPAND editPolicyCommand»«ENDDEFINE»
+
+«DEFINE contextElementTypeConstant FOR gmfgen::GenDiagram»«getBaseEditHelperQualifiedClassName()».«EXPAND contextElementType»«ENDDEFINE»
+
+«DEFINE getEditHelperAdvice FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice[] getEditHelperAdvice(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest req) {
+ if (req.getParameter(«EXPAND contextElementType») instanceof org.eclipse.gmf.runtime.emf.type.core.IElementType) {
+ return org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry.getInstance().getEditHelperAdvice((org.eclipse.gmf.runtime.emf.type.core.IElementType) req.getParameter(«EXPAND contextElementType»));
+ }
+ return super.getEditHelperAdvice(req);
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelper.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelper.xpt
new file mode 100644
index 000000000..f5e436dfb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelper.xpt
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE EditHelper FOR gmfgen::MetamodelType-»
+«EXPAND xpt::Common::copyright FOR diagramElement.getDiagram().editorGen-»
+package «diagramElement.getDiagram().editHelpersPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editHelperClassName» extends «diagramElement.getDiagram().getBaseEditHelperQualifiedClassName()» {
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::MetamodelType»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelperAdvice.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelperAdvice.xpt
new file mode 100644
index 000000000..8709546c3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/edithelpers/EditHelperAdvice.xpt
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE EditHelperAdvice FOR gmfgen::SpecializationType-»
+«EXPAND xpt::Common::copyright FOR diagramElement.getDiagram().editorGen-»
+package «diagramElement.getDiagram().editHelpersPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editHelperAdviceClassName» extends org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice {
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::SpecializationType»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Common.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Common.xpt
new file mode 100644
index 000000000..b953130f1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Common.xpt
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE visualIDConstant FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final int VISUAL_ID = «visualID»;
+«ENDDEFINE»
+
+«DEFINE behaviour FOR gmfgen::GenCommonBase-»
+ «EXPAND behaviour FOREACH behaviour-»
+«ENDDEFINE»
+
+«DEFINE behaviour FOR gmfgen::Behaviour-»
+«ENDDEFINE»
+
+«DEFINE behaviour FOR gmfgen::CustomBehaviour-»
+«IF editPolicyQualifiedClassName = null or editPolicyQualifiedClassName.trim().xpandLength() = 0-»
+ removeEditPolicy(«key»); «IF key.xpandStartsWith('"') and key.xpandEndsWith('"')»«EXPAND xpt::Common::nonNLS»«ENDIF»
+«ELSE-»
+ installEditPolicy(«key», new «getEditPolicyQualifiedClassName()»()); «IF key.xpandStartsWith('"') and key.xpandEndsWith('"')»«EXPAND xpt::Common::nonNLS»«ENDIF»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE behaviour FOR gmfgen::OpenDiagramBehaviour-»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.OPEN_ROLE,
+ new «getEditPolicyQualifiedClassName()»());
+«ENDDEFINE»
+
+«DEFINE labelFigure FOR gmfgen::ParentAssignedViewmap-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createFigure() {
+ // Parent should assign one using «EXPAND impl::diagram::editparts::TextAware::labelSetterName»() method
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE labelFigure FOR gmfgen::Viewmap-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createFigure() {
+ org.eclipse.draw2d.IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createFigurePrim() {
+ «EXPAND labelFigurePrim FOR self-»
+«ENDDEFINE»
+
+«DEFINE labelFigurePrim FOR gmfgen::FigureViewmap-»
+«IF figureQualifiedClassName = null-»
+ return new org.eclipse.draw2d.Label();
+«ELSE-»
+ return new «figureQualifiedClassName»();
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE labelFigurePrim FOR gmfgen::SnippetViewmap-»
+ return «body»;
+ }
+«ENDDEFINE»
+
+«DEFINE labelFigurePrim FOR gmfgen::InnerClassViewmap-»
+ return new «className»();
+ }
+
+ «classBody»
+«ENDDEFINE»
+
+«DEFINE labelFigurePrim FOR gmfgen::Viewmap-»
+ «ERROR 'Unknown viewmap: ' + self.repr()-»
+ }
+«ENDDEFINE»
+
+«DEFINE notationalListeners FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); «EXPAND xpt::Common::nonNLS»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); «EXPAND xpt::Common::nonNLS»
+ }
+«ENDDEFINE»
+
+«DEFINE handleBounds FOR gmfgen::GenCommonBase-»
+ 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 handleText FOR gmfgen::GenCommonBase-»
+ if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry.getInstance().getColor(c));
+ } else if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) ||
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) ||
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) ||
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) {
+ org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser modelParser =
+ (org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE installSemanticEditPolicy FOR gmfgen::GenCommonBase-»
+ «IF sansDomain-»
+removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE);
+ «ELSE-»
+installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE, new «getItemSemanticEditPolicyQualifiedClassName()»());
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE installCanonicalEditPolicy FOR gmfgen::GenContainerBase-»
+ «IF needsCanonicalEditPolicy()-»
+installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new «getCanonicalEditPolicyQualifiedClassName()»());
+ «ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/EditPartFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/EditPartFactory.xpt
new file mode 100644
index 000000000..e505c92c8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/EditPartFactory.xpt
@@ -0,0 +1,129 @@
+/*
+ * 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 EditPartFactory FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «editPartsPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPartFactoryClassName» implements org.eclipse.gef.EditPartFactory {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.EditPart createEditPart(org.eclipse.gef.EditPart context, Object model) {
+ if (model instanceof org.eclipse.gmf.runtime.notation.View) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) model;
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(view)) {
+ «EXPAND createEditPart FOR self-»
+ «FOREACH getAllNodes()->asSequence() AS node-»
+ «EXPAND createEditPart FOR node-»
+ «EXPAND createEditPart FOREACH node.labels-»
+ «ENDFOREACH-»
+ «EXPAND createEditPart FOREACH compartments-»
+ «FOREACH links->asSequence() AS link-»
+ «EXPAND createEditPart FOR link-»
+ «EXPAND createEditPart FOREACH link.labels»
+ «ENDFOREACH-»
+ }
+ }
+ return createUnrecognizedEditPart(context, model);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gef.EditPart createUnrecognizedEditPart(org.eclipse.gef.EditPart context, Object model) {
+ // Handle creation of unrecognized child node EditParts here
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static org.eclipse.gef.tools.CellEditorLocator getTextCellEditorLocator(
+ org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart source) {
+ if (source.getFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel)
+ return new TextCellEditorLocator((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) source.getFigure());
+ else {
+ return new LabelCellEditorLocator((org.eclipse.draw2d.Label) source.getFigure());
+ }
+ }
+
+ «EXPAND xpt::Common::generatedClassComment»
+ static private class TextCellEditorLocator implements org.eclipse.gef.tools.CellEditorLocator {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel wrapLabel;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public TextCellEditorLocator(org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel wrapLabel) {
+ this.wrapLabel = wrapLabel;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel getWrapLabel() {
+ return wrapLabel;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void relocate(org.eclipse.jface.viewers.CellEditor celleditor) {
+ org.eclipse.swt.widgets.Text text = (org.eclipse.swt.widgets.Text) celleditor.getControl();
+ org.eclipse.draw2d.geometry.Rectangle rect = getWrapLabel().getTextBounds().getCopy();
+ getWrapLabel().translateToAbsolute(rect);
+ if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) {
+ rect.setSize(new org.eclipse.draw2d.geometry.Dimension(
+ text.computeSize(rect.width, org.eclipse.swt.SWT.DEFAULT)));
+ } else {
+ int avr = org.eclipse.draw2d.FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
+ rect.setSize(new org.eclipse.draw2d.geometry.Dimension(
+ text.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
+ }
+ if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+
+ «EXPAND xpt::Common::generatedClassComment»
+ private static class LabelCellEditorLocator implements org.eclipse.gef.tools.CellEditorLocator {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.Label label;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public LabelCellEditorLocator(org.eclipse.draw2d.Label label) {
+ this.label = label;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.draw2d.Label getLabel() {
+ return label;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void relocate(org.eclipse.jface.viewers.CellEditor celleditor) {
+ org.eclipse.swt.widgets.Text text = (org.eclipse.swt.widgets.Text) celleditor.getControl();
+ org.eclipse.draw2d.geometry.Rectangle rect = getLabel().getTextBounds().getCopy();
+ getLabel().translateToAbsolute(rect);
+ int avr = org.eclipse.draw2d.FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
+ rect.setSize(new org.eclipse.draw2d.geometry.Dimension(
+ text.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
+ if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createEditPart FOR gmfgen::GenCommonBase»
+ «EXPAND xpt::Common::caseVisualID»
+ return new «getEditPartQualifiedClassName()»(view);
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Utils.qvto
new file mode 100644
index 000000000..5275ce260
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editparts/Utils.qvto
@@ -0,0 +1,67 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Utils;
+
+helper isStoringChildPositions(node : genModel::GenNode) : Boolean {
+ return node.getLayoutType() = genModel::ViewmapLayoutType::XY_LAYOUT
+}
+
+helper getExternalLabels(node : genModel::GenNode) : Sequence(genModel::GenExternalNodeLabel) {
+ return (node.labels)[genModel::GenExternalNodeLabel]->asSequence()
+}
+
+helper getSideAffixedChildren(node : genModel::GenNode) : Sequence(genModel::GenChildSideAffixedNode) {
+ return (node.childNodes)[genModel::GenChildSideAffixedNode]->asSequence()
+}
+
+helper getInnerFixedLabels(node : genModel::GenNode) : Sequence(genModel::GenLabel) {
+ return node.labels->-((node.labels)[genModel::GenExternalNodeLabel])->select(e | (Sequence { e.oclAsType(genModel::GenLabel).viewmap })[genModel::ParentAssignedViewmap]->size() > 0)->asSequence()
+}
+
+helper getPinnedCompartments(node : genModel::GenNode) : Sequence(genModel::GenCompartment) {
+ return node.compartments->select(e | (Sequence { e.viewmap })[genModel::ParentAssignedViewmap]->size() > 0)->asSequence()
+}
+
+helper hasFixedChildren(node : genModel::GenNode) : Boolean {
+ return getInnerFixedLabels(node)->size() > 0 or getPinnedCompartments(node)->size() > 0
+}
+
+helper hasChildren(node : genModel::GenNode) : Boolean {
+ return not node.childNodes->isEmpty()
+}
+
+helper listCompartmentHasChildren(compartment : genModel::GenCompartment) : Boolean {
+ return compartment.listLayout and compartment.childNodes->size() > 0
+}
+
+helper hasChildrenInListCompartments(node : genModel::GenNode) : Boolean {
+ return node.compartments->exists(e | listCompartmentHasChildren(e))
+}
+
+helper hasBorderItems(node : genModel::GenNode) : Boolean {
+ return getSideAffixedChildren(node)->size() > 0 or getExternalLabels(node)->size() > 0
+}
+
+helper needsGraphicalNodeEditPolicy(node : genModel::GenNode) : Boolean {
+ return null <> node.modelFacet and node.reorientedIncomingLinks->size() > 0
+}
+
+helper i18nKeyForCompartmentTitle(compartment : genModel::GenCompartment) : String {
+ return compartment.editPartClassName + '.title'
+}
+
+helper shouldGenerateDiagramViewmap(genDiagram : genModel::GenDiagram) : Boolean {
+ return not Sequence { genModel::ViewmapLayoutType::UNKNOWN, genModel::ViewmapLayoutType::XY_LAYOUT }->includes(genDiagram.viewmap.layoutType)
+}
+
+helper getAssistantOutgoingLinks(node : genModel::GenNode) : Sequence(genModel::GenLink) {
+ return node.genOutgoingLinks->select(link | not selectGenNodes(link.targets->asSequence())->isEmpty())->asSequence()
+}
+
+helper getAssistantIncomingLinks(node : genModel::GenNode) : Sequence(genModel::GenLink) {
+ return node.genIncomingLinks->select(link | not selectGenNodes(link.sources->asSequence())->isEmpty())->asSequence()
+}
+
+helper selectGenNodes(ends : Sequence(genModel::GenLinkEnd)) : Sequence(genModel::GenLinkEnd) {
+ return (ends)[genModel::GenNode]
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..1066db193
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
@@ -0,0 +1,547 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::diagram::editpolicies::Utils»
+«EXTENSION xpt::diagram::Utils»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::expressions::ValueExpression»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE BaseItemSemanticEditPolicy FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «baseItemSemanticEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Extended request data key to hold editpart visual id.
+Add visual id of edited editpart to extended data of the request
+so command switch can decide what kind of diagram element is being edited.
+It is done in those cases when it''s not possible to deduce diagram
+element kind from domain element.
+'
+ )»
+ public org.eclipse.gef.commands.Command getCommand(org.eclipse.gef.Request request) {
+ if (request instanceof org.eclipse.gef.requests.ReconnectRequest) {
+ Object view = ((org.eclipse.gef.requests.ReconnectRequest) request).getConnectionEditPart().getModel();
+ if (view instanceof org.eclipse.gmf.runtime.notation.View) {
+ Integer id = new Integer(«EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»((org.eclipse.gmf.runtime.notation.View) view));
+ request.getExtendedData().put(VISUAL_ID_KEY, id);
+ }
+ }
+ return super.getCommand(request);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Returns visual id from request parameters.
+')»
+ protected int getVisualID(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ Object id = request.getParameter(VISUAL_ID_KEY);
+ return id instanceof Integer ? ((Integer) id).intValue() : -1;
+ }
+
+ «EXPAND semanticPart-»
+
+ «EXPAND xpt::Common::generatedMemberComment('Returns editing domain from the host edit part.
+')»
+ protected org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain() {
+ return ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Creates command to destroy the link.
+')»
+ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.notation.View view) {
+ org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) getHost().getViewer().getEditPartRegistry().get(view);
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest request =
+ new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(getEditingDomain(), false);
+ return editPart.getCommand(
+ new org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper(request, java.util.Collections.EMPTY_MAP));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Creates commands to destroy all host incoming and outgoing links.
+')»
+ protected org.eclipse.gef.commands.CompoundCommand getDestroyEdgesCommand() {
+ org.eclipse.gef.commands.CompoundCommand cmd = new org.eclipse.gef.commands.CompoundCommand();
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ for (java.util.Iterator it = view.getSourceEdges().iterator(); it.hasNext();) {
+ cmd.add(getDestroyElementCommand((org.eclipse.gmf.runtime.notation.Edge) it.next()));
+ }
+ for (java.util.Iterator it = view.getTargetEdges().iterator(); it.hasNext();) {
+ cmd.add(getDestroyElementCommand((org.eclipse.gmf.runtime.notation.Edge) it.next()));
+ }
+ return cmd;
+ }
+
+ «EXPAND addDestroyShortcutsCommand-»
+
+ «EXPAND linkConstraints-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment('Extended request data key to hold editpart visual id.
+')»
+ public static final String VISUAL_ID_KEY = "visual_id"; «EXPAND xpt::Common::nonNLS»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.gmf.runtime.emf.type.core.IElementType myElementType;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «baseItemSemanticEditPolicyClassName»(org.eclipse.gmf.runtime.emf.type.core.IElementType elementType) {
+ myElementType = elementType;
+ }
+«ENDDEFINE»
+
+«DEFINE addDestroyShortcutsCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void addDestroyShortcutsCommand(org.eclipse.gef.commands.CompoundCommand command) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ if (view.getEAnnotation("Shortcut") != null) { «EXPAND xpt::Common::nonNLS»
+ return;
+ }
+ for (java.util.Iterator it = view.getDiagram().getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { «EXPAND xpt::Common::nonNLS»
+ continue;
+ }
+ command.add(getDestroyElementCommand(nextView));
+ }
+}
+«ENDDEFINE»
+
+«DEFINE semanticPart FOR gmfgen::GenDiagram-»
+ «EXPAND getSemanticCommand-»
+
+ «EXPAND addDeleteViewCommand-»
+
+ «EXPAND getEditHelperCommand-»
+
+ «EXPAND getContextElementType-»
+
+ «EXPAND getSemanticCommandSwitch-»
+
+ «EXPAND getConfigureCommand-»
+
+ «EXPAND getCreateRelationshipCommand-»
+
+ «EXPAND getCreateCommand-»
+
+ «EXPAND getSetCommand-»
+
+ «EXPAND getEditContextCommand-»
+
+ «EXPAND getDestroyElementCommand-»
+
+ «EXPAND getDestroyReferenceCommand-»
+
+ «EXPAND getDuplicateCommand-»
+
+ «EXPAND getMoveCommand-»
+
+ «EXPAND getReorientReferenceRelationshipCommand-»
+
+ «EXPAND getReorientRelationshipCommand-»
+
+ «EXPAND getGEFWrapper-»
+ «EXPAND getMSLWrapper-»
+
+ «EXPAND getSemanticElement-»
+«ENDDEFINE»
+
+«DEFINE getEditHelperCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gef.commands.Command getEditHelperCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request, org.eclipse.gef.commands.Command editPolicyCommand) {
+ if (editPolicyCommand != null) {
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = editPolicyCommand instanceof org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy ? ((org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) editPolicyCommand).getICommand() : new org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy(editPolicyCommand);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::editPolicyCommandConstant», command);
+ }
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestContextElementType = getContextElementType(request);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::contextElementTypeConstant», requestContextElementType);
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = requestContextElementType.getEditCommand(request);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::editPolicyCommandConstant», null);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::contextElementTypeConstant», null);
+ if (command != null) {
+ if (!(command instanceof org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ command = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command);
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ }
+ return editPolicyCommand;
+ }
+«ENDDEFINE»
+
+«DEFINE getContextElementType FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.emf.type.core.IElementType getContextElementType(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestContextElementType = «getElementTypesQualifiedClassName()».getElementType(getVisualID(request));
+ return requestContextElementType != null ? requestContextElementType : myElementType;
+ }
+«ENDDEFINE»
+
+«DEFINE getSemanticCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getSemanticCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest completedRequest = completeRequest(request);
+ org.eclipse.gef.commands.Command semanticCommand = getSemanticCommandSwitch(completedRequest);
+ semanticCommand = getEditHelperCommand(completedRequest, semanticCommand);
+ if (completedRequest instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) {
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest destroyRequest = (org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) completedRequest;
+ return shouldProceed(destroyRequest) ? addDeleteViewCommand(semanticCommand, destroyRequest) : null;
+ }
+ return semanticCommand;
+ }
+«ENDDEFINE»
+
+«DEFINE addDeleteViewCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command addDeleteViewCommand(org.eclipse.gef.commands.Command mainCommand, org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest completedRequest){
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ org.eclipse.gef.commands.Command deleteViewCommand = getGEFWrapper(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(editingDomain, (org.eclipse.gmf.runtime.notation.View) getHost().getModel()));
+ return mainCommand == null ? deleteViewCommand : mainCommand.chain(deleteViewCommand);
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticCommandSwitch FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getSemanticCommandSwitch(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest req) {
+ if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest) {
+ return getCreateRelationshipCommand((org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) {
+ return getCreateCommand((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) {
+ return getConfigureCommand((org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) {
+ return getDestroyElementCommand((org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest) {
+ return getDestroyReferenceCommand((org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest) {
+ return getDuplicateCommand((org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest) {
+ return getEditContextCommand((org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest) {
+ return getMoveCommand((org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest) {
+ return getReorientReferenceRelationshipCommand((org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest) {
+ return getReorientRelationshipCommand((org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest) {
+ return getSetCommand((org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest) req);
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getConfigureCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getCreateRelationshipCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getCreateCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getSetCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getEditContextCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getEditContextCommand(org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDestroyElementCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDestroyReferenceCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDuplicateCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDuplicateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getMoveCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getMoveCommand(org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getReorientReferenceRelationshipCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getReorientReferenceRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest req) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+}
+«ENDDEFINE»
+
+«DEFINE getReorientRelationshipCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+}
+«ENDDEFINE»
+
+«DEFINE getGEFWrapper FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected final org.eclipse.gef.commands.Command getGEFWrapper(org.eclipse.gmf.runtime.common.core.command.ICommand cmd) {
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(cmd);
+ }
+«ENDDEFINE»
+
+«DEFINE getMSLWrapper FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment('@deprecated use getGEFWrapper() instead')»
+ protected final org.eclipse.gef.commands.Command getMSLWrapper(org.eclipse.gmf.runtime.common.core.command.ICommand cmd) {
+ // XXX deprecated: use getGEFWrapper() instead
+ return getGEFWrapper(cmd);
+ }
+«ENDDEFINE»
+
+«DEFINE getSemanticElement FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.emf.ecore.EObject getSemanticElement() {
+ return org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.resolveSemanticElement((org.eclipse.gmf.runtime.notation.View) getHost().getModel());
+}
+«ENDDEFINE»
+
+
+«REM»
+ FIXME need to check constraint's provider to ensure we don't generate a field
+ for e.g. Java (or Literal, which is unlikely, though) expressions
+«ENDREM»
+«DEFINE linkConstraints FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedClassComment»
+public static class «getLinkCreationConstraintsClassName()» {
+
+«IF null <> editorGen.expressionProviders-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static final String OPPOSITE_END_VAR = "oppositeEnd"; «EXPAND xpt::Common::nonNLS»
+
+«FOREACH getValidLinkConstraints(self) AS lc-»
+«IF lc.sourceEnd <> null-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static «editorGen.expressionProviders.getAbstractExpressionQualifiedClassName()» «sourceConstraintFieldName(lc.link)»;
+«ENDIF-»
+«IF lc.targetEnd <> null-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static «editorGen.expressionProviders.getAbstractExpressionQualifiedClassName()» «targetConstraintFieldName(lc.link)»;
+«ENDIF-»
+«ENDFOREACH»
+«ENDIF-»
+
+ «EXPAND canCreate FOREACH links-»
+ «EXPAND canExist FOREACH links-»
+}
+«ENDDEFINE»
+
+«DEFINE canCreate FOR gmfgen::GenLink»
+
+«EXPAND xpt::Common::generatedMemberComment»
+public static boolean canCreate«getUniqueIdentifier()»(«EXPAND canCreateParameters FOR modelFacet») {
+ «EXPAND checkEMFConstraints FOR modelFacet-»
+ return canExist«getUniqueIdentifier()»(«EXPAND canCreateValues FOR modelFacet»);
+}
+«ENDDEFINE»
+
+«REM»
+ XXX for now, both constraints are injected into single method
+ which may nob be suitable for modification especially when mixing
+ java and ocl constraints (former requires manual code).
+ Better approach would be:
+ if either is non-null and providers are not the same - introduce two methods,
+ to check source and target separately. Otherwize, do it inplace.
+«ENDREM»
+«DEFINE canExist FOR gmfgen::GenLink»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static boolean canExist«getUniqueIdentifier()»(«EXPAND canCreateParameters FOR modelFacet») {
+«IF creationConstraints <> null and (creationConstraints.isValid() and null <> getDiagram().editorGen.expressionProviders)-»
+ try {
+«IF null <> creationConstraints.sourceEnd-»
+ «EXPAND checkAdditionalConstraint(creationConstraints.sourceEnd, sourceConstraintFieldName(self), 'source', 'target', creationConstraints.getSourceEndContextClass(), creationConstraints.getTargetEndContextClass()) FOR creationConstraints.sourceEnd.provider-»
+«ENDIF-»
+«IF null <> creationConstraints.targetEnd-»
+ «EXPAND checkAdditionalConstraint(creationConstraints.targetEnd, targetConstraintFieldName(self), 'target', 'source', creationConstraints.getTargetEndContextClass(), creationConstraints.getSourceEndContextClass()) FOR creationConstraints.targetEnd.provider-»
+«ENDIF-»
+ return true;
+ } catch(Exception e) {
+ «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Link constraint evaluation error", e); «EXPAND xpt::Common::nonNLS»
+ return false;
+ }
+«ELSE-»
+ return true;
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE canCreateParameters FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE»
+«DEFINE canCreateParameters FOR gmfgen::TypeLinkModelFacet»«IF hasContainerOtherThanSource(self)»«EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container, «ENDIF»«EXPAND sourceTargetParameters»«ENDDEFINE»
+«DEFINE canCreateParameters FOR gmfgen::FeatureLinkModelFacet»«EXPAND sourceTargetParameters»«ENDDEFINE»
+
+«DEFINE sourceTargetParameters FOR gmfgen::LinkModelFacet»«EXPAND MetaModel::QualifiedClassName FOR getSourceType()» source, «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» target«ENDDEFINE»
+
+«DEFINE canCreateValues FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE»
+«DEFINE canCreateValues FOR gmfgen::TypeLinkModelFacet»«IF hasContainerOtherThanSource(self)»container, «ENDIF»source, target«ENDDEFINE»
+«DEFINE canCreateValues FOR gmfgen::FeatureLinkModelFacet»source, target«ENDDEFINE»
+
+
+
+«DEFINE checkEMFConstraints FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE»
+
+«DEFINE checkEMFConstraints FOR gmfgen::TypeLinkModelFacet-»
+ «LET childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 AS checkChildFeatureUpperBound-»
+ «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 or checkChildFeatureUpperBound-»
+if («getContainerVariable(self)» != null) {
+ «EXPAND checkEMFConstraints(self) FOR containmentMetaFeature-»
+ «IF checkChildFeatureUpperBound-»
+ «EXPAND checkEMFConstraints(self) FOR childMetaFeature-»
+ «ENDIF-»
+}
+ «ENDIF-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE checkEMFConstraints(modelFacet : gmfgen::TypeLinkModelFacet) FOR genmodel::GenFeature-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) > 0-»
+if («EXPAND featureBoundComparator(getContainerVariable(modelFacet), modelFacet.getSourceType())») {
+ return false;
+}
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkEMFConstraints FOR gmfgen::FeatureLinkModelFacet-»
+if (source != null) {
+ if («EXPAND featureBoundsConditionClause('source', getSourceType()) FOR metaFeature») {
+ return false;
+ }
+ «IF isContains(metaFeature)-»
+ if (source == target) {
+ return false;
+ }
+ «ENDIF-»
+}
+«IF getReverse(metaFeature) <> null-»
+if (target != null && («EXPAND featureBoundsConditionClause('target', getTargetType()) FOR getReverse(metaFeature)»)) {
+ return false;
+}
+«ENDIF»
+«ENDDEFINE»
+
+«DEFINE featureBoundsConditionClause(targetVar : String, targetType : genmodel::GenClass) FOR genmodel::GenFeature-»
+«REM»Checking upper bounds if was specified in MM«ENDREM»«-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) > 0»«EXPAND featureBoundComparator(targetVar, targetType)»«ENDIF-»
+«REM»Checking uniqueness in addition if upper bounds > 1«ENDREM»«-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) > 1» || «ENDIF-»
+«REM»Checking uniqueness in if upper bounds > 1 or < 0«ENDREM»«-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) <> 1»«EXPAND featureUniquenessComparator(targetVar, targetType)»«ENDIF»
+«ENDDEFINE»
+
+«DEFINE featureBoundComparator(featureVar : String, featureVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature»«EXPAND MetaModel::getFeatureValue(featureVar, featureVarGenClass)»«IF ecoreFeature.upperBound.oclAsType(Integer) = 1» != null«ELSE».size() >= «ecoreFeature.upperBound.oclAsType(Integer)»«ENDIF»«ENDDEFINE»
+«DEFINE featureUniquenessComparator(featureVar : String, featureVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature»«EXPAND MetaModel::getFeatureValue(featureVar, featureVarGenClass) FOR self».contains(target)«ENDDEFINE»
+
+
+«DEFINE checkAdditionalConstraint(valueExpr : gmfgen::ValueExpression, constraintFieldName : String, sourceEndVar : String, targetEndVar : String, context : genmodel::GenClass, oppositeEndContext : genmodel::GenClass) FOR gmfgen::GenExpressionProviderBase»
+«ERROR 'Have no idea what extra constraints to check for ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE checkAdditionalConstraint(valueExpr : gmfgen::ValueExpression, constraintFieldName : String, sourceEndVar : String, targetEndVar : String, context : genmodel::GenClass, oppositeEndContext : genmodel::GenClass) FOR gmfgen::GenExpressionInterpreter-»
+ if («sourceEndVar» == null) {
+ return true;
+ }
+ if («constraintFieldName» == null) {
+ java.util.Map env = java.util.Collections.singletonMap(OPPOSITE_END_VAR, «EXPAND MetaModel::MetaClass FOR oppositeEndContext»);
+ «constraintFieldName» = «getQualifiedClassName()».«getExpressionAccessor(valueExpr)»(«valueExpr.getBodyString()», «EXPAND MetaModel::MetaClass FOR context», env); «EXPAND xpt::Common::nonNLS»
+ }
+ Object «sourceEndVar»Val = «constraintFieldName».evaluate(«sourceEndVar», java.util.Collections.singletonMap(OPPOSITE_END_VAR, «targetEndVar»));
+ if (false == «sourceEndVar»Val instanceof Boolean || !((Boolean) «sourceEndVar»Val).booleanValue()) {
+ return false;
+ } // else fall-through
+«ENDDEFINE»
+
+«DEFINE checkAdditionalConstraint(valueExpr : gmfgen::ValueExpression, constraintFieldName : String, sourceEndVar : String, targetEndVar : String, context : genmodel::GenClass, oppositeEndContext : genmodel::GenClass) FOR gmfgen::GenJavaExpressionProvider-»
+«IF injectExpressionBody and (valueExpr.body <> null and valueExpr.body.xpandLength() <> 0)-»
+ «valueExpr.body»
+«ELSEIF throwException or (injectExpressionBody and (valueExpr.body = null or valueExpr.body.xpandLength() = 0))-»
+ // TODO: implement this method, using «sourceEndVar» and «targetEndVar»
+ // to access link source and target, respectively
+ // Ensure that you remove @generated or mark it @generated NOT
+ if (Boolean.TRUE.booleanValue()) {
+ throw new java.lang.UnsupportedOperationException("No java implementation provided");«EXPAND xpt::Common::nonNLS»
+ }
+«ELSE-»
+ if (Boolean.TRUE.booleanValue()) {«REM»just in case there are two consecutive java expression with neither throw nor inject - avoid unreachable code.«ENDREM»
+ return false;
+ }
+«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE incorrectLinkModelFacet FOR gmfgen::LinkModelFacet»«ERROR 'Unrecognized link model facet: ' + self.repr()»«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE defaultConstructor FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «itemSemanticEditPolicyClassName»() {
+ «EXPAND defaultConstructorBody-»
+ }
+«ENDDEFINE»
+
+«REM»
+ This method should be called only with diagram, node or link used as a parameter
+ (then elementType != null)
+«ENDREM»
+«DEFINE defaultConstructorBody FOR gmfgen::GenCommonBase-»
+ «IF elementType = null-»
+ «ERROR 'No element type in the passed node. Only diagram, node or link are supported in this template: ' + self.repr()-»
+ «ENDIF-»
+ super(«EXPAND xpt::providers::ElementTypes::accessElementType»);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt
new file mode 100644
index 000000000..a13e0fed6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE ChildContainerCanonicalEditPolicy FOR gmfgen::GenChildContainer-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «canonicalEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy {
+
+ «EXPAND xpt::diagram::updater::containerBaseCanonicalMethods::containerBaseCanonicalMethods-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenChildContainer»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..72cbc5316
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt
@@ -0,0 +1,38 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE CompartmentItemSemanticEditPolicy FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «getDiagram().getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND _constructor-»
+
+ «EXPAND xpt::diagram::editpolicies::childContainerCreateCommand::childContainerCreateCommand FOR childNodes->asSequence()-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «itemSemanticEditPolicyClassName»() {
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructorBody FOR node-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenCompartment-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt
new file mode 100644
index 000000000..143126a59
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::editpolicies::Utils»
+«EXTENSION xpt::diagram::updater::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE DiagramCanonicalEditPolicy FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «canonicalEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalConnectionEditPolicy {
+
+ «EXPAND xpt::diagram::updater::containerBaseCanonicalMethods::containerBaseCanonicalMethods-»
+
+ «EXPAND getSemanticConnectionsList-»
+
+ «EXPAND getSourceElement-»
+
+ «EXPAND getTargetElement-»
+
+ «EXPAND shouldIncludeConnection-»
+
+ «EXPAND refreshSemantic-»
+
+ «EXPAND getDiagram-»
+
+ «EXPAND refreshLinks-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticConnectionsList FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected java.util.List getSemanticConnectionsList() {
+ return java.util.Collections.EMPTY_LIST;
+}
+«ENDDEFINE»
+
+«DEFINE getSourceElement FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.emf.ecore.EObject getSourceElement(org.eclipse.emf.ecore.EObject relationship) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getTargetElement FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.emf.ecore.EObject getTargetElement(org.eclipse.emf.ecore.EObject relationship) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE shouldIncludeConnection FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected boolean shouldIncludeConnection(org.eclipse.gmf.runtime.notation.Edge connector, java.util.Collection children) {
+ return false;
+}
+«ENDDEFINE»
+
+«DEFINE refreshSemantic FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void refreshSemantic() {
+ java.util.List createdViews = new java.util.LinkedList();
+ createdViews.addAll(refreshSemanticChildren());
+ java.util.List createdConnectionViews = new java.util.LinkedList();
+ createdConnectionViews.addAll(refreshSemanticConnections());
+ «IF not links->isEmpty()-»
+ createdConnectionViews.addAll(refreshConnections());
+ «ENDIF-»
+
+ if (createdViews.size() > 1) {
+ // perform a layout of the container
+ org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand layoutCmd = new org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
+ executeCommand(new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(layoutCmd));
+ }
+
+ createdViews.addAll(createdConnectionViews);
+ makeViewsImmutable(createdViews);
+}
+«ENDDEFINE»
+
+«DEFINE refreshLinks FOR gmfgen::GenDiagram-»
+ «IF not links->isEmpty()-»
+ «EXPAND refreshConnections-»
+
+ «EXPAND collectAllLinks-»
+
+ «EXPAND createConnections-»
+
+ «EXPAND getEditPart-»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE refreshConnections FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection refreshConnections() {
+ java.util.Map domain2NotationMap = new java.util.HashMap();
+ java.util.Collection linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap);
+ java.util.Collection existingLinks = new java.util.LinkedList(getDiagram().getEdges());
+ for (java.util.Iterator linksIterator = existingLinks.iterator(); linksIterator.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge nextDiagramLink = (org.eclipse.gmf.runtime.notation.Edge) linksIterator.next();
+ int diagramLinkVisualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(nextDiagramLink);
+ if (diagramLinkVisualID == -1) {
+ if (nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) {
+ linksIterator.remove();
+ }
+ continue;
+ }
+ org.eclipse.emf.ecore.EObject diagramLinkObject = nextDiagramLink.getElement();
+ org.eclipse.emf.ecore.EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
+ org.eclipse.emf.ecore.EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
+ for (java.util.Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
+ «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») linkDescriptorsIterator.next();
+ if (diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) {
+ linksIterator.remove();
+ linkDescriptorsIterator.remove();
+ break;
+ }
+ }
+ }
+ deleteViews(existingLinks.iterator());
+ return createConnections(linkDescriptors, domain2NotationMap);
+}
+«ENDDEFINE»
+
+«DEFINE collectAllLinks FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection collectAllLinks(org.eclipse.gmf.runtime.notation.View view, java.util.Map domain2NotationMap) {
+ if (!«EXPAND xpt::editor::VisualIDRegistry::modelID».equals(«EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall»(view))) {
+ return java.util.Collections.EMPTY_LIST;
+ }
+ java.util.Collection result = new java.util.LinkedList();
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(view)) {
+ «EXPAND caseSemanticElement FOREACH getAllSemanticElements(self)-»
+ }
+ for (java.util.Iterator children = view.getChildren().iterator(); children.hasNext();) {
+ result.addAll(collectAllLinks((org.eclipse.gmf.runtime.notation.View) children.next(), domain2NotationMap));
+ }
+ for (java.util.Iterator edges = view.getSourceEdges().iterator(); edges.hasNext();) {
+ result.addAll(collectAllLinks((org.eclipse.gmf.runtime.notation.View) edges.next(), domain2NotationMap));
+ }
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE caseSemanticElement FOR gmfgen::GenCommonBase-»
+«EXPAND xpt::Common::caseVisualID» {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+«REM»
+ Processing each domain element only once. Prevents us from
+ having duplicated links if a shortcut to one of the "main"
+ diagram elements present on diagram.
+«ENDREM»«-»
+ result.addAll(«EXPAND xpt::diagram::updater::DiagramUpdater::getContainedLinksMethodCall»(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { «EXPAND xpt::Common::nonNLS»
+«REM»
+ Storing element view or replacing shortcut by the "original" element view.
+«ENDREM»«-»
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+}
+«ENDDEFINE»
+
+«REM»
+ GMF has no links to "leaf" child nodes.
+«ENDREM»
+«DEFINE caseSemanticElement FOR gmfgen::GenChildLabelNode»«ENDDEFINE»
+
+«DEFINE colectContainedLink FOR gmfgen::GenLink-»
+«EXPAND xpt::diagram::updater::DiagramUpdater::getContainedLinksMethodCall»(modelElement));
+«ENDDEFINE»
+
+«DEFINE createConnections FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection createConnections(java.util.Collection linkDescriptors, java.util.Map domain2NotationMap) {
+ java.util.List adapters = new java.util.LinkedList();
+ for (java.util.Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
+ final «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») linkDescriptorsIterator.next();
+ org.eclipse.gef.EditPart sourceEditPart = getEditPart(nextLinkDescriptor.getSource(), domain2NotationMap);
+ org.eclipse.gef.EditPart targetEditPart = getEditPart(nextLinkDescriptor.getDestination(), domain2NotationMap);
+ if (sourceEditPart == null || targetEditPart == null) {
+ continue;
+ }
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor(nextLinkDescriptor.getSemanticAdapter(), null, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, false, ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getDiagramPreferencesHint());
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest ccr = new org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest(descriptor);
+ ccr.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_CONNECTION_START);
+ ccr.setSourceEditPart(sourceEditPart);
+ sourceEditPart.getCommand(ccr);
+ ccr.setTargetEditPart(targetEditPart);
+ ccr.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_CONNECTION_END);
+ org.eclipse.gef.commands.Command cmd = targetEditPart.getCommand(ccr);
+ if (cmd != null && cmd.canExecute()) {
+ executeCommand(cmd);
+ org.eclipse.core.runtime.IAdaptable viewAdapter = (org.eclipse.core.runtime.IAdaptable) ccr.getNewObject();
+ if (viewAdapter != null) {
+ adapters.add(viewAdapter);
+ }
+ }
+ }
+ return adapters;
+}
+«ENDDEFINE»
+
+«DEFINE getEditPart FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gef.EditPart getEditPart(org.eclipse.emf.ecore.EObject domainModelElement, java.util.Map domain2NotationMap) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) domain2NotationMap.get(domainModelElement);
+ if (view != null) {
+ return (org.eclipse.gef.EditPart) getHost().getViewer().getEditPartRegistry().get(view);
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDiagram FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gmf.runtime.notation.Diagram getDiagram() {
+ return ((org.eclipse.gmf.runtime.notation.View) getHost().getModel()).getDiagram();
+}
+«ENDDEFINE»
+
+«DEFINE incorrectLinkModelFacet FOR gmfgen::LinkModelFacet-»
+ «ERROR 'Incorrect LinkModelFacet: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..687c1ff54
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE DiagramItemSemanticEditPolicy FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructor-»
+
+ «EXPAND xpt::diagram::editpolicies::childContainerCreateCommand::childContainerCreateCommand FOR topLevelNodes->asSequence()-»
+
+ «EXPAND getDuplicateCommand-»
+
+ «EXPAND DuplicateAnythingCommand-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE getDuplicateCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDuplicateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest req) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
+}
+«ENDDEFINE»
+
+«DEFINE DuplicateAnythingCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private static class DuplicateAnythingCommand extends org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand {
+
+ «EXPAND DAC_constructor-»
+
+ «EXPAND DAC_additions-»
+}
+«ENDDEFINE»
+
+«DEFINE DAC_constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public DuplicateAnythingCommand(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest req) {
+ super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(), req.getAllDuplicatedElementsMap());
+}
+«ENDDEFINE»
+
+«DEFINE DAC_additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt
new file mode 100644
index 000000000..c0590c364
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt
@@ -0,0 +1,72 @@
+/*
+ * 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'»
+
+«DEFINE GraphicalNodeEditPolicy FOR gmfgen::GenNode-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «graphicalNodeEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy {
+
+ «EXPAND xpt::Common::generatedClassComment»
+ protected org.eclipse.gef.commands.Command getConnectionCompleteCommand(
+ org.eclipse.gef.requests.CreateConnectionRequest request) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getElementType(request);
+ «FOREACH reorientedIncomingLinks->asSequence() AS link-»
+ if («EXPAND xpt::providers::ElementTypes::accessElementType FOR link» == elementType) {
+ «IF link.outgoingCreationAllowed-»
+ if (request.getSourceEditPart() != getHost()) {
+ «ENDIF-»
+ return getConnectionWithReorientedViewCompleteCommand(request);
+ «IF link.outgoingCreationAllowed-»
+ }
+ «ENDIF-»
+ }
+ «ENDFOREACH-»
+ return super.getConnectionCompleteCommand(request);
+ }
+
+ «EXPAND xpt::Common::generatedClassComment»
+ protected org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(
+ org.eclipse.gef.requests.CreateConnectionRequest request) {
+ if (request instanceof org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest) {
+ org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter requestAdapter =
+ ((org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest) request)
+ .getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
+ return (org.eclipse.gmf.runtime.emf.type.core.IElementType) requestAdapter.getAdapter(
+ org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
+ }
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedClassComment»
+ protected org.eclipse.gef.commands.Command getConnectionWithReorientedViewCompleteCommand(
+ org.eclipse.gef.requests.CreateConnectionRequest request) {
+ org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy c =
+ (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) super.getConnectionCompleteCommand(request);
+ org.eclipse.gmf.runtime.common.core.command.CompositeCommand cc =
+ (org.eclipse.gmf.runtime.common.core.command.CompositeCommand) c.getICommand();
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain =
+ ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ «getDiagram().getReorientConnectionViewCommandQualifiedClassName()» rcvCommand =
+ new «getDiagram().getReorientConnectionViewCommandQualifiedClassName()»(editingDomain, null);
+ rcvCommand.setEdgeAdaptor(getViewAdapter());
+ cc.compose(rcvCommand);
+ return c;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..764aace1f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
@@ -0,0 +1,68 @@
+/*
+ * 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
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::editpolicies::LinkUtils»
+
+«DEFINE LinkItemSemanticEditPolicy FOR gmfgen::GenLink-»
+ «EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «diagram.getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructor-»
+
+ «EXPAND classBody-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE classBody FOR gmfgen::GenLink-»
+ «EXPAND getDestroySemanticCommand FOR modelFacet -»
+ «IF isTypeLink(self)-»
+ «EXPAND xpt::diagram::editpolicies::linkCommands::linkCommands -»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getDestroySemanticCommand FOR gmfgen::LinkModelFacet-»
+ «ERROR 'Unsupported model facet: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE getDestroySemanticCommand FOR gmfgen::FeatureLinkModelFacet-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
+ return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(req)«IF isContains(metaFeature)» {
+
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.emf.ecore.EObject referencedObject = getReferencedObject();
+ org.eclipse.emf.ecore.resource.Resource resource = referencedObject.eResource();
+ org.eclipse.gmf.runtime.common.core.command.CommandResult result = super.doExecuteWithResult(progressMonitor, info);
+ resource.getContents().add(referencedObject);
+ return result;
+ }
+
+ }«ENDIF»);
+}
+«ENDDEFINE»
+
+«DEFINE getDestroySemanticCommand FOR gmfgen::TypeLinkModelFacet-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLink»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto
new file mode 100644
index 000000000..1726ee0d5
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto
@@ -0,0 +1,40 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
+
+library LinkUtils;
+
+helper isTypeLink(link : genModel::GenLink) : Boolean {
+ return (Sequence { link.modelFacet })[genModel::TypeLinkModelFacet]->size() > 0
+}
+
+helper isRefLink(link : genModel::GenLink) : Boolean {
+ return (Sequence { link.modelFacet })[genModel::FeatureLinkModelFacet]->size() > 0
+}
+
+helper canBeSource(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return link.sources->includes(linkEnd)
+}
+
+helper canBeTarget(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return link.targets->includes(linkEnd)
+}
+
+helper canBeContainer(link : genModel::GenLink, metaClass : genModel_1::GenClass) : Boolean {
+ return null <> link.modelFacet and isCompatible(link.modelFacet.getContainerClass(), metaClass)
+}
+
+helper genModel::LinkModelFacet::getContainerClass() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::TypeLinkModelFacet::getContainerClass() : genModel_1::GenClass {
+ return self.childMetaFeature.genClass
+}
+
+helper genModel::FeatureLinkModelFacet::getContainerClass() : genModel_1::GenClass {
+ return self.getSourceType()
+}
+
+helper isCompatible(desiredType : genModel_1::GenClass, actualClass : genModel_1::GenClass) : Boolean {
+ return null <> desiredType and desiredType.ecoreClass.isSuperTypeOf(actualClass.ecoreClass)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..50c775256
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt
@@ -0,0 +1,112 @@
+/*
+ * 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
+ */
+
+«REM»
+ This template should be called only for non-design nodes (modelFacet != null)
+ because *ItemSemanticEditPolicy responsible for dealing with semantic model
+ elements and meaningless (should not be generated) for pure design nodes.
+«ENDREM»
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::diagram::editpolicies::Utils»
+
+«DEFINE NodeItemSemanticEditPolicy FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «getDiagram().getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructor-»
+
+ «EXPAND xpt::diagram::editpolicies::childContainerCreateCommand::childContainerCreateCommand FOR childNodes->asSequence()-»
+
+ «EXPAND getDestroyElementCommand-»
+ «IF hasChildrenOrCompartments(self)-»
+ «EXPAND addDestroyChildNodesCommand-»
+ «ENDIF-»
+ «EXPAND xpt::diagram::editpolicies::linkCommands::linkCommands-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE getDestroyElementCommand FOR gmfgen::GenNode-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ org.eclipse.gef.commands.CompoundCommand cc = getDestroyEdgesCommand();
+ «IF hasChildrenOrCompartments(self)-»
+ addDestroyChildNodesCommand(cc);
+ «ENDIF-»
+ addDestroyShortcutsCommand(cc);
+ «EXPAND destroySemanticElement-»
+ return cc.unwrap();
+}
+«ENDDEFINE»
+
+«DEFINE destroySemanticElement FOR gmfgen::GenNode-»
+ «EXPAND fixElementToDeleteIfShortcut-»
+cc.add(getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)));
+«ENDDEFINE»
+
+«DEFINE addDestroyChildNodesCommand FOR gmfgen::GenNode-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addDestroyChildNodesCommand(org.eclipse.gef.commands.CompoundCommand cmd) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «EXPAND xpt::Common::nonNLS»
+ if (annotation != null) {
+ return;
+ }
+ for (java.util.Iterator it = view.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) it.next();
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(node)) {
+ «EXPAND destroyChildNodes('node')-»
+ «IF not compartments->isEmpty()-»
+ «FOREACH compartments->asSequence() AS compartment-»
+ «EXPAND xpt::Common::caseVisualID FOR compartment»
+ for (java.util.Iterator cit = node.getChildren().iterator(); cit.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Node cnode = (org.eclipse.gmf.runtime.notation.Node) cit.next();
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(cnode)) {
+ «EXPAND destroyChildNodes('cnode') FOR compartment-»
+ }
+ }
+ break;
+ «ENDFOREACH-»
+ «ENDIF-»
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE destroyChildNodes(nodeVar : String) FOR gmfgen::GenChildContainer-»
+ «FOREACH childNodes->asSequence() AS childNode-»
+ «EXPAND xpt::Common::caseVisualID FOR childNode»
+ cmd.add(getDestroyElementCommand(«nodeVar»));
+ break;
+ «ENDFOREACH-»
+«ENDDEFINE»
+
+
+«DEFINE fixElementToDeleteIfShortcut FOR gmfgen::GenTopLevelNode-»
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ if (view.getEAnnotation("Shortcut") != null) { «EXPAND xpt::Common::nonNLS»
+ req.setElementToDestroy(view);
+ }
+«ENDDEFINE»
+
+«REM»Shortcuts supported only for top-level elements«ENDREM»
+«DEFINE fixElementToDeleteIfShortcut FOR gmfgen::GenNode»«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt
new file mode 100644
index 000000000..306ca246d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::editpolicies::Utils»
+
+«DEFINE OpenDiagram FOR gmfgen::OpenDiagramBehaviour»
+«EXPAND xpt::Common::copyright FOR subject.getDiagram().editorGen-»
+package «subject.getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPolicyClassName» extends «EXPAND extendsList» {
+
+«EXPAND getOpenCommand-»
+
+«EXPAND openCommandClass-»
+
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::OpenDiagramBehaviour»org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy«ENDDEFINE»
+
+«DEFINE getOpenCommand FOR gmfgen::OpenDiagramBehaviour»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.commands.Command getOpenCommand(org.eclipse.gef.Request request) {
+ org.eclipse.gef.EditPart targetEditPart = getTargetEditPart(request);
+ if (false == targetEditPart.getModel() instanceof org.eclipse.gmf.runtime.notation.View) {
+ return null;
+ }
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) targetEditPart.getModel();
+ org.eclipse.gmf.runtime.notation.Style link = view.getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getHintedDiagramLinkStyle());
+ if (false == link instanceof org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle) {
+ return null;
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(new OpenDiagramCommand((org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle) link));
+ }
+«ENDDEFINE»
+
+«DEFINE openCommandClass FOR gmfgen::OpenDiagramBehaviour»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static class OpenDiagramCommand extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle diagramFacet;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ OpenDiagramCommand(org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle linkStyle) {
+ // editing domain is taken for original diagram,
+ // if we open diagram from another file, we should use another editing domain
+ super(org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(linkStyle), «EXPAND xpt::Externalizer::accessorCall(i18nKeyForOpenCommandName()) FOR subject.getDiagram().editorGen», null);
+ diagramFacet = linkStyle;
+ }
+
+ // FIXME canExecute if !(readOnly && getDiagramToOpen == null), i.e. open works on ro diagrams only when there's associated diagram already
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ try {
+ org.eclipse.gmf.runtime.notation.Diagram diagram = getDiagramToOpen();
+ if (diagram == null) {
+ diagram = intializeNewDiagram();
+ }
+ «EXPAND xpt::navigator::getEditorInput::defineURIEditorInput('diagram') FOR subject.getDiagram()-»
+ org.eclipse.ui.IWorkbenchPage page = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.openEditor(editorInput, getEditorID());
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ } catch (Exception ex) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't open diagram", ex);
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.Diagram getDiagramToOpen() {
+ return diagramFacet.getDiagramLink();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.Diagram intializeNewDiagram() throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.gmf.runtime.notation.Diagram d = org.eclipse.gmf.runtime.diagram.core.services.ViewService.createDiagram(getDiagramDomainElement(), getDiagramKind(), getPreferencesHint());
+ if (d == null) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind");
+ }
+ diagramFacet.setDiagramLink(d);
+ «EXPAND xpt::Common::_assert('diagramFacet.eResource() != null')-»
+ diagramFacet.eResource().getContents().add(d);
+ org.eclipse.emf.ecore.EObject container = diagramFacet.eContainer();
+ while (container instanceof org.eclipse.gmf.runtime.notation.View) {
+ ((org.eclipse.gmf.runtime.notation.View) container).persist();
+ container = container.eContainer();
+ }
+ try {
+ «IF null = subject.getDiagram().editorGen.application-»
+ new org.eclipse.ui.actions.WorkspaceModifyOperation() {
+ protected void execute(org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, java.lang.reflect.InvocationTargetException, InterruptedException {
+ try {
+ «ENDIF-»
+ for (java.util.Iterator it = diagramFacet.eResource().getResourceSet().getResources().iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ if (nextResource.isLoaded() && !getEditingDomain().isReadOnly(nextResource)) {
+ nextResource.save(«EXPAND xpt::Common::getSaveOptions FOR subject.getDiagram()»);
+ }
+ }
+ «IF null = subject.getDiagram().editorGen.application-»
+ } catch (java.io.IOException ex) {
+ throw new java.lang.reflect.InvocationTargetException(ex, "Save operation failed");
+ }
+ }
+ }.run(null);
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e);
+ } catch (InterruptedException e) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e);
+ }
+ «ELSE-»
+ } catch (java.io.IOException ex) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", ex);
+ }
+ «ENDIF-»
+ return d;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.emf.ecore.EObject getDiagramDomainElement() {
+ // use same element as associated with EP
+ return ((org.eclipse.gmf.runtime.notation.View) diagramFacet.eContainer()).getElement();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint getPreferencesHint() {
+ // XXX prefhint from target diagram's editor?
+ return «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR subject.getDiagram().editorGen»;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getDiagramKind() {
+ return «IF diagramKind = null»«EXPAND xpt::editor::VisualIDRegistry::modelID FOR subject.getDiagram()»«ELSE»"«diagramKind»"«ENDIF»;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getEditorID() {
+ return «IF editorID = null»«subject.getDiagram().editorGen.editor.getQualifiedClassName()».ID«ELSE»"«editorID»"«ENDIF»;
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::OpenDiagramBehaviour»«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForOpenCommandName())-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForOpenCommandName(), 'Open Diagram')-»
+«ENDDEFINE»
+
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt
new file mode 100644
index 000000000..5f1bca683
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt
@@ -0,0 +1,203 @@
+/*
+ * 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 TextSelectionEditPolicy FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «textSelectionEditPolicyClassName» extends org.eclipse.gef.editpolicies.SelectionEditPolicy {
+
+ «EXPAND textFeedback FOR self-»
+}
+«ENDDEFINE»
+
+«DEFINE TextNonResizableEditPolicy FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «textNonResizableEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx {
+
+ «EXPAND textFeedback FOR self-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createSelectionHandles() {
+ org.eclipse.gef.handles.MoveHandle moveHandle =
+ new org.eclipse.gef.handles.MoveHandle((org.eclipse.gef.GraphicalEditPart) getHost());
+ moveHandle.setBorder(null);
+ moveHandle.setDragTracker(new org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx(getHost()));
+ return java.util.Collections.singletonList(moveHandle);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE textFeedback FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.IFigure selectionFeedbackFigure;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.IFigure focusFeedbackFigure;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.FigureListener hostPositionListener;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void showPrimarySelection() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setSelected(true);
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ showSelection();
+ showFocus();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void showSelection() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setSelected(true);
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ hideSelection();
+ addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
+ getHostFigure().addFigureListener(getHostPositionListener());
+ refreshSelectionFeedback();
+ hideFocus();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void hideSelection() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setSelected(false);
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (selectionFeedbackFigure != null) {
+ removeFeedback(selectionFeedbackFigure);
+ getHostFigure().removeFigureListener(getHostPositionListener());
+ selectionFeedbackFigure = null;
+ }
+ hideFocus();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void showFocus() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ hideFocus();
+ addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
+ refreshFocusFeedback();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void hideFocus() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (focusFeedbackFigure != null) {
+ removeFeedback(focusFeedbackFigure);
+ focusFeedbackFigure = null;
+ }
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.geometry.Rectangle getFeedbackBounds() {
+ org.eclipse.draw2d.geometry.Rectangle bounds;
+ if (getHostFigure() instanceof org.eclipse.draw2d.Label) {
+ bounds = ((org.eclipse.draw2d.Label) getHostFigure()).getTextBounds();
+ bounds.intersect(getHostFigure().getBounds());
+ } else {
+ bounds = getHostFigure().getBounds().getCopy();
+ }
+ getHostFigure().getParent().translateToAbsolute(bounds);
+ getFeedbackLayer().translateToRelative(bounds);
+ return bounds;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createSelectionFeedbackFigure() {
+ if (getHostFigure() instanceof org.eclipse.draw2d.Label) {
+ org.eclipse.draw2d.Label feedbackFigure = new org.eclipse.draw2d.Label();
+ feedbackFigure.setOpaque(true);
+ feedbackFigure.setBackgroundColor(org.eclipse.draw2d.ColorConstants.menuBackgroundSelected);
+ feedbackFigure.setForegroundColor(org.eclipse.draw2d.ColorConstants.menuForegroundSelected);
+ return feedbackFigure;
+ } else {
+ org.eclipse.draw2d.RectangleFigure feedbackFigure = new org.eclipse.draw2d.RectangleFigure();
+ feedbackFigure.setFill(false);
+ return feedbackFigure;
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createFocusFeedbackFigure() {
+ return new org.eclipse.draw2d.Figure() {
+
+ protected void paintFigure(org.eclipse.draw2d.Graphics graphics) {
+ graphics.drawFocus(getBounds().getResized(-1, -1));
+ }
+ };
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void updateLabel(org.eclipse.draw2d.Label target) {
+ org.eclipse.draw2d.Label source = (org.eclipse.draw2d.Label) getHostFigure();
+ target.setText(source.getText());
+ target.setTextAlignment(source.getTextAlignment());
+ target.setFont(source.getFont());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshSelectionFeedback() {
+ if (selectionFeedbackFigure != null) {
+ if (selectionFeedbackFigure instanceof org.eclipse.draw2d.Label) {
+ updateLabel((org.eclipse.draw2d.Label) selectionFeedbackFigure);
+ selectionFeedbackFigure.setBounds(getFeedbackBounds());
+ } else {
+ selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5));
+ }
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshFocusFeedback() {
+ if (focusFeedbackFigure != null) {
+ focusFeedbackFigure.setBounds(getFeedbackBounds());
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void refreshFeedback() {
+ refreshSelectionFeedback();
+ refreshFocusFeedback();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.FigureListener getHostPositionListener() {
+ if (hostPositionListener == null) {
+ hostPositionListener = new org.eclipse.draw2d.FigureListener() {
+ public void figureMoved(org.eclipse.draw2d.IFigure source) {
+ refreshFeedback();
+ }
+ };
+ }
+ return hostPositionListener;
+ }
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
new file mode 100644
index 000000000..cdb4a132c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
@@ -0,0 +1,90 @@
+import xpt.diagram.editpolicies.LinkUtils;
+import xpt.GenModelUtils;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Utils;
+
+helper hasChildrenOrCompartments(node : genModel::GenNode) : Boolean {
+ return not node.childNodes->isEmpty() or not node.compartments->isEmpty()
+}
+
+helper getContainerVariable(modelFacet : genModel::TypeLinkModelFacet) : String {
+ return (if null <> modelFacet.sourceMetaFeature then 'container' else 'source' endif)
+}
+
+helper getValidLinkConstraints(diagram : genModel::GenDiagram) : Sequence(genModel::GenLinkConstraints) {
+ return diagram.links->select(l | null <> l.creationConstraints and l.creationConstraints.isValid())->collect(l | l.creationConstraints)
+}
+
+helper getAllPotentialLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedLinks(linkEnd)->select(link | isCreationAllowed(link))
+}
+
+helper getReroutableTypeLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedReroutableLinks(linkEnd)->select(link | isTypeLink(link))
+}
+
+helper getReroutableRefLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedReroutableLinks(linkEnd)->select(link | isRefLink(link))
+}
+
+helper getAllRelatedLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) or canBeTarget(link, linkEnd))->asSequence()
+}
+
+helper getAllRelatedReroutableLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) and link.sourceReorientingAllowed or (canBeTarget(link, linkEnd) and link.targetReorientingAllowed))->asSequence()
+}
+
+helper isCreationAllowed(link : genModel::GenLink) : Boolean {
+ return null <> link.modelFacet and (link.outgoingCreationAllowed or link.incomingCreationAllowed)
+}
+
+helper createStartLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return createStartOutgoingLinkCommand(link, linkEnd) or createStartIncomingLinkCommand(link, linkEnd)
+}
+
+helper createStartOutgoingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isSelf(link, linkEnd) or (isOutgoing(link, linkEnd) and link.outgoingCreationAllowed)
+}
+
+helper createStartIncomingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isIncoming(link, linkEnd) and link.incomingCreationAllowed
+}
+
+helper createCompleteLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return createCompleteIncomingLinkCommand(link, linkEnd) or createCompleteOutgoingLinkCommand(link, linkEnd)
+}
+
+helper createCompleteIncomingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isSelf(link, linkEnd) or (isIncoming(link, linkEnd) and link.outgoingCreationAllowed)
+}
+
+helper createCompleteOutgoingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isOutgoing(link, linkEnd) and link.incomingCreationAllowed
+}
+
+helper checkSource(reversedRequest : Boolean, isCompleteCommand : Boolean) : Boolean {
+ return not reversedRequest or isCompleteCommand
+}
+
+helper checkTarget(reversedRequest : Boolean, isCompleteCommand : Boolean) : Boolean {
+ return reversedRequest or isCompleteCommand
+}
+
+helper isSelf(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeSource(link, linkEnd) and canBeTarget(link, linkEnd)
+}
+
+helper isOutgoing(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeSource(link, linkEnd) and not canBeTarget(link, linkEnd)
+}
+
+helper isIncoming(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeTarget(link, linkEnd) and not canBeSource(link, linkEnd)
+}
+
+helper i18nKeyForOpenCommandName() : String {
+ return 'CommandName.OpenDiagram'
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt
new file mode 100644
index 000000000..675eda752
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE childContainerCreateCommand FOR Sequence(gmfgen::GenNode)-»
+«IF not self->isEmpty()-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+«FOREACH self AS n-»
+ «EXPAND childNodeCreateCommand(n) FOR n.modelFacet-»
+«ENDFOREACH-»
+ return super.getCreateCommand(req);
+ }
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE childNodeCreateCommand(node : gmfgen::GenNode) FOR gmfgen::TypeModelFacet-»
+if («EXPAND xpt::providers::ElementTypes::accessElementType FOR node» == req.getElementType()) {
+ return getGEFWrapper(new «node.getCreateCommandQualifiedClassName()»(req));
+}
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt
new file mode 100644
index 000000000..297223b6f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Dmitry Stadnik (Borland) - creation logic was moved in commands
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::editpolicies::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«REM»
+ * Start start of link creation.
+ * User click to this editpart and start dragging with link tool.
+ * Complete end of the command
+ * User points to this editpart as a link target and release mouse button.
+ *
+ * Outgoing the node is link source
+ * This element could be a source for this type of link.
+ * Incoming the node is link destination
+ * This element could be a target for this type of link.
+ *
+ * Parameters:
+ *
+ * diagram GenDiagram used to collect all defined links
+ *
+ * this Instance of GenLinkEnd for the element link could be creates to/from.
+ * This could be GenNode or GenLink in case of links to links,
+ * in the latter case it is assumed that its a TypeLink (so its model facet is LinkTypeModelFacet),
+ * because RefLinks don't have underlying semantic identity
+ *
+«ENDREM»
+
+«DEFINE linkCommands FOR gmfgen::GenLinkEnd-»
+ «IF getAllPotentialLinks(self)->size() > 0-»
+ «EXPAND createLinkCommands -»
+ «ENDIF-»
+ «IF getReroutableTypeLinks(self)->size() > 0-»
+ «EXPAND reorientTypeLinkCommands -»
+ «ENDIF-»
+ «IF getReroutableRefLinks(self)->size() > 0-»
+ «EXPAND reorientRefLinkCommands -»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE createLinkCommands FOR gmfgen::GenLinkEnd-»
+
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ org.eclipse.gef.commands.Command command = req.getTarget() == null ?
+ getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+}
+
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getStartCreateRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ «EXPAND startLinkCommands(self) FOREACH getAllPotentialLinks(self)-»
+ return null;
+}
+
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCompleteCreateRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ «EXPAND completeLinkCommands(self) FOREACH getAllPotentialLinks(self)-»
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE startLinkCommands(linkEnd : gmfgen::GenLinkEnd) FOR gmfgen::GenLink-»
+if («EXPAND xpt::providers::ElementTypes::accessElementType» == req.getElementType()) {
+ «IF createStartLinkCommand(self, linkEnd)-»
+ return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
+ «IF createStartIncomingLinkCommand(self, linkEnd)-»
+ req.getTarget(), req.getSource()
+ «ELSE-»
+ req.getSource(), req.getTarget()
+ «ENDIF-»
+ ));
+ «ELSE-»
+ return null;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE completeLinkCommands(linkEnd : gmfgen::GenLinkEnd) FOR gmfgen::GenLink-»
+if («EXPAND xpt::providers::ElementTypes::accessElementType» == req.getElementType()) {
+ «IF createCompleteLinkCommand(self, linkEnd)-»
+ return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
+ «IF createCompleteOutgoingLinkCommand(self, linkEnd)-»
+ req.getTarget(), req.getSource()
+ «ELSE-»
+ req.getSource(), req.getTarget()
+ «ENDIF-»
+ ));
+ «ELSE-»
+ return null;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE reorientTypeLinkCommands FOR gmfgen::GenLinkEnd-»
+
+«EXPAND xpt::Common::generatedMemberComment(
+ 'Returns command to reorient EClass based link. New link target or source
+should be the domain model element associated with this node.
+'
+)»
+protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ «EXPAND reorientLinkCommand FOREACH getReroutableTypeLinks(self)-»
+ }
+ return super.getReorientRelationshipCommand(req);
+}
+«ENDDEFINE»
+
+«DEFINE reorientRefLinkCommands FOR gmfgen::GenLinkEnd-»
+
+«EXPAND xpt::Common::generatedMemberComment(
+ 'Returns command to reorient EReference based link. New link target or source
+should be the domain model element associated with this node.
+'
+)»
+protected org.eclipse.gef.commands.Command getReorientReferenceRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ «EXPAND reorientLinkCommand FOREACH getReroutableRefLinks(self)-»
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+}
+«ENDDEFINE»
+
+«DEFINE reorientLinkCommand FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::caseVisualID»
+ return getGEFWrapper(new «getReorientCommandQualifiedClassName()»(req));
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/PreferenceInitializer.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/PreferenceInitializer.xpt
new file mode 100644
index 000000000..7fd4918b1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/PreferenceInitializer.xpt
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::diagram::Utils»
+
+«DEFINE className FOR gmfgen::GenDiagram»DiagramPreferenceInitializer«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«preferencesPackageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE PreferenceInitializer FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «preferencesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» extends org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void initializeDefaultPreferences() {
+ org.eclipse.jface.preference.IPreferenceStore store = getPreferenceStore();
+«IF preferences = null-»
+ «EXPAND initDefaults('store') FOREACH allPreferencePages(self)»
+«ELSE»«REM»default values for predefined pages will be set manually«ENDREM-»
+ «EXPAND initDefaults('store') FOREACH (allPreferencePages(self))[gmfgen::GenCustomPreferencePage]»
+ «EXPAND initDefaults('store') FOR preferences-»
+«ENDIF-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.jface.preference.IPreferenceStore getPreferenceStore() {
+ return «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getPreferenceStore();
+ }
+}
+«ENDDEFINE»
+
+«DEFINE initDefaults(storeVar : String) FOR gmfgen::GenPreferencePage»«ERROR 'Abstract define for ' + self.repr()»«ENDDEFINE»
+
+«DEFINE initDefaults(storeVar : String) FOR gmfgen::GenStandardPreferencePage-»
+«EXPAND impl::preferences::StandardPage::call_initDefaults(storeVar)»
+«ENDDEFINE»
+
+«DEFINE initDefaults(storeVar : String) FOR gmfgen::GenCustomPreferencePage-»
+«EXPAND impl::preferences::CustomPage::call_initDefaults(storeVar)»
+«ENDDEFINE»
+
+«DEFINE initDefaults(storeVar : String) FOR gmfgen::GenDiagramPreferences»
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_SHOW_CONNECTION_HANDLES, «showConnectionHandles»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_SHOW_POPUP_BARS, «showPopupBars»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_ENABLE_ANIMATED_LAYOUT, «enableAnimatedLayout»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_ENABLE_ANIMATED_ZOOM, «enableAnimatedZoom»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_ENABLE_ANTIALIAS, «enableAntiAlias»);
+ «EXPAND initDefaultFont(storeVar, 'PREF_DEFAULT_FONT') FOR defaultFont-»
+ «EXPAND initDefaultColor(storeVar, 'PREF_FONT_COLOR') FOR fontColor-»
+ «EXPAND initDefaultColor(storeVar, 'PREF_FILL_COLOR') FOR fillColor-»
+ «EXPAND initDefaultColor(storeVar, 'PREF_LINE_COLOR') FOR lineColor-»
+ «EXPAND initDefaultColor(storeVar, 'PREF_NOTE_FILL_COLOR') FOR noteFillColor-»
+ «EXPAND initDefaultColor(storeVar, 'PREF_NOTE_LINE_COLOR') FOR noteLineColor-»
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE, org.eclipse.gmf.runtime.notation.Routing.«lineStyle»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_SHOW_RULERS, «showRulers»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_RULER_UNITS, «showRulers»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_SHOW_GRID, org.eclipse.gef.rulers.RulerProvider.UNIT_«rulerUnits»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_SNAP_TO_GRID, «snapToGrid»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_SNAP_TO_GEOMETRY, «snapToGeometry»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_GRID_SPACING, «gridSpacing»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_MODEL, «promptOnDelFromModel»);
+ «storeVar».setDefault(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_DIAGRAM, «promptOnDelFromDiagram»);
+«ENDDEFINE»
+
+«DEFINE initDefaultColor(storeVar : String, prefName : String) FOR gmfgen::GenColor»
+ org.eclipse.jface.preference.PreferenceConverter.setDefault(«storeVar»,
+ org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.«prefName», «EXPAND rgb»);
+«ENDDEFINE»
+
+«DEFINE initDefaultFont(storeVar : String, prefName : String) FOR gmfgen::GenFont»
+ org.eclipse.jface.preference.PreferenceConverter.setDefault(«storeVar»,
+ org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.«prefName», «EXPAND fontData»);
+«ENDDEFINE»
+
+«DEFINE rgb FOR gmfgen::GenColor»
+ «ERROR 'Unknown colour: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE rgb FOR gmfgen::GenConstantColor»
+ org.eclipse.gmf.runtime.diagram.ui.figures.DiagramColorConstants.«name».getRGB()
+«ENDDEFINE»
+
+«DEFINE rgb FOR gmfgen::GenRGBColor»
+ new org.eclipse.swt.graphics.RGB(«red», «green», «blue»)
+«ENDDEFINE»
+
+«DEFINE fontData FOR gmfgen::GenFont»
+ «ERROR 'Unknown font: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE fontData FOR gmfgen::GenCustomFont»
+ new org.eclipse.swt.graphics.FontData("«name»", «height», org.eclipse.swt.SWT.«style»)
+«ENDDEFINE»
+
+«DEFINE fontData FOR gmfgen::GenStandardFont»
+ org.eclipse.jface.resource.JFaceResources.get«name»Font().getFontData()
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/extensions.xpt
new file mode 100644
index 000000000..eaf445a07
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/preferences/extensions.xpt
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::diagram::Utils»
+
+«DEFINE extensions FOR gmfgen::GenDiagram-»
+
+ <extension point="org.eclipse.core.runtime.preferences" id="prefs">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <initializer class="«EXPAND xpt::diagram::preferences::PreferenceInitializer::qualifiedClassName»"/>
+ </extension>
+
+«IF preferencePages->size() > 0-»
+ <extension point="org.eclipse.ui.preferencePages" id="prefpages">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+«EXPAND preferencePage FOREACH allPreferencePages(self)-»
+ </extension>
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE preferencePage FOR gmfgen::GenPreferencePage-»
+ <page
+ id="«iD»"
+ name="%prefpage.«iD»"
+«IF null <> parent-»
+ category="«parent.iD»"
+«ENDIF-»
+ class="«getQualifiedClassName()»">
+ </page>
+«ENDDEFINE»
+
+«DEFINE i18n FOR gmfgen::GenDiagram»
+# Preferences
+«FOREACH allPreferencePages(self) AS p-»
+prefpage.«p.iD»=«p.name»
+«ENDFOREACH»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt
new file mode 100644
index 000000000..2bcb9cb66
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt
@@ -0,0 +1,488 @@
+/*
+ * 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
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ */
+
+«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::diagram::updater::Utils»
+«EXTENSION xpt::diagram::editpolicies::LinkUtils»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::NativeGenModelUtils»
+
+«DEFINE DiagramUpdater FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «diagramUpdaterClassName» {
+ «EXPAND isShortcutOrphaned-»
+«LET editorGen.diagram.getAllContainers()->select(container | hasSemanticChildren(container))->asSequence() AS semanticContainers-»
+
+ «EXPAND getGenericSemanticChildrenOfView(semanticContainers)-»
+ «EXPAND getSemanticChildrenOfView FOREACH semanticContainers-»
+ «EXPAND getPhantomNodesIterator-»
+«ENDLET-»
+
+ «EXPAND getGenericConnectedLinks(getAllSemanticElements(editorGen.diagram), getContainedLinksMethodNameSuffix())-»
+
+ «EXPAND getGenericConnectedLinks(getAllSemanticDiagramElements(editorGen.diagram), getIncomingLinksMethodNameSuffix())-»
+
+ «EXPAND getGenericConnectedLinks(getAllSemanticDiagramElements(editorGen.diagram), getOutgoingLinksMethodNameSuffix())-»
+ «EXPAND getContainedLinks FOREACH getAllSemanticElements(editorGen.diagram)-»
+ «EXPAND getIncomingLinks FOREACH getAllSemanticDiagramElements(editorGen.diagram)-»
+ «EXPAND getOutgoingLinks FOREACH getAllSemanticDiagramElements(editorGen.diagram)-»
+ «EXPAND getContainedLinksByTypeMethod FOREACH getAllContainedLinks(editorGen.diagram)-»
+ «EXPAND getIncomingLinksByTypeMethod FOREACH getAllIncomingLinks(editorGen.diagram)-»
+ «EXPAND getOutgoingLinksByTypeMethod FOREACH getAllOutgoingLinks(editorGen.diagram)-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«REM»
+ Currently shortcuts are supported only for domain-based diagram element.
+ This means, view.isSetElement() == true.
+«ENDREM»
+«DEFINE isShortcutOrphaned FOR gmfgen::GenDiagramUpdater-»
+ «IF not editorGen.diagram.containsShortcutsTo->isEmpty()-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public static boolean isShortcutOrphaned(org.eclipse.gmf.runtime.notation.View view) {
+ return !view.isSetElement() || view.getElement() == null || view.getElement().eIsProxy();
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getGenericSemanticChildrenOfView(semanticContainers : Sequence(gmfgen::GenContainerBase)) FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List getSemanticChildren(org.eclipse.gmf.runtime.notation.View view) {
+ «IF not semanticContainers->isEmpty()-»
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) {
+ «EXPAND getSemanticChildrenCase FOREACH semanticContainers-»
+ }
+ «ENDIF-»
+ return java.util.Collections.EMPTY_LIST;
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenCase FOR gmfgen::GenContainerBase-»
+«EXPAND xpt::Common::caseVisualID»
+ return «EXPAND getSemanticChildrenMethodName»(view);
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenOfView FOR gmfgen::GenContainerBase-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List «EXPAND getSemanticChildrenMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ «IF getSemanticChildrenChildFeatures(self)->size() > 0 or self.getPhantomNodes()->size() > 0-»
+ «EXPAND defineModelElement-»
+ java.util.List result = new java.util.LinkedList();
+«REM»childMetaFeature can be null here!«ENDREM»«-»
+ «FOREACH getSemanticChildrenChildFeatures(self) AS childMetaFeature-»
+ «IF null = childMetaFeature-»
+ { /*FIXME no containment/child feature found in the genmodel, toolsmith need to specify Class here manually*/ childElement = /*FIXME no containment/child feature found in the genmodel, toolsmith need to specify correct one here manually*/;
+ «ELSEIF isListType(childMetaFeature)-»
+ for (java.util.Iterator it = «EXPAND MetaModel::getFeatureValue('modelElement', self.getModelElementType()) FOR childMetaFeature».iterator(); it.hasNext();) {
+ «EXPAND MetaModel::DeclareAndAssign('childElement', 'it.next()', true) FOR getTypeGenClassX(childMetaFeature)»
+ «ELSE-»
+ { «EXPAND MetaModel::DeclareAndAssign('childElement', 'modelElement', self.getModelElementType(), childMetaFeature) FOR getTypeGenClassX(childMetaFeature)»
+ «ENDIF-»
+ int visualID = «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»(view, «EXPAND MetaModel::DowncastToEObject('childElement') FOR getTypeGenClassX(childMetaFeature)»);
+ «EXPAND checkChildElementVisualID(null <> childMetaFeature and isListType(childMetaFeature)) FOREACH getSemanticChildren(self, childMetaFeature)-»
+ }
+ «ENDFOREACH-»
+ «IF not self.getPhantomNodes()->isEmpty()-»
+ org.eclipse.emf.ecore.resource.Resource resource = modelElement.eResource();
+ for (java.util.Iterator semanticIterator = getPhantomNodesIterator(resource); semanticIterator.hasNext();) {
+ org.eclipse.emf.ecore.EObject childElement = (org.eclipse.emf.ecore.EObject) semanticIterator.next();
+ if (childElement == modelElement) {
+ continue;
+ }
+ «EXPAND addNextIfPhantom FOREACH self.getPhantomNodes()-»
+ }
+ «ENDIF-»
+ return result;
+ «ELSE-»
+ return java.util.Collections.EMPTY_LIST;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE defineModelElement FOR gmfgen::GenContainerBase-»
+if (!view.isSetElement()) {
+ return java.util.Collections.EMPTY_LIST;
+}
+«EXPAND MetaModel::DeclareAndAssign('modelElement', 'view.getElement()') FOR self.getModelElementType()»
+«ENDDEFINE»
+
+«DEFINE defineModelElement FOR gmfgen::GenCompartment-»
+if (false == view.eContainer() instanceof org.eclipse.gmf.runtime.notation.View) {
+ return java.util.Collections.EMPTY_LIST;
+}
+org.eclipse.gmf.runtime.notation.View containerView = (org.eclipse.gmf.runtime.notation.View) view.eContainer();
+if (!containerView.isSetElement()) {
+ return java.util.Collections.EMPTY_LIST;
+}
+«EXPAND MetaModel::DeclareAndAssign('modelElement', 'containerView.getElement()') FOR self.getModelElementType()»
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenMethodName FOR gmfgen::GenContainerBase»get«getUniqueIdentifier()»SemanticChildren«ENDDEFINE»
+
+«DEFINE getSemanticChildrenMethodCall FOR gmfgen::GenContainerBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND getSemanticChildrenMethodName»«ENDDEFINE»
+
+«DEFINE checkChildElementVisualID(inLoop : Boolean) FOR gmfgen::GenNode-»
+if (visualID == «EXPAND xpt::editor::VisualIDRegistry::visualID») {
+ result.add(new «getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()»(«IF null <> modelFacet.childMetaFeature»«EXPAND MetaModel::DowncastToEObject('childElement') FOR getTypeGenClassX(modelFacet.childMetaFeature)»«ENDIF», visualID));
+«IF inLoop-»
+ continue;
+«ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE addNextIfPhantom FOR gmfgen::GenNode-»
+if («EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»(view, childElement) == «EXPAND xpt::editor::VisualIDRegistry::visualID») {
+ result.add(new «getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()»(childElement, «EXPAND xpt::editor::VisualIDRegistry::visualID»));
+ continue;
+}
+«ENDDEFINE»
+
+
+«DEFINE getPhantomNodesIterator FOR gmfgen::GenDiagramUpdater-»
+ «IF not editorGen.diagram.getPhantomNodes()->isEmpty()-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private static java.util.Iterator getPhantomNodesIterator(org.eclipse.emf.ecore.resource.Resource resource) {
+ return resource.getAllContents();
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getGenericConnectedLinks(linkContainers : Sequence(gmfgen::GenCommonBase), methodNameSuffix : String) FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List get«methodNameSuffix»Links(org.eclipse.gmf.runtime.notation.View view) {
+ «IF not linkContainers->isEmpty()-»
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) {
+ «EXPAND getContainedLinksCase(methodNameSuffix) FOREACH linkContainers-»
+ }
+ «ENDIF-»
+ return java.util.Collections.EMPTY_LIST;
+}
+«ENDDEFINE»
+
+«DEFINE getContainedLinksCase(methodNameSuffix : String) FOR gmfgen::GenCommonBase-»
+«EXPAND xpt::Common::caseVisualID»
+ return «EXPAND linkGetterName(methodNameSuffix)»(view);
+«ENDDEFINE»
+
+«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
+«DEFINE getContainedLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getContainedLinksMethodNameSuffix())»«ENDDEFINE»
+
+«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
+«DEFINE getIncomingLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getIncomingLinksMethodNameSuffix())»«ENDDEFINE»
+
+«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
+«DEFINE getOutgoingLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getOutgoingLinksMethodNameSuffix())»«ENDDEFINE»
+
+«DEFINE linkGetterName(suffix : String) FOR gmfgen::GenCommonBase»get«getUniqueIdentifier()»«suffix»Links«ENDDEFINE»
+
+«DEFINE getContainedLinks FOR gmfgen::GenCommonBase-»
+ «EXPAND getConnectedLinks(getContainedLinks(self.getMetaClass(), getDiagram()), getContainedLinksMethodNameSuffix(), false)-»
+«ENDDEFINE»
+
+«DEFINE getIncomingLinks FOR gmfgen::GenLinkEnd-»
+ «EXPAND getConnectedLinks(getIncomingLinks(self), getIncomingLinksMethodNameSuffix(), true)-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinks FOR gmfgen::GenLinkEnd-»
+ «EXPAND getConnectedLinks(getOutgoingLinks(self), getOutgoingLinksMethodNameSuffix(), false)-»
+«ENDDEFINE»
+
+«DEFINE getConnectedLinks(genLinks : Sequence(gmfgen::GenLink), methodNameSuffix : String, needCrossReferencer : Boolean) FOR gmfgen::GenCommonBase-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List «EXPAND linkGetterName(methodNameSuffix)»(org.eclipse.gmf.runtime.notation.View view) {
+ «IF not genLinks->isEmpty()-»
+ «LET self.getMetaClass() AS metaclass-»
+ «EXPAND MetaModel::DeclareAndAssign('modelElement', 'view.getElement()') FOR metaclass»
+ «IF needCrossReferencer-»
+ java.util.Map crossReferences = org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ «ENDIF-»
+ java.util.List result = new java.util.LinkedList();
+ «EXPAND colectConnectedLinks(methodNameSuffix, needCrossReferencer, isExternalInterface(metaclass)) FOREACH genLinks-»
+ return result;
+ «ENDLET-»
+ «ELSE-»
+ return java.util.Collections.EMPTY_LIST;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE colectConnectedLinks(methodNameSuffix : String, needCrossReferencer : Boolean, isExternalInterface : Boolean) FOR gmfgen::GenLink-»
+«IF isExternalInterface-»
+ if («EXPAND MetaModel::IsInstance('modelElement') FOR modelFacet.getLinkEndType(methodNameSuffix)») {
+«ENDIF-»
+ result.addAll(«EXPAND chooseConnectedLinksByTypeMethodName(methodNameSuffix, self) FOR modelFacet»(«IF isExternalInterface-»
+«EXPAND MetaModel::CastEObject('modelElement') FOR modelFacet.getLinkEndType(methodNameSuffix)»«ELSE»modelElement«ENDIF»«IF needCrossReferencer», crossReferences«ENDIF»));
+«IF isExternalInterface-»
+ }
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE chooseConnectedLinksByTypeMethodName(methodNameSuffix : String, genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«REM»
+ For FeatureModelFacet-based links we are calling
+ getOutgoing???Links instead of getContained???Links
+«ENDREM»
+«DEFINE chooseConnectedLinksByTypeMethodName(methodNameSuffix : String, genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+«IF getContainedLinksMethodNameSuffix() = methodNameSuffix»«EXPAND getConnectedLinksByTypeMethodName(getOutgoingLinksMethodNameSuffix()) FOR genLink-»
+«ELSE»«EXPAND getConnectedLinksByTypeMethodName(methodNameSuffix) FOR genLink-»
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ For TypeModelFacet-based links we are calling
+ getContained???Links instead of getOutgoinf???Links
+ if sourceMetaFeature was not specified
+«ENDREM»
+«DEFINE chooseConnectedLinksByTypeMethodName(methodNameSuffix : String, genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+«IF getOutgoingLinksMethodNameSuffix() = methodNameSuffix and null = sourceMetaFeature»«EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink-»
+«ELSE»«EXPAND getConnectedLinksByTypeMethodName(methodNameSuffix) FOR genLink-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod FOR gmfgen::GenLink»«EXPAND getContainedLinksByTypeMethod(self) FOR modelFacet»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodName(suffix : String) FOR gmfgen::GenLink»get«suffix»«EXPAND getConnectedLinksByTypeMethodFragment FOR modelFacet»_«visualID»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::TypeLinkModelFacet»TypeModelFacetLinks_«metaClass.ecoreClass.name»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::FeatureLinkModelFacet»FeatureModelFacetLinks_«metaFeature.genClass.ecoreClass.name»_«metaFeature.ecoreFeature.name.firstToUpper()»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet»«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink»(«EXPAND MetaModel::QualifiedClassName FOR childMetaFeature.genClass» container) {
+ «EXPAND getContainedLinksByTypeMethodBody(genLink, false)-»
+}
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethodBody(genLink : gmfgen::GenLink, sourceVarDefined : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+java.util.Collection result = new java.util.LinkedList();
+ «LET isListType(childMetaFeature) AS inLoop-»
+«IF inLoop-»
+for (java.util.Iterator links = «EXPAND MetaModel::getFeatureValue('container', childMetaFeature.genClass) FOR childMetaFeature».iterator(); links.hasNext();) {
+ org.eclipse.emf.ecore.EObject linkObject = (org.eclipse.emf.ecore.EObject ) links.next();
+ if («EXPAND MetaModel::NotInstance('linkObject') FOR metaClass») {
+ continue;
+ }
+ «EXPAND MetaModel::DeclareAndAssign('link', 'linkObject') FOR metaClass»
+«ELSE-»
+ «IF getTypeGenClassX(childMetaFeature) = metaClass-»
+ «EXPAND MetaModel::DeclareAndAssign('link', 'container', getSourceType(), childMetaFeature) FOR metaClass»
+ «ELSE-»
+ «EXPAND MetaModel::DeclareAndAssign('linkObject', 'container', getSourceType(), childMetaFeature) FOR getTypeGenClassX(childMetaFeature)»
+ if («EXPAND MetaModel::NotInstance('linkObject') FOR metaClass») {
+ return result;
+ }
+ «EXPAND MetaModel::DeclareAndAssign('link', 'linkObject') FOR metaClass»
+ «ENDIF-»
+«ENDIF-»
+ «EXPAND checkLinkVisualID(genLink, inLoop)-»
+ «EXPAND defineLinkDestination(inLoop)-»
+ «IF null <> sourceMetaFeature-»
+ «EXPAND defineLinkSource(inLoop)-»
+ «IF sourceVarDefined-»
+ «EXPAND checkLinkSource(inLoop)-»
+ «ENDIF-»
+ «EXPAND addLinkDescriptor(genLink, 'src', 'dst')-»
+ «ELSE-»
+ «EXPAND addLinkDescriptor(genLink, 'container', 'dst')-»
+ «ENDIF-»
+«IF inLoop-»
+}
+«ENDIF-»
+ «ENDLET-»
+return result;
+«ENDDEFINE»
+
+«DEFINE addLinkDescriptor(genLink : gmfgen::GenLink, srcVar : String, dstVar : String) FOR gmfgen::TypeLinkModelFacet-»
+result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(«EXPAND MetaModel::DowncastToEObject(srcVar) FOR getSourceType()», «EXPAND MetaModel::DowncastToEObject(dstVar) FOR getTargetType()», «EXPAND MetaModel::DowncastToEObject('link') FOR metaClass», «EXPAND xpt::providers::ElementTypes::accessElementType FOR genLink», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
+«ENDDEFINE»
+
+«DEFINE checkLinkVisualID(genLink : gmfgen::GenLink, inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+if («EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink» != «EXPAND xpt::editor::VisualIDRegistry::getLinkWithClassVisualIDMethodCall FOR genLink.getDiagram()»(«EXPAND MetaModel::DowncastToEObject('link') FOR metaClass»)) {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«ENDDEFINE»
+
+«DEFINE defineLinkSource(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+ «IF isListType(sourceMetaFeature)-»
+java.util.List sources = «EXPAND MetaModel::getFeatureValue('link', metaClass) FOR sourceMetaFeature»;
+Object theSource = sources.size() == 1 ? sources.get(0) : null;
+if («EXPAND MetaModel::NotInstance('theSource') FOR getSourceType()») {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«EXPAND MetaModel::DeclareAndAssign('src', 'theSource', true) FOR getSourceType()»
+ «ELSE-»
+«EXPAND MetaModel::DeclareAndAssign('src', 'link', metaClass, sourceMetaFeature) FOR getSourceType()»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkLinkSource(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+if (src != source) {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«ENDDEFINE»
+
+«DEFINE defineLinkDestination(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+ «IF isListType(targetMetaFeature)-»
+java.util.List targets = «EXPAND MetaModel::getFeatureValue('link', metaClass) FOR targetMetaFeature»;
+Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+if («EXPAND MetaModel::NotInstance('theTarget') FOR getTargetType()») {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«EXPAND MetaModel::DeclareAndAssign('dst', 'theTarget', true) FOR getTargetType()»
+ «ELSE-»
+«EXPAND MetaModel::DeclareAndAssign('dst', 'link', metaClass, targetMetaFeature) FOR getTargetType()»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE stopLinkProcessing(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+«IF inLoop-»
+continue;
+«ELSE-»
+return result;
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethod FOR gmfgen::GenLink-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getIncomingLinksMethodNameSuffix())»(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.getTargetType()» target, java.util.Map crossReferences) {
+ java.util.Collection result = new java.util.LinkedList();
+ java.util.Collection settings = (java.util.Collection) crossReferences.get(target);
+ for (java.util.Iterator it = settings.iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.EStructuralFeature.Setting setting = (org.eclipse.emf.ecore.EStructuralFeature.Setting) it.next();
+ «EXPAND getIncomingLinksByTypeMethodBody(self) FOR modelFacet-»
+ }
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethodBody(genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+if (setting.getEStructuralFeature() != «EXPAND MetaModel::MetaFeature FOR targetMetaFeature» || «EXPAND MetaModel::NotInstance('setting.getEObject()') FOR metaClass») {
+ continue;
+}
+«EXPAND MetaModel::DeclareAndAssign('link', 'setting.getEObject()') FOR metaClass»
+ «EXPAND checkLinkVisualID(genLink, true)-»
+ «IF null <> sourceMetaFeature-»
+ «EXPAND defineLinkSource(true)-»
+ «EXPAND addLinkDescriptor(genLink, 'src', 'target')-»
+ «ELSE-»
+ «EXPAND defineLinkContainer(true)-»
+ «EXPAND addLinkDescriptor(genLink, 'container', 'target')-»
+«REM»TODO: continue here.«ENDREM»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE defineLinkContainer(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+if (false == «EXPAND MetaModel::IsContainerInstance('link', metaClass) FOR containmentMetaFeature.genClass») {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«EXPAND MetaModel::DeclareAndAssignContainer('container', 'link', metaClass) FOR containmentMetaFeature.genClass»
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethodBody(genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+if (setting.getEStructuralFeature() == «EXPAND MetaModel::MetaFeature FOR metaFeature») {
+ result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(setting.getEObject(), «EXPAND MetaModel::DowncastToEObject('target') FOR getTargetType()», «EXPAND xpt::providers::ElementTypes::accessElementType FOR genLink», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
+}
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethodBody(genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethod FOR gmfgen::GenLink-»
+ «EXPAND getOutgoingLinksByTypeMethod(self) FOR modelFacet-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethodSignature FOR gmfgen::GenLink»private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getOutgoingLinksMethodNameSuffix())»(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.getSourceType()» source)«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+«EXPAND getOutgoingLinksByTypeMethodSignature FOR genLink» {
+ java.util.Collection result = new java.util.LinkedList();
+ «IF isListType(metaFeature)-»
+ for (java.util.Iterator destinations = «EXPAND MetaModel::getFeatureValue('source', getSourceType()) FOR metaFeature».iterator(); destinations.hasNext();) {
+ «EXPAND MetaModel::DeclareAndAssign('destination', 'destinations.next()', true) FOR getTargetType()»
+ «ELSE-»
+ «EXPAND MetaModel::DeclareAndAssign('destination', 'source', getSourceType(), metaFeature) FOR getTargetType()»
+ if (destination == null) {
+ return result;
+ }
+ «ENDIF-»
+ result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(«EXPAND MetaModel::DowncastToEObject('source') FOR getSourceType()», «EXPAND MetaModel::DowncastToEObject('destination') FOR getTargetType()», «EXPAND xpt::providers::ElementTypes::accessElementType FOR genLink», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
+ «IF isListType(metaFeature)-»
+ }
+ «ENDIF-»
+ return result;
+}
+«ENDDEFINE»
+
+«REM»More careful way to find container should be used here then GMF will be modified in accordance«ENDREM»
+«DEFINE getOutgoingLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ «IF null <> sourceMetaFeature-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+«EXPAND getOutgoingLinksByTypeMethodSignature FOR genLink» {
+ «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container = null;
+ // Find container element for the link.
+ // Climb up by containment hierarchy starting from the source
+ // and return the first element that is instance of the container class.
+ for (org.eclipse.emf.ecore.EObject element = «EXPAND MetaModel::DowncastToEObject('source') FOR getSourceType()»; element != null && container == null; element = element.eContainer()) {
+ if («EXPAND MetaModel::IsInstance('element') FOR containmentMetaFeature.genClass») {
+ container = «EXPAND MetaModel::CastEObject('element') FOR containmentMetaFeature.genClass»;
+ }
+ }
+ if (container == null) {
+ return java.util.Collections.EMPTY_LIST;
+ }
+ «EXPAND getContainedLinksByTypeMethodBody(genLink, true)-»
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE incorrectLinkModelFacet FOR gmfgen::LinkModelFacet-»
+ «ERROR 'Incorrect LinkModelFacet: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt
new file mode 100644
index 000000000..5343f13dc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE LinkDescriptor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «linkDescriptorClassName» extends «getNodeDescriptorQualifiedClassName()» {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND refOnlyLinkConstructor-»
+
+ «EXPAND typeLinkConstructor-»
+
+ «EXPAND getSource-»
+
+ «EXPAND getDestination-»
+
+ «EXPAND getSemanticAdapter-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+
+«DEFINE attributes FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.ecore.EObject mySource;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.ecore.EObject myDestination;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.core.runtime.IAdaptable mySemanticAdapter;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private «linkDescriptorClassName»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.emf.ecore.EObject linkElement, int linkVID) {
+ super(linkElement, linkVID);
+ mySource = source;
+ myDestination = destination;
+}
+«ENDDEFINE»
+
+«DEFINE refOnlyLinkConstructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «linkDescriptorClassName»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.gmf.runtime.emf.type.core.IElementType elementType, int linkVID) {
+ this(source, destination, (org.eclipse.emf.ecore.EObject) null, linkVID);
+ «EXPAND elementTypeCopy-»
+ mySemanticAdapter = new org.eclipse.core.runtime.IAdaptable() {
+ public Object getAdapter(Class adapter) {
+ «EXPAND elementTypeAdapter-»
+ return null;
+ }
+ };
+}
+«ENDDEFINE»
+
+«DEFINE typeLinkConstructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «linkDescriptorClassName»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.emf.ecore.EObject linkElement, org.eclipse.gmf.runtime.emf.type.core.IElementType elementType, int linkVID) {
+ this(source, destination, linkElement, linkVID);
+ «EXPAND elementTypeCopy-»
+ mySemanticAdapter = new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(linkElement) {
+ public Object getAdapter(Class adapter) {
+ «EXPAND elementTypeAdapter-»
+ return super.getAdapter(adapter);
+ }
+ };
+}
+«ENDDEFINE»
+
+«DEFINE elementTypeCopy FOR gmfgen::GenDiagramUpdater-»
+final org.eclipse.gmf.runtime.emf.type.core.IElementType elementTypeCopy = elementType;
+«ENDDEFINE»
+
+«DEFINE elementTypeAdapter FOR gmfgen::GenDiagramUpdater-»
+if (org.eclipse.gmf.runtime.emf.type.core.IElementType.class.equals(adapter)) {
+ return elementTypeCopy;
+}
+«ENDDEFINE»
+
+«DEFINE getSource FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.EObject getSource() {
+ return mySource;
+}
+«ENDDEFINE»
+
+«DEFINE getDestination FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.EObject getDestination() {
+ return myDestination;
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticAdapter FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.core.runtime.IAdaptable getSemanticAdapter() {
+ return mySemanticAdapter;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt
new file mode 100644
index 000000000..6ed617fae
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE NodeDescriptor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «nodeDescriptorClassName» {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND getModelElement-»
+
+ «EXPAND getVisualID-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject myModelElement;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final int myVisualID;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «nodeDescriptorClassName»(org.eclipse.emf.ecore.EObject modelElement, int visualID) {
+ myModelElement = modelElement;
+ myVisualID = visualID;
+}
+«ENDDEFINE»
+
+«DEFINE getModelElement FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.EObject getModelElement() {
+ return myModelElement;
+}
+«ENDDEFINE»
+
+«DEFINE getVisualID FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public int getVisualID() {
+ return myVisualID;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt
new file mode 100644
index 000000000..490e9c464
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE UpdateCommand FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «updateCommandClassName» implements org.eclipse.core.commands.IHandler {
+
+ «EXPAND addHandlerListener-»
+
+ «EXPAND dispose-»
+
+ «EXPAND execute-»
+
+ «EXPAND isEnabled-»
+
+ «EXPAND isHandled-»
+
+ «EXPAND removeHandlerListener-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE addHandlerListener FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void addHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener) {
+}
+«ENDDEFINE»
+
+«DEFINE dispose FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void dispose() {
+}
+«ENDDEFINE»
+
+«DEFINE execute FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public Object execute(org.eclipse.core.commands.ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.jface.viewers.ISelection selection = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection) {
+ org.eclipse.jface.viewers.IStructuredSelection structuredSelection = (org.eclipse.jface.viewers.IStructuredSelection) selection;
+ if (structuredSelection.size() != 1) {
+ return null;
+ }
+ if (structuredSelection.getFirstElement() instanceof org.eclipse.gef.EditPart && ((org.eclipse.gef.EditPart) structuredSelection.getFirstElement()).getModel() instanceof org.eclipse.gmf.runtime.notation.View) {
+ org.eclipse.emf.ecore.EObject modelElement = ((org.eclipse.gmf.runtime.notation.View) ((org.eclipse.gef.EditPart) structuredSelection.getFirstElement()).getModel()).getElement();
+ java.util.List editPolicies = org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.getRegisteredEditPolicies(modelElement);
+ for (java.util.Iterator it = editPolicies.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy nextEditPolicy = (org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy) it.next();
+ nextEditPolicy.refresh();
+ }
+
+ }
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE isEnabled FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isEnabled() {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE isHandled FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isHandled() {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE removeHandlerListener FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void removeHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener) {
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto
new file mode 100644
index 000000000..f461b32d2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto
@@ -0,0 +1,150 @@
+import xpt.diagram.editpolicies.LinkUtils;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
+
+library Utils;
+
+helper getContainedLinksMethodNameSuffix() : String {
+ return 'Contained'
+}
+
+helper getIncomingLinksMethodNameSuffix() : String {
+ return 'Incoming'
+}
+
+helper getOutgoingLinksMethodNameSuffix() : String {
+ return 'Outgoing'
+}
+
+helper getContainedLinks(metaClass : genModel_1::GenClass, diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | canBeContainer(link, metaClass))->asSequence()
+}
+
+helper getOutgoingLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | linkEnd.genOutgoingLinks->includes(link))->asSequence()
+}
+
+helper getIncomingLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | linkEnd.genIncomingLinks->includes(link))->asSequence()
+}
+
+helper getAllContainedLinks(diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | not getAllSemanticElements(diagram)->select(commonBase | canBeContainer(link, commonBase.getMetaClass()))->isEmpty())->asSequence()
+}
+
+helper getAllIncomingLinks(diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | not link.targets->isEmpty())->asSequence()
+}
+
+helper getAllOutgoingLinks(diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | link.isOutgoingLink())->select(link | not link.sources->isEmpty())->asSequence()
+}
+
+helper genModel::GenLink::isOutgoingLink() : Boolean {
+ return null <> self.modelFacet and self.modelFacet.isOutgoingLink()
+}
+
+helper genModel::LinkModelFacet::isOutgoingLink() : Boolean {
+ return true
+}
+
+helper genModel::TypeLinkModelFacet::isOutgoingLink() : Boolean {
+ return null <> self.sourceMetaFeature
+}
+
+helper getAllSemanticDiagramElements(diagram : genModel::GenDiagram) : Sequence(genModel::GenLinkEnd) {
+ return ((diagram.getAllNodes()->asSequence())[genModel::GenLinkEnd]->union(diagram.links->asSequence()))[genModel::GenLinkEnd]->select(linkEnd | null <> linkEnd.getMetaClass())
+}
+
+helper getAllSemanticElements(diagram : genModel::GenDiagram) : Sequence(genModel::GenCommonBase) {
+ return (if null <> diagram.domainDiagramElement then (Sequence { diagram })[genModel::GenCommonBase]->union(getAllSemanticDiagramElements(diagram)) else getAllSemanticDiagramElements(diagram) endif)
+}
+
+helper genModel::GenCommonBase::getMetaClass() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::GenDiagram::getMetaClass() : genModel_1::GenClass {
+ return self.domainDiagramElement
+}
+
+helper genModel::GenNode::getMetaClass() : genModel_1::GenClass {
+ return self.modelFacet.metaClass
+}
+
+helper genModel::GenLink::getMetaClass() : genModel_1::GenClass {
+ return (if null <> self.modelFacet then self.modelFacet.getMetaClass() else null endif)
+}
+
+helper genModel::LinkModelFacet::getMetaClass() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::TypeLinkModelFacet::getMetaClass() : genModel_1::GenClass {
+ return self.metaClass
+}
+
+helper hasSemanticChildren(container : genModel::GenContainerBase) : Boolean {
+ return not container.sansDomain and not container.containedNodes->isEmpty()
+}
+
+helper genModel::GenContainerBase::getModelElementType() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::GenDiagram::getModelElementType() : genModel_1::GenClass {
+ return self.domainDiagramElement
+}
+
+helper genModel::GenCompartment::getModelElementType() : genModel_1::GenClass {
+ return self.node.getModelElementType()
+}
+
+helper genModel::GenNode::getModelElementType() : genModel_1::GenClass {
+ return self.modelFacet.metaClass
+}
+
+helper getSemanticChildrenChildFeatures(containerBase : genModel::GenContainerBase) : Set(genModel_1::GenFeature) {
+ return getNonPhantomSemanticChildren(containerBase)->collect(node | node.modelFacet.childMetaFeature)->asOrderedSet()
+}
+
+helper getSemanticChildrenContainmentFeatures(containerBase : genModel::GenContainerBase) : Set(genModel_1::GenFeature) {
+ return getNonPhantomSemanticChildren(containerBase)->collect(node | node.modelFacet.containmentMetaFeature)->asOrderedSet()
+}
+
+helper getSemanticChildren(containerBase : genModel::GenContainerBase, childMetaFeature : genModel_1::GenFeature) : Sequence(genModel::GenNode) {
+ return getNonPhantomSemanticChildren(containerBase)->select(node | node.modelFacet.childMetaFeature = childMetaFeature)
+}
+
+helper getNonPhantomSemanticChildren(containerBase : genModel::GenContainerBase) : Sequence(genModel::GenNode) {
+ return getSemanticChildren(containerBase)->select(node | not node.modelFacet.isPhantomElement())
+}
+
+helper genModel::GenContainerBase::getPhantomNodes() : Sequence(genModel::GenNode) {
+ return Sequence { }
+}
+
+helper genModel::GenDiagram::getPhantomNodes() : Sequence(genModel::GenNode) {
+ return getSemanticChildren(self)->select(node | node.modelFacet.isPhantomElement())
+}
+
+helper getSemanticChildren(containerBase : genModel::GenContainerBase) : Sequence(genModel::GenNode) {
+ return containerBase.containedNodes->select(node | null <> node.modelFacet)->asSequence()
+}
+
+helper hasConformableSemanticChildren(containerBase : genModel::GenContainerBase) : Boolean {
+ return let childMetaClasses = getSemanticChildren(containerBase)->collect(node | node.modelFacet.metaClass) in not childMetaClasses->forAll(mc | childMetaClasses->select(mc2 | mc = mc2)->size() = 1)
+}
+
+helper genModel::LinkModelFacet::getLinkEndType(methodNameSuffix : String) : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::FeatureLinkModelFacet::getLinkEndType(methodNameSuffix : String) : genModel_1::GenClass {
+ return (if getIncomingLinksMethodNameSuffix() = methodNameSuffix then self.getTargetType() else self.getSourceType() endif)
+}
+
+helper genModel::TypeLinkModelFacet::getLinkEndType(methodNameSuffix : String) : genModel_1::GenClass {
+ return (if getIncomingLinksMethodNameSuffix() = methodNameSuffix then self.getTargetType() else (if getOutgoingLinksMethodNameSuffix() = methodNameSuffix and null <> self.sourceMetaFeature then self.getSourceType() else self.containmentMetaFeature.genClass endif) endif)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt
new file mode 100644
index 000000000..4a2666aaa
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::diagram::updater::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE containerBaseCanonicalMethods FOR gmfgen::GenContainerBase-»
+ «EXPAND attributes-»
+
+ «EXPAND getSemanticChildrenList-»
+ «EXPAND shouldDeleteView-»
+
+ «EXPAND isOrphaned-»
+ «IF hasConformableSemanticChildren(self)-»
+
+ «EXPAND populateViewProperties-»
+ «ENDIF-»
+
+ «EXPAND getDefaultFactoryHint-»
+ «EXPAND getFeaturesToSynchronize-»
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenContainerBase-»
+«IF getSemanticChildrenContainmentFeatures(self)->size() > 0-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+java.util.Set myFeaturesToSynchronize;
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenList FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected java.util.List getSemanticChildrenList() {
+ «IF hasSemanticChildren(self)-»
+ org.eclipse.gmf.runtime.notation.View viewObject = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ java.util.List result = new java.util.LinkedList();
+ for (java.util.Iterator it = «EXPAND xpt::diagram::updater::DiagramUpdater::getSemanticChildrenMethodCall»(viewObject).iterator(); it.hasNext();) {
+ result.add(((«getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()») it.next()).getModelElement());
+ }
+ return result;
+ «ELSE-»
+ return java.util.Collections.EMPTY_LIST;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE shouldDeleteView FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE shouldDeleteView FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+protected boolean shouldDeleteView(org.eclipse.gmf.runtime.notation.View view) {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE checkShortcutProperty FOR gmfgen::GenDiagram-»
+ «IF not containsShortcutsTo->isEmpty()-»
+if (view.getEAnnotation("Shortcut") != null) {«EXPAND xpt::Common::nonNLS»
+ return «editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».isShortcutOrphaned(view);
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkShortcutProperty FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE getDefaultFactoryHint FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected String getDefaultFactoryHint() {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE isOrphaned FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected boolean isOrphaned(java.util.Collection semanticChildren, final org.eclipse.gmf.runtime.notation.View view) {
+ «EXPAND checkShortcutProperty-»
+ «IF not getSemanticChildren(self)->isEmpty()-»
+ int visualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(view);
+ switch (visualID) {
+ «EXPAND xpt::Common::caseVisualID FOREACH getSemanticChildren(self)»
+ if (!semanticChildren.contains(view.getElement())) {
+ return true;
+ }
+ «IF hasConformableSemanticChildren(self)-»
+ «EXPAND updateNotationModelElement-»
+ «ENDIF-»
+ }
+ «ENDIF-»
+ return false;
+}
+«ENDDEFINE»
+
+«DEFINE updateNotationModelElement FOR gmfgen::GenCommonBase-»
+ org.eclipse.emf.ecore.EObject domainModelElement = view.getElement();
+ if (visualID != «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»((org.eclipse.gmf.runtime.notation.View) getHost().getModel(), domainModelElement)) {
+ java.util.List createdViews = createViews(java.util.Collections.singletonList(domainModelElement));
+ «EXPAND xpt::Common::_assert('createdViews.size() == 1')-»
+ final org.eclipse.gmf.runtime.notation.View createdView = (org.eclipse.gmf.runtime.notation.View) ((org.eclipse.core.runtime.IAdaptable) createdViews.get(0)).getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (createdView != null) {
+ try {
+ new org.eclipse.emf.workspace.AbstractEMFOperation(host().getEditingDomain(), org.eclipse.gmf.runtime.common.core.util.StringStatics.BLANK, Collections.singletonMap(org.eclipse.emf.transaction.Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) {
+ protected org.eclipse.core.runtime.IStatus doExecute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ populateViewProperties(view, createdView);
+ return org.eclipse.core.runtime.Status.OK_STATUS;
+ }
+ }.execute(new org.eclipse.core.runtime.NullProgressMonitor(), null);
+ } catch (org.eclipse.core.commands.ExecutionException e) {
+ «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Error while copyign view information to newly created view", e); //$NON-NLS-1$
+ }
+ }
+ deleteViews(java.util.Collections.singletonList(view).iterator());
+ }
+«ENDDEFINE»
+
+«DEFINE populateViewProperties FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void populateViewProperties(org.eclipse.gmf.runtime.notation.View oldView, org.eclipse.gmf.runtime.notation.View newView) {
+ if (oldView instanceof org.eclipse.gmf.runtime.notation.Node && newView instanceof org.eclipse.gmf.runtime.notation.Node) {
+ org.eclipse.gmf.runtime.notation.Node oldNode = (org.eclipse.gmf.runtime.notation.Node) oldView;
+ org.eclipse.gmf.runtime.notation.Node newNode = (org.eclipse.gmf.runtime.notation.Node) newView;
+ if (oldNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Location && newNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Location) {
+ ((org.eclipse.gmf.runtime.notation.Location) newNode.getLayoutConstraint()).setX(((org.eclipse.gmf.runtime.notation.Location) oldNode.getLayoutConstraint()).getX());
+ ((org.eclipse.gmf.runtime.notation.Location) newNode.getLayoutConstraint()).setY(((org.eclipse.gmf.runtime.notation.Location) oldNode.getLayoutConstraint()).getY());
+ }
+ if (oldNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Size && newNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Size) {
+ ((org.eclipse.gmf.runtime.notation.Size) newNode.getLayoutConstraint()).setWidth(((org.eclipse.gmf.runtime.notation.Size) oldNode.getLayoutConstraint()).getWidth());
+ ((org.eclipse.gmf.runtime.notation.Size) newNode.getLayoutConstraint()).setHeight(((org.eclipse.gmf.runtime.notation.Size) oldNode.getLayoutConstraint()).getHeight());
+ }
+ if (oldNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Ratio && newNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Ratio) {
+ ((org.eclipse.gmf.runtime.notation.Ratio) newNode.getLayoutConstraint()).setValue(((org.eclipse.gmf.runtime.notation.Ratio) oldNode.getLayoutConstraint()).getValue());
+ }
+ newNode.persist();
+ }
+}
+«ENDDEFINE»
+
+«DEFINE getFeaturesToSynchronize FOR gmfgen::GenContainerBase-»
+«IF getSemanticChildrenChildFeatures(self)->size() > 0-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+protected java.util.Set getFeaturesToSynchronize(){
+ if (myFeaturesToSynchronize == null) {
+ myFeaturesToSynchronize = new java.util.HashSet();
+ «EXPAND addContainmentFeature FOREACH getSemanticChildrenContainmentFeatures(self)-»
+ }
+ return myFeaturesToSynchronize;
+}
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE addContainmentFeature FOR genmodel::GenFeature-»
+myFeaturesToSynchronize.add(«EXPAND MetaModel::MetaFeature»);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt
new file mode 100644
index 000000000..49f34316f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE extensions FOR gmfgen::GenDiagramUpdater-»
+ <extension point="org.eclipse.ui.commands" id="update-cmd">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <command
+ categoryId="org.eclipse.ui.category.edit"
+ defaultHandler="«getUpdateCommandQualifiedClassName()»"
+ description="%update.diagram.description"
+ id="«updateCommandID»"
+ name="%update.diagram.name"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.bindings" id="update-cmd-binding">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <key
+ commandId="«updateCommandID»"
+ contextId="«editorGen.editor.contextID»"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="F5"/>
+ </extension>
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt
new file mode 100644
index 000000000..fbae97bdf
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/CompartmentViewFactory.xpt
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+
+«DEFINE CompartmentViewFactory FOR gmfgen::GenCompartment-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().notationViewFactoriesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.BasicNodeViewFactory {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
+ java.util.List styles = new java.util.ArrayList();
+ «IF canCollapse-»
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDrawerStyle());
+ «ENDIF-»
+ «IF needsTitle-»
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createTitleStyle());
+ «ENDIF-»
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createSortingStyle());
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFilteringStyle());
+ «IF isStoringChildPositions(node.getLayoutType())-»
+ «EXPAND xpt::diagram::views::Utils::addShapeStyle('styles') FOR viewmap-»
+ «ENDIF-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
+ return styles;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
+ org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
+ «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
+ super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
+ setupCompartmentTitle(view);
+ setupCompartmentCollapsed(view);
+ «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
+ }
+ «IF isStoringChildPositions(node.getLayoutType())-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.LayoutConstraint createLayoutConstraint() {
+ return org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBounds();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void initializeFromPreferences(org.eclipse.gmf.runtime.notation.View view) {
+ super.initializeFromPreferences(view);
+ org.eclipse.jface.preference.IPreferenceStore store =
+ (org.eclipse.jface.preference.IPreferenceStore) getPreferencesHint().getPreferenceStore();
+ org.eclipse.swt.graphics.RGB fillRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(store,
+ org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_FILL_COLOR);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(view,
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(),
+ org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fillRGB));
+ }
+ «ENDIF-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setupCompartmentTitle(org.eclipse.gmf.runtime.notation.View view) {
+ org.eclipse.gmf.runtime.notation.TitleStyle titleStyle = (org.eclipse.gmf.runtime.notation.TitleStyle) view.getStyle(
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getTitleStyle());
+ if (titleStyle != null){
+ titleStyle.setShowTitle(true);
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void setupCompartmentCollapsed(org.eclipse.gmf.runtime.notation.View view) {
+ org.eclipse.gmf.runtime.notation.DrawerStyle drawerStyle = (org.eclipse.gmf.runtime.notation.DrawerStyle) view.getStyle(
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getDrawerStyle());
+ if (drawerStyle != null){
+ drawerStyle.setCollapsed(false);
+ }
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenCompartment»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt
new file mode 100644
index 000000000..863064c28
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/DiagramViewFactory.xpt
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE DiagramViewFactory FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «notationViewFactoriesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.DiagramViewFactory {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
+ java.util.List styles = new java.util.ArrayList();
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagramStyle());
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
+ return styles;
+ }
+«IF units <> null-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.MeasurementUnit getMeasurementUnit() {
+ return org.eclipse.gmf.runtime.notation.MeasurementUnit.«units.toUpper()»_LITERAL;
+ }
+«ENDIF-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt
new file mode 100644
index 000000000..f50da15e8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/FloatingLabelViewFactory.xpt
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+
+«DEFINE FloatingLabelViewFactory FOR gmfgen::GenLabel-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().notationViewFactoriesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.AbstractLabelViewFactory {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.View createView(org.eclipse.core.runtime.IAdaptable semanticAdapter,
+ org.eclipse.gmf.runtime.notation.View containerView, String semanticHint, int index, boolean persisted,
+ org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ org.eclipse.gmf.runtime.notation.Node view = (org.eclipse.gmf.runtime.notation.Node) super.createView(
+ semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint);
+ «EXPAND offset-»
+ return view;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
+ java.util.List styles = new java.util.ArrayList();
+ «EXPAND xpt::diagram::views::Utils::addTextStyle('styles') FOR modelFacet-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
+ return styles;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE offset FOR gmfgen::GenLabel-»
+«ENDDEFINE»
+
+«DEFINE offset FOR gmfgen::GenLinkLabel-»
+ «LET labelOffsetX(viewmap, 0) AS x-»
+ «LET labelOffsetY(viewmap, 0) AS y-»
+ «IF x <> 0 or y <> 0-»
+ «EXPAND offset(x, y)-»
+ «ENDIF-»
+ «ENDLET-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE offset FOR gmfgen::GenExternalNodeLabel-»
+ «EXPAND offset(0, 5)-»
+«ENDDEFINE»
+
+«DEFINE offset(x : Integer, y : Integer) FOR gmfgen::GenLabel-»
+ org.eclipse.gmf.runtime.notation.Location location = (org.eclipse.gmf.runtime.notation.Location) view.getLayoutConstraint();
+ org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode mapMode =
+ org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(containerView.getDiagram().getMeasurementUnit());
+ location.setX(mapMode.DPtoLP(«x»));
+ location.setY(mapMode.DPtoLP(«y»));
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLabel»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt
new file mode 100644
index 000000000..78336e585
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelNodeViewFactory.xpt
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+
+«DEFINE LabelNodeViewFactory FOR gmfgen::GenChildLabelNode-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().notationViewFactoriesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.AbstractLabelViewFactory {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
+ java.util.List styles = new java.util.ArrayList();
+ «EXPAND xpt::diagram::views::Utils::addLinkedDiagramStyle('styles')-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
+ return styles;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
+ org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
+ «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
+ super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
+ «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
+ «EXPAND xpt::diagram::views::Utils::backgroundColour('view') FOR viewmap-»
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenChildLabelNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt
new file mode 100644
index 000000000..df5f3943b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LabelViewFactory.xpt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+
+«DEFINE LabelViewFactory FOR gmfgen::GenNodeLabel-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().notationViewFactoriesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.BasicNodeViewFactory {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
+ java.util.List styles = new java.util.ArrayList();
+ «EXPAND xpt::diagram::views::Utils::addTextStyle('styles') FOR modelFacet-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
+ return styles;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNodeLabel»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt
new file mode 100644
index 000000000..636555d30
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/LinkViewFactory.xpt
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+
+«DEFINE LinkViewFactory FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().notationViewFactoriesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.ConnectionViewFactory {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
+ java.util.List styles = new java.util.ArrayList();
+ «IF not isFixedForeground(viewmap)-»
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createConnectorStyle());
+ «ELSE-»
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createRoutingStyle());
+ «ENDIF-»
+ «IF not isFixedFont(viewmap)-»
+ styles.add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFontStyle());
+ «ENDIF-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
+ return styles;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
+ org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
+ «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
+ super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
+ «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
+ «IF labels->size() > 0-»
+ org.eclipse.core.runtime.IAdaptable eObjectAdapter = null;
+ «EXPAND xpt::diagram::views::Utils::domainElementAdapter('eObjectAdapter') FOR modelFacet-»
+ «EXPAND xpt::diagram::views::Utils::createChildNode FOREACH labels-»
+ «ENDIF-»
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLink»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt
new file mode 100644
index 000000000..5558f9a0f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/NodeViewFactory.xpt
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+
+«DEFINE NodeViewFactory FOR gmfgen::GenNode-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().notationViewFactoriesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «notationViewFactoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.view.factories.AbstractShapeViewFactory {
+
+ «EXPAND createStyles-»
+
+ «EXPAND decorateView-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE createStyles FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createStyles(org.eclipse.gmf.runtime.notation.View view) {
+ java.util.List styles = new java.util.ArrayList();
+ «EXPAND xpt::diagram::views::Utils::addShapeStyle('styles') FOR viewmap-»
+ «EXPAND xpt::diagram::views::Utils::addLinkedDiagramStyle('styles')-»
+ «EXPAND xpt::diagram::views::Utils::addCustomStyles('styles')-»
+ return styles;
+ }
+«ENDDEFINE»
+
+«DEFINE decorateView FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void decorateView(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.View view,
+ org.eclipse.core.runtime.IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
+ «EXPAND xpt::diagram::views::Utils::updateSemanticHint-»
+ super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
+ «EXPAND addShortcut-»
+ «EXPAND xpt::diagram::views::Utils::foregroundColour('view') FOR viewmap-»
+ «EXPAND xpt::diagram::views::Utils::backgroundColour('view') FOR viewmap-»
+ «IF labels->size() > 0 or compartments->size() > 0-»
+ org.eclipse.core.runtime.IAdaptable eObjectAdapter = null;
+ «EXPAND xpt::diagram::views::Utils::domainElementAdapter('eObjectAdapter') FOR modelFacet-»
+ «EXPAND xpt::diagram::views::Utils::createChildNode FOREACH labels-»
+ «EXPAND xpt::diagram::views::Utils::createChildNode FOREACH compartments-»
+ «ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE addShortcut FOR gmfgen::GenNode-»
+«ENDDEFINE»
+
+«DEFINE addShortcut FOR gmfgen::GenTopLevelNode-»
+ if (!«getDiagram().getEditPartQualifiedClassName()».MODEL_ID.equals(
+ «getDiagram().getVisualIDRegistryQualifiedClassName()».getModelID(containerView))) {
+ «EXPAND xpt::Common::addShortcutAnnotation('view') FOR getDiagram()-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt
new file mode 100644
index 000000000..33eba2ec3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/views/Utils.xpt
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE updateSemanticHint FOR gmfgen::GenCommonBase-»
+ if (semanticHint == null) {
+ semanticHint = «getDiagram().getVisualIDRegistryQualifiedClassName()».getType(
+ «getEditPartQualifiedClassName()».VISUAL_ID);
+ view.setType(semanticHint);
+ }
+«ENDDEFINE»
+
+«DEFINE createChildNode FOR gmfgen::GenCommonBase-»
+ getViewService().createNode(eObjectAdapter, view,
+ «getDiagram().getVisualIDRegistryQualifiedClassName()».getType(«getEditPartQualifiedClassName()».VISUAL_ID),
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true, getPreferencesHint());
+«ENDDEFINE»
+
+«DEFINE domainElementAdapter(adapterVar : String) FOR gmfgen::ModelFacet-»
+«ENDDEFINE»
+
+«DEFINE domainElementAdapter(adapterVar : String) FOR gmfgen::TypeModelFacet-»
+ org.eclipse.emf.ecore.EObject eObject =
+ (org.eclipse.emf.ecore.EObject) semanticAdapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
+ if (eObject != null) {
+ «adapterVar» = new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(eObject);
+ }
+«ENDDEFINE»
+
+«DEFINE foregroundColour(viewVar : String) FOR gmfgen::Viewmap-»
+ «EXPAND foregroundColour(viewVar) FOREACH attributes-»
+«ENDDEFINE»
+
+«DEFINE foregroundColour(viewVar : String) FOR gmfgen::Attributes-»
+«ENDDEFINE»
+
+«DEFINE foregroundColour(viewVar : String) FOR gmfgen::ColorAttributes-»
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar»,
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(),
+ org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger(
+ org.eclipse.draw2d.ColorConstants.«foregroundColor»));
+«ENDDEFINE»
+
+«DEFINE backgroundColour(viewVar : String) FOR gmfgen::Viewmap-»
+ «EXPAND backgroundColour(viewVar) FOREACH attributes-»
+«ENDDEFINE»
+
+«DEFINE backgroundColour(viewVar : String) FOR gmfgen::Attributes-»
+«ENDDEFINE»
+
+«DEFINE backgroundColour(viewVar : String) FOR gmfgen::ColorAttributes-»
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar»,
+ org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(),
+ org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger(
+ org.eclipse.draw2d.ColorConstants.«backgroundColor»));
+«ENDDEFINE»
+
+«DEFINE addShapeStyle(stylesVar : String) FOR gmfgen::Viewmap-»
+ «IF isFixedFont(self)-»
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFillStyle());
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLineStyle());
+ «ELSE-»
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShapeStyle());
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE addTextStyle(stylesVar : String) FOR gmfgen::LabelModelFacet-»
+«ENDDEFINE»
+
+«DEFINE addTextStyle(stylesVar : String) FOR gmfgen::DesignLabelModelFacet-»
+ «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());
+«ENDDEFINE»
+
+«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::GenCommonBase-»
+ «EXPAND addLinkedDiagramStyle(stylesVar) FOREACH behaviour-»
+«ENDDEFINE»
+
+«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::Behaviour-»
+«ENDDEFINE»
+
+«DEFINE addLinkedDiagramStyle(stylesVar : String) FOR gmfgen::OpenDiagramBehaviour-»
+ {
+ org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle diagramFacet =
+ org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createHintedDiagramLinkStyle();
+ «IF diagramKind <> null-»
+ diagramFacet.setHint("«diagramKind»"); // $NON-NLS-1$
+ «ENDIF-»
+ «stylesVar».add(diagramFacet);
+ }
+«ENDDEFINE»
+
+«DEFINE addCustomStyles(stylesVar : String) FOR gmfgen::GenCommonBase-»
+ «FOREACH styles->asSequence() AS style-»
+ «stylesVar».add(«EXPAND MetaModel::NewInstance FOR style»);
+ «ENDFOREACH-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt
new file mode 100644
index 000000000..4caf0da89
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/ActionBarContributor.xpt
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::GenEditorGenerator»
+
+«DEFINE ActionBarContributor FOR gmfgen::GenEditorView-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «actionBarContributorClassName»«EXPAND extendsList» {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected Class getEditorClass() {
+ return «getQualifiedClassName()».class;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getEditorId() {
+ return «getQualifiedClassName()».ID;
+ }
+ «EXPAND initMethod-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenEditorView» extends org.eclipse.gmf.runtime.diagram.ui.parts.DiagramActionBarContributor«ENDDEFINE»
+
+«DEFINE initMethod FOR gmfgen::GenEditorView»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void init(org.eclipse.ui.IActionBars bars, org.eclipse.ui.IWorkbenchPage page) {
+ super.init(bars, page);
+ // print preview
+ org.eclipse.jface.action.IMenuManager fileMenu = bars.getMenuManager().findMenuUsingPath(org.eclipse.ui.IWorkbenchActionConstants.M_FILE);
+ «EXPAND xpt::Common::_assert('fileMenu != null')-»
+«IF editorGen.plugin.printingEnabled-»
+ org.eclipse.jface.action.IAction printPreviewAction = new org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.RenderedPrintPreviewAction(new org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.EnhancedPrintActionHelper());
+ fileMenu.insertBefore("print", printPreviewAction);«EXPAND xpt::Common::nonNLS»
+«ELSE-»
+ fileMenu.remove("pageSetupAction");«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+«IF /*hasAudits || hasMetrics */editorGen.diagram.validationEnabled or hasAudits(editorGen) or (editorGen.metrics <> null and editorGen.metrics.metrics->size() > 0)-»
+ org.eclipse.jface.action.IMenuManager editMenu = bars.getMenuManager().findMenuUsingPath(org.eclipse.ui.IWorkbenchActionConstants.M_EDIT);
+ «EXPAND xpt::Common::_assert('editMenu != null')-»
+ if (editMenu.find("validationGroup") == null) {«EXPAND xpt::Common::nonNLS»
+ editMenu.add(new org.eclipse.jface.action.GroupMarker("validationGroup"));«EXPAND xpt::Common::nonNLS»
+ }
+«IF editorGen.diagram.validationEnabled or hasAudits(editorGen)-»
+ org.eclipse.jface.action.IAction validateAction = new «EXPAND xpt::editor::ValidateAction::qualifiedClassName FOR editorGen.diagram»(page);
+ editMenu.appendToGroup("validationGroup", validateAction);«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+«IF editorGen.metrics <> null and editorGen.metrics.metrics->size() > 0-»
+ org.eclipse.jface.action.IAction metricsAction = new «editorGen.diagram.getMetricProviderQualifiedClassName()».MetricsAction(page);
+ editMenu.appendToGroup("validationGroup", metricsAction);«EXPAND xpt::Common::nonNLS»
+«ENDIF-»
+«ENDIF /*hasAudits || hasMetrics */-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenEditorView»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt
new file mode 100644
index 000000000..c6af45b84
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizard.xpt
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE CreationWizard FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «creationWizardClassName»
+ extends org.eclipse.jface.wizard.Wizard implements org.eclipse.ui.INewWizard {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbench workbench;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.jface.viewers.IStructuredSelection selection;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «getCreationWizardPageQualifiedClassName()» diagramModelFilePage;
+ «IF isStandaloneDomainModel(self)-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «getCreationWizardPageQualifiedClassName()» domainModelFilePage;
+ «ENDIF-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.emf.ecore.resource.Resource diagram;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private boolean openNewlyCreatedDiagramEditor = true;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.ui.IWorkbench getWorkbench() {
+ return workbench;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.jface.viewers.IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final org.eclipse.emf.ecore.resource.Resource getDiagram() {
+ return diagram;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final boolean isOpenNewlyCreatedDiagramEditor() {
+ return openNewlyCreatedDiagramEditor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) {
+ this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void init(org.eclipse.ui.IWorkbench workbench, org.eclipse.jface.viewers.IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizard(self))) FOR editorGen»);
+ setDefaultPageImageDescriptor(«editorGen.plugin.getActivatorQualifiedClassName()».getBundledImageDescriptor(
+ "icons/wizban/New«IF domainDiagramElement <> null»«domainDiagramElement.genPackage.prefix»«ENDIF»Wizard.gif")); //$NON-NLS-1$
+ setNeedsProgressMonitor(true);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void addPages() {
+ diagramModelFilePage = new «getCreationWizardPageQualifiedClassName()»(
+ "DiagramModelFile", getSelection(), "«editorGen.diagramFileExtension»"); //$NON-NLS-1$ //$NON-NLS-2$
+ diagramModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizardDiagramPage(self))) FOR editorGen»);
+ diagramModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForCreationWizardDiagramPage(self))) FOR editorGen»);
+ addPage(diagramModelFilePage);
+ «IF isStandaloneDomainModel(self)-»
+
+ domainModelFilePage = new «getCreationWizardPageQualifiedClassName()»(
+ "DomainModelFile", getSelection(), "«editorGen.domainFileExtension»") { //$NON-NLS-1$ //$NON-NLS-2$
+
+ public void setVisible(boolean visible) {
+ if (visible) {
+ String fileName = diagramModelFilePage.getFileName();
+ fileName = fileName.substring(0, fileName.length() - ".«editorGen.diagramFileExtension»".length()); //$NON-NLS-1$
+ setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
+ getContainerFullPath(), fileName, "«editorGen.domainFileExtension»")); //$NON-NLS-1$
+ }
+ super.setVisible(visible);
+ }
+ };
+ domainModelFilePage.setTitle(«EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»);
+ domainModelFilePage.setDescription(«EXPAND xpt::Externalizer::accessorCall(descriptionKey(i18nKeyForCreationWizardDomainPage(self))) FOR editorGen»);
+ addPage(domainModelFilePage);
+ «ENDIF-»
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean performFinish() {
+ org.eclipse.jface.operation.IRunnableWithProgress op =
+ «IF editorGen.application = null-»
+ new org.eclipse.ui.actions.WorkspaceModifyOperation(null) {
+
+ protected void execute(org.eclipse.core.runtime.IProgressMonitor monitor)
+ throws org.eclipse.core.runtime.CoreException, InterruptedException {
+ «ELSE-»
+ new org.eclipse.jface.operation.IRunnableWithProgress() {
+
+ public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ «ENDIF-»
+ diagram = «getDiagramEditorUtilQualifiedClassName()».createDiagram(diagramModelFilePage.getURI(),
+ «IF isStandaloneDomainModel(self)-»
+ domainModelFilePage.getURI(),
+ «ENDIF-»
+ monitor);
+ if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
+ try {
+ «getDiagramEditorUtilQualifiedClassName()».openDiagram(diagram);
+ } catch (org.eclipse.ui.PartInitException e) {
+ org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardOpenEditorError(self)) FOR editorGen», null, e.getStatus());
+ }
+ }
+ }
+ };
+ try {
+ getContainer().run(false, true, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ if (e.getTargetException() instanceof org.eclipse.core.runtime.CoreException) {
+ org.eclipse.jface.dialogs.ErrorDialog.openError(getContainer().getShell(),
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardCreationError(self)) FOR editorGen», null,
+ ((org.eclipse.core.runtime.CoreException) e.getTargetException()).getStatus());
+ } else {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(
+ "Error creating diagram", e.getTargetException()); //$NON-NLS-1$
+ }
+ return false;
+ }
+ return diagram != null;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizard(self)), 'New ' + editorGen.modelID + ' Diagram')-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizardDiagramPage(self)), 'Create ' + editorGen.modelID + ' Diagram')-»
+«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForCreationWizardDiagramPage(self)), (if isStandaloneDomainModel(self) then 'Select file that will contain diagram model.' else 'Select file that will contain diagram and domain models.' endif))-»
+«IF isStandaloneDomainModel(self)-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForCreationWizardDomainPage(self)), 'Create ' + editorGen.modelID + ' Domain Model')-»
+«EXPAND xpt::Externalizer::messageEntry(descriptionKey(i18nKeyForCreationWizardDomainPage(self)), 'Select file that will contain domain model.')-»
+«ENDIF-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardOpenEditorError(self), 'Error opening diagram editor')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardCreationError(self), 'Creation Problems')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizard(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizardDiagramPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForCreationWizardDiagramPage(self)))-»
+ «IF isStandaloneDomainModel(self)-»
+ «EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForCreationWizardDomainPage(self)))-»
+ «EXPAND xpt::Externalizer::accessorField(descriptionKey(i18nKeyForCreationWizardDomainPage(self)))-»
+ «ENDIF-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardOpenEditorError(self))-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardCreationError(self))-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt
new file mode 100644
index 000000000..ef872708e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/CreationWizardPage.xpt
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE CreationWizardPage FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «creationWizardPageClassName» extends
+ «IF editorGen.application = null-»
+ org.eclipse.ui.dialogs.WizardNewFileCreationPage
+ «ELSE-»
+ «editorGen.application.packageName».WizardNewFileCreationPage
+ «ENDIF-»
+ {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final String fileExtension;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «creationWizardPageClassName»(String pageName,
+ org.eclipse.jface.viewers.IStructuredSelection selection, String fileExtension) {
+ super(pageName, selection);
+ this.fileExtension = fileExtension;
+ }
+
+ /**
+ * Override to create files with this extension.
+ *
+ * @generated
+ */
+ protected String getExtension() {
+ return fileExtension;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.common.util.URI getURI() {
+ «IF editorGen.application = null-»
+ return org.eclipse.emf.common.util.URI.createPlatformResourceURI(getFilePath().toString(), false);
+ «ELSE-»
+ return org.eclipse.emf.common.util.URI.createFileURI(getFilePath().toString());
+ «ENDIF-»
+ }
+ «IF editorGen.application = null-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.core.runtime.IPath getFilePath() {
+ org.eclipse.core.runtime.IPath path = getContainerFullPath();
+ if (path == null) {
+ path = new org.eclipse.core.runtime.Path(""); //$NON-NLS-1$
+ }
+ String fileName = getFileName();
+ if (fileName != null) {
+ path = path.append(fileName);
+ }
+ return path;
+ }
+ «ENDIF-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void createControl(org.eclipse.swt.widgets.Composite parent) {
+ super.createControl(parent);
+ setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
+ getContainerFullPath(), getFileName(), getExtension()));
+ setPageComplete(validatePage());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected boolean validatePage() {
+ if (!super.validatePage()) {
+ return false;
+ }
+ String extension = getExtension();
+ if (extension != null && !getFilePath().toString().endsWith("." + extension)) {
+ setErrorMessage(org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardPageExtensionError(self)) FOR editorGen», extension));
+ return false;
+ }
+ return true;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardPageExtensionError(self), 'File name should have {0} extension.')-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardPageExtensionError(self))-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt
new file mode 100644
index 000000000..13b6490a3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DeleteElementAction.xpt
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE className FOR gmfgen::GenDiagram»DeleteElementAction«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE DeleteElementAction FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» extends org.eclipse.gmf.runtime.diagram.ui.actions.AbstractDeleteFromAction {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.ui.IWorkbenchPart part) {
+ super(part);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «EXPAND className»(org.eclipse.ui.IWorkbenchPage workbenchPage) {
+ super(workbenchPage);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void init() {
+ super.init();
+ setId(org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds.ACTION_DELETE_FROM_MODEL);
+ setText(org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages.DiagramEditor_Delete_from_Model);
+ setToolTipText(org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages.DiagramEditor_Delete_from_ModelToolTip);
+ org.eclipse.ui.ISharedImages workbenchImages = org.eclipse.ui.PlatformUI.getWorkbench().getSharedImages();
+ setHoverImageDescriptor(workbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_TOOL_DELETE));
+ setImageDescriptor(workbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_TOOL_DELETE));
+ setDisabledImageDescriptor(workbenchImages.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getCommandLabel() {
+ return org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages.DiagramEditor_Delete_from_Model;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.commands.Command getCommand(org.eclipse.gef.Request request) {
+ java.util.List operationSet = getOperationSet();
+ if (operationSet.isEmpty()) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ java.util.Iterator editParts = operationSet.iterator();
+ org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand command =
+ new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), getCommandLabel());
+ while (editParts.hasNext()) {
+ org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) editParts.next();
+ org.eclipse.gef.commands.Command curCommand = editPart.getCommand(request);
+ if (curCommand != null) {
+ command.compose(new org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy(curCommand));
+ }
+ }
+ if (command.isEmpty() || command.size() != operationSet.size()) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt
new file mode 100644
index 000000000..9397e3041
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramContentInitializer.xpt
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«EXTENSION xpt::diagram::updater::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE DiagramContentInitializer FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «diagramContentInitializerClassName» {
+
+ «EXPAND attributes-»
+
+ «EXPAND initDiagramContent-»
+
+ «EXPAND createChildren FOREACH getAllContainers()->select(container | not container.sansDomain)-»
+
+ «EXPAND createNode-»
+
+ «EXPAND createLinks-»
+ «IF not (getAllContainers())[gmfgen::GenCompartment]->isEmpty()-»
+
+ «EXPAND getCompartment-»
+ «ENDIF-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Map myDomain2NotationMap = new java.util.HashMap();
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection myLinkDescriptors = new java.util.LinkedList();
+«ENDDEFINE»
+
+«DEFINE initDiagramContent FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void initDiagramContent(org.eclipse.gmf.runtime.notation.Diagram diagram) {
+ if (!«EXPAND xpt::editor::VisualIDRegistry::modelID».equals(diagram.getType())) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Incorrect diagram passed as a parameter: " + diagram.getType());
+ return;
+ }
+ if («EXPAND MetaModel::NotInstance('diagram.getElement()') FOR domainDiagramElement») {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Incorrect diagram element specified: " + diagram.getElement() + " instead of «domainDiagramElement.ecoreClass.name»");
+ return;
+ }
+ «EXPAND createChildrenMethodName»(diagram);
+ createLinks(diagram);
+}
+«ENDDEFINE»
+
+«DEFINE createChildrenMethodName FOR gmfgen::GenContainerBase»create«getUniqueIdentifier()»Children«ENDDEFINE»
+
+«DEFINE createChildren FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void «EXPAND createChildrenMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ «EXPAND collectContainedLinks-»
+ «IF hasSemanticChildren(self)-»
+ java.util.Collection childNodeDescriptors = «EXPAND xpt::diagram::updater::DiagramUpdater::getSemanticChildrenMethodCall»(view);
+ for (java.util.Iterator it = childNodeDescriptors.iterator(); it.hasNext();) {
+ createNode(view, («getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()») it.next());
+ }
+ «ENDIF-»
+ «EXPAND createCompartmentsChildren-»
+}
+«ENDDEFINE»
+
+«DEFINE collectContainedLinks FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE collectContainedLinks FOR gmfgen::GenNode-»
+ myDomain2NotationMap.put(view.getElement(), view);
+ myLinkDescriptors.addAll(«EXPAND xpt::diagram::updater::DiagramUpdater::getOutgoingLinksMethodCall»(view));
+«ENDDEFINE»
+
+«DEFINE createCompartmentsChildren FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE createCompartmentsChildren FOR gmfgen::GenNode-»
+ «EXPAND callCreateCompartmentChildren FOREACH compartments»
+«ENDDEFINE»
+
+«REM»
+ Will be called for each compartment of GenNode for GenNode.isSansDomain() == false.
+ if !GenNode.isSansDomain() => !GenCompartment.isSansDomain() so should not check
+ !this.isSansDomain() here.
+«ENDREM»
+«DEFINE callCreateCompartmentChildren FOR gmfgen::GenCompartment-»
+ «EXPAND createChildrenMethodName»(getCompartment(view, «EXPAND xpt::editor::VisualIDRegistry::visualID»));
+«ENDDEFINE»
+
+«DEFINE createNode FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void createNode(org.eclipse.gmf.runtime.notation.View parentView, «editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()» nodeDescriptor) {
+ final String nodeType = «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall('nodeDescriptor.getVisualID()')»;
+ org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.diagram.core.services.ViewService.createNode(parentView, nodeDescriptor.getModelElement(), nodeType, «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ switch (nodeDescriptor.getVisualID()) {
+ «EXPAND createNodeCase FOREACH getAllNodes()->select(node | not node.sansDomain)-»
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createNodeCase FOR gmfgen::GenContainerBase-»
+«EXPAND xpt::Common::caseVisualID»
+ «EXPAND createChildrenMethodName»(node);
+ return;
+«ENDDEFINE»
+
+«REM»Adopt this code to work with links to links«ENDREM»
+«DEFINE createLinks FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void createLinks(org.eclipse.gmf.runtime.notation.Diagram diagram) {
+ for (boolean continueLinkCreation = true; continueLinkCreation;) {
+ continueLinkCreation = false;
+ java.util.Collection additionalDescriptors = new java.util.LinkedList();
+ for (java.util.Iterator it = myLinkDescriptors.iterator(); it.hasNext();) {
+ «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») it.next();
+ if (!myDomain2NotationMap.containsKey(nextLinkDescriptor.getSource()) || !myDomain2NotationMap.containsKey(nextLinkDescriptor.getDestination())) {
+ continue;
+ }
+ final String linkType = «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall('nextLinkDescriptor.getVisualID()')»;
+ org.eclipse.gmf.runtime.notation.Edge edge = org.eclipse.gmf.runtime.diagram.core.services.ViewService.getInstance().createEdge(nextLinkDescriptor.getSemanticAdapter(), diagram, linkType, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true, «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ if (edge != null) {
+ edge.setSource((org.eclipse.gmf.runtime.notation.View) myDomain2NotationMap.get(nextLinkDescriptor.getSource()));
+ edge.setTarget((org.eclipse.gmf.runtime.notation.View) myDomain2NotationMap.get(nextLinkDescriptor.getDestination()));
+ it.remove();
+ if (nextLinkDescriptor.getModelElement() != null) {
+ myDomain2NotationMap.put(nextLinkDescriptor.getModelElement(), edge);
+ }
+ continueLinkCreation = true;
+ switch (nextLinkDescriptor.getVisualID()) {
+ «EXPAND createLinksCase FOREACH links->select(link | null <> link.getMetaClass())-»
+ }
+ }
+ }
+ myLinkDescriptors.addAll(additionalDescriptors);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE createLinksCase FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::caseVisualID»
+ additionalDescriptors.addAll(«EXPAND xpt::diagram::updater::DiagramUpdater::getOutgoingLinksMethodCall»(edge));
+ break;
+«ENDDEFINE»
+
+«DEFINE getCompartment FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gmf.runtime.notation.Node getCompartment(org.eclipse.gmf.runtime.notation.View node, int visualID) {
+ String type = «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall('visualID')»;
+ for (java.util.Iterator it = node.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (nextView instanceof org.eclipse.gmf.runtime.notation.Node && type.equals(nextView.getType())) {
+ return (org.eclipse.gmf.runtime.notation.Node) nextView;
+ }
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt
new file mode 100644
index 000000000..b60800bcc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorContextMenuProvider.xpt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE className FOR gmfgen::GenDiagram»DiagramEditorContextMenuProvider«ENDDEFINE»
+
+«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»
+
+«DEFINE DiagramEditorContextMenuProvider FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «EXPAND className» extends org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.ui.IWorkbenchPart part;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName» deleteAction;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public DiagramEditorContextMenuProvider(org.eclipse.ui.IWorkbenchPart part, org.eclipse.gef.EditPartViewer viewer) {
+ super(part, viewer);
+ this.part = part;
+ deleteAction = new «EXPAND xpt::editor::DeleteElementAction::qualifiedClassName»(part);
+ deleteAction.init();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void dispose() {
+ if (deleteAction != null) {
+ deleteAction.dispose();
+ deleteAction = null;
+ }
+ super.dispose();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void buildContextMenu(final org.eclipse.jface.action.IMenuManager menu) {
+ getViewer().flush();
+ try {
+ org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(
+ (org.eclipse.emf.ecore.EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {
+
+ public void run() {
+ org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService.getInstance().contributeToPopupMenu(
+ DiagramEditorContextMenuProvider.this, part);
+ menu.remove(org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds.ACTION_DELETE_FROM_MODEL);
+ menu.appendToGroup("editGroup", deleteAction);
+ }
+ });
+ } catch (Exception e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Error building context menu", e);
+ }
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt
new file mode 100644
index 000000000..17db5997a
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DiagramEditorUtil.xpt
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::editor::GenDiagram»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE DiagramEditorUtil FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «diagramEditorUtilClassName» {
+
+«EXPAND saveOptions-»
+
+«EXPAND openDiagramMethod-»
+«IF editorGen.application = null-»
+
+ «EXPAND setCharsetMethods-»
+«ENDIF-»
+
+«EXPAND getUniqueFileNameMethod-»
+
+«IF editorGen.application <> null»
+ /**
+ * Allows user to select file and loads it as a model.
+ *
+ * @generated
+ */
+ public static org.eclipse.emf.ecore.resource.Resource openModel(
+ org.eclipse.swt.widgets.Shell shell, String description, org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain) {
+ org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell, org.eclipse.swt.SWT.OPEN);
+ if (description != null) {
+ fileDialog.setText(description);
+ }
+ fileDialog.open();
+ String fileName = fileDialog.getFileName();
+ if (fileName == null || fileName.length() == 0) {
+ return null;
+ }
+ if (fileDialog.getFilterPath() != null) {
+ fileName = fileDialog.getFilterPath() + java.io.File.separator + fileName;
+ }
+ org.eclipse.emf.common.util.URI uri = org.eclipse.emf.common.util.URI.createFileURI(fileName);
+ org.eclipse.emf.ecore.resource.Resource resource = null;
+ try {
+ resource = editingDomain.getResourceSet().getResource(uri, true);
+ } catch (org.eclipse.emf.common.util.WrappedException we) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to load resource: " + uri, we); «EXPAND xpt::Common::nonNLS»
+ org.eclipse.jface.dialogs.MessageDialog.openError(shell,
+ «EXPAND xpt::Externalizer::accessorCall(titleKey(i18nKeyForOpenModelResourceErrorDialog(self))) FOR editorGen»,
+ org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(messageKey(i18nKeyForOpenModelResourceErrorDialog(self))) FOR editorGen»,
+ fileName));
+ }
+ return resource;
+ }
+«ENDIF»
+
+ /**
+ * Runs the wizard in a dialog.
+ *
+ * @generated
+ */
+ public static void runWizard(org.eclipse.swt.widgets.Shell shell, org.eclipse.jface.wizard.Wizard wizard, String settingsKey) {
+ org.eclipse.jface.dialogs.IDialogSettings pluginDialogSettings = «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getDialogSettings();
+ org.eclipse.jface.dialogs.IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
+ if (wizardDialogSettings == null) {
+ wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
+ }
+ wizard.setDialogSettings(wizardDialogSettings);
+ org.eclipse.jface.wizard.WizardDialog dialog = new org.eclipse.jface.wizard.WizardDialog(shell, wizard);
+ dialog.create();
+ dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
+ dialog.open();
+ }
+
+«EXPAND createDiagramMethod-»
+«IF domainDiagramElement <> null»
+ «EXPAND createInitialModelMethod»
+ «EXPAND attachModelMethod»
+ «IF hasDocumentRoot(self)»«EXPAND createDocumentRootMethod»«ENDIF»
+«ENDIF»
+
+«EXPAND selectElementsMethod»
+«EXPAND findElementsMethod»
+«EXPAND findViewMethod»
+
+«EXPAND additions»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE saveOptions FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static java.util.Map getSaveOptions() {
+ java.util.Map saveOptions = new java.util.HashMap();
+ saveOptions.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_ENCODING, "UTF-8"); «EXPAND xpt::Common::nonNLS»
+ saveOptions.put(org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED, org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ return saveOptions;
+ }
+«ENDDEFINE»
+
+«DEFINE openDiagramMethod FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static boolean openDiagram(org.eclipse.emf.ecore.resource.Resource diagram) throws org.eclipse.ui.PartInitException {
+«IF editorGen.application = null-»
+ String path = diagram.getURI().toPlatformString(true);
+ org.eclipse.core.resources.IResource workspaceResource = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(new org.eclipse.core.runtime.Path(path));
+ if (workspaceResource instanceof org.eclipse.core.resources.IFile) {
+ org.eclipse.ui.IWorkbenchPage page = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ return null != page.openEditor(new org.eclipse.ui.part.FileEditorInput((org.eclipse.core.resources.IFile) workspaceResource), «editorGen.editor.getQualifiedClassName()».ID);
+ }
+ return false;
+«ELSE-»
+ org.eclipse.ui.IWorkbenchPage page = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.openEditor(new org.eclipse.emf.common.ui.URIEditorInput(diagram.getURI()), «editorGen.editor.getQualifiedClassName()».ID);
+ return true;
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE setCharsetMethods FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static void setCharset(org.eclipse.core.resources.IFile file) {
+ if (file == null) {
+ return;
+ }
+ try {
+ file.setCharset("UTF-8", new org.eclipse.core.runtime.NullProgressMonitor()); «EXPAND xpt::Common::nonNLS»
+ } catch (org.eclipse.core.runtime.CoreException e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to set charset for file " + file.getFullPath(), e); «EXPAND xpt::Common::nonNLS»
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE getUniqueFileNameMethod FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static String getUniqueFileName(org.eclipse.core.runtime.IPath containerFullPath, String fileName, String extension) {
+ if (containerFullPath == null) {
+ containerFullPath = new org.eclipse.core.runtime.Path(""); «EXPAND xpt::Common::nonNLS»
+ }
+ if (fileName == null || fileName.trim().length() == 0) {
+ fileName = "default"; «EXPAND xpt::Common::nonNLS»
+ }
+ org.eclipse.core.runtime.IPath filePath = containerFullPath.append(fileName);
+ if (extension != null && !extension.equals(filePath.getFileExtension())) {
+ filePath = filePath.addFileExtension(extension);
+ }
+ extension = filePath.getFileExtension();
+ fileName = filePath.removeFileExtension().lastSegment();
+ int i = 1;
+ while (
+ «IF editorGen.application = null-»
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().exists(filePath)
+ «ELSE-»
+ filePath.toFile().exists()
+ «ENDIF-»
+ ) {
+ i++;
+ filePath = containerFullPath.append(fileName + i);
+ if (extension != null) {
+ filePath = filePath.addFileExtension(extension);
+ }
+ }
+ return filePath.lastSegment();
+ }
+«ENDDEFINE»
+
+«DEFINE createDiagramMethod FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment((if editorGen.application = null then 'This method should be called within a workspace modify operation since it creates resources.' else '' endif))»
+ public static org.eclipse.emf.ecore.resource.Resource createDiagram(org.eclipse.emf.common.util.URI diagramURI,«IF standaloneDomainModel(self)» org.eclipse.emf.common.util.URI modelURI,«ENDIF» org.eclipse.core.runtime.IProgressMonitor progressMonitor) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ progressMonitor.beginTask(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreateDiagramProgressTask(self)) FOR editorGen», 3);
+ final org.eclipse.emf.ecore.resource.Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI);
+«IF standaloneDomainModel(self)-»
+ final org.eclipse.emf.ecore.resource.Resource modelResource = editingDomain.getResourceSet().createResource(modelURI);
+«ELSEIF domainDiagramElement <> null and hasDocumentRoot(self) /*for standalone models, we assume its resourcefactory would be able to set extendedMetaData option*/-»
+ ((org.eclipse.emf.ecore.xmi.XMLResource) diagramResource).getDefaultSaveOptions().put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
+ ((org.eclipse.emf.ecore.xmi.XMLResource) diagramResource).getDefaultLoadOptions().put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
+«ENDIF-»
+ final String diagramName = diagramURI.lastSegment();
+ org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand command = new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(editingDomain, «EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreateDiagramCommandLabel(self)) FOR editorGen», java.util.Collections.EMPTY_LIST) {
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+«IF domainDiagramElement <> null-»
+ «EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» model = createInitialModel();
+ attachModelToResource(model, «IF standaloneDomainModel(self)»model«ELSE»diagram«ENDIF»Resource);
+«ENDIF»
+ org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.diagram.core.services.ViewService.createDiagram(
+«IF domainDiagramElement <> null-»
+ «EXPAND MetaModel::DowncastToEObject('model') FOR domainDiagramElement»,
+«ENDIF-»
+ «EXPAND xpt::editor::VisualIDRegistry::modelID», «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR editorGen»);
+ if (diagram != null) {
+ diagramResource.getContents().add(diagram);
+ diagram.setName(diagramName);
+«IF domainDiagramElement <> null-»
+ diagram.setElement(«EXPAND MetaModel::DowncastToEObject('model') FOR domainDiagramElement»);
+«ENDIF-»
+ }
+
+ try {
+ «IF standaloneDomainModel(self)»modelResource.save(«EXPAND xpt::Common::getSaveOptions»);«ENDIF»
+ diagramResource.save(«EXPAND xpt::Common::getSaveOptions»);
+ } catch (java.io.IOException e) {
+ «/* TODO CommandResult.newErrorCommandResult(e) would be better? Or even throw ExecutionEx?*/»
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to store model and diagram resources", e); «EXPAND xpt::Common::nonNLS»
+ }
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ }
+ };
+ try {
+ org.eclipse.core.commands.operations.OperationHistoryFactory.getOperationHistory().execute(command, new org.eclipse.core.runtime.SubProgressMonitor(progressMonitor, 1), null);
+ } catch (org.eclipse.core.commands.ExecutionException e) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Unable to create model and diagram", e); «EXPAND xpt::Common::nonNLS»
+ }
+«IF editorGen.application = null-»
+ «IF standaloneDomainModel(self)»setCharset(org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(modelResource));«ENDIF»
+ setCharset(org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(diagramResource));
+«ENDIF-»
+ return diagramResource;
+ }
+«ENDDEFINE»
+
+«DEFINE createInitialModelMethod FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment('Create a new instance of domain element associated with canvas.
+<!-- begin-user-doc -->
+<!-- end-user-doc -->')»
+ private static «EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» createInitialModel() {
+ return «EXPAND MetaModel::NewInstance FOR domainDiagramElement»;
+ }
+«ENDDEFINE»
+
+«DEFINE attachModelMethod FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment('Store model element in the resource.
+<!-- begin-user-doc -->
+<!-- end-user-doc -->')»
+ private static void attachModelToResource(«EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» model, org.eclipse.emf.ecore.resource.Resource resource) {
+ resource.getContents().add(«IF hasDocumentRoot(self)»createDocumentRoot(model)«ELSE»«EXPAND MetaModel::DowncastToEObject('model') FOR domainDiagramElement»«ENDIF»);
+ }
+«ENDDEFINE»
+
+// invoke only when there's DocumentRoot in the domain model
+«DEFINE createDocumentRootMethod FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static «EXPAND MetaModel::QualifiedClassName FOR getDocumentRoot(self)» createDocumentRoot(«EXPAND MetaModel::QualifiedClassName FOR domainDiagramElement» model) {
+ «EXPAND MetaModel::NewInstance('docRoot') FOR getDocumentRoot(self)»
+«LET getDocumentRootSetFeature(self) AS f»«IF f = null-»
+ docRoot.set«domainDiagramElement.ecoreClass.name»(model); // FIXME name of the set method is pure guess«ELSE-»
+ «EXPAND MetaModel::modifyFeature('docRoot', getDocumentRoot(self), 'model') FOR f»;«ENDIF»
+«ENDLET-»
+ return docRoot;
+ }
+«ENDDEFINE»
+
+«DEFINE selectElementsMethod FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static void selectElementsInDiagram(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart, java.util.List/*EditPart*/ editParts) {
+ diagramPart.getDiagramGraphicalViewer().deselectAll();
+
+ org.eclipse.gef.EditPart firstPrimary = null;
+ for (java.util.Iterator it = editParts.iterator(); it.hasNext();) {
+ org.eclipse.gef.EditPart nextPart = (org.eclipse.gef.EditPart) it.next();
+ diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
+ if(firstPrimary == null && nextPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart) {
+ firstPrimary = nextPart;
+ }
+ }
+
+ if(!editParts.isEmpty()) {
+ diagramPart.getDiagramGraphicalViewer().reveal(firstPrimary != null ? firstPrimary : (org.eclipse.gef.EditPart)editParts.get(0));
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE findElementsMethod FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static int findElementsInDiagramByID(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramPart, org.eclipse.emf.ecore.EObject element, java.util.List editPartCollector) {
+ org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer viewer = (org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) diagramPart.getViewer();
+ final int intialNumOfEditParts = editPartCollector.size();
+
+ if (element instanceof org.eclipse.gmf.runtime.notation.View) { // support notation element lookup
+ org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) viewer.getEditPartRegistry().get(element);
+ if (editPart != null) {
+ editPartCollector.add(editPart);
+ return 1;
+ }
+ }
+
+ String elementID = org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getProxyID(element);
+ java.util.List associatedParts = viewer.findEditPartsForElement(elementID, org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ // perform the possible hierarchy disjoint -> take the top-most parts only
+ for (java.util.Iterator editPartIt = associatedParts.iterator(); editPartIt.hasNext();) {
+ org.eclipse.gef.EditPart nextPart = (org.eclipse.gef.EditPart) editPartIt.next();
+ org.eclipse.gef.EditPart parentPart = nextPart.getParent();
+ while (parentPart != null && !associatedParts.contains(parentPart)) {
+ parentPart = parentPart.getParent();
+ }
+ if (parentPart == null) {
+ editPartCollector.add(nextPart);
+ }
+ }
+
+ if (intialNumOfEditParts == editPartCollector.size()) {
+ if (!associatedParts.isEmpty()) {
+ editPartCollector.add(associatedParts.iterator().next());
+ } else {
+ if (element.eContainer() != null) {
+ return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector);
+ }
+ }
+ }
+ return editPartCollector.size() - intialNumOfEditParts;
+ }
+«ENDDEFINE»
+
+«DEFINE findViewMethod FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static org.eclipse.gmf.runtime.notation.View findView(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart, org.eclipse.emf.ecore.EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) {
+ boolean hasStructuralURI = false;
+ if(targetElement.eResource() instanceof org.eclipse.emf.ecore.xmi.XMLResource) {
+ hasStructuralURI = ((org.eclipse.emf.ecore.xmi.XMLResource)targetElement.eResource()).getID(targetElement) == null;
+ }
+
+ org.eclipse.gmf.runtime.notation.View view = null;
+ if(hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) {
+ view = (org.eclipse.gmf.runtime.notation.View)lazyElement2ViewMap.getElement2ViewMap().get(targetElement);
+ } else if (findElementsInDiagramByID(diagramEditPart, targetElement, lazyElement2ViewMap.editPartTmpHolder) > 0) {
+ org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) lazyElement2ViewMap.editPartTmpHolder.get(0);
+ lazyElement2ViewMap.editPartTmpHolder.clear();
+ view = editPart.getModel() instanceof org.eclipse.gmf.runtime.notation.View ? (org.eclipse.gmf.runtime.notation.View) editPart.getModel() : null;
+ }
+
+ return (view == null) ? diagramEditPart.getDiagramView() : view;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static class LazyElement2ViewMap {
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.util.Map element2ViewMap;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.notation.View scope;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private java.util.Set elementSet;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final java.util.List editPartTmpHolder = new java.util.ArrayList();
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public LazyElement2ViewMap(org.eclipse.gmf.runtime.notation.View scope, java.util.Set elements) {
+ this.scope = scope;
+ this.elementSet = elements;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public final java.util.Map getElement2ViewMap() {
+ if(element2ViewMap == null) {
+ element2ViewMap = new java.util.HashMap();
+ // map possible notation elements to itself as these can't be found by view.getElement()
+ for (java.util.Iterator it = elementSet.iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) it.next();
+ if(element instanceof org.eclipse.gmf.runtime.notation.View) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) element;
+ if(view.getDiagram() == scope.getDiagram()) {
+ element2ViewMap.put(element, element); // take only those that part of our diagram
+ }
+ }
+ }
+
+ buildElement2ViewMap(scope, element2ViewMap, elementSet);
+ }
+ return element2ViewMap;
+ }
+ «EXPAND xpt::Common::generatedMemberComment»
+ static java.util.Map buildElement2ViewMap(org.eclipse.gmf.runtime.notation.View parentView, java.util.Map element2ViewMap, java.util.Set elements) {
+ if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+
+ if(parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) && elements.contains(parentView.getElement())) {
+ element2ViewMap.put(parentView.getElement(), parentView);
+ if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ }
+
+ for (java.util.Iterator it = parentView.getChildren().iterator(); it.hasNext();) {
+ buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
+ if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ }
+ for (java.util.Iterator it = parentView.getSourceEdges().iterator(); it.hasNext();) {
+ buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
+ if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ }
+ for (java.util.Iterator it = parentView.getSourceEdges().iterator(); it.hasNext();) {
+ buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
+ if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ }
+ return element2ViewMap;
+ }
+ } //LazyElement2ViewMap
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::accessorField(titleKey(i18nKeyForOpenModelResourceErrorDialog(self)))-»
+«EXPAND xpt::Externalizer::accessorField(messageKey(i18nKeyForOpenModelResourceErrorDialog(self)))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForCreateDiagramProgressTask(self))-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForCreateDiagramCommandLabel(self))-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(titleKey(i18nKeyForOpenModelResourceErrorDialog(self)), 'Error')-»
+«EXPAND xpt::Externalizer::messageEntry(messageKey(i18nKeyForOpenModelResourceErrorDialog(self)), 'Failed to load model file {0}')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreateDiagramProgressTask(self), 'Creating diagram and model files')-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreateDiagramCommandLabel(self), 'Creating diagram and model')-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt
new file mode 100644
index 000000000..c274dc9ac
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/DocumentProvider.xpt
@@ -0,0 +1,748 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::editor::Utils»
+
+«DEFINE DocumentProvider FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «documentProviderClassName» extends org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider implements org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider {
+
+ «EXPAND createElementInfo-»
+
+ «EXPAND createDocument-»
+
+ «EXPAND setupDocument-»
+
+ «EXPAND computeModificationStamp-»
+
+ «EXPAND createEmptyDocument-»
+
+ «EXPAND createEditingDomain-»
+
+ «EXPAND setDocumentContent-»
+
+ «EXPAND getModificationStamp-»
+
+ «EXPAND isDeleted-»
+
+ «EXPAND getResourceSetInfo-»
+
+ «EXPAND disposeElementInfo-»
+ «IF null = editorGen.application-»
+
+ «EXPAND doValidateState-»
+ «ENDIF-»
+
+ «EXPAND isReadOnly-»
+
+ «EXPAND isModifiable-»
+
+ «EXPAND updateCache-»
+
+ «EXPAND doUpdateStateCache-»
+
+ «EXPAND isSynchronized-»
+ «IF null = editorGen.application-»
+
+ «EXPAND getResetRule-»
+
+ «EXPAND getSaveRule-»
+
+ «EXPAND getSynchronizeRule-»
+
+ «EXPAND getValidateStateRule-»
+
+ «EXPAND computeSchedulingRule-»
+ «ENDIF-»
+
+ «EXPAND doSynchronize-»
+
+ «EXPAND doSaveDocument-»
+
+ «EXPAND handleElementChanged-»
+
+ «EXPAND handleElementMoved-»
+
+ «EXPAND createInputWithEditingDomain-»
+
+ «EXPAND getDiagramDocument-»
+
+ «EXPAND getOperationRunner-»
+ «IF null <> editorGen.application-»
+
+ «EXPAND getFile-»
+ «ENDIF-»
+
+ «EXPAND xpt::editor::ResourceSetInfo::ResourceSetInfo-»
+
+ «EXPAND xpt::editor::ResourceSetModificationListener::ResourceSetModificationListener-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE createElementInfo FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected ElementInfo createElementInfo(Object element) throws org.eclipse.core.runtime.CoreException {
+ «EXPAND checkEditorInputInstance-»
+ org.eclipse.ui.IEditorInput editorInput = (org.eclipse.ui.IEditorInput) element;
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document = (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) createDocument(editorInput);
+
+ ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
+ info.setModificationStamp(computeModificationStamp(info));
+ info.fStatus = null;
+ return info;
+}
+«ENDDEFINE»
+
+«DEFINE checkEditorInputInstance FOR gmfgen::GenDiagram-»
+if («IF null = editorGen.application»false == element instanceof «EXPAND fileEditorInputClassFQName» && «ENDIF»false == element instanceof «EXPAND uriEditorInputClassFQName») {
+ «EXPAND throwIncorrectInputException-»
+}
+«ENDDEFINE»
+
+«DEFINE throwIncorrectInputException FOR gmfgen::GenDiagram-»
+throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, 0,
+ org.eclipse.osgi.util.NLS.bind(
+ «EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderIncorrectInputError(self)) FOR editorGen»,
+ new Object[] {element, «IF null = editorGen.application»"«EXPAND fileEditorInputClassFQName»", «ENDIF»"«EXPAND uriEditorInputClassFQName»"}),«EXPAND xpt::Common::nonNLS(1)»«IF null = editorGen.application»«EXPAND xpt::Common::nonNLS(2)»«ENDIF»
+ null));
+«ENDDEFINE»
+
+«DEFINE fileEditorInputClassFQName FOR gmfgen::GenDiagram»org.eclipse.ui.part.FileEditorInput«ENDDEFINE»
+
+«DEFINE uriEditorInputClassFQName FOR gmfgen::GenDiagram»org.eclipse.emf.common.ui.URIEditorInput«ENDDEFINE»
+
+«DEFINE createDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument createDocument(Object element) throws org.eclipse.core.runtime.CoreException {
+ «EXPAND checkEditorInputInstance-»
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document = createEmptyDocument();
+ setDocumentContent(document, (org.eclipse.ui.IEditorInput) element);
+ setupDocument(element, document);
+ return document;
+}
+«ENDDEFINE»
+
+«DEFINE setupDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Sets up the given document as it would be provided for the given element. The
+content of the document is not changed. This default implementation is empty.
+Subclasses may reimplement.
+
+@param element the blue-print element
+@param document the document to set up'
+ )»
+protected void setupDocument(Object element, org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document) {
+ // for subclasses
+}
+«ENDDEFINE»
+
+«DEFINE computeModificationStamp FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private long computeModificationStamp(ResourceSetInfo info) {
+ int result = 0;
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ if (file.getLocation() != null) {
+ result += file.getLocation().toFile().lastModified();
+ } else {
+ result += file.getModificationStamp();
+ }
+ }
+ «ELSE-»
+ java.io.File file = getFile(nextResource);
+ if (file != null && file.exists()) {
+ result += file.lastModified();
+ }
+ «ENDIF-»
+ }
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE createEmptyDocument FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument createEmptyDocument() {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument document = new org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument();
+ document.setEditingDomain(createEditingDomain());
+ return document;
+}
+«ENDDEFINE»
+
+«DEFINE createEditingDomain FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.transaction.TransactionalEditingDomain createEditingDomain() {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory.getInstance().createEditingDomain();
+ editingDomain.setID("«editingDomainID»");«EXPAND xpt::Common::nonNLS»
+ final org.eclipse.emf.transaction.NotificationFilter diagramResourceModifiedFilter = org.eclipse.emf.transaction.NotificationFilter.createNotifierFilter(editingDomain.getResourceSet()).and(org.eclipse.emf.transaction.NotificationFilter.createEventTypeFilter(org.eclipse.emf.common.notify.Notification.ADD)).and(org.eclipse.emf.transaction.NotificationFilter.createFeatureFilter(org.eclipse.emf.ecore.resource.ResourceSet.class, org.eclipse.emf.ecore.resource.ResourceSet.RESOURCE_SET__RESOURCES));
+ editingDomain.getResourceSet().eAdapters().add(new org.eclipse.emf.common.notify.Adapter() {
+
+ private org.eclipse.emf.common.notify.Notifier myTarger;
+
+ public org.eclipse.emf.common.notify.Notifier getTarget() {
+ return myTarger;
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
+ if (diagramResourceModifiedFilter.matches(notification)) {
+ Object value = notification.getNewValue();
+ if (value instanceof org.eclipse.emf.ecore.resource.Resource) {
+ ((org.eclipse.emf.ecore.resource.Resource) value).setTrackingModification(true);
+ }
+ }
+ }
+
+ public void setTarget(org.eclipse.emf.common.notify.Notifier newTarget) {
+ myTarger = newTarget;
+ }
+
+ });
+
+ return editingDomain;
+}
+«ENDDEFINE»
+
+«DEFINE setDocumentContent FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void setDocumentContent(org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document, org.eclipse.ui.IEditorInput element) throws org.eclipse.core.runtime.CoreException {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument diagramDocument = (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) document;
+ org.eclipse.emf.transaction.TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
+ «IF null = editorGen.application»if (element instanceof «EXPAND fileEditorInputClassFQName») {
+ org.eclipse.core.resources.IStorage storage = ((«EXPAND fileEditorInputClassFQName») element).getStorage();
+ org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil.load(domain, storage, true, getProgressMonitor());
+ document.setContent(diagram);
+ } else «ENDIF»if(element instanceof «EXPAND uriEditorInputClassFQName») {
+ org.eclipse.emf.common.util.URI uri = ((«EXPAND uriEditorInputClassFQName») element).getURI();
+ org.eclipse.emf.ecore.resource.Resource resource = null;
+ try {
+ resource = domain.getResourceSet().getResource(uri.trimFragment(), false);
+ if (resource == null) {
+ resource = domain.getResourceSet().createResource(uri.trimFragment());
+ }
+ if (!resource.isLoaded()) {
+ try {
+ java.util.Map options = new java.util.HashMap(org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory.getDefaultLoadOptions());
+ // @see 171060
+ // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
+ resource.load(options);
+ } catch (java.io.IOException e) {
+ resource.unload();
+ throw e;
+ }
+ }
+ if (uri.fragment() != null) {
+ org.eclipse.emf.ecore.EObject rootElement = resource.getEObject(uri.fragment());
+ if (rootElement instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ document.setContent((org.eclipse.gmf.runtime.notation.Diagram) rootElement);
+ return;
+ }
+ } else {
+ for (java.util.Iterator it = resource.getContents().iterator(); it.hasNext();) {
+ Object rootElement = it.next();
+ if (rootElement instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ document.setContent((org.eclipse.gmf.runtime.notation.Diagram) rootElement);
+ return;
+ }
+ }
+ }
+ throw new RuntimeException(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderNoDiagramInResourceError(self)) FOR editorGen»);
+ } catch (Exception e) {
+ org.eclipse.core.runtime.CoreException thrownExcp = null;
+ if (e instanceof org.eclipse.core.runtime.CoreException) {
+ thrownExcp = (org.eclipse.core.runtime.CoreException) e;
+ } else {
+ String msg = e.getLocalizedMessage();
+ thrownExcp = new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, «editorGen.plugin.getActivatorQualifiedClassName()».ID, 0,
+ msg != null ? msg : «EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderDiagramLoadingError(self)) FOR editorGen», e));
+ }
+ throw thrownExcp;
+ }
+ } else {
+ «EXPAND throwIncorrectInputException-»
+ }
+}
+«ENDDEFINE»
+
+«DEFINE getModificationStamp FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public long getModificationStamp(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return computeModificationStamp(info);
+ }
+ return super.getModificationStamp(element);
+}
+«ENDDEFINE»
+
+«DEFINE isDeleted FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isDeleted(Object element) {
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document = getDiagramDocument(element);
+ if (document != null) {
+ org.eclipse.emf.ecore.resource.Resource diagramResource = document.getDiagram().eResource();
+ if (diagramResource != null) {
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(diagramResource);
+ return file == null || file.getLocation() == null || !file.getLocation().toFile().exists();
+ «ELSE-»
+ java.io.File file = getFile(diagramResource);
+ return file != null && !file.exists();
+ «ENDIF-»
+ }
+ }
+ return super.isDeleted(element);
+}
+«ENDDEFINE»
+
+«DEFINE getResourceSetInfo FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public ResourceSetInfo getResourceSetInfo(Object editorInput) {
+ return (ResourceSetInfo) super.getElementInfo(editorInput);
+}
+«ENDDEFINE»
+
+«DEFINE disposeElementInfo FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void disposeElementInfo(Object element, ElementInfo info) {
+ if (info instanceof ResourceSetInfo) {
+ ResourceSetInfo resourceSetInfo = (ResourceSetInfo) info;
+ resourceSetInfo.dispose();
+ }
+ super.disposeElementInfo(element, info);
+}
+«ENDDEFINE»
+
+«DEFINE doValidateState FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void doValidateState(Object element, Object computationContext) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.resources.IFile>*/ files2Validate = new java.util.ArrayList/*<org.eclipse.core.resources.IFile>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ files2Validate.add(file);
+ }
+ }
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().validateEdit((org.eclipse.core.resources.IFile[]) files2Validate.toArray(new org.eclipse.core.resources.IFile[files2Validate.size()]), computationContext);
+ }
+
+ super.doValidateState(element, computationContext);
+}
+«ENDDEFINE»
+
+«DEFINE isReadOnly FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isReadOnly(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ «EXPAND callUpdateCache-»
+ return info.isReadOnly();
+ }
+ return super.isReadOnly(element);
+}
+«ENDDEFINE»
+
+«DEFINE isModifiable FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isModifiable(Object element) {
+ if (!isStateValidated(element)) {
+ if («IF null = editorGen.application»element instanceof «EXPAND fileEditorInputClassFQName» || «ENDIF»element instanceof «EXPAND uriEditorInputClassFQName») {
+ return true;
+ }
+ }
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ «EXPAND callUpdateCache-»
+ return info.isModifiable();
+ }
+ return super.isModifiable(element);
+}
+«ENDDEFINE»
+
+«DEFINE callUpdateCache FOR gmfgen::GenDiagram-»
+if (info.isUpdateCache()) {
+ try {
+ updateCache(element);
+ } catch (org.eclipse.core.runtime.CoreException ex) {
+ «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderIsModifiable(self)) FOR editorGen», ex);
+ // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
+ }
+}
+«ENDDEFINE»
+
+«DEFINE updateCache FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void updateCache(Object element) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ «IF null = editorGen.application-»
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null && file.isReadOnly()) {
+ «ELSE-»
+ java.io.File file = getFile(nextResource);
+ if (file != null && file.exists() && !file.canWrite()) {
+ «ENDIF-»
+ info.setReadOnly(true);
+ info.setModifiable(false);
+ return;
+ }
+ }
+ info.setReadOnly(false);
+ info.setModifiable(true);
+ return;
+ }
+}
+«ENDDEFINE»
+
+«DEFINE doUpdateStateCache FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void doUpdateStateCache(Object element) throws org.eclipse.core.runtime.CoreException {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ info.setUpdateCache(true);
+ }
+ super.doUpdateStateCache(element);
+}
+«ENDDEFINE»
+
+«DEFINE isSynchronized FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isSynchronized(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ return info.isSynchronized();
+ }
+ return super.isSynchronized(element);
+}
+«ENDDEFINE»
+
+«DEFINE getResetRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.core.runtime.jobs.ISchedulingRule getResetRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/ rules = new java.util.ArrayList/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file));
+ }
+ }
+ return new org.eclipse.core.runtime.jobs.MultiRule((org.eclipse.core.runtime.jobs.ISchedulingRule[]) rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getSaveRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.core.runtime.jobs.ISchedulingRule getSaveRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/ rules = new java.util.ArrayList/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.eclipse.core.resources.IFile file = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(nextResource);
+ if (file != null) {
+ rules.add(computeSchedulingRule(file));
+ }
+ }
+ return new org.eclipse.core.runtime.jobs.MultiRule((org.eclipse.core.runtime.jobs.ISchedulingRule[]) rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getSynchronizeRule FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.core.runtime.jobs.ISchedulingRule getSynchronizeRule(Object element) {
+ ResourceSetInfo info = getResourceSetInfo(element);
+ if (info != null) {
+ java.util.Collection/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/ rules = new java.util.ArrayList/*<org.eclipse.core.runtime.jobs.ISchedulingRule>*/();
+ for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = info.getLoadedResourcesIterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ org.e