Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/toolsmiths/gmf-tooling')
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/plugin.properties1
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/src/org/eclipse/papyrus/gmf/codegen/gmfgen/provider/GenEditorGeneratorItemProvider.java24
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/META-INF/MANIFEST.MF5
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/PapyrusGMFExtensionMigrator.java22
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ChildNodeLabelEditPart.xtend37
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/CompartmentEditPart.xtend74
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/DiagramEditPart.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ExternalNodeLabelEditPart.xtend68
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkEditPart.xtend20
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkLabelEditPart.xtend66
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeEditPart.xtend29
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeLabelEditPart.xtend61
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/actions/LoadResourceAction.xtend21
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChildNodeLabelEditPart.xtend37
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChoiceUtils_qvto.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/CompartmentEditPart.xtend93
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/DiagramEditPart.xtend105
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ExternalNodeLabelEditPart.xtend27
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend77
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkLabelEditPart.xtend36
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeEditPart.xtend388
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeLabelEditPart.xtend29
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/TextAware.xtend1059
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/update/CanonicalUpdate.xtend228
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/AbstractParser.xtend44
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/ParserProvider.xtend106
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/preferences/StandardPage.xtend21
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/metamodel/MetaModel.xtend21
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/parsers/PredefinedParser.xtend70
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditHelperUtils_qvto.xtend31
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditPartsUtils_qvto.xtend40
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/PrefsConstant_qvto.xtend95
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/UtilsItemSemanticEditPolicy.xtend56
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/CodeStyle.xtend28
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/Common.xtend44
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenEditorGenerator_qvto.xtend32
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenModelUtils_qvto.xtend26
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/QualifiedClassNameProvider.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateLinkUtils.xtend67
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateNodeCommand.xtend147
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/ReorientLinkUtils.xtend27
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/BaseEditHelper.xtend27
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/EditHelper.xtend22
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/Common.xtend36
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/EditPartFactory.xtend61
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend554
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend101
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend47
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend235
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/OpenDiagram.xtend19
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/Utils_qvto.xtend41
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/childContainerCreateCommand.xtend57
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/linkCommands.xtend129
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/preferences/extensions.xtend56
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/DiagramUpdater.xtend436
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/LinkDescriptor.xtend27
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/NodeDescriptor.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/extensions.xtend31
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/views/ViewStyles.xtend36
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ActionBarContributor.xtend20
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/CreationWizard.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramContentInitializer.xtend24
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorContextMenuProvider.xtend57
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorUtil.xtend33
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DocumentProvider.xtend59
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/Editor.xtend877
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/InitDiagramFileAction.xtend18
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ModelElementSelectionPage.xtend24
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/NewDiagramFileWizard.xtend37
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetInfo.xtend31
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetModificationListener.xtend24
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ValidateAction.xtend88
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/VisualIDRegistry.xtend198
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/extensions.xtend148
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteConfiguration.xtend116
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteFactory.xtend127
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/Utils_qvto.xtend204
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/expressions/AbstractExpression.xtend51
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/AbstractNavigatorItem.xtend29
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorContentProvider.xtend24
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorItem.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorContentProvider.xtend343
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorGroup.xtend26
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorItem.xtend31
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLabelProvider.xtend27
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLinkHelper.xtend20
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorSorter.xtend19
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/ActivatorImpl.xtend150
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/manifest.xtend40
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/plugin.xtend300
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend19
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/PropertySection.xtend23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/EditPartProvider.xtend24
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers.xtend119
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers_qvto.xtend42
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementTypes.xtend95
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/IconProvider.xtend29
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/MarkerNavigationProvider.xtend30
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ParserUtils_qvto.xtend37
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationDecoratorProvider.xtend347
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationProvider.xtend58
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ViewProvider.xtend788
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/VisualTypeProvider.xtend97
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/extensions.xtend104
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.ecore5
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.genmodel1
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GMFGenPackage.java22
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GenEditorGenerator.java28
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java10
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GenEditorGeneratorImpl.java57
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java13
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java52
114 files changed, 6759 insertions, 3847 deletions
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/plugin.properties b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/plugin.properties
index b1cc336551b..9f147ad7e41 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/plugin.properties
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/plugin.properties
@@ -1368,3 +1368,4 @@ _UI_GenFloatingLabel_visibleByDefault_feature = Visible By Default
_UI_RefreshHook_refreshCondition_feature = Refresh Condition
_UI_RefreshHook_refreshAction_feature = Refresh Action
_UI_GenNode_refreshHook_feature = Refresh Hook
+_UI_GenEditorGenerator_jdkComplianceLevel_feature = Jdk Compliance Level
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/src/org/eclipse/papyrus/gmf/codegen/gmfgen/provider/GenEditorGeneratorItemProvider.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/src/org/eclipse/papyrus/gmf/codegen/gmfgen/provider/GenEditorGeneratorItemProvider.java
index 2c518c2dffb..db529b89a5e 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/src/org/eclipse/papyrus/gmf/codegen/gmfgen/provider/GenEditorGeneratorItemProvider.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.edit/src/org/eclipse/papyrus/gmf/codegen/gmfgen/provider/GenEditorGeneratorItemProvider.java
@@ -88,6 +88,7 @@ public class GenEditorGeneratorItemProvider
addTemplateDirectoryPropertyDescriptor(object);
addCopyrightTextPropertyDescriptor(object);
addPluginDirectoryPropertyDescriptor(object);
+ addJdkComplianceLevelPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
@@ -313,6 +314,28 @@ public class GenEditorGeneratorItemProvider
}
/**
+ * This adds a property descriptor for the Jdk Compliance Level feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addJdkComplianceLevelPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_GenEditorGenerator_jdkComplianceLevel_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_GenEditorGenerator_jdkComplianceLevel_feature", "_UI_GenEditorGenerator_type"),
+ GMFGenPackage.eINSTANCE.getGenEditorGenerator_JdkComplianceLevel(),
+ true,
+ false,
+ false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
+ null,
+ null));
+ }
+
+ /**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
@@ -411,6 +434,7 @@ public class GenEditorGeneratorItemProvider
case GMFGenPackage.GEN_EDITOR_GENERATOR__TEMPLATE_DIRECTORY:
case GMFGenPackage.GEN_EDITOR_GENERATOR__COPYRIGHT_TEXT:
case GMFGenPackage.GEN_EDITOR_GENERATOR__PLUGIN_DIRECTORY:
+ case GMFGenPackage.GEN_EDITOR_GENERATOR__JDK_COMPLIANCE_LEVEL:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case GMFGenPackage.GEN_EDITOR_GENERATOR__AUDITS:
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/META-INF/MANIFEST.MF b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/META-INF/MANIFEST.MF
index 5336cd878cd..dfdc647d3f3 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/META-INF/MANIFEST.MF
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/META-INF/MANIFEST.MF
@@ -19,7 +19,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ocl.ecore,
com.google.guava,
org.eclipse.xtext.xbase.lib,
- org.eclipse.gmf.runtime.notation
+ org.eclipse.gmf.runtime.notation,
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0.0)",
+ org.eclipse.papyrus.infra.types;bundle-version="[5.0.0,6.0.0)",
+ org.eclipse.papyrus.infra.types.core;bundle-version="[5.0.0,6.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Vendor: %providerName
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/PapyrusGMFExtensionMigrator.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/PapyrusGMFExtensionMigrator.java
index 89c596c776d..b5009eb9ce2 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/PapyrusGMFExtensionMigrator.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/PapyrusGMFExtensionMigrator.java
@@ -61,9 +61,9 @@ public class PapyrusGMFExtensionMigrator extends GenExtensionSwitch<Boolean> {
/**
- *
+ *
* Migrates {@link AdditionalEditPartCandies} to {@link GenDiagram}.
- *
+ *
* @param object
* @return
*/
@@ -79,7 +79,7 @@ public class PapyrusGMFExtensionMigrator extends GenExtensionSwitch<Boolean> {
/**
- *
+ *
* Migrates {@link CustomDiagramUpdaterSingleton} to {@link GenDiagramUpdater}.
* Resolve first from whole resource.
*
@@ -233,7 +233,7 @@ public class PapyrusGMFExtensionMigrator extends GenExtensionSwitch<Boolean> {
extendedView.getGenView().forEach(node -> {
if (node instanceof GenNode) {
GenNode extenedNode = (GenNode) node;
-
+
RefreshHook refreshHook = GMFGenFactory.eINSTANCE.createRefreshHook();
// @deprecated
// extenedNode.setRefreshComment(refreshHook.getComment());
@@ -269,7 +269,11 @@ public class PapyrusGMFExtensionMigrator extends GenExtensionSwitch<Boolean> {
@Override
public Boolean caseSpecificLocator(SpecificLocator object) {
object.getGenChildSideAffixedNode().forEach(node -> {
- node.setLocatorClassName(object.getClasspath());
+ if (node.getLocatorClassName() == null) {
+ // keep only the first locator found
+ // multiplicity change
+ node.setLocatorClassName(object.getClasspath());
+ }
});
return true; // delete
}
@@ -283,12 +287,16 @@ public class PapyrusGMFExtensionMigrator extends GenExtensionSwitch<Boolean> {
@Override
public Boolean caseSpecificLocatorExternalLabel(SpecificLocatorExternalLabel object) {
object.getGenExternalNodeLabel().forEach(node -> {
- node.setLocatorClassName(object.getClasspath());
+ if (node.getLocatorClassName() == null) {
+ // keep only the first locator found
+ // multiplicity change
+ node.setLocatorClassName(object.getClasspath());
+ }
});
return true; // delete
}
-
+
/**
* Migrates {@link VisualIDOverride} to {@link GenCommonBase}.
*
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ChildNodeLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ChildNodeLabelEditPart.xtend
index 371129f01b6..eebd6a07fbd 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ChildNodeLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ChildNodeLabelEditPart.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
@@ -20,16 +21,11 @@ import com.google.inject.Inject
import impl.diagram.editparts.TextAware
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildLabelNode
import xpt.Common
-import xpt.Common_qvto
-import xpt.diagram.editparts.Utils_qvto
@com.google.inject.Singleton class ChildNodeLabelEditPart {
@Inject extension Common;
- @Inject extension Common_qvto;
- @Inject extension Utils_qvto;
@Inject impl.diagram.editparts.ChildNodeLabelEditPart xptChildNodeLabelEditPart;
- @Inject impl.diagram.editparts.NodeEditPart xptNodeEditPart;
@Inject xpt.diagram.editparts.Common xptEditpartsCommon;
@Inject TextAware xptTextAware;
@@ -66,9 +62,18 @@ public class «xptChildNodeLabelEditPart.className(it)» «extendsList(it)» «i
}
'''
- def extendsList(GenChildLabelNode it) '''extends org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart'''
+ def extendsList(GenChildLabelNode it) '''
+«««BEGIN: PapyrusGenCode
+«««Add own extension
+«IF superEditPart !== null»
+ extends «superEditPart»
+«««END: PapyrusGenCode
+«ELSE»
+ extends org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart
+«ENDIF»
+'''
- def implementsList(GenChildLabelNode it) '''implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart'''
+ def implementsList(GenChildLabelNode it) '''implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart, org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart, org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit'''
def attributes(GenChildLabelNode it) '''
«xptEditpartsCommon.visualIDConstant(it)»
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/CompartmentEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/CompartmentEditPart.xtend
index b37fea4aeab..3730e48bcd5 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/CompartmentEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/CompartmentEditPart.xtend
@@ -1,27 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCompartment
import xpt.Common
import xpt.diagram.editparts.Utils_qvto
-@com.google.inject.Singleton class CompartmentEditPart {
+@Singleton class CompartmentEditPart {
@Inject extension Common;
@Inject extension Utils_qvto;
@@ -66,7 +67,15 @@ public class «xptCompartmentEditPartImpl.className(it)» «extendsList(it)» «
'''
def extendsList(GenCompartment it) '''
- extends «IF listLayout»org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart«ENDIF»
+
+«««BEGIN: PapyrusGenCode
+«««Add own extension
+«IF superEditPart!== null»
+ extends «superEditPart»
+«««END: BEGIN: PapyrusGenCode
+«ELSE»
+ extends «IF listLayout»org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart«ELSE»org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.linklf.LinkLFShapeCompartmentEditPart«ENDIF»
+«ENDIF»
'''
def implementsList(GenCompartment it) ''''''
@@ -91,6 +100,47 @@ public class «xptCompartmentEditPartImpl.className(it)» «extendsList(it)» «
«ENDIF»
'''
- def additions(GenCompartment it) ''''''
+ def additions(GenCompartment it) '''
+ «handleSize(it)»
+ «refreshbound(it)»
+ «refreshvisual(it)»
+ '''
+
+ def handleSize(GenCompartment it) '''
+ «generatedMemberComment»
+protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification 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();
+ }
+ super.handleNotificationEvent(notification);
+ }
+'''
+
+ def refreshbound(GenCompartment it) '''
+ «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));
+ }
+ '''
+ def refreshvisual(GenCompartment it) '''
+ «generatedMemberComment»
+protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBounds();
+ }
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/DiagramEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/DiagramEditPart.xtend
index b2c74d39ab4..846a79b6ad9 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/DiagramEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/DiagramEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation and others, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
@@ -21,8 +21,8 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExternalNodeLabel
import xpt.Common
import xpt.Common_qvto
-
@com.google.inject.Singleton class DiagramEditPart {
+
@Inject extension Common;
@Inject extension Common_qvto;
@@ -61,7 +61,7 @@ public class «xptDiagramEditPart.className(it)» «extendsList(it)» «implemen
}
'''
- def extendsList(GenDiagram it) '''extends org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart'''
+ def extendsList(GenDiagram it) '''extends «xptDiagramEditPart.extendsListContents(it)»'''
def implementsList(GenDiagram it) ''''''
@@ -80,4 +80,5 @@ public class «xptDiagramEditPart.className(it)» «extendsList(it)» «implemen
'''
def additions(GenDiagram it) ''''''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ExternalNodeLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ExternalNodeLabelEditPart.xtend
index d8f8486df2b..7247b3b3b9b 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ExternalNodeLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/ExternalNodeLabelEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
@@ -61,9 +61,25 @@ public class «xptExternalNodeLabelEditPart.className(it)» «extendsList(it)»
}
'''
- def extendsList(GenExternalNodeLabel it) '''extends org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart'''
+ def extendsList(GenExternalNodeLabel it) '''
+ «««BEGIN: PapyrusGenCode
+ «««specify a java super class for external nodes
+ «IF superEditPart !== null»
+ extends «superEditPart»
+ «««END: PapyrusGenCode
+ «ELSE»
+ extends org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart
+ «ENDIF»
+ '''
- def implementsList(GenExternalNodeLabel it) '''implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart, org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart'''
+ def implementsList(GenExternalNodeLabel it) '''
+ implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart, org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart
+ ««« BEGIN: PapyrusGenCode
+ «IF labelVisibilityPreference !== null»
+ , org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider
+ «ENDIF»
+ ««« END: PapyrusGenCode
+ '''
def attributes(GenExternalNodeLabel it) '''
«xptEditpartsCommon.visualIDConstant(it)»
@@ -85,5 +101,33 @@ public class «xptExternalNodeLabelEditPart.className(it)» «extendsList(it)»
}
'''
- def additions(GenExternalNodeLabel it) ''''''
+ def additions(GenExternalNodeLabel it) '''
+ ««« BEGIN: PapyrusGenCode
+ «IF labelVisibilityPreference !== null»
+ «generatedClassComment»
+ public String getLabelRole(){
+ return "«labelVisibilityPreference.role»";//$NON-NLS-1$
+ }
+
+ «generatedClassComment»
+ public String getIconPathRole(){
+ return "«labelVisibilityPreference.iconPathRole»";//$NON-NLS-1$
+ }
+ «ENDIF»
+ ««« END: PapyrusGenCode
+ '''
+
+ def refreshBounds(GenExternalNodeLabel it) '''
+ ««« BEGIN: PapyrusGenCode
+ 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));
+ getBorderItemLocator().relocate(getFigure());
+ }
+ ««« END: PapyrusGenCode
+ '''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkEditPart.xtend
index 08a7f0ce2d6..56a8f213e46 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
@@ -57,7 +57,7 @@ import xpt.Common
}
'''
- def extendsList(GenLink it) '''extends org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart'''
+ def extendsList(GenLink it) '''extends «xptLinkEditPart.extendsListContents(it)»'''
def implementsList(GenLink it) '''
«IF treeBranch»implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart«ENDIF»
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkLabelEditPart.xtend
index e5c1b869039..9f43034db21 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/LinkLabelEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
@@ -20,6 +20,7 @@ import com.google.inject.Inject
import impl.diagram.editparts.TextAware
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLinkLabel
import xpt.Common
+import org.eclipse.papyrus.gmf.codegen.gmfgen.CustomBehaviour
@com.google.inject.Singleton class LinkLabelEditPart {
@Inject extension Common;
@@ -59,9 +60,16 @@ import xpt.Common
}
'''
- def extendsList(GenLinkLabel it) '''extends org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart'''
+ def extendsList(GenLinkLabel it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart'''
- def implementsList(GenLinkLabel it) '''implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart'''
+ def implementsList(GenLinkLabel it) '''
+ implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart, org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit
+ ««« BEGIN: PapyrusGenCode
+ «IF labelVisibilityPreference !== null»
+ , org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider
+ «ENDIF»
+ ««« END: PapyrusGenCode
+ '''
def attributes(GenLinkLabel it) '''
«xptEditpartsCommon.visualIDConstant(it)»
@@ -70,10 +78,22 @@ import xpt.Common
'''
def createDefaultEditPolicies(GenLinkLabel it) '''
- «generatedMemberComment»
- protected void createDefaultEditPolicies() {
- «xptLinkLabelEditPart.createDefaultEditPoliciesBody(it)»
- }
+ /**
+ * @generated Papyrus Generation
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ 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 «diagram.getTextSelectionEditPolicyQualifiedClassName()»());
+ ««« BEGIN: PapyrusGenCode
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy());
+ ««« END: PapyrusGenCode
+ ««« Get the added custom behavoir
+ «FOR CustomBehaviour:it.behaviour.filter(typeof (CustomBehaviour))»
+ installEditPolicy(«CustomBehaviour.key», new «CustomBehaviour.editPolicyQualifiedClassName»());
+ «ENDFOR»
+ }
'''
def handleNotificationEvent(GenLinkLabel it) '''
@@ -83,5 +103,19 @@ import xpt.Common
}
'''
- def additions(GenLinkLabel it) ''''''
+ def additions(GenLinkLabel it) '''
+ ««« BEGIN: PapyrusGenCode
+ «IF labelVisibilityPreference !== null»
+ «generatedClassComment»
+ public String getLabelRole(){
+ return "«labelVisibilityPreference.role»";//$NON-NLS-1$
+ }
+
+ «generatedClassComment»
+ public String getIconPathRole(){
+ return "«labelVisibilityPreference.iconPathRole»";//$NON-NLS-1$
+ }
+ «ENDIF»
+ ««« END: PapyrusGenCode
+ '''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeEditPart.xtend
index cf65bb897f3..7a59f63cba5 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
- *
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
@@ -22,6 +22,9 @@ import xpt.diagram.editparts.Utils_qvto
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenTopLevelNode
+//DOCUMENTATION: PapyrusGenCode
+//add call template in order to generate handlenotification in order to refresh figure by taking account event
+
@com.google.inject.Singleton class NodeEditPart {
@Inject extension Common;
@Inject extension Utils_qvto;
@@ -48,6 +51,11 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenTopLevelNode
«xptNodeEditPartImpl.createLayoutEditPolicy(it)»
+««« BEGIN: PapyrusGenCode
+««« call template to paste code for refresh figure by taking account event
+ «xptNodeEditPartImpl.specificHandleNotificationEvent(it)»
+««« END: PapyrusGenCode
+
«xptNodeEditPartImpl.createNodeShape(it.viewmap, it)»
«IF hasFixedChildren(it)»
@@ -76,7 +84,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenTopLevelNode
«xptNodeEditPartImpl.setForegroundColor(it)»
- «xptNodeEditPartImpl.setBackgroundColor(it)»
+««« «xptNodeEditPartImpl.setBackgroundColor(it)»
«xptNodeEditPartImpl.setLineWidth(it)»
@@ -130,6 +138,5 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenTopLevelNode
«ENDIF»
'''
- def additions(GenNode it) ''''''
-
+ def additions(GenNode it) ''''''
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeLabelEditPart.xtend
index 52c3a2b53f5..b3f678792cd 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/diagram/editparts/NodeLabelEditPart.xtend
@@ -1,18 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package diagram.editparts
@@ -62,9 +61,9 @@ import xpt.diagram.editparts.Utils_qvto
}
'''
- def extendsList(GenNodeLabel it) '''extends org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart'''
+ def extendsList(GenNodeLabel it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart'''
- def implementsList(GenNodeLabel it) '''implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart'''
+ def implementsList(GenNodeLabel it) '''implements org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart, org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit'''
def attributes(GenNodeLabel it) '''
«xptEditpartsCommon.visualIDConstant(it)»
@@ -82,9 +81,45 @@ import xpt.diagram.editparts.Utils_qvto
def handleNotificationEvent(GenNodeLabel it) '''
«generatedMemberComment»
protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
+ refreshLabel();
«xptNodeLabelEditPart.handleNotificationEventBody(it)»
}
'''
- def additions(GenNodeLabel it) ''''''
+
+ def additions(GenNodeLabel it) '''
+ ««« Code to refresh icon
+
+ «generatedMemberComment»
+ private static final String ADD_PARENT_MODEL = "AddParentModel";
+
+
+ «generatedMemberComment»
+ public void activate() {
+ super.activate();
+ addOwnerElementListeners();
+ }
+
+ «generatedMemberComment»
+ protected void addOwnerElementListeners() {
+ addListenerFilter(ADD_PARENT_MODEL, this, ((org.eclipse.gmf.runtime.notation.View) getParent().getModel()));
+
+ }
+
+ «generatedMemberComment»
+ public void deactivate() {
+ removeOwnerElementListeners();
+ super.deactivate();
+
+ }
+
+
+ «generatedMemberComment»
+ protected void removeOwnerElementListeners() {
+ removeListenerFilter(ADD_PARENT_MODEL);
+
+ }
+
+ «««END: PapyrusGenCode
+ '''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/actions/LoadResourceAction.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/actions/LoadResourceAction.xtend
index 1aaa0a460a7..2daedbbb421 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/actions/LoadResourceAction.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/actions/LoadResourceAction.xtend
@@ -1,16 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2013 Montages AG
- *
+/*****************************************************************************
+ * Copyright (c) 2013, 2027, 2021 Montages AG, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.actions
@@ -44,7 +45,7 @@ import xpt.Common_qvto
'''
def extendsList(org.eclipse.papyrus.gmf.codegen.gmfgen.LoadResourceAction it) //
- ''' extends org.eclipse.gmf.tooling.runtime.actions.DefaultLoadResourceAction'''
+ ''' extends org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.actions.DefaultLoadResourceAction'''
def implementsList(org.eclipse.papyrus.gmf.codegen.gmfgen.LoadResourceAction it) //
''''''
@@ -56,6 +57,6 @@ import xpt.Common_qvto
}
'''
- def additions(org.eclipse.papyrus.gmf.codegen.gmfgen.LoadResourceAction it) ''''''
+ def additions(org.eclipse.papyrus.gmf.codegen.gmfgen.LoadResourceAction it) ''''''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChildNodeLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChildNodeLabelEditPart.xtend
index 6c4852e0a56..15a2f70760b 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChildNodeLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChildNodeLabelEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013 , 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
@@ -20,7 +20,8 @@ import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildLabelNode
import xpt.Common
import xpt.QualifiedClassNameProvider
-import xpt.diagram.editpolicies.TextNonResizableEditPolicy import xpt.CodeStyle
+import xpt.diagram.editpolicies.TextNonResizableEditPolicy
+import xpt.CodeStyle
/**
* Revisit: [MG]: @Inject extension same-named-api-class -> template extends api-class?
@@ -29,7 +30,7 @@ import xpt.diagram.editpolicies.TextNonResizableEditPolicy import xpt.CodeStyle
@Inject extension Common;
@Inject extension QualifiedClassNameProvider
@Inject extension CodeStyle
-
+ @Inject extension xpt.diagram.editparts.Common;
@Inject xpt.diagram.editparts.Common xptEditpartsCommon;
@Inject TextNonResizableEditPolicy xptTextNonResizable;
@@ -64,9 +65,17 @@ import xpt.diagram.editpolicies.TextNonResizableEditPolicy import xpt.CodeStyle
def additionalEditPolicies(GenChildLabelNode it) ''''''
def handleNotificationEventBody(GenChildLabelNode it) '''
- Object feature = event.getFeature();
- «xptEditpartsCommon.handleText(it)»
- super.handleNotificationEvent(event);
+ Object feature = event.getFeature();
+ «handleText(it)»
+ «IF labelElementIcon»
+ if(event.getNewValue() instanceof org.eclipse.emf.ecore.EAnnotation && org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((org.eclipse.emf.ecore.EAnnotation)event.getNewValue()).getSource())){
+ refreshLabel();
+ }
+ «ENDIF»
+ if (org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) {
+ refreshUnderline();
+ }
+ super.handleNotificationEvent(event);
'''
def isSelectable(GenChildLabelNode it) '''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChoiceUtils_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChoiceUtils_qvto.xtend
index 767fab108ad..1097b7610b2 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChoiceUtils_qvto.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ChoiceUtils_qvto.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2011 - 2013 Montages AG
+/*****************************************************************************
+ * Copyright (c) 2011 - 2013, 2021 Montages AG, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Svyatoslav Kovalsky (Montages) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Svyatoslav Kovalsky (Montages) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
@@ -46,7 +46,11 @@ import xpt.Common_qvto
def boolean isChoiceLabel(LabelModelFacet modelFacet) {
var parser = modelFacet.parser;
- return parser.oclIsKindOf(typeof(PredefinedEnumParser)) || parser.oclIsKindOf(typeof(OclChoiceParser));
+ if (parser != null) {
+ return parser.oclIsKindOf(typeof(PredefinedEnumParser)) || parser.oclIsKindOf(typeof(OclChoiceParser));
+ } else {
+ return false;
+ }
}
def String getDirectManagerFQN(LabelModelFacet modelFacet) {
@@ -64,5 +68,4 @@ import xpt.Common_qvto
default: null
}
}
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/CompartmentEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/CompartmentEditPart.xtend
index 7f541f1b2da..71501719b81 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/CompartmentEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/CompartmentEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2021 Borland Software Corporation, CEA LIST, ARTAL and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
@@ -25,7 +25,8 @@ import xpt.Common
import xpt.Common_qvto
import xpt.Externalizer
import xpt.diagram.editparts.Utils_qvto
-import xpt.providers.ElementTypes import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLink
+import xpt.providers.ElementTypes
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLink
@com.google.inject.Singleton class CompartmentEditPart {
@Inject extension Common;
@Inject extension Common_qvto;
@@ -63,16 +64,31 @@ import xpt.providers.ElementTypes import org.eclipse.papyrus.gmf.codegen.gmfgen.
}
'''
- def createFigure(GenCompartment it) '''
- «IF !needsTitle»
- «/*By default titles are shown even if there are no TitleStyle, we need to switch it off*/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»
- '''
+ def createFigure(GenCompartment it) {
+ if (hasExternalSuperClass(it,
+ 'org.eclipse.papyrus.uml.diagram.activity.edit.part.ShapeCompartmentWithoutScrollbarsEditPart')) {
+ '''
+ @Override
+ public org.eclipse.draw2d.IFigure createFigure() {
+ return super.createFigure();
+ }
+ '''
+ } else {
+
+ '''
+ «IF !needsTitle»
+ «/*By default titles are shown even if there are no TitleStyle, we need to switch it off*/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»
+ '''
+ }
+ }
+
+
def createDefaultEditPoliciesBody(GenCompartment it) '''
super.createDefaultEditPolicies();
@@ -80,13 +96,13 @@ import xpt.providers.ElementTypes import org.eclipse.papyrus.gmf.codegen.gmfgen.
installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableCompartmentEditPolicy());
«ENDIF»
«xptEditpartsCommon.installSemanticEditPolicy(it)»
- «IF childNodes.notEmpty»
- «xptEditpartsCommon.installCreationEditPolicy(it)»
+ «IF ! childNodes.empty»
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy());
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
+ installEditPolicy(org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy.PASTE_ROLE, new org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy());
«ENDIF»
«xptEditpartsCommon.installCanonicalEditPolicy(it)»
«xptEditpartsCommon.behaviour(it)»
- «additionalEditPolicies(it)»
'''
def additionalEditPolicies(GenCompartment it) ''''''
@@ -142,32 +158,7 @@ import xpt.providers.ElementTypes import org.eclipse.papyrus.gmf.codegen.gmfgen.
def getTargetEditPartMethod(GenCompartment it) '''
«generatedMemberComment»
public org.eclipse.gef.EditPart getTargetEditPart(org.eclipse.gef.Request request) {
- «IF childNodes.notEmpty»
- 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);
- «FOR childNode : it.childNodes»
- if (type == «xptElementTypes.accessElementType(childNode)») {
- return this;
- }
- «ENDFOR»
- return getParent().getTargetEditPart(request);
- }
- if (request instanceof org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest) {
- «IF haveOneOfChildNodesIncomimgLinks(it)»
- if (org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_CONNECTION_END.equals(request.getType())) {
- for (Object type : ((org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest) request).getElementTypes()) {
- if (type instanceof org.eclipse.gmf.runtime.emf.type.core.IElementType) {
- org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = (org.eclipse.gmf.runtime.emf.type.core.IElementType) type;
- if («FOR GenLink link : collectIncomingLinks(it) SEPARATOR " || "»elementType.equals(«xptElementTypes.accessElementType(link)»)«ENDFOR»)
- return super.getTargetEditPart(request);
- }
- }
- }
- «ENDIF»
- return getParent().getTargetEditPart(request);
- }
- «ENDIF»
+
return super.getTargetEditPart(request);
}
'''
@@ -194,6 +185,8 @@ import xpt.providers.ElementTypes import org.eclipse.papyrus.gmf.codegen.gmfgen.
@Localization def String i18nKeyForCompartmentTitle(GenCompartment compartment) {
return className(compartment) + '.title'
}
-
+ def boolean hasExternalSuperClass(GenCompartment it, String className) {
+ superEditPart == className
+ }
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/DiagramEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/DiagramEditPart.xtend
index 8f8a537eb0e..5599f1b8a36 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/DiagramEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/DiagramEditPart.xtend
@@ -1,35 +1,38 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
import com.google.inject.Inject
+import com.google.inject.Singleton
+import metamodel.MetaModel
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
import org.eclipse.papyrus.gmf.codegen.gmfgen.ViewmapLayoutType
import xpt.Common
-import xpt.diagram.editparts.Utils_qvto
import xpt.diagram.commands.CreateShortcutDecorationsCommand
+import xpt.diagram.editparts.Utils_qvto
/**
* Revisit: [MG]: @Inject extension same-named-api-class -> template extends api-class?
*/
-@com.google.inject.Singleton class DiagramEditPart {
+@Singleton class DiagramEditPart {
@Inject extension Common;
@Inject extension Utils_qvto;
-
+ @Inject extension MetaModel;
@Inject xpt.diagram.editparts.Common xptEditpartsCommon;
@Inject CreateShortcutDecorationsCommand createShoutrtcutDecorationCommand;
@@ -45,20 +48,56 @@ import xpt.diagram.commands.CreateShortcutDecorationsCommand
'''
def createDefaultEditPoliciesBody(GenDiagram it) '''
- super.createDefaultEditPolicies();
- «xptEditpartsCommon.installSemanticEditPolicy(it)»
- «xptEditpartsCommon.installCanonicalEditPolicy(it)»
- «xptEditpartsCommon.installCreationEditPolicy(it)»
- «IF generateCreateShortcutAction() && null == editorGen.application»
- «dragDropEditPolicy(it)»
- «ENDIF»
- «IF shouldGenerateDiagramViewmap(it)»
- «layotEditPolicy(it)»
- «ENDIF»
- «xptEditpartsCommon.behaviour(it)»
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
- «additionalEditPolicies(it)»
- '''
+ super.createDefaultEditPolicies();
+
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy());
+ installEditPolicy(org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy.PASTE_ROLE, new org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy());
+
+ «xptEditpartsCommon.installSemanticEditPolicy(it)»
+ «xptEditpartsCommon.installCanonicalEditPolicy(it)»
+ ««« «xptEditpartsCommon.installCreationEditPolicy(it)»
+ «IF generateCreateShortcutAction() && 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<org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor> viewDescriptors = new java.util.ArrayList<org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor>();
+ 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<org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor> 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 «createShoutrtcutDecorationCommand.qualifiedClassName(it)»(getEditingDomain(), (org.eclipse.gmf.runtime.notation.View) getModel(), viewDescriptors)));
+ }
+ return null;
+ }
+ });
+ «ENDIF»
+ «IF shouldGenerateDiagramViewmap(it)»
+ // diagram figure does layout; need to install child editpolicy to show selection feedback
+ installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.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»
+ «xptEditpartsCommon.behaviour(it)»
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
+'''
def dragDropEditPolicy(GenDiagram it) '''
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy() {
@@ -128,4 +167,18 @@ import xpt.diagram.commands.CreateShortcutDecorationsCommand
org.eclipse.draw2d.LayoutManager «varName» = null; /*FIXME - unknown layout type*/
«ENDIF»
'''
+
+
+//BEGIN: PapyrusGenCode
+//computes super type of the link edit part in case the edit part manages a representation of a UML element
+def extendsListContents(GenDiagram it)'''
+org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusDiagramEditPart
+'''
+//END: BEGIN: PapyrusGenCode
+
+def featureForMetaclass (GenNode it)'''
+ if (« MetaClass(modelFacet.metaClass)».equals(class1)) {
+ return «MetaFeature(modelFacet.containmentMetaFeature)»;
+ }
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ExternalNodeLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ExternalNodeLabelEditPart.xtend
index f5c035ca28b..371ee17aa57 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ExternalNodeLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/ExternalNodeLabelEditPart.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
+/*****************************************************************************
+ * Copyright (c) 2006, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
@@ -55,7 +55,10 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
«additionalEditPolicies(it)»
'''
- def additionalEditPolicies(GenExternalNodeLabel it) ''''''
+ def additionalEditPolicies(GenExternalNodeLabel it)
+ '''
+ installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy());
+ '''
def getBorderItemLocator(GenExternalNodeLabel it) '''
«generatedMemberComment»
@@ -88,5 +91,5 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
def createFigure(GenExternalNodeLabel it) '''
«xptEditpartsCommon.labelFigure(viewmap)»
- '''
-}
+ '''
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend
index 3316d6a023b..27b8ce26626 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkEditPart.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Remi Schnekenburger (CEA LIST) - modification for Papyrus MDT
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
@@ -27,7 +28,8 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.ParentAssignedViewmap
import org.eclipse.papyrus.gmf.codegen.gmfgen.SnippetViewmap
import org.eclipse.papyrus.gmf.codegen.gmfgen.Viewmap
import xpt.Common
-import xpt.Common_qvto import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
+import xpt.Common_qvto
+import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
/**
* Revisit: [MG]: @Inject extension same-named-api-class -> template extends api-class?
@@ -71,16 +73,16 @@ import xpt.Common_qvto import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
* FIXME: [MG] check counterpart for ModeledViewmap,
*/
def addFixedChild(GenLink it) '''
- «IF it.hasFixedLabels»
+ «IF labels.size > 0»
«generatedMemberComment»
protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) {
«FOR label : labels»
- «addLabel(label.viewmap, label)»
+ «addLabel(label.viewmap,label)»
«ENDFOR»
return false;
}
«ENDIF»
- '''
+'''
// Note, condition in addFixedChild template above should be changed if addLabel support added for Viewmaps other than ParentAssignedViewmap
def dispatch addLabel(Viewmap it, GenLinkLabel label) ''''''
@@ -104,7 +106,7 @@ import xpt.Common_qvto import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
'''
def removeFixedChild(GenLink it) '''
- «IF it.hasFixedLabels»
+ «IF ! labels.empty»
«generatedMemberComment»
protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) {
«FOR label : labels»
@@ -133,19 +135,19 @@ import xpt.Common_qvto import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
'''
def addChildVisual(GenLink it) '''
- «IF it.hasFixedLabels»
+ «IF ! labels.empty»
«generatedMemberComment»
protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) {
if (addFixedChild(childEditPart)) {
return;
}
- super.addChildVisual(childEditPart, index);
+ super.addChildVisual(childEditPart, -1);
}
«ENDIF»
'''
def removeChildVisual(GenLink it) '''
- «IF it.hasFixedLabels»
+ «IF ! labels.empty»
«generatedMemberComment»
protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) {
if (removeFixedChild(childEditPart)) {
@@ -168,19 +170,22 @@ import xpt.Common_qvto import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
def dispatch createLinkFigure(Viewmap it, GenLink link) '''«ERROR('Unknown viewmap: ' + it + ", for link: " + link)»'''
def dispatch createLinkFigure(ModeledViewmap it, GenLink link) '''
- protected org.eclipse.draw2d.Connection createConnectionFigure() {
- return new «modeledViewmapFigureFQN(it)»();
- }
-
- «generatedMemberComment»
- public «modeledViewmapFigureFQN(it)» getPrimaryShape() {
- return («modeledViewmapFigureFQN(it)») getFigure();
- }
-
- «xptModeledViewmapProducer.viewmapClassBody(it)»
+««« «generatedMemberComment»
+««« protected org.eclipse.draw2d.Connection createConnectionFigure() {
+««« return new «modeledViewmapFigureFQN(it)»();
+««« }
+«««
+««« «generatedMemberComment»
+««« public «modeledViewmapFigureFQN(it)» getPrimaryShape() {
+««« return («modeledViewmapFigureFQN(it)») getFigure();
+««« }
+«««
+««« «xptModeledViewmapProducer.viewmapClassBody(it)»
'''
- def modeledViewmapFigureFQN(ModeledViewmap it) '''«xptModeledViewmapProducer.viewmapFigureFQN(it)»'''
+ def modeledViewmapFigureFQN(ModeledViewmap it) '''
+««« «xptModeledViewmapProducer.viewmapFigureFQN(it)»
+ '''
def dispatch createLinkFigure(FigureViewmap it, GenLink link) {
var fqn = if(figureQualifiedClassName == null) 'org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx' else figureQualifiedClassName
@@ -222,4 +227,20 @@ import xpt.Common_qvto import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
def boolean hasFixedLabels(GenLink it){
labels.notEmpty && (labels.filter(l | l.viewmap.oclIsKindOf(typeof(ParentAssignedViewmap))).notEmpty || labels.filter(l | l.viewmap.oclIsKindOf(typeof(ModeledViewmap))).notEmpty)
}
+
+
+
+ /**
+ * computes super type of the link edit part in case the edit part manages a representation of a UML element
+ */
+ def extendsListContents(GenLink it)'''
+ «IF superEditPart !== null»
+ «superEditPart»
+ «ELSE»
+ org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart
+ «ENDIF»
+ '''
}
+
+
+
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkLabelEditPart.xtend
index 3cbf4e11eea..75444cef8c8 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/LinkLabelEditPart.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
@@ -28,7 +29,7 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
@Inject extension Common;
@Inject extension ViewmapAttributesUtils_qvto;
- @Inject xpt.diagram.editparts.Common xptEditpartsCommon;
+ @Inject extension xpt.diagram.editparts.Common xptEditpartsCommon;
@Inject VisualIDRegistry xptVisualIDRegistry;
@Inject TextSelectionEditPolicy textSelection;
@@ -61,7 +62,9 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
'''
- def additionalEditPolicies(GenLinkLabel it) ''''''
+ def additionalEditPolicies(GenLinkLabel it) '''
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy());
+ '''
def getKeyPoint(GenLinkLabel it) '''
«generatedMemberComment»
@@ -72,7 +75,15 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
def handleNotificationEventBody(GenLinkLabel it) '''
Object feature = event.getFeature();
- «xptEditpartsCommon.handleText(it)»
+ «handleText (it)»
+
+ ««« START Papyrus Code
+ «IF elementIcon»
+ if(event.getNewValue() instanceof org.eclipse.emf.ecore.EAnnotation && org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((org.eclipse.emf.ecore.EAnnotation)event.getNewValue()).getSource())){
+ refreshLabel();
+ }
+ «ENDIF»
+ ««« End Papyrus Code
super.handleNotificationEvent(event);
'''
@@ -84,4 +95,5 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
def linkLabelDragPolicyQualifiedClassName(GenDiagram it) '''org.eclipse.gmf.tooling.runtime.edit.policies.DefaultLinkLabelDragPolicy'''
def linkLabelDragPolicyClass(GenDiagram it) '''«/*not generated by default anymore */»'''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeEditPart.xtend
index 828fee0ea8b..f8164434a3c 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeEditPart.xtend
@@ -1,58 +1,69 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2014, 2021 Borland Software Corporation, Christian W. Damus, CEA LIST, Artal and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Patrick Tessier (CEA) - initial API and implementation
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) - Bug 335987 [General][Enhancement] Show/Hide Connectors Labels and External Nodes Labels
+ * Christian W. Damus - bug 451230
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
import com.google.inject.Inject
-import xpt.Common
-import xpt.diagram.ViewmapAttributesUtils_qvto
-import xpt.Common_qvto
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildSideAffixedNode
-import org.eclipse.papyrus.gmf.codegen.gmfgen.ViewmapLayoutType
-import xpt.editor.VisualIDRegistry
-import org.eclipse.papyrus.gmf.codegen.gmfgen.Viewmap
-import org.eclipse.papyrus.gmf.codegen.gmfgen.ModeledViewmap
+import com.google.inject.Singleton
+import impl.diagram.editparts.viewmaps.modeledViewmapProducer
import org.eclipse.papyrus.gmf.codegen.gmfgen.FigureViewmap
-import org.eclipse.papyrus.gmf.codegen.gmfgen.SnippetViewmap
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildSideAffixedNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExternalNodeLabel
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorChildReference
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenTopLevelNode
import org.eclipse.papyrus.gmf.codegen.gmfgen.InnerClassViewmap
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ModeledViewmap
import org.eclipse.papyrus.gmf.codegen.gmfgen.ParentAssignedViewmap
-import org.eclipse.papyrus.gmf.gmfgraph.DiagramLabel
+import org.eclipse.papyrus.gmf.codegen.gmfgen.RefreshHook
+import org.eclipse.papyrus.gmf.codegen.gmfgen.SnippetViewmap
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolEntry
+import org.eclipse.papyrus.gmf.codegen.gmfgen.Viewmap
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ViewmapLayoutType
import org.eclipse.papyrus.gmf.gmfgraph.Compartment
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExternalNodeLabel
-import xpt.providers.ElementTypes
-import org.eclipse.papyrus.gmf.codegen.xtend.annotations.MetaDef
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenTopLevelNode
-import xpt.diagram.editpolicies.GraphicalNodeEditPolicy
-import xpt.diagram.editpolicies.TextSelectionEditPolicy
+import utils.EditPartsUtils_qvto
+import xpt.CodeStyle
+import xpt.Common
+import xpt.Common_qvto
+import xpt.diagram.ViewmapAttributesUtils_qvto
import xpt.diagram.editparts.EditPartFactory
+import xpt.diagram.editparts.Utils_qvto
+import xpt.diagram.editpolicies.TextSelectionEditPolicy
+import xpt.editor.VisualIDRegistry
+import xpt.providers.ElementTypes
-@com.google.inject.Singleton class NodeEditPart {
+@Singleton class NodeEditPart {
+ @Inject extension CodeStyle;
@Inject extension Common;
@Inject extension Common_qvto;
@Inject extension ViewmapAttributesUtils_qvto;
- @Inject extension xpt.diagram.editparts.Utils_qvto;
+ @Inject extension Utils_qvto;
@Inject extension xpt.diagram.Utils_qvto;
-
+ @Inject extension VisualIDRegistry
+ @Inject extension EditPartsUtils_qvto;
@Inject xpt.diagram.editparts.Common xptEditpartsCommon;
- @Inject impl.diagram.editparts.viewmaps.modeledViewmapProducer xptModeledViewmapProducer;
+ @Inject modeledViewmapProducer xptModeledViewmapProducer;
@Inject TextAware xptTextAware;
@Inject VisualIDRegistry xptVisualIDRegistry;
@Inject ElementTypes xptElementTypes;
- @Inject GraphicalNodeEditPolicy graphicalEditPolicy;
@Inject TextSelectionEditPolicy textSelection;
@Inject EditPartFactory xptEditPartFactory;
@@ -61,11 +72,25 @@ import xpt.diagram.editparts.EditPartFactory
def packageName(GenNode it) '''«getDiagram().editPartsPackageName»'''
def dispatch extendsListContents(GenNode it) '''
- «IF hasBorderItems(it)»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart«ENDIF»
- '''
+«««BEGIN: PapyrusGenCode
+«««Add own extension
+«IF superEditPart !== null»
+«superEditPart»
+«««END: BEGIN: PapyrusGenCode
+«ELSE»
+ org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart
+«ENDIF»
+'''
def dispatch extendsListContents(GenChildSideAffixedNode it) '''
- «IF hasBorderItems(it)»org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart«ENDIF»
+ «««BEGIN: PapyrusGenCode
+ «««Add own extension
+ «IF superEditPart !== null»
+ «superEditPart»
+ «««END: BEGIN: PapyrusGenCode
+ «ELSE»
+ «IF hasBorderItems(it)»org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart«ENDIF»
+ «ENDIF»
'''
def constructor(GenNode it) '''
@@ -95,10 +120,10 @@ import xpt.diagram.editparts.EditPartFactory
def additionalEditPolicies(GenNode it) ''''''
def installGraphicalNodeEditPolicy(GenNode it) '''
- «IF needsGraphicalNodeEditPolicy(it)»
- installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE, new «graphicalEditPolicy.qualifiedClassName(it)»());
- «ENDIF»
- '''
+
+ installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE, new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy());
+
+ '''
def installCreationRolePolicy(GenNode it) '''
«IF !childNodes.empty || hasChildrenInListCompartments(it)»
@@ -167,30 +192,36 @@ import xpt.diagram.editparts.EditPartFactory
def createLayoutEditPolicyBody_FLOW_LAYOUT(GenNode it) '''
org.eclipse.gmf.runtime.diagram.ui.editpolicies.FlowLayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.FlowLayoutEditPolicy() {
«IF hasBorderItems(it)»
- «extraLineBreak»
+ «extraLineBreak»
+ «overrideC»
protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
«borderItemSelectionEditPolicy()»
return super.createChildEditPolicy(child);
}
«ENDIF»
+ «overrideC»
protected org.eclipse.gef.commands.Command createAddCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
return null;
}
+ «overrideC»
protected org.eclipse.gef.commands.Command createMoveChildCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
return null;
}
+ «overrideC»
protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
return null;
}
};
return lep;
'''
+
def createLayoutEditPolicyBody_DEFAULT(GenNode it) '''
org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+ «overrideC»
protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
«borderItemSelectionEditPolicy(it)»
org.eclipse.gef.EditPolicy result = child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE);
@@ -200,10 +231,12 @@ import xpt.diagram.editparts.EditPartFactory
return result;
}
+ «overrideC»
protected org.eclipse.gef.commands.Command getMoveChildrenCommand(org.eclipse.gef.Request request) {
return null;
}
+ «overrideC»
protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
return null;
}
@@ -214,27 +247,34 @@ import xpt.diagram.editparts.EditPartFactory
def borderItemSelectionEditPolicy(GenNode it) '''
«IF hasBorderItems(it)»
org.eclipse.gmf.runtime.notation.View childView = (org.eclipse.gmf.runtime.notation.View) child.getModel();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(childView)) {
- «IF !getExternalLabels(it).empty»
- «FOR nextLabel : getExternalLabels(it)»
- «xptVisualIDRegistry.caseVisualID(nextLabel)»
- «ENDFOR»
- return «borderItemSelectionEP(it)»;
- «ENDIF»
- «IF !getSideAffixedChildren(it).empty»
- «FOR nextBorderItem : getSideAffixedChildren(it)»
- «xptVisualIDRegistry.caseVisualID(nextBorderItem)»
- «ENDFOR»
- return new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy();
- «ENDIF»
+ String vid = «getVisualIDMethodCall(getDiagram())»(childView);
+ if (vid != null) {
+ switch (vid) {
+ «IF getExternalLabels(it).size > 0»
+ «FOR nextLabel : getExternalLabels(it) »
+ «caseVisualID(nextLabel)»
+ «ENDFOR»
+ return «borderItemSelectionEP(it)»;
+ «ENDIF»
+ «IF getSideAffixedChildren(it).size > 0»
+ «FOR nextBorderItem : getSideAffixedChildren(it)»
+ «caseVisualID(nextBorderItem)»
+ «ENDFOR»
+ ««« BEGIN PapyrusGenCode
+ ««« The purprose is to add replace GMF edit prolicy by an new editPolicy that allows to resize BorderItem
+ return new org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy();
+ ««« END PapyrusGenCode
+ «ENDIF»
+ }
}
- «ENDIF»
- '''
+«ENDIF»
+'''
- def borderItemSelectionEP(GenNode it) '''
+ def borderItemSelectionEP(GenNode it)'''
new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy() {
- protected java.util.List createSelectionHandles() {
+ «overrideC»
+ 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);
@@ -314,47 +354,41 @@ import xpt.diagram.editparts.EditPartFactory
def addFixedChild(GenNode it) '''
«generatedMemberComment»
protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) {
- «FOR label : getInnerFixedLabels(it)»
- «var childViewmap = label.viewmap as ParentAssignedViewmap»
+«FOR label:getInnerFixedLabels(it)»«var childViewmap = label.viewmap as ParentAssignedViewmap»
if (childEditPart instanceof «xptEditPartFactory.getEditPartQualifiedClassName(label)») {
((«xptEditPartFactory.getEditPartQualifiedClassName(label)») childEditPart).«xptTextAware.labelSetterName(childViewmap)»(getPrimaryShape().«childViewmap.getterName»());
return true;
}
- «ENDFOR»
- «FOR label : getInnerFixedLabelsWithModeledViewmaps(it)»
- «var childViewmap = label.viewmap as ModeledViewmap»
- «var getterName = (childViewmap.figureModel as DiagramLabel).accessor.accessor»
- if (childEditPart instanceof «xptEditPartFactory.getEditPartQualifiedClassName(label)») {
- ((«xptEditPartFactory.getEditPartQualifiedClassName(label)») childEditPart).«xptTextAware.labelSetterName(childViewmap)»(getPrimaryShape().«getterName»());
- return true;
- }
- «ENDFOR»
- «FOR compartment : getPinnedCompartments(it)»
- «var childViewmap = compartment.viewmap as ParentAssignedViewmap»
- if (childEditPart instanceof «xptEditPartFactory.getEditPartQualifiedClassName(compartment)») {
+«ENDFOR»
+
+«FOR compartment : getPinnedCompartments(it)»«var childViewmap = compartment.viewmap as ParentAssignedViewmap»
+
+ 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(((«xptEditPartFactory.getEditPartQualifiedClassName(compartment)») childEditPart).getFigure());
+ pane.add(((«compartment.getEditPartQualifiedClassName()») childEditPart).getFigure());
return true;
}
- «ENDFOR»
- «FOR compartment : getPinnedCompartmentsWithModeledViewmaps(it)»
- «var childViewmap = compartment.viewmap as ModeledViewmap»
- «var getterName = (childViewmap.figureModel as Compartment).accessor.accessor»
- if (childEditPart instanceof «xptEditPartFactory.getEditPartQualifiedClassName(compartment)») {
- org.eclipse.draw2d.IFigure pane = getPrimaryShape().«getterName»();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((«xptEditPartFactory.getEditPartQualifiedClassName(compartment)») childEditPart).getFigure());
- return true;
- }
- «ENDFOR»
- «FOR child : getSideAffixedChildren(it)»
- if (childEditPart instanceof «xptEditPartFactory.getEditPartQualifiedClassName(child)») {
+«ENDFOR»
+
+«FOR child:getSideAffixedChildren(it)»
+ ««« BEGIN PapyrusGencode
+ ««« adding IF else end in order to take in account the case where a specific locator is added
+
+
+ «IF child.locatorClassName !== null»
+ «genSpecificLocator(child)»
+ «ELSE»
+ «««END PapyrusGencode«ENDREM
+ 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(((«xptEditPartFactory.getEditPartQualifiedClassName(child)») childEditPart).getFigure(), locator);
+ getBorderedFigure().getBorderItemContainer().add(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure(), locator);
return true;
}
- «ENDFOR»
+ ««« BEGIN PapyrusGencode
+ «ENDIF»
+ «««END PapyrusGencode
+«ENDFOR»
return false;
}
'''
@@ -446,36 +480,62 @@ import xpt.diagram.editparts.EditPartFactory
'''
def addBorderItem(GenNode it) '''
- «IF !getExternalLabels(it).empty»
+ «IF getExternalLabels(it).size > 0»
«generatedMemberComment»
protected void addBorderItem(org.eclipse.draw2d.IFigure borderItemContainer, org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart borderItemEditPart) {
- if («FOR label : getExternalLabels(it) SEPARATOR ' || '»borderItemEditPart instanceof «xptEditPartFactory.getEditPartQualifiedClassName(label)»«ENDFOR») {
+ «IF getExternalLabelsWithoutSpecificLocator(it).size > 0»
+ if («FOR label : getExternalLabelsWithoutSpecificLocator(it) SEPARATOR ' || '»borderItemEditPart instanceof «label.getEditPartQualifiedClassName()»«ENDFOR») {
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 {
+ } else
+ «ENDIF»
+ «FOR label : getExternalLabelsWithSpecificLocator(it)»
+ if (borderItemEditPart instanceof «label.getEditPartQualifiedClassName()») {
+ org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator locator = new «getSpecificLocator(label)»(getMainFigure());
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else
+ «ENDFOR»
+ {
super.addBorderItem(borderItemContainer, borderItemEditPart);
}
}
«ENDIF»
- '''
+'''
def createNodePlate(GenNode it) '''
«generatedMemberComment»
+ ««« @deprecated
+ ««« «IF nodePlateQualifiedName !== null»
+ ««« protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodePlate() {
+ ««« «nodePlateQualifiedName» result = new «nodePlateQualifiedName»(«IF getDiagram().isPixelMapMode()»«defaultSizeWidth(viewmap, 40)», «defaultSizeHeight(viewmap, 40)»«ELSE»getMapMode().DPtoLP(«defaultSizeWidth(viewmap, 40)»), getMapMode().DPtoLP(«defaultSizeHeight(viewmap, 40)»)«ENDIF»);
+ ««« «setupNodePlate»
+ ««« return result;
+ ««« }
+ ««« «««END: BEGIN: PapyrusGenCode
+ ««« «ELSE»
+ ««« «super.createNodePlate(it)»
+ «««
+ ««« By default node edit part are now RoundedRectangleNodePlateFigure
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(«IF getDiagram().isPixelMapMode()»«defaultSizeWidth(viewmap, 40)», «defaultSizeHeight(viewmap, 40)»«ELSE»getMapMode().DPtoLP(«defaultSizeWidth(viewmap, 40)»), getMapMode().DPtoLP(«defaultSizeHeight(viewmap, 40)»)«ENDIF»);
+ org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure result = new org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure(«IF getDiagram().isPixelMapMode()»«defaultSizeWidth(viewmap, 40)», «defaultSizeHeight(viewmap, 40)»«ELSE»getMapMode().DPtoLP(«defaultSizeWidth(viewmap, 40)»), getMapMode().DPtoLP(«defaultSizeHeight(viewmap, 40)»)«ENDIF»);
«setupNodePlate»
return result;
}
+ ««« «ENDIF»
'''
- def dispatch setupNodePlate(GenNode it) ''''''
- def dispatch setupNodePlate(GenChildSideAffixedNode it) '''
- «extraLineBreak»
- //FIXME: workaround for #154536
- result.getBounds().setSize(result.getPreferredSize());
- '''
+
+def setupNodePlate (GenNode it) ''''''
+
+//FIXME EAL dead code no dispatch
+//def setupNodePlate (GenChildSideAffixedNode it)'''
+// //FIXME: workaround for #154536
+// result.getBounds().setSize(result.getPreferredSize());
+//'''
+
+
def getPrimaryDragEditPolicy(GenNode it) '''
«var rc = getResizeConstraints(it.viewmap)»
@@ -509,12 +569,17 @@ import xpt.diagram.editparts.EditPartFactory
'so you may safely remove <i>generated</i> tag and modify it.\n'
protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure create«IF hasBorderItems(it)»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;
+ «IF it instanceof GenChildSideAffixedNode»
+ 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;
+ «ELSE»
+ return new org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure(createMainFigureWithSVG());
+ «ENDIF»
+
}
'''
@@ -580,17 +645,18 @@ import xpt.diagram.editparts.EditPartFactory
def setLineWidth(GenNode it) '''
«generatedMemberComment»
protected void setLineWidth(int width) {
- if (primaryShape instanceof org.eclipse.draw2d.Shape) {
- ((org.eclipse.draw2d.Shape) primaryShape).setLineWidth(«IF getDiagram().isPixelMapMode()»width«ELSE»getMapMode().DPtoLP(width)«ENDIF»);
- }
+««« if (primaryShape instanceof org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure) {
+««« ((org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure) primaryShape).setLineWidth(«IF getDiagram().isPixelMapMode()»width«ELSE»getMapMode().DPtoLP(width)«ENDIF»);
+««« }
+ super.setLineWidth(width);
}
'''
def setLineStyle(GenNode it) '''
«generatedMemberComment»
protected void setLineType(int style) {
- if (primaryShape instanceof org.eclipse.draw2d.Shape) {
- ((org.eclipse.draw2d.Shape) primaryShape).setLineStyle(style);
+ if (primaryShape instanceof org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure) {
+ ((org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure) primaryShape).setLineStyle(style);
}
}
'''
@@ -621,23 +687,99 @@ import xpt.diagram.editparts.EditPartFactory
'''
def getTargetEditPartMethod(GenNode it) '''
- «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);
- «FOR compartment : compartments»
- «IF listCompartmentHasChildren(compartment)»
- «FOR childNode : compartment.childNodes»
- if (type == «xptElementTypes.accessElementType(childNode)») {
- return getChildBySemanticHint(«xptVisualIDRegistry.typeMethodCall(compartment)»);
+ «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);
+ «FOR compartment : compartments»
+ «IF listCompartmentHasChildren(compartment)»
+ «FOR childNode : compartment.childNodes»
+ if («xptElementTypes.className(it.diagram)».isKindOf(type, «xptElementTypes.accessElementType(childNode)»)) {
+ return getChildBySemanticHint(«xptVisualIDRegistry.typeMethodCall(compartment)»);
+ }
+ «ENDFOR»
+ «ENDIF»
+ «ENDFOR»
+ }
+ return super.getTargetEditPart(request);
+ }
+'''
+
+
+//---------
+// GMF
+//---------
+
+
+
+//---------
+// PAPYRUS
+//---------
+
+
+
+def genSpecificLocator(GenCommonBase it, GenChildSideAffixedNode child) ''''''
+
+def genSpecificLocator(ToolEntry it, GenChildSideAffixedNode child) ''''''
+
+def genSpecificLocator(GenNavigatorChildReference it,GenChildSideAffixedNode child)''''''
+
+def genSpecificLocator(GenChildSideAffixedNode it)'''
+ ««« // @depracated Papyrus Gencode :«locatorComment»
+ if (childEditPart instanceof «it.getEditPartQualifiedClassName()») {
+ org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator locator = new «locatorClassName»(getMainFigure(), org.eclipse.draw2d.PositionConstants.«preferredSideName»);
+ getBorderedFigure().getBorderItemContainer().add(((«it.getEditPartQualifiedClassName()») childEditPart).getFigure(), locator);
+ return true;
+ }
+
+'''
+
+
+
+/**
+ * CreateGenerator to refresh figure by taking account of event of UML element or graphical element
+ */
+def specificHandleNotificationEvent (GenNode it) '''
+ «IF it.specificNotificationEvent »
+ /**
+ *Papyrus codeGen
+ *@generated
+ **/
+ protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
+ «IF it.labels.filter(typeof(GenExternalNodeLabel)).size != 0»
+ /*
+ * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart
+ * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)!
+ */
+ if(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) {
+ Object notifier = event.getNotifier();
+ java.util.List<?> modelChildren = ((org.eclipse.gmf.runtime.notation.View)getModel()).getChildren();
+ if (false == notifier instanceof org.eclipse.gmf.runtime.notation.Edge
+ ««« see Bug 463769
+ && false == notifier instanceof org.eclipse.gmf.runtime.notation.BasicCompartment) {
+ if(modelChildren.contains(event.getNotifier())) {
+ return;
+ }
+ }
}
- «ENDFOR»
+ «ENDIF»
+ super.handleNotificationEvent(event);
+ «IF refreshHook !== null»
+ «specificHandleNotificationEventBody(refreshHook)»
+ «ENDIF»
+
+ }
«ENDIF»
- «ENDFOR»
+
+'''
+
+def specificHandleNotificationEventBody(RefreshHook it) '''
+ if (resolveSemanticElement() != null) {
+ if(«refreshCondition»){
+ «refreshAction»;
+ refreshVisuals();
}
- return super.getTargetEditPart(request);
}
-'''
-
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeLabelEditPart.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeLabelEditPart.xtend
index bcecade1c20..97b861507fc 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeLabelEditPart.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/NodeLabelEditPart.xtend
@@ -1,18 +1,20 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Benoit Maggi (CEA LIST) -#510281 change dependency to replace gmft-runtime
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
@@ -75,6 +77,13 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
«xptEditpartsCommon.handleBounds(it)»
«ENDIF»
«xptEditpartsCommon.handleText(it)»
+ ««« START Papyrus Code
+ «IF elementIcon»
+ if(event.getNewValue() instanceof org.eclipse.emf.ecore.EAnnotation && org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((org.eclipse.emf.ecore.EAnnotation)event.getNewValue()).getSource())){
+ refreshLabel();
+ }
+ «ENDIF»
+ ««« End Papyrus Code
super.handleNotificationEvent(event);
'''
@@ -83,7 +92,7 @@ import xpt.diagram.editpolicies.TextSelectionEditPolicy
* see org.eclipse.gmf.tooling.runtime.edit.policies.DefaultNodeLabelDragPolicy.
* The next 2 DEFINE's are left here as a hook for possible AROUND's
*/
- def nodeLabelDragPolicyQualifiedClassName(GenDiagram it) '''org.eclipse.gmf.tooling.runtime.edit.policies.DefaultNodeLabelDragPolicy'''
+ def nodeLabelDragPolicyQualifiedClassName(GenDiagram it) '''org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.DefaultNodeLabelDragPolicy'''
def nodeLabelDragPolicyClass(GenDiagram it) '''«/*not generated by default anymore*/»'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/TextAware.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/TextAware.xtend
index 82c8c30374b..8ca67601502 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/TextAware.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/editparts/TextAware.xtend
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006-2013 Borland Software Corporation and others
+ * Copyright (c) 2006-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,67 +9,63 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.editparts
import com.google.inject.Inject
-import impl.diagram.editparts.viewmaps.modeledViewmapProducer
-import impl.parsers.expression_qvto
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.DesignLabelModelFacet
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.gmfgen.LabelModelFacet
-import org.eclipse.papyrus.gmf.codegen.gmfgen.ModeledViewmap
-import org.eclipse.papyrus.gmf.codegen.gmfgen.ParentAssignedViewmap
import org.eclipse.papyrus.gmf.codegen.gmfgen.Viewmap
-import parsers.ParserProvider
import xpt.CodeStyle
import xpt.Common
import xpt.diagram.ViewmapAttributesUtils_qvto
import xpt.diagram.editparts.EditPartFactory
import xpt.providers.ElementTypes
-@com.google.inject.Singleton class TextAware {
+@Singleton class TextAware {
@Inject extension Common
@Inject extension CodeStyle
@Inject extension ViewmapAttributesUtils_qvto
@Inject extension ChoiceUtils_qvto
@Inject extension RuntimeLabelsSupport_qvto
- @Inject extension expression_qvto
- @Inject modeledViewmapProducer xptModeledViewmapProducer;
- @Inject ParserProvider xptParserProvider;
@Inject EditPartFactory xptEditPartFactory
@Inject ElementTypes xptElementTypes;
def fields(GenCommonBase it) '''
- «generatedMemberComment()»
- private org.eclipse.gef.tools.DirectEditManager manager;
-
- «generatedMemberComment()»
- private org.eclipse.gmf.runtime.common.ui.services.parser.IParser parser;
-
- «IF isOclChoiceLabel(it) || isViewExpressionDefinedAndOcl(it)»
- «generatedMemberComment()»
- private org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker.Registrator myOclRegistrator;
- «ELSE»
- «generatedMemberComment()»
- private java.util.List<?> parserElements;
- «ENDIF»
-
- «generatedMemberComment()»
- private String defaultText;
-
- «generatedMemberComment()»
- private org.eclipse.gmf.runtime.diagram.ui.label.ILabelDelegate labelDelegate;
- '''
+ «generatedMemberComment»
+ private org.eclipse.gef.tools.DirectEditManager manager;
+
+ «generatedMemberComment»
+ private org.eclipse.gmf.runtime.common.ui.services.parser.IParser parser;
+
+ «generatedMemberComment»
+ private java.util.List<?> parserElements;
+
+ «generatedMemberComment»
+ private String defaultText;
+
+ ««« BEGIN: PapyrusGenCode
+ ««« Add attributes to manage extended editors
+ «generatedMemberComment('direct edition mode (default, undefined, registered editor, etc.)')»
+ protected int directEditionMode = org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ «generatedMemberComment('configuration from a registered edit dialog')»
+ protected org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IDirectEditorConfiguration configuration;
+ ««« END: BEGIN: PapyrusGenCode
+
+'''
def methods(GenCommonBase it, boolean needsRefreshBounds, boolean readOnly, boolean useElementIcon, Viewmap viewmap,
LabelModelFacet modelFacet, GenCommonBase host, GenDiagram diagram) '''
+
«getLabelTextHelper(it)»
«setLabelTextHelper(it)»
@@ -78,150 +74,139 @@ import xpt.providers.ElementTypes
«setLabelIconHelper(it)»
- «labelSetter(it)»
+ « labelSetter(it)»
- «getModelChildren(it)»
+ « getModelChildren(it)»
- «getChildBySemanticHint(it)»
+ « getChildBySemanticHint(it)»
+««« ITEMIS CHANGES
+ « setParser (it)»
+««« ITEMIS CHANGES END
+ « getParserElement(it,modelFacet)»
- «getParserElement(it, modelFacet)»
+ « getLabelIcon(it,useElementIcon, diagram)»
- «getLabelIcon(it, useElementIcon, diagram)»
+ « getLabelText(it)»
- «getLabelText(it)»
+ « setLabelText(it,diagram)»
- «setLabelText(it, diagram)»
+ « getEditText(it)»
- «getEditText(it)»
+ « isEditable(it,readOnly)»
- «isEditable(it, readOnly)»
+ « getEditTextValidator(it)»
- «getEditTextValidator(it)»
+ « getCompletionProcessor(it)»
- «getCompletionProcessor(it)»
+ « getParserOptions(it)»
- «getParserOptions(it)»
+ « getParser(it,modelFacet, diagram, host)»
- «getParser(it, modelFacet, diagram, host)»
+ « getManager(it,diagram)»
- «getManager(it, diagram, modelFacet)»
+ « setManager(it)»
- «setManager(it)»
+ « performDirectEdit(it)»
- «performDirectEdit(it)»
+ « performDirectEditAtPoint(it)»
- «performDirectEditAtPoint(it, modelFacet)»
-
-«IF !(isChoiceLabel(modelFacet))»
- «performDirectEditWithInitialChar(it)»
-«ENDIF»
+ « performDirectEditWithInitialChar(it)»
- «performDirectEditRequest(it, modelFacet)»
+ « performDirectEditRequest(it,diagram)»
- «refreshVisuals(it, needsRefreshBounds)»
+ « initializeDirectEditManager(it)»
- «refreshLabel(it, diagram)»
+ « refreshVisuals(it,needsRefreshBounds)»
- «refreshUnderline(it)»
+ « refreshLabel(it,diagram)»
- «refreshStrikeThrough(it)»
+ « refreshUnderline(it)»
- «refreshFont(it)»
+ « refreshStrikeThrough(it)»
- «refreshSelectionFeedback(it)»
+ « refreshFont(it)»
- «setFontColor(it)»
+ « setFontColor(it)»
- «addSemanticListeners(it)»
+ « addSemanticListeners(it)»
- «removeSemanticListeners(it)»
+ « removeSemanticListeners(it)»
- «getAccessibleEditPart(it)»
+ « getAccessibleEditPart(it)»
- «getFontStyleOwnerView(it, viewmap)»
-
-«IF isOclChoiceLabelWithShowExpr(it) || isViewExpressionDefinedAndOcl(it)»
- «getOclTracker(it)»
-«ENDIF»
+ « getFontStyleOwnerView(it,viewmap)»
+
+ ««« BEGIN: PapyrusGenCode
+ ««« Add extended editors management for direct edit
+ « getDirectEditionType(it,readOnly)»
-«IF isOclChoiceLabel(it) || isViewExpressionDefinedAndOcl(it)»
- «getOclRegistrator(it)»
-«ENDIF»
+ « checkExtendedEditor(it)»
- «getLabelDelegate(it)»
-
- «getAdapter(it)»
-'''
+ « checkDefaultEdition(it)»
- def dispatch labelSetterName(ParentAssignedViewmap it) '''«IF setterName != null»«setterName»«ELSE»setLabel«ENDIF»'''
+ « initExtendedEditorConfiguration(it)»
+
+ « updateExtendedEditorConfiguration(it)»
+
+ « performDefaultDirectEditorEdit(it)»
+
+ «««END: PapyrusGenCode
+'''
- def dispatch labelSetterName(Viewmap it) '''setLabel'''
+def labelSetterName(Viewmap it)'''setLabel'''
- def dispatch labelSetterName(ModeledViewmap it) '''setLabel'''
def getLabelTextHelper(GenCommonBase it) '''
- «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();
- } «IF isVerticalLabel(it)» else if (figure instanceof «getVerticalLabelFQN()») {
- return ((«getVerticalLabelFQN()») figure).getText();
- } «ENDIF» else if (figure instanceof org.eclipse.draw2d.Label) {
- return ((org.eclipse.draw2d.Label) figure).getText();
- } else {
- return getLabelDelegate().getText();
- }
- }
- '''
+ « 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 if (figure instanceof org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) {
+ return ((org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) figure).getText();
+ } else {
+ return ((org.eclipse.draw2d.Label) figure).getText();
+ }
+ }
+'''
def setLabelTextHelper(GenCommonBase it) '''
- «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);
- } «IF isVerticalLabel(it)» else if (figure instanceof «getVerticalLabelFQN()») {
- ((«getVerticalLabelFQN()») figure).setText(text);
- } «ENDIF» else if (figure instanceof org.eclipse.draw2d.Label) {
- ((org.eclipse.draw2d.Label) figure).setText(text);
- } else {
- getLabelDelegate().setText(text);
- }
- }
- '''
+ «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 if (figure instanceof org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) {
+ ((org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) figure).setText(text);
+ } else {
+ ((org.eclipse.draw2d.Label) figure).setText(text);
+ }
+ }
+'''
def getLabelIconHelper(GenCommonBase it) '''
- «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();
- } «IF isVerticalLabel(it)» else if (figure instanceof «getVerticalLabelFQN()») {
- //icons are not supported for verical labels now
- return null;
- } «ENDIF» else if (figure instanceof org.eclipse.draw2d.Label) {
- return ((org.eclipse.draw2d.Label) figure).getIcon();
- } else {
- return getLabelDelegate().getIcon(0);
- }
- }
- '''
+ «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 if (figure instanceof org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) {
+ return ((org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) figure).getIcon();
+ } else {
+ return ((org.eclipse.draw2d.Label) figure).getIcon();
+ }
+ }
+'''
def setLabelIconHelper(GenCommonBase it) '''
- «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);
- return;
- } «IF isVerticalLabel(it)» else if (figure instanceof «getVerticalLabelFQN()») {
- //icons are not supported for verical labels now, nothing to do
- return;
- } «ENDIF» else if (figure instanceof org.eclipse.draw2d.Label) {
- ((org.eclipse.draw2d.Label) figure).setIcon(icon);
- return;
- } else {
- getLabelDelegate().setIcon(icon, 0);
- }
- }
- '''
+ «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 if (figure instanceof org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) {
+ ((org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure) figure).setIcon(icon);
+ } else {
+ ((org.eclipse.draw2d.Label) figure).setIcon(icon);
+ }
+ }
+'''
def getLabelDelegate(GenCommonBase it) '''
«generatedMemberComment()»
@@ -252,55 +237,43 @@ import xpt.providers.ElementTypes
'''
def labelSetter(GenCommonBase it) '''
- «generatedMemberComment()»
- public void «labelSetterName(viewmap)»(«labelSetterFigureClassName(viewmap)» figure) {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
- '''
-
- def dispatch labelSetterFigureClassName(ParentAssignedViewmap it) //
- '''
- «IF figureQualifiedClassName != null»«figureQualifiedClassName»«ELSE»org.eclipse.draw2d.IFigure«ENDIF»
- '''
-
- def dispatch labelSetterFigureClassName(ModeledViewmap it) '''
-«xptModeledViewmapProducer.viewmapFigureFQN(it)»
+ «generatedMemberComment»
+ public void « labelSetterName (viewmap)»(« labelSetterFigureClassName(viewmap)» figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
'''
- def dispatch labelSetterFigureClassName(Viewmap it) '''
- org.eclipse.draw2d.IFigure
- '''
+def labelSetterFigureClassName (Viewmap it)'''
+ org.eclipse.draw2d.IFigure
+'''
def getModelChildren(GenCommonBase it) '''
- «generatedMemberComment()»
- «SuppressWarnings('"rawtypes"')»
- protected java.util.List getModelChildren() {
- return java.util.Collections.EMPTY_LIST;
- }
- '''
+ «generatedMemberComment»
+ protected java.util.List<?> getModelChildren() {
+ return java.util.Collections.EMPTY_LIST;
+ }
+'''
def getChildBySemanticHint(GenCommonBase it) '''
- «generatedMemberComment()»
- public org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
- return null;
- }
- '''
+ «generatedMemberComment»
+ public org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+'''
def getParserElement(GenCommonBase it, LabelModelFacet modelFacet) '''
- «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»
- «dispatch_getParserElement(modelFacet)»
- «ENDIF»
- }
- '''
+ «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»« getParserElement(modelFacet)»«ENDIF»
+ }
+'''
def dispatch dispatch_getParserElement(LabelModelFacet it) '''
return resolveSemanticElement();
@@ -311,56 +284,61 @@ import xpt.providers.ElementTypes
'''
def getLabelIcon(GenCommonBase it, boolean useElementIcon, GenDiagram diagram) '''
- «generatedMemberComment()»
- protected org.eclipse.swt.graphics.Image getLabelIcon() {
- «IF useElementIcon»
- org.eclipse.emf.ecore.EObject parserElement = getParserElement();
- if (parserElement == null) {
- return null;
- }
- return «xptElementTypes.qualifiedClassName(diagram)».getImage(parserElement.eClass());
- «ELSE»
- return null;
- «ENDIF»
- }
- '''
+ «generatedMemberComment»
+ protected org.eclipse.swt.graphics.Image getLabelIcon() {
+ «IF useElementIcon»
+ ««« START: PapyrusGenCode
+ return org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil.getIcon(getParserElement(), getViewer());
+ ««« END: PapyrusGenCode
+ «ELSE»
+ return null;
+ «ENDIF»
+ }
+'''
def getLabelText(GenCommonBase it) '''
- «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;
+ «generatedMemberComment»
+ protected String getLabelText() {
+ String text = null;
+ org.eclipse.emf.ecore.EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(
+ org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil.getParserAdapter(getParserElement(), this),
+ getParserOptions().intValue());
}
- '''
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+'''
def setLabelText(GenCommonBase it, GenDiagram diagram) '''
- «generatedMemberComment()»
- public void setLabelText(String text) {
- setLabelTextHelper(getFigure(), text);
- refreshSelectionFeedback();
- }
- '''
+ «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();
+ }
+ }
+'''
def getEditText(GenCommonBase it) '''
- «generatedMemberComment()»
- public String getEditText() {
- if (getParserElement() == null || getParser() == null) {
- return ""; «nonNLS()»
- }
- return getParser().getEditString(
- new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(getParserElement()),
- getParserOptions().intValue());
- }
- '''
+ «generatedMemberComment»
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; «nonNLS»
+ }
+ return getParser().getEditString(
+ org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil.getParserAdapter(getParserElement(), this),
+ getParserOptions().intValue());
+ }
+'''
def isEditable(GenCommonBase it, Boolean readOnly) '''
«generatedMemberComment()»
@@ -374,10 +352,11 @@ import xpt.providers.ElementTypes
'''
def getEditTextValidator(GenCommonBase it) '''
- «generatedMemberComment()»
- public org.eclipse.jface.viewers.ICellEditorValidator getEditTextValidator() {
- return new org.eclipse.jface.viewers.ICellEditorValidator() {
-
+ «generatedMemberComment»
+ public org.eclipse.jface.viewers.ICellEditorValidator getEditTextValidator() {
+ return new org.eclipse.jface.viewers.ICellEditorValidator() {
+
+ «overrideI»
public String isValid(final Object value) {
if (value instanceof String) {
final org.eclipse.emf.ecore.EObject element = getParserElement();
@@ -385,51 +364,53 @@ import xpt.providers.ElementTypes
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<org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus>() {
-
- 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();
- }
+ new org.eclipse.emf.transaction.RunnableWithResult.Impl<java.lang.Object>() {
+
+ «overrideI»
+ public void run() {
+ setResult(parser.isValidEditString(org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil.getParserAdapter(getParserElement(), «editPartClassName».this), (String) value));
+ }
+ });
+ return valid.getCode() == org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
}
-
- // shouldn't get here
- return null;
}
- };
- }
- '''
- def getCompletionProcessor(GenCommonBase it) '''
- «generatedMemberComment()»
- public org.eclipse.jface.text.contentassist.IContentAssistProcessor getCompletionProcessor() {
- if (getParserElement() == null || getParser() == null) {
+ // shouldn't get here
return null;
}
- return getParser().getCompletionProcessor(new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(getParserElement()));
+ };
+ }
+'''
+
+ def getCompletionProcessor(GenCommonBase it) '''
+ «generatedMemberComment»
+ public org.eclipse.jface.text.contentassist.IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
}
- '''
+ return getParser().getCompletionProcessor(org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil.getParserAdapter(getParserElement(), this));
+ }
+'''
+
def getParserOptions(GenCommonBase it) '''
- «generatedMemberComment()»
- public org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions getParserOptions() {
- return org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions.NONE;
- }
- '''
+ «generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions getParserOptions() {
+ return org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions.NONE;
+ }
+'''
def getParser(GenCommonBase it, LabelModelFacet modelFacet, GenDiagram diagram, GenCommonBase host) '''
- «generatedMemberComment()»
- public org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser() {
- if (parser == null) {
- parser = «xptParserProvider.accessorCall(it, host, modelFacet, 'getParserElement()')»;
- }
- return parser;
+ «generatedMemberComment»
+ public org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser() {
+ if (parser == null) {
+ parser = org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil.getParser(«xptElementTypes.accessElementType(host)», getParserElement(), this, VISUAL_ID);
}
- '''
+ return parser;
+ }
+'''
def getManager(GenCommonBase it, GenDiagram diagram, LabelModelFacet modelFacet) '''
«generatedMemberComment()»
@@ -444,18 +425,24 @@ import xpt.providers.ElementTypes
'''
def setManager(GenCommonBase it) '''
- «generatedMemberComment()»
- protected void setManager(org.eclipse.gef.tools.DirectEditManager manager) {
- this.manager = manager;
- }
- '''
+ «generatedMemberComment»
+ protected void setManager(org.eclipse.gef.tools.DirectEditManager manager) {
+ this.manager = manager;
+ }
+'''
def performDirectEdit(GenCommonBase it) '''
- «generatedMemberComment()»
- protected void performDirectEdit() {
- getManager().show();
- }
- '''
+ «generatedMemberComment»
+ protected void performDirectEdit() {
+ org.eclipse.swt.custom.BusyIndicator.showWhile(org.eclipse.swt.widgets.Display.getDefault(), new java.lang.Runnable() {
+
+ «overrideI»
+ public void run() {
+ getManager().show();
+ }
+ });
+ }
+'''
def performDirectEditAtPoint(GenCommonBase it, LabelModelFacet modelFacet) '''
«generatedMemberComment()»
@@ -467,16 +454,15 @@ import xpt.providers.ElementTypes
'''
def performDirectEditWithInitialChar(GenCommonBase it) '''
- «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();
- }
- }
- '''
+ «generatedMemberComment»
+ protected 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();
+ }
+ }
+'''
def performDirectEditRequest(GenCommonBase it, LabelModelFacet modelFacet) '''
«generatedMemberComment()»
@@ -522,53 +508,79 @@ import xpt.providers.ElementTypes
'''
def refreshLabel(GenCommonBase it, GenDiagram diagram) '''
- «generatedMemberComment()»
- protected void refreshLabel() {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- refreshSelectionFeedback();
+ «generatedMemberComment»
+ protected void refreshLabel() {
+ org.eclipse.gef.EditPolicy maskLabelPolicy = getEditPolicy(org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if(maskLabelPolicy==null){
+ maskLabelPolicy = getEditPolicy(org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+ if (maskLabelPolicy == null) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View)getModel();
+ if(view.isVisible()) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ else {
+ setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
+ setLabelIconHelper(getFigure(), null);
+ }
}
- '''
+ 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();
+ }
+ }
+'''
def refreshUnderline(GenCommonBase it) '''
- «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());
+ «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());
+ }
+ if(resolveSemanticElement() instanceof org.eclipse.uml2.uml.Feature){
+ if(((org.eclipse.uml2.uml.Feature)resolveSemanticElement()).isStatic()){
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel)getFigure()).setTextUnderline(true);
}
+ else{((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel)getFigure()).setTextUnderline(false);}
}
- '''
+ }
+'''
def refreshStrikeThrough(GenCommonBase it) '''
- «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());
- }
- }
- '''
+ «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());
+ }
+ }
+'''
- def refreshFont(GenCommonBase it) '''
- «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);
- }
- }
- '''
+ def refreshFont(GenCommonBase it)'''
+ «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);
+ }
+ }
+'''
def refreshSelectionFeedback(GenCommonBase it) '''
«generatedMemberComment()»
@@ -587,89 +599,66 @@ import xpt.providers.ElementTypes
'''
def setFontColor(GenCommonBase it) '''
- «generatedMemberComment()»
- protected void setFontColor(org.eclipse.swt.graphics.Color color) {
- getFigure().setForegroundColor(color);
- }
- '''
+ «generatedMemberComment»
+ protected void setFontColor(org.eclipse.swt.graphics.Color color) {
+ getFigure().setForegroundColor(color);
+ }
+'''
def addSemanticListeners(GenCommonBase it) '''
- «generatedMemberComment()»
- protected void addSemanticListeners() {
- «IF isOclChoiceLabel(it) || isViewExpressionDefinedAndOcl(it)»
- «IF isOclChoiceLabelWithShowExpr(it) || isViewExpressionDefinedAndOcl(it)»
- org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker tracker = getTracker();
- tracker.initialize(resolveSemanticElement());
- tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
- «ELSE»
- super.addSemanticListeners();
- «ENDIF»
- «IF isOclChoiceLabel(it)»
- ((org.eclipse.gmf.tooling.runtime.parsers.OclChoiceParser) getParser()).installListeners(this, getOclRegistrator());
- «ENDIF»
- «ELSE»
- 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)); «nonNLS()»
- }
- } else {
- super.addSemanticListeners();
+ «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)); «nonNLS»
}
- «ENDIF»
+ } else {
+ super.addSemanticListeners();
}
- '''
+ }
+'''
def removeSemanticListeners(GenCommonBase it) '''
- «generatedMemberComment()»
- protected void removeSemanticListeners() {
- «IF isOclChoiceLabel(it) || isViewExpressionDefinedAndOcl(it)»
- «IF isOclChoiceLabel(it)»
- ((org.eclipse.gmf.tooling.runtime.parsers.OclChoiceParser) getParser()).uninstallListeners();
- «ENDIF»
- «IF isOclChoiceLabelWithShowExpr(it) || isViewExpressionDefinedAndOcl(it)»
- getTracker().uninstallListeners();
- «ELSE»
- super.removeSemanticListeners();
- «ENDIF»
- «ELSE»
- if (parserElements != null) {
- for (int i = 0; i < parserElements.size(); i++) {
- removeListenerFilter("SemanticModel" + i); «nonNLS()»
- }
- } else {
- super.removeSemanticListeners();
+ «generatedMemberComment»
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); «nonNLS»
}
- «ENDIF»
+ } else {
+ super.removeSemanticListeners();
}
- '''
+ }
+'''
def getAccessibleEditPart(GenCommonBase it) '''
- «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;
+ «generatedMemberComment»
+ protected org.eclipse.gef.AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ «overrideC»
+ public void getName(org.eclipse.swt.accessibility.AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
}
- '''
+ return accessibleEP;
+ }
+'''
def getFontStyleOwnerView(GenCommonBase it, Viewmap viewmap) '''
- «generatedMemberComment()»
- private org.eclipse.gmf.runtime.notation.View getFontStyleOwnerView() {
- «IF viewmap.isFixedFont()»
- return (org.eclipse.gmf.runtime.notation.View) getModel();
- «ELSE»
- return getPrimaryView();
- «ENDIF»
- }
- '''
+ «generatedMemberComment»
+ private org.eclipse.gmf.runtime.notation.View getFontStyleOwnerView() {
+ «IF isFixedFont(viewmap)»
+ return (org.eclipse.gmf.runtime.notation.View) getModel();
+ «ELSE»
+ return getPrimaryView();
+ «ENDIF»
+ }
+'''
def getOclTracker(GenCommonBase it) '''
«generatedMemberComment()»
@@ -699,4 +688,298 @@ import xpt.providers.ElementTypes
}
'''
+// FIXME eallogo hidden code ??? (dispatch ?)
+//def dispatch labelSetterName(ParentAssignedViewmap it) '''«IF setterName !== null »«setterName»«ELSE»setLabel«ENDIF»'''
+
+// FIXME eallogo hidden code ??? (dispatch ?)
+//def dispatch labelSetterFigureClassName (ParentAssignedViewmap it)'''
+// «IF figureQualifiedClassName !== null»
+// «figureQualifiedClassName»
+// «ELSE»
+// org.eclipse.draw2d.IFigure
+// «ENDIF»
+//'''
+
+
+
+def setParser (GenCommonBase it)'''
+ «generatedMemberComment»
+ public void setParser(org.eclipse.gmf.runtime.common.ui.services.parser.IParser parser) {
+ this.parser = parser;
+ }
+'''
+
+
+def getParserElement (LabelModelFacet it)'''
+ return resolveSemanticElement();
+'''
+
+def getParserElement (DesignLabelModelFacet it)'''
+ return (org.eclipse.gmf.runtime.notation.View) getModel();
+'''
+
+
+def isEditable(GenCommonBase it, boolean readOnly ) '''
+ «generatedMemberComment»
+ protected boolean isEditable() {
+ «IF readOnly»
+ return false;
+ «ELSE»
+ return getParser() != null;
+ «ENDIF»
+ }
+'''
+
+def getManager(GenCommonBase it,GenDiagram diagram) '''
+ «generatedMemberComment»
+ protected org.eclipse.gef.tools.DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager(this,
+ org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ «diagram.getEditPartFactoryQualifiedClassName()».getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+'''
+
+
+
+def performDirectEditAtPoint (GenCommonBase it)'''
+ «generatedMemberComment»
+ protected void performDirectEdit(org.eclipse.draw2d.geometry.Point eventLocation) {
+ if (getManager() instanceof org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) {
+ ((org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+'''
+
+
+def performDirectEditRequest(GenCommonBase it, GenDiagram diagram ) '''
+ «generatedMemberComment»
+ protected void performDirectEditRequest(org.eclipse.gef.Request request) {
+
+ final org.eclipse.gef.Request theRequest = request;
+
+ if (org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch (directEditionMode) {
+ case org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if (configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager(this,
+ org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager.getTextCellEditorClass(this),
+ «diagram.getEditPartFactoryQualifiedClassName()».getTextCellEditorLocator(this)));
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ org.eclipse.jface.dialogs.Dialog dialog = null;
+ if (configuration instanceof org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration) {
+ setManager(((org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if (configuration instanceof org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IPopupEditorConfiguration) {
+ org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.ui.IPopupEditorHelper helper = ((org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IPopupEditorConfiguration)configuration).createPopupEditorHelper(this) ;
+ helper.showEditor() ;
+ return ;
+ }
+ else if(configuration instanceof org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IAdvancedEditorConfiguration) {
+ dialog = ((org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IAdvancedEditorConfiguration)configuration).createDialog(org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if(configuration instanceof org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IDirectEditorConfiguration) {
+ dialog = new org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.ui.ExtendedDirectEditionDialog(org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration);
+ } else {
+ return;
+ }
+ final org.eclipse.jface.dialogs.Dialog finalDialog = dialog;
+
+ if (org.eclipse.jface.window.Window.OK == dialog.open()) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain domain = getEditingDomain();
+ org.eclipse.emf.transaction.RecordingCommand command = new org.eclipse.emf.transaction.RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.ui.ILabelEditorDialog)finalDialog).getValue());
+
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ initializeDirectEditManager(theRequest);
+ break;
+ default:
+ break;
+ }
+ }
+'''
+
+def initializeDirectEditManager (GenCommonBase it)'''
+ «generatedMemberComment»
+ protected void initializeDirectEditManager(final org.eclipse.gef.Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+ «overrideI»
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (request.getExtendedData().get(
+ org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) request.getExtendedData().get(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ }
+ else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+'''
+
+def refreshVisuals(GenCommonBase it, boolean needsRefreshBounds ) '''
+ «generatedMemberComment»
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ «IF needsRefreshBounds»
+ refreshBounds();
+ «ENDIF»
+ }
+'''
+
+
+//BEGIN: PapyrusGenCode
+//Methods for advanced direct edition
+
+def getDirectEditionType(GenCommonBase it, Boolean readOnly) '''
+ /**
+ * Returns the kind of associated editor for direct edition.
+ *
+ * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition
+ * @generated
+ */
+ public int getDirectEditionType() {
+ «IF readOnly»
+ // The label is read-only (defined in GMFGen model)
+ return org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.NO_DIRECT_EDITION;
+ «ELSE»
+ if (checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if (checkDefaultEdition()) {
+ return org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+
+ // not a named element. no specific editor => do nothing
+ return org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition.NO_DIRECT_EDITION;
+ «ENDIF»
+ }
+'''
+
+def checkExtendedEditor (GenCommonBase it)'''
+ /**
+ * Checks if an extended editor is present.
+ *
+ * @return <code>true</code> if an extended editor is present.
+ * @generated
+ */
+ protected boolean checkExtendedEditor() {
+ if (resolveSemanticElement() != null) {
+ return org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(),this);
+ }
+ return false;
+ }
+'''
+
+def checkDefaultEdition (GenCommonBase it)'''
+ /**
+ * Checks if a default direct edition is available
+ *
+ * @return <code>true</code> if a default direct edition is available
+ * @generated
+ */
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+'''
+
+def initExtendedEditorConfiguration (GenCommonBase it)'''
+ /**
+ * Initializes the extended editor configuration
+ * @generated
+ */
+ protected void initExtendedEditorConfiguration() {
+ if (configuration == null) {
+ final String languagePreferred = org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.Activator.getDefault().getPreferenceStore().getString(org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this);
+ } else {
+ configuration = org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.DirectEditorsUtil.findEditorConfiguration(org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this);
+ }
+ }
+ }
+'''
+
+def updateExtendedEditorConfiguration (GenCommonBase it)'''
+ /**
+ * Updates the preference configuration
+ * @generated
+ */
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.Activator.getDefault().getPreferenceStore().getString(
+ org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if (languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
+ configuration = org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(),this);
+ } else if (org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.utils.IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+'''
+
+def performDefaultDirectEditorEdit (GenCommonBase it)'''
+ /**
+ * Performs the direct edit usually used by GMF editors.
+ * @param theRequest the direct edit request that starts the direct edit system
+ * @generated
+ */
+ protected void performDefaultDirectEditorEdit(final org.eclipse.gef.Request theRequest) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ «overrideI»
+ 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();
+ }
+ }
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/update/CanonicalUpdate.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/update/CanonicalUpdate.xtend
index cb91da6790e..63105b7b2a8 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/update/CanonicalUpdate.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/diagram/update/CanonicalUpdate.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Artem Tikhomirov - refactoring of containerBaseCanonicalMethods.xpt; extraction of API/non-API of CEP templates
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Artem Tikhomirov - refactoring of containerBaseCanonicalMethods.xpt; extraction of API/non-API of CEP templates
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.diagram.update
@@ -92,44 +92,44 @@ def refreshOnActivateMethod(GenContainerBase it) '''
'''
def getFeaturesToSynchronizeMethod(GenContainerBase it) '''
-«IF getSemanticChildrenChildFeatures(it).size == 1»
-
- «generatedMemberComment»
- protected org.eclipse.emf.ecore.EStructuralFeature getFeatureToSynchronize() {
- return «xptMetaModel.MetaFeature(getSemanticChildrenContainmentFeatures(it).head)»;
- }
-«ELSEIF getSemanticChildrenChildFeatures(it).size > 1»
-
- «generatedMemberComment»
- protected java.util.Set getFeaturesToSynchronize() {
- if (myFeaturesToSynchronize == null) {
- myFeaturesToSynchronize = new java.util.HashSet<org.eclipse.emf.ecore.EStructuralFeature>();
- «FOR f : getSemanticChildrenContainmentFeatures(it)»
- «addContainmentFeature(f)»
- «ENDFOR»
- }
- return myFeaturesToSynchronize;
- }
-«ENDIF»
-'''
+ «IF getSemanticChildrenChildFeatures(it).size == 1»
+
+ «generatedMemberComment»
+ protected org.eclipse.emf.ecore.EStructuralFeature getFeatureToSynchronize() {
+ return «xptMetaModel.MetaFeature(getSemanticChildrenContainmentFeatures(it).head)»;
+ }
+ «ELSEIF getSemanticChildrenChildFeatures(it).size > 1»
+
+ «generatedMemberComment»
+ protected java.util.Set<org.eclipse.emf.ecore.EStructuralFeature> getFeaturesToSynchronize() {
+ if (myFeaturesToSynchronize == null) {
+ myFeaturesToSynchronize = new java.util.HashSet<org.eclipse.emf.ecore.EStructuralFeature>();
+ «FOR f : getSemanticChildrenContainmentFeatures(it)»
+ «addContainmentFeature(f)»
+ «ENDFOR»
+ }
+ return myFeaturesToSynchronize;
+ }
+ «ENDIF»
+ '''
def getSemanticChildrenListMethod(GenContainerBase it) '''
-«generatedMemberComment»
-@SuppressWarnings("rawtypes")
-protected java.util.List getSemanticChildrenList() {
- «IF hasSemanticChildren(it) /*REVISIT: is there real need for this check - Generator seems to consult needsCanonicalEP, which in turns ensures there are semantic children?*/»
- org.eclipse.gmf.runtime.notation.View viewObject = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- java.util.LinkedList<org.eclipse.emf.ecore.EObject> result = new java.util.LinkedList<org.eclipse.emf.ecore.EObject>();
- java.util.List<«nodeDescriptor.qualifiedClassName(it.diagram.editorGen.diagramUpdater)»> childDescriptors = «xptDiagramUpdater.getSemanticChildrenMethodCall(it)»(viewObject);
- for («nodeDescriptor.qualifiedClassName(it.diagram.editorGen.diagramUpdater)» d : childDescriptors) {
- result.add(d.getModelElement());
- }
- return result;
- «ELSE»
- return java.util.Collections.EMPTY_LIST;
- «ENDIF»
-}
-'''
+ «generatedMemberComment»
+ protected java.util.List<org.eclipse.emf.ecore.EObject> getSemanticChildrenList() {
+ «IF hasSemanticChildren(it)/*REVISIT: is there real need for this check - Generator seems to consult needsCanonicalEP, which in turns ensures there are semantic children?*/»
+ org.eclipse.gmf.runtime.notation.View viewObject = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ java.util.LinkedList<org.eclipse.emf.ecore.EObject> result = new java.util.LinkedList<org.eclipse.emf.ecore.EObject>();
+ java.util.List<«nodeDescriptor.qualifiedClassName(it.diagram.editorGen.diagramUpdater)»> childDescriptors = «xptDiagramUpdater.
+ getSemanticChildrenMethodCall(it)»(viewObject);
+ for («nodeDescriptor.qualifiedClassName(it.diagram.editorGen.diagramUpdater)» d : childDescriptors) {
+ result.add(d.getModelElement());
+ }
+ return result;
+ «ELSE»
+ return java.util.Collections.EMPTY_LIST;
+ «ENDIF»
+ }
+ '''
def boolean isDiagramThatContainsShortcurs(GenContainerBase it) {
return it.oclIsKindOf(typeof(GenDiagram)) && (it as GenDiagram).containsShortcutsTo.notEmpty;
@@ -327,33 +327,41 @@ def executeLayoutCommand(GenContainerBase it, String createdViewsVar) '''
'''
def refreshConnectionsBody(GenDiagram it) '''
- «Domain2Notation(it)» domain2NotationMap = new «Domain2Notation(it)»();
- java.util.Collection<«linkDescriptor.qualifiedClassName(editorGen.diagramUpdater)»> 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 = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(nextDiagramLink);
- if (diagramLinkVisualID == -1«FOR link : links.filter[gl | gl.modelFacet == null]»«compareLinkVisualID(link)»«ENDFOR») {
- if (nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) {
- linksIterator.remove();
+ «Domain2Notation(it)» domain2NotationMap = new «Domain2Notation(it)»();
+ java.util.Collection<«linkDescriptor.qualifiedClassName(editorGen.diagramUpdater)»> linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap);
+ java.util.List<org.eclipse.gmf.runtime.notation.View> edges = new java.util.ArrayList<org.eclipse.gmf.runtime.notation.View>();
+ for (Object edge : getDiagram().getEdges())
+ {
+ if (edge instanceof org.eclipse.gmf.runtime.notation.View)
+ {
+ edges.add((org.eclipse.gmf.runtime.notation.View) edge);
}
- 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<«it.editorGen.diagramUpdater.linkDescriptorQualifiedClassName»> linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
- «linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)» nextLinkDescriptor = linkDescriptorsIterator.next();
- if (diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) {
- linksIterator.remove();
- linkDescriptorsIterator.remove();
- break;
+ java.util.Collection<org.eclipse.gmf.runtime.notation.View> existingLinks = new java.util.LinkedList<org.eclipse.gmf.runtime.notation.View>(edges);
+ for (java.util.Iterator<org.eclipse.gmf.runtime.notation.View> linksIterator = existingLinks.iterator(); linksIterator.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge nextDiagramLink = (org.eclipse.gmf.runtime.notation.Edge) linksIterator.next();
+ int diagramLinkVisualID = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(nextDiagramLink);
+ if (diagramLinkVisualID == -1«FOR link : links.filter[gl|gl.modelFacet == null]»«compareLinkVisualID(link)»«ENDFOR») {
+ 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<«it.editorGen.diagramUpdater.linkDescriptorQualifiedClassName»> linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
+ «linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)» nextLinkDescriptor = 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);
-'''
+ deleteViews(existingLinks.iterator());
+ return createConnections(linkDescriptors, domain2NotationMap);
+ '''
def refreshConnectionsAuxMethods(GenDiagram it) '''
«collectAllLinksMethod(it)»
@@ -366,26 +374,31 @@ def refreshConnectionsAuxMethods(GenDiagram it) '''
'''
def collectAllLinksMethod(GenDiagram it) '''
-«generatedMemberComment»
-private java.util.Collection<«linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)»> collectAllLinks(org.eclipse.gmf.runtime.notation.View view, «Domain2Notation(it)» domain2NotationMap) {
- if (!«VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(view))) {
- return java.util.Collections.emptyList();
- }
- java.util.LinkedList<«linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)»> result = new java.util.LinkedList<«linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)»>();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it)»(view)) {
- «FOR se : it.allSemanticElements»
- «caseSemanticElement(se)»
- «ENDFOR»
- }
- 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;
-}
-'''
+ «generatedMemberComment»
+ private java.util.Collection<«linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)»> collectAllLinks(org.eclipse.gmf.runtime.notation.View view, «Domain2Notation(
+ it)» domain2NotationMap) {
+ if (!«VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(view))) {
+ return java.util.Collections.emptyList();
+ }
+ java.util.LinkedList<«linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)»> result = new java.util.LinkedList<«linkDescriptor.
+ qualifiedClassName(it.editorGen.diagramUpdater)»>();
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(view);
+ if (vid != null) {
+ switch (vid) {
+ «FOR se : it.allSemanticElements»
+ «caseSemanticElement(se)»
+ «ENDFOR»
+ }
+ }
+ 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;
+ }
+ '''
def createConnectionsMethod(GenDiagram it) '''
«generatedMemberComment»
@@ -419,26 +432,26 @@ private java.util.Collection<org.eclipse.core.runtime.IAdaptable> createConnecti
'''
def getEditPartMethod(GenDiagram it) '''
-«generatedMemberComment»
-private org.eclipse.gef.EditPart getEditPart(org.eclipse.emf.ecore.EObject domainModelElement, «Domain2Notation(it)» 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;
-}
-'''
+ «generatedMemberComment»
+ private org.eclipse.gef.EditPart getEditPart(org.eclipse.emf.ecore.EObject domainModelElement, «Domain2Notation(it)» domain2NotationMap) {
+ org.eclipse.gmf.runtime.notation.View view = domain2NotationMap.get(domainModelElement);
+ if (view != null) {
+ return (org.eclipse.gef.EditPart) getHost().getViewer().getEditPartRegistry().get(view);
+ }
+ return null;
+ }
+ '''
def getHintedEditPartMethod(GenDiagram it) '''
- «generatedMemberComment»
-protected final org.eclipse.gef.EditPart getHintedEditPart(org.eclipse.emf.ecore.EObject domainModelElement, «Domain2Notation(it)» domain2NotationMap, int hintVisualId) {
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) domain2NotationMap.getHinted(domainModelElement, «xptVisualIDRegistry.typeMethodCall(it, 'hintVisualId')»);
- if (view != null) {
- return (org.eclipse.gef.EditPart) getHost().getViewer().getEditPartRegistry().get(view);
- }
- return null;
-}
-'''
+ «generatedMemberComment»
+ protected final org.eclipse.gef.EditPart getHintedEditPart(org.eclipse.emf.ecore.EObject domainModelElement, «Domain2Notation(it)» domain2NotationMap, int hintVisualId) {
+ org.eclipse.gmf.runtime.notation.View view = domain2NotationMap.getHinted(domainModelElement, «xptVisualIDRegistry.typeMethodCall(it, 'hintVisualId')»);
+ if (view != null) {
+ return (org.eclipse.gef.EditPart) getHost().getViewer().getEditPartRegistry().get(view);
+ }
+ return null;
+ }
+ '''
def getSourceEditPartMethod(GenDiagram it) '''
«generatedMemberComment»
@@ -492,5 +505,4 @@ case «VisualIDRegistry::visualID(it)»: {
break;
}
'''
-
-} \ No newline at end of file
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/AbstractParser.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/AbstractParser.xtend
deleted file mode 100644
index 0cf47ea06eb..00000000000
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/AbstractParser.xtend
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2020 Montages AG, CEA LIST, Artal and others
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Michael Golubev (Montages) - [368169] extract not-generated shared code to GMF-T runtime
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
- *****************************************************************************/
-package impl.parsers
-
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenParsers
-
-/**
- * Since GMFT 3.1 we don't generate class AbstractParser into every diagram, by extending the
- * org.eclipse.gmf.tooling.runtime.parsers.AbstractAttributeParser.
- * If you want to extend other custom implementation you may change the className and quialifiedClassName DEFINE's
- * which are still used in the extend's clauses for generated PredefinedParser's
- * <p>
- * However, for 3.1 release we still will generate empty file (without any java content),
- * to ensure that the old code, including calls to non existing i18n fields in Messages is cleaned up.
- */
-@com.google.inject.Singleton class AbstractParser {
-
- def className(GenParsers it) '''AbstractAttributeParser'''
-
- def packageName(GenParsers it) '''org.eclipse.gmf.tooling.runtime.parsers'''
-
- def String qualifiedClassName(GenParsers it) '''«packageName(it)».«className(it)»'''
-
- def fullPath(GenParsers it) '''«qualifiedClassName(it)»'''
-
- def deprecatedQualifiedClassName(GenParsers it) '''«implPackageName».AbstractParser'''
-
- def Main(GenParsers it) '''
- //Since GMFT 3.1 we don't generate class AbstractParser into every diagram, instead extend org.eclipse.gmf.tooling.runtime.parsers.AbstractAttributeParser.
- '''
-}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/ParserProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/ParserProvider.xtend
index 40554ed5e12..6ba9b155fde 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/ParserProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/parsers/ParserProvider.xtend
@@ -1,20 +1,20 @@
-/*******************************************************************************
- * Copyright (c) 2007-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) - [235113] alternative parser access
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [235113] alternative parser access
* [244419] custom parsers
* [138179] expression-backed labels
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.parsers
@@ -157,43 +157,45 @@ import plugin.Activator
'''
def HintAdapterClass(GenParsers it) '''
- «generatedMemberComment()»
- private static class HintAdapter extends org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter {
-
- «generatedMemberComment()»
- private final org.eclipse.gmf.runtime.emf.type.core.IElementType elementType;
-
«generatedMemberComment()»
- public HintAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType type,
- org.eclipse.emf.ecore.EObject object, String parserHint) {
+ private static class HintAdapter extends org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter {
+
+ «generatedMemberComment()»
+ private final org.eclipse.gmf.runtime.emf.type.core.IElementType elementType;
+
+ «generatedMemberComment()»
+ public HintAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType type,
+ org.eclipse.emf.ecore.EObject object, String parserHint) {
super(object, parserHint);
«_assert('type != null')»
elementType = type;
- }
-
- «generatedMemberComment()»
- public Object getAdapter(Class adapter) {
- if (org.eclipse.gmf.runtime.emf.type.core.IElementType.class.equals(adapter)) {
- return elementType;
}
- return super.getAdapter(adapter);
+
+ «generatedMemberComment()»
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ if (org.eclipse.gmf.runtime.emf.type.core.IElementType.class.equals(adapter)) {
+ return elementType;
+ }
+ return super.getAdapter(adapter);
+ }
}
- }
'''
- def getParserByVisualIdMethod(GenParsers it) '''
+ def getParserByVisualIdMethod(GenParsers it) '''
«generatedMemberComment()»
- protected org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser(int visualID) {
- switch (visualID) {
- «FOR node : editorGen.diagram.topLevelNodes»
- «dispatch_getParsers(node)»
- «ENDFOR»
- «FOR node : editorGen.diagram.childNodes»
- «dispatch_getParsers(node)»
- «ENDFOR»
- «FOR link : editorGen.diagram.links»
- «dispatch_getParsers(link)»
- «ENDFOR»
+ protected org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ «FOR node : editorGen.diagram.topLevelNodes»
+ «dispatch_getParsers(node)»
+ «ENDFOR»
+ «FOR node : editorGen.diagram.childNodes»
+ «dispatch_getParsers(node)»
+ «ENDFOR»
+ «FOR link : editorGen.diagram.links»
+ «dispatch_getParsers(link)»
+ «ENDFOR»
+ }
}
return null;
}
@@ -202,21 +204,28 @@ import plugin.Activator
def dispatch dispatch_getParsers(GenNode it) //
'''
«FOR label : it.labels»
- «doGetParser(label.modelFacet.parser, label)»
+ «IF label.modelFacet != null»
+ «doGetParser(label.modelFacet.parser, label)»
+ «ENDIF»
«ENDFOR»
+
'''
- def dispatch dispatch_getParsers(GenLink it) //
+ def dispatch dispatch_getParsers(GenLink it) //
'''
«FOR label : it.labels»
- «doGetParser(label.modelFacet.parser, label)»
+ «IF label.modelFacet != null»
+ «doGetParser(label.modelFacet.parser, label)»
+ «ENDIF»
«ENDFOR»
+
'''
- def dispatch dispatch_getParsers(GenChildLabelNode it) '''
- «doGetParser(it.labelModelFacet.parser, it)»
+ def dispatch dispatch_getParsers(GenChildLabelNode it)'''
+ «IF it.modelFacet != null»
+ «doGetParser(it.labelModelFacet.parser, it)»
+ «ENDIF»
'''
-
def doGetParser(GenParserImplementation parser, GenCommonBase element) '''
«IF parser.oclIsKindOf(typeof(PredefinedEnumParser)) || parser.oclIsKindOf(typeof(OclChoiceParser))»
«extraLineBreak»
@@ -229,16 +238,19 @@ import plugin.Activator
def dispatch dispatch_parsers(GenNode it) '''
«FOR label : it.labels»
- «dispatch_parser(label.modelFacet.parser, label.modelFacet, label)»
+ «IF label.modelFacet != null»
+ «dispatch_parser(label.modelFacet.parser, label.modelFacet, label)»
+ «ENDIF»
«ENDFOR»
'''
def dispatch dispatch_parsers(GenLink it) '''
«FOR label : it.labels»
- «dispatch_parser(label.modelFacet.parser, label.modelFacet, label)»
+ «IF label.modelFacet != null»
+ «dispatch_parser(label.modelFacet.parser, label.modelFacet, label)»
+ «ENDIF»
«ENDFOR»
'''
-
def dispatch dispatch_parsers(GenChildLabelNode it) '''«dispatch_parser(it.labelModelFacet.parser, it.labelModelFacet, it)»'''
def dispatch dispatch_parser(GenParserImplementation it, LabelModelFacet modelFacet, GenCommonBase element) '''«ERROR("Abstract template for " + it + ", element: " + element)»'''
@@ -378,4 +390,4 @@ import plugin.Activator
«ENDIF»
'''
-} \ No newline at end of file
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/preferences/StandardPage.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/preferences/StandardPage.xtend
index b71b4bb204b..cfab27b4970 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/preferences/StandardPage.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/impl/preferences/StandardPage.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package impl.preferences
@@ -42,13 +42,16 @@ import xpt.Common
«generatedMemberComment»
public «className(it)»() {
setPreferenceStore(«getDiagram().editorGen.plugin.activatorQualifiedClassName».getInstance().getPreferenceStore());
+ «IF StandardPreferencePages.GENERAL_LITERAL == kind»
+ setPreferenceKey(«getDiagram().editPartsPackageName».«getDiagram().editPartClassName».MODEL_ID);
+ «ENDIF»
}
}
'''
def extendsList(GenStandardPreferencePage it) '''
«IF kind == StandardPreferencePages::GENERAL_LITERAL»
- extends org.eclipse.gmf.runtime.diagram.ui.preferences.DiagramsPreferencePage«»
+ extends org.eclipse.papyrus.infra.gmfdiag.preferences.pages.DiagramPreferencePage«»
«ELSEIF kind == StandardPreferencePages::APPEARANCE_LITERAL»
extends org.eclipse.gmf.runtime.diagram.ui.preferences.AppearancePreferencePage«»
«ELSEIF kind == StandardPreferencePages::CONNECTIONS_LITERAL»
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/metamodel/MetaModel.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/metamodel/MetaModel.xtend
index a0be2736b5c..ca86467e437 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/metamodel/MetaModel.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/metamodel/MetaModel.xtend
@@ -1,17 +1,18 @@
-/******************************************************************************
- * Copyright (c) 2008, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2008, 2015, 2021 Anatoliy Tischenko, Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Anatoliy Tischenko - Initial API and implementation
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package metamodel
@@ -174,7 +175,7 @@ import xpt.GenModelUtils_qvto
* Same as DeclareAndAssign, with extra operation applied to source object
*/
def DeclareAndAssign2(GenClass it, String assignee, String src, GenClass srcMetaClass, GenFeature srcFeature, String srcExt, boolean needCast) //
- '''«getQualifiedInterfaceName(it)» «assignee» = «IF needCast»(«getQualifiedInterfaceName(it)») «ENDIF»«getFeatureValue(srcFeature, src, srcMetaClass)».«srcExt»;'''
+ '''«getQualifiedInterfaceName(it)» «assignee» = «getFeatureValue(srcFeature, src, srcMetaClass)».«srcExt»;'''
/**
* Cast value of type EObject to specific type. Would be no-op with dynamic model instances,
@@ -193,4 +194,4 @@ import xpt.GenModelUtils_qvto
def dispatch QualifiedClassName(GenClassifier xptSelf) '''«getQualifiedClassName(xptSelf)»'''
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/parsers/PredefinedParser.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/parsers/PredefinedParser.xtend
index 883f8e59099..f41e5e58de2 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/parsers/PredefinedParser.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/parsers/PredefinedParser.xtend
@@ -1,20 +1,24 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal
- *
+/*****************************************************************************
+ * Copyright (c) 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial implementation
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial implementation
* Artem Tikhomirov (Borland) - [235113] alternative parser access
* [244419] custom parsers
* initial API
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 464625
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package parsers
@@ -41,8 +45,8 @@ import plugin.Activator
def fullPath(org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedParser it) '''«qualifiedClassName(it)»'''
def extendsList(org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedParser it) //
- '''extends org.eclipse.gmf.tooling.runtime.parsers.AbstractAttributeParser'''
-
+ '''extends org.eclipse.papyrus.infra.gmfdiag.common.parsers.AbstractElementTypeBasedAttributeParser'''
+
def Main(org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedParser it) '''
«copyright(it.holder.editorGen)»
package «packageName(it)»;
@@ -64,7 +68,48 @@ import plugin.Activator
}
'''
- def additions(org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedParser it) ''''''
+ def additions(org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedParser it) //
+ '''
+ /**
+ * @generated
+ * {@inheritDoc}
+ * @see org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.parsers.AbstractFeatureParser#getModificationCommand(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature, java.lang.Object)
+ */
+ @Override
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getModificationCommand(final org.eclipse.emf.ecore.EObject element, final org.eclipse.emf.ecore.EStructuralFeature feature, final Object value) {
+ org.eclipse.gmf.runtime.common.core.command.ICommand result = null;
+
+ // If the feature to edit is the name, check that this is not really the internationalization to edit and not the name
+ if (feature.equals(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNamedElement_Name())) {
+ if (org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils.getInternationalizationPreference(element) && null != org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization.getInstance().getLabelWithoutUML((org.eclipse.uml2.uml.NamedElement) element)) {
+ final org.eclipse.papyrus.infra.core.resource.ModelSet modelSet = (org.eclipse.papyrus.infra.core.resource.ModelSet) element.eResource().getResourceSet();
+ if (null != modelSet) {
+ result = new org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper(UMLLabelInternationalization.getInstance().getSetLabelCommand(modelSet.getTransactionalEditingDomain(), (org.eclipse.uml2.uml.NamedElement) element, (String) value, null));
+ }
+ }
+ }
+
+ return null != result ? result : super.getModificationCommand(element, feature, value);
+ }
+
+ /**
+ * @generated
+ * {@inheritDoc}
+ * @see org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.parsers.AbstractAttributeParser#getValue(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature)
+ */
+ @Override
+ protected Object getValue(final org.eclipse.emf.ecore.EObject element, final org.eclipse.emf.ecore.EStructuralFeature feature) {
+ Object result = null;
+
+ if(element instanceof org.eclipse.uml2.uml.NamedElement && feature.equals(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNamedElement_Name())){
+ if (org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils.getInternationalizationPreference(element) && null != org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization.getInstance().getLabelWithoutUML((org.eclipse.uml2.uml.NamedElement)element)) {
+ result = UMLLabelInternationalization.getInstance().getLabelWithoutUML((org.eclipse.uml2.uml.NamedElement)element);
+ }
+ }
+
+ return null != result ? result : super.getValue(element, feature);
+ }
+ '''
def fields(org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedParser it) '''
«IF viewMethod == LabelTextAccessMethod::MESSAGE_FORMAT || viewMethod == LabelTextAccessMethod::PRINTF»
@@ -355,4 +400,5 @@ import plugin.Activator
@Localization protected def String i18nKeyForMessageFormatParserInvalidInputError() {
return 'MessageFormatParser.InvalidInputError'
}
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditHelperUtils_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditHelperUtils_qvto.xtend
new file mode 100644
index 00000000000..75999e6ca6c
--- /dev/null
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditHelperUtils_qvto.xtend
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (c) 2014, 2021 CEA LIST, Artal and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Florian Noyrit - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
+package utils
+
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+
+@Singleton class EditHelperUtils_qvto {
+
+ def String getBaseEditHelperFullName(GenDiagram diagram) {
+ // Bug 569174 : from AdditionalEditPartCandies
+ if(diagram.baseEditHelperPackage !== null) {
+ return diagram.baseEditHelperPackage + "." + diagram.baseEditHelperClassName
+ } else {
+ return diagram.getBaseEditHelperQualifiedClassName();
+ }
+
+ }
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditPartsUtils_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditPartsUtils_qvto.xtend
new file mode 100644
index 00000000000..0da798c77dd
--- /dev/null
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/EditPartsUtils_qvto.xtend
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2021 CEA LIST, Artal and others
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Yann Tanguy (CEA LIST) - initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
+package utils
+
+import com.google.inject.Singleton
+import java.util.List
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExternalNodeLabel
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+
+@Singleton class EditPartsUtils_qvto {
+
+ def boolean hasSpecificLocator(GenExternalNodeLabel it) {
+ return locatorClassName !== null
+ }
+
+ def String getSpecificLocator(GenExternalNodeLabel it) {
+ return locatorClassName;
+ }
+
+ def List<GenExternalNodeLabel> getExternalLabelsWithoutSpecificLocator(GenNode it) {
+ return it.labels.filter(typeof(GenExternalNodeLabel)).filter[l|!hasSpecificLocator(l)].toList;
+ }
+
+ def List<GenExternalNodeLabel> getExternalLabelsWithSpecificLocator(GenNode it) {
+ return it.labels.filter(typeof(GenExternalNodeLabel)).filter[l|hasSpecificLocator(l)].toList;
+ }
+
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/PrefsConstant_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/PrefsConstant_qvto.xtend
new file mode 100644
index 00000000000..6c37bc51e1c
--- /dev/null
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/PrefsConstant_qvto.xtend
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * Copyright (c) 2008, 2021 Atos Origin, CEA LIST, Artal and others
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Patrick Tessier(CEA LIST)
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
+package utils
+
+import com.google.inject.Singleton
+
+@Singleton class PrefsConstant_qvto {
+
+
+ def String getDiagramPreferencePageCategory() {
+ return "org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams"
+ }
+
+ def String getPreferenceConstant() {
+ return "_PREF_"
+ }
+
+ def String getPreferenceGradientPolicyConstant(String _element) {
+ return _element + getPreferenceConstant() + "GRADIENT_POLICY"
+ }
+
+ def String getPreferenceGradientColorConstant(String _element) {
+ return _element + getPreferenceConstant() + "GRADIENT_COLOR"
+ }
+
+ def String getPreferenceFillColorConstant(String _element) {
+ return _element + getPreferenceConstant() + "FILL_COLOR"
+ }
+
+ def String getPreferenceFontColorConstant(String _element) {
+ return _element + getPreferenceConstant() + "FONT_COLOR"
+ }
+
+ def String getPreferenceFontConstant(String _element) {
+ return _element + getPreferenceConstant() + "FONT"
+ }
+
+ def String getPreferenceLineColorConstant(String _element) {
+ return _element + getPreferenceConstant() + "LINE_COLOR"
+ }
+
+ def String getPreferenceJumpLinkConstant() {
+ return getPreferenceConstant() + "JUMPLINK_"
+ }
+
+ def String getPreferenceJumpLinkReverseConstant(String _element) {
+ return _element + getPreferenceJumpLinkConstant() + "REVERSE"
+ }
+
+ def String getPreferenceJumpLinkStatusConstant(String _element) {
+ return _element + getPreferenceJumpLinkConstant() + "STATUS"
+ }
+
+ def String getPreferenceJumpLinkTypeConstant(String _element) {
+ return _element + getPreferenceJumpLinkConstant() + "TYPE"
+ }
+
+ def String getPreferenceRoutingConstant() {
+ return getPreferenceConstant() + "ROUTING_"
+ }
+
+ def String getPreferenceRoutingDistancePolicyConstant(String _element) {
+ return _element + getPreferenceRoutingConstant() + "DISTANCE_POLICY"
+ }
+
+ def String getPreferenceRoutingObstructionPolicyConstant(String _element) {
+ return _element + getPreferenceRoutingConstant() + "OBSTRUCTION_POLICY"
+ }
+
+ def String getPreferenceRoutingStyleConstant(String _element) {
+ return _element + getPreferenceRoutingConstant() + "STYLE"
+ }
+
+ def String getPreferenceSmoothnessConstant(String _element) {
+ return _element + getPreferenceConstant() + "SMOOTHNESS"
+ }
+
+ def String getPreferencePageSuffix() {
+ return "PreferencePage"
+ }
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/UtilsItemSemanticEditPolicy.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/UtilsItemSemanticEditPolicy.xtend
new file mode 100644
index 00000000000..e1fc337442f
--- /dev/null
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/utils/UtilsItemSemanticEditPolicy.xtend
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2021 CEA LIST, Artal and others
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
+package utils
+
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeLinkModelFacet
+
+@Singleton class UtilsItemSemanticEditPolicy {
+
+ //Command for the EditPart which use the Delete Service
+ def getDestroyElementCommandByService(GenNode i) '''
+ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ org.eclipse.emf.ecore.EObject selectedEObject = req.getElementToDestroy();
+ org.eclipse.papyrus.infra.services.edit.service.IElementEditService provider =org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(selectedEObject);
+ if(provider != null) {
+ // Retrieve delete command from the Element Edit service
+ org.eclipse.gmf.runtime.common.core.command.ICommand deleteCommand = provider.getEditCommand(req);
+
+ if(deleteCommand != null) {
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(deleteCommand);
+ }
+ }
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ '''
+
+ def getDestroyElementCommandByService(TypeLinkModelFacet it) '''
+ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ org.eclipse.emf.ecore.EObject selectedEObject = req.getElementToDestroy();
+ org.eclipse.papyrus.infra.services.edit.service.IElementEditService provider =org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(selectedEObject);
+ if(provider != null) {
+ // Retrieve delete command from the Element Edit service
+ org.eclipse.gmf.runtime.common.core.command.ICommand deleteCommand = provider.getEditCommand(req);
+
+ if(deleteCommand != null) {
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(deleteCommand);
+ }
+ }
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ '''
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/CodeStyle.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/CodeStyle.xtend
index f80a3b123f5..2586c16bda9 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/CodeStyle.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/CodeStyle.xtend
@@ -1,24 +1,26 @@
-/*******************************************************************************
- * Copyright (c) 2013-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2015, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Michael Golubev (Montages) - initial API and implementation
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Michael Golubev (Montages) - initial API and implementation
+ * Anatoliy Tischenko - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
-@com.google.inject.Singleton class CodeStyle {
+@Singleton class CodeStyle {
@Inject extension GenEditorGenerator_qvto
@Inject extension Common;
/**
@@ -30,12 +32,8 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
«ENDIF»
'''
- def overrideI(GenCommonBase xptSelf) '''
- «IF xptSelf.jdkComplianceLevel() > 5»
- @Override
- «ELSE»
- «extraLineBreak»
- «ENDIF»
+ def overrideI(GenCommonBase xptSelf)'''
+ @Override
'''
/**
@@ -51,4 +49,4 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
@SuppressWarnings(«warnToken»)
«ENDIF»
'''
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/Common.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/Common.xtend
index 8dd6a3fb936..16632b88779 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/Common.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/Common.xtend
@@ -1,37 +1,35 @@
-/*******************************************************************************
- * Copyright (c) 2006-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
-
-
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
-import xpt.editor.VisualIDRegistry
import org.eclipse.papyrus.gmf.internal.common.codegen.Conversions
+import xpt.editor.VisualIDRegistry
/**
* XXX: [MG] I don't like dependency from Common -> VisualIdRegistry
*/
-@com.google.inject.Singleton class Common {
+@Singleton class Common {
def copyright(GenEditorGenerator it)
'''
- «IF copyrightText != null»
- /*
+ «IF copyrightText !== null»
+ /**
* «copyrightText.replaceAll('\n', '\n * ')»
*/
«ENDIF»
@@ -132,5 +130,19 @@ import org.eclipse.papyrus.gmf.internal.common.codegen.Conversions
}
return b.toString;
}
+
+ def String stringVisualID(GenCommonBase it) {
+ if (visualIDOverride !== null)
+ visualIDOverride
+ else
+ visualID.toString
+ }
+
+ def String stringUniqueIdentifier(GenCommonBase it) {
+ if (visualIDOverride !== null)
+ visualIDOverride
+ else
+ it.uniqueIdentifier
+ }
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenEditorGenerator_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenEditorGenerator_qvto.xtend
index 6cd75b3a15f..78277901623 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenEditorGenerator_qvto.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenEditorGenerator_qvto.xtend
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2007, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -7,34 +7,42 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt
-import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
-@com.google.inject.Singleton class GenEditorGenerator_qvto {
- @Inject extension GenModelUtils_qvto;
+@Singleton class GenEditorGenerator_qvto {
/**
* FIXME remove java-only GenEditorGenerator#hasAudits or declare it in metamodel
*/
def boolean hasAudits(GenEditorGenerator editorGen) {
- return editorGen.audits != null && !editorGen.audits.rules.empty
+ return editorGen.audits !== null && !editorGen.audits.rules.empty
}
/**
- * @see GenModelUtils#jdkComplianceLevel
+ * Returns java version number.
+ *
+ * @returns 4 for Java1.4, 5 for JDK 5.0, 6 for JDK6.0 and 7 for JDK7.0, etc.
*/
def int jdkComplianceLevel(GenEditorGenerator xptSelf) {
- //TODO honest field in the GenEditorGenerator instead of hardcoded value
- return xptSelf.diagram.domainDiagramElement.jdkComplianceLevel();
+ var GenJDKLevel l = if (xptSelf === null || xptSelf.jdkComplianceLevel === null)
+ GenJDKLevel::JDK110_LITERAL
+ else
+ xptSelf.jdkComplianceLevel;
+ switch (l) {
+ case GenJDKLevel::JDK14_LITERAL: 4
+ default: Double.valueOf(l.literal).intValue
+ }
}
def int jdkComplianceLevel(GenCommonBase xptSelf) {
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenModelUtils_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenModelUtils_qvto.xtend
index f52b8ee5200..a8b8c3cec12 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenModelUtils_qvto.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/GenModelUtils_qvto.xtend
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006-2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2006-2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,9 +9,9 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt
@@ -19,12 +19,11 @@ import java.util.Set
import org.eclipse.emf.codegen.ecore.genmodel.GenClass
import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier
import org.eclipse.emf.codegen.ecore.genmodel.GenFeature
-import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel
import org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl
import org.eclipse.emf.ecore.EDataType
@com.google.inject.Singleton class GenModelUtils_qvto {
- private static final Set<String> PRIMITIVES = newHashSet('boolean', 'byte', 'char', 'double', 'float', 'int', 'long',
+ static final Set<String> PRIMITIVES = newHashSet('boolean', 'byte', 'char', 'double', 'float', 'int', 'long',
'short');
/**
@@ -90,19 +89,4 @@ import org.eclipse.emf.ecore.EDataType
}
return xptSelf.ecoreClass.isSuperTypeOf(subclassCandidate.ecoreClass)
}
-
- /**
- * @returns 4 for Java1.4, 5 for JDK 5.0, 6 for JDK6.0 and 7 for JDK7.0
- */
- def int jdkComplianceLevel(GenClass xptSelf) {
- var GenJDKLevel l = if (xptSelf == null) GenJDKLevel::JDK60_LITERAL else xptSelf.genPackage.genModel.complianceLevel;
- switch (l) {
- case GenJDKLevel::JDK14_LITERAL: 4
- case GenJDKLevel::JDK50_LITERAL: 5
- case GenJDKLevel::JDK60_LITERAL: 6
- case GenJDKLevel::JDK70_LITERAL: 7
- default: 6
- }
- }
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/QualifiedClassNameProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/QualifiedClassNameProvider.xtend
index 643aa8e535b..271e561326e 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/QualifiedClassNameProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/QualifiedClassNameProvider.xtend
@@ -1,16 +1,17 @@
-/******************************************************************************
- * Copyright (c) 2014, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2015, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Svyatoslav Kovalsky (Montages) - initial API and implementation
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Florian Noyrit - Initial API and implementation
+ * Svyatoslav Kovalsky (Montages) - initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt
@@ -38,10 +39,10 @@ import xpt.diagram.commands.CreateLinkCommand
@Inject CreateNodeCommand nodeCommand
def dispatch getItemSemanticEditPolicyQualifiedClassName(GenCommonBase it) ''''''
- def dispatch getItemSemanticEditPolicyQualifiedClassName(GenDiagram it) '''«diagramItemSemantic.qualifiedClassName(it)»'''
- def dispatch getItemSemanticEditPolicyQualifiedClassName(GenCompartment it) '''«compItemSemantic.qualifiedClassName(it)»'''
- def dispatch getItemSemanticEditPolicyQualifiedClassName(GenLink it) '''«linkItemSemantic.qualifiedClassName(it)»'''
- def dispatch getItemSemanticEditPolicyQualifiedClassName(GenNode it) '''«nodeItemSemantic.qualifiedClassName(it)»'''
+ def dispatch getItemSemanticEditPolicyQualifiedClassName(GenDiagram it)'''org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCompartmentSemanticEditPolicy'''
+ def dispatch getItemSemanticEditPolicyQualifiedClassName(GenCompartment it) '''org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCompartmentSemanticEditPolicy'''
+ def dispatch getItemSemanticEditPolicyQualifiedClassName(GenLink it) '''org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy'''
+ def dispatch getItemSemanticEditPolicyQualifiedClassName(GenNode it) '''org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy'''
def dispatch getItemSemanticEditPolicyClassName(GenCommonBase it) ''''''
def dispatch getItemSemanticEditPolicyClassName(GenDiagram it) '''«diagramItemSemantic.className(it)»'''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateLinkUtils.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateLinkUtils.xtend
index ecdfd5bc0e6..d5e784009dc 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateLinkUtils.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateLinkUtils.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2007-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007-2012, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.commands
@@ -77,23 +77,23 @@ import xpt.diagram.editpolicies.BaseItemSemanticEditPolicy
def dispatch fields(LinkModelFacet it) '''
«extraLineBreak»
«generatedMemberComment()»
- private final org.eclipse.emf.ecore.EObject source;
+ protected final org.eclipse.emf.ecore.EObject source;
«generatedMemberComment()»
- private final org.eclipse.emf.ecore.EObject target;
+ protected final org.eclipse.emf.ecore.EObject target;
'''
def dispatch fields(TypeLinkModelFacet it) '''
«extraLineBreak»
«generatedMemberComment()»
- private final org.eclipse.emf.ecore.EObject source;
+ protected final org.eclipse.emf.ecore.EObject source;
«generatedMemberComment()»
- private final org.eclipse.emf.ecore.EObject target;
+ protected final org.eclipse.emf.ecore.EObject target;
«IF hasContainerOtherThanSource(it)»
«generatedMemberComment()»
- private final «xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» container;
+ protected «xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» container;
«ENDIF»
'''
@@ -117,30 +117,29 @@ import xpt.diagram.editpolicies.BaseItemSemanticEditPolicy
def dispatch containerAccessor(TypeLinkModelFacet it) '''
«IF hasContainerOtherThanSource(it)»
-
- «generatedMemberComment()»
- public «xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» getContainer() {
- return container;
- }
-
- «generatedMemberComment(
- 'Default approach is to traverse ancestors of the source to find instance of container.\n' +
- 'Modify with appropriate logic.'
- )»
- private static «xptMetaModel.QualifiedClassName(it.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 («xptMetaModel.IsInstance(containmentMetaFeature.genClass, 'element')») {
- return «xptMetaModel.CastEObject(it.containmentMetaFeature.genClass, 'element')»;
+
+ «generatedMemberComment()»
+ public «xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» getContainer() {
+ return container;
+ }
+
+ «generatedMemberComment(
+ 'Default approach is to traverse ancestors of the source to find instance of container.\n' + 'Modify with appropriate logic.'
+ )»
+ protected «xptMetaModel.QualifiedClassName(it.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 («xptMetaModel.IsInstance(containmentMetaFeature.genClass, 'element')») {
+ return «xptMetaModel.CastEObject(it.containmentMetaFeature.genClass, 'element')»;
+ }
}
+ return null;
}
- return null;
- }
«ENDIF»
-
-'''
+
+ '''
/**
* Part of the constructor that performs initialization.
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateNodeCommand.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateNodeCommand.xtend
index dfa58a7e825..c322ff92dd8 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateNodeCommand.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/CreateNodeCommand.xtend
@@ -1,31 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.commands
import com.google.inject.Inject
+import com.google.inject.Singleton
import metamodel.MetaModel
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeModelFacet
import xpt.Common
+import xpt.OclMigrationProblems_qvto
import xpt.diagram.Utils_qvto
import xpt.providers.ElementInitializers
-import xpt.OclMigrationProblems_qvto
-@com.google.inject.Singleton class CreateNodeCommand {
+@Singleton class CreateNodeCommand {
@Inject extension Common;
+ @Inject extension MetaModel
@Inject extension Utils_qvto;
@Inject extension OclMigrationProblems_qvto;
@@ -44,8 +46,15 @@ import xpt.OclMigrationProblems_qvto
«copyright(it.diagram.editorGen)»
package «packageName(it)»;
+
+
«generatedClassComment()»
public class «className(it)» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
+
+ «IF ! it.modelFacet.isPhantomElement()»
+ «generatedMemberComment()»
+ private org.eclipse.gmf.runtime.notation.Diagram diagram = null;
+ «ENDIF»
«_constructor(it)»
@@ -61,10 +70,13 @@ import xpt.OclMigrationProblems_qvto
}
'''
- def _constructor(GenNode it) '''
+ def _constructor(GenNode it) '''
«generatedMemberComment()»
- public «className(it)»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+ public «className(it)»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.gmf.runtime.notation.Diagram diagram) {
super(req.getLabel(), null, req);
+ «IF ! it.modelFacet.isPhantomElement()»
+ this.diagram = diagram;
+ «ENDIF»
}
'''
@@ -85,22 +97,32 @@ import xpt.OclMigrationProblems_qvto
def doExecuteWithResultMethod(GenNode it) '''
«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 it.modelFacet.isPhantomElement()»
- «phantomElementCreation(it.modelFacet, it, 'newElement')»
- «ELSE»
- «normalElementCreation(it.modelFacet, it, 'newElement')»
- «ENDIF»
- «extraLineBreak»
- «initialize(it.modelFacet, it, 'newElement')»
- «IF true/*FIXME boolean needsExternalConfiguration*/»
- «extraLineBreak»
- doConfigure(newElement, monitor, info);
+ ««« [AbstractElement] START
+
+ «IF it.modelFacet.metaClass.ecoreClass.abstract != true»
+ ««« [AbstractElement] END
+ «IF it.modelFacet.isPhantomElement()»
+ «phantomElementCreation(it.modelFacet, it, 'newElement')»
+ «ELSE»
+ «normalElementCreation(it.modelFacet, it, 'newElement')»
+ «ENDIF»
«extraLineBreak»
+ «initialize(it.modelFacet, it, 'newElement')»
+ «IF true/*FIXME boolean needsExternalConfiguration*/»
+ «extraLineBreak»
+ doConfigure(newElement, monitor, info);
+ «extraLineBreak»
+ «ENDIF»
+ ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«xptMetaModel.
+ DowncastToEObject(it.modelFacet.metaClass, 'newElement')»);
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement);
+ }
+ ««« [AbstractElement] START
+ «ELSE»
+ throw new UnsupportedOperationException("Unimplemented operation (abstract domain element).");
+ }
«ENDIF»
- ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«xptMetaModel.
- DowncastToEObject(it.modelFacet.metaClass, 'newElement')»);
- return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement);
- }
+ ««« [AbstractElement] END
'''
/**
@@ -136,32 +158,37 @@ import xpt.OclMigrationProblems_qvto
'''
def canExecute_Normal(TypeModelFacet it) '''
-«IF !isUnbounded(it.containmentMetaFeature.ecoreFeature) ||
- (childMetaFeature != containmentMetaFeature && !isUnbounded(it.childMetaFeature.ecoreFeature))»
- «xptMetaModel.DeclareAndAssign(it.containmentMetaFeature.genClass, 'container', 'getElementToEdit()')»
- «IF !isUnbounded(it.containmentMetaFeature.ecoreFeature)»
- «IF isSingleValued(containmentMetaFeature.ecoreFeature)»
- if («xptMetaModel.getFeatureValue(containmentMetaFeature, 'container', containmentMetaFeature.genClass)» != null) {
- «ELSE»
- if («xptMetaModel.getFeatureValue(containmentMetaFeature, 'container', containmentMetaFeature.genClass)».size() >= «containmentMetaFeature.
- ecoreFeature.upperBound») {
+ «IF containmentMetaFeature != null»
+ «IF containmentMetaFeature.ecoreFeature != null»
+ «IF ! isUnbounded(containmentMetaFeature.ecoreFeature) || (childMetaFeature != containmentMetaFeature && ! isUnbounded(childMetaFeature.ecoreFeature))»
+ «IF ! isUnbounded(containmentMetaFeature.ecoreFeature)»
+ «DeclareAndAssign(containmentMetaFeature.genClass,'container', 'getElementToEdit()') »
+ «IF isSingleValued(containmentMetaFeature.ecoreFeature)»
+ if («getFeatureValue(containmentMetaFeature,'container', containmentMetaFeature.genClass) » != null) {
+ «ELSE»
+ if (« getFeatureValue(containmentMetaFeature,'container', containmentMetaFeature.genClass)».size() >= «containmentMetaFeature.ecoreFeature.upperBound») {
+ «ENDIF»
+ return false;
+ }
+ «ENDIF»
+ «IF childMetaFeature != containmentMetaFeature && ! isUnbounded(childMetaFeature.ecoreFeature)»
+ «IF isSingleValued(childMetaFeature.ecoreFeature)»
+ if («getFeatureValue(childMetaFeature,'container', containmentMetaFeature.genClass) » != null) {
+ «ELSE»
+ if («getFeatureValue(childMetaFeature,'container', containmentMetaFeature.genClass) ».size() >= «childMetaFeature.ecoreFeature.upperBound») {
+ «ENDIF»
+ return false;
+ }
+ «ENDIF»
+ «ENDIF»
«ENDIF»
- return false;
- }
- «ENDIF»
- «IF childMetaFeature != containmentMetaFeature && !isUnbounded(childMetaFeature.ecoreFeature)»
- «IF isSingleValued(childMetaFeature.ecoreFeature)»
- if («xptMetaModel.getFeatureValue(childMetaFeature, 'container', containmentMetaFeature.genClass)» != null) {
- «ELSE»
- if («xptMetaModel.getFeatureValue(childMetaFeature, 'container', containmentMetaFeature.genClass)».size() >= «childMetaFeature.
- ecoreFeature.upperBound») {
- «ENDIF»
- return false;
- }
«ENDIF»
-«ENDIF»
- return true;
-'''
+
+ org.eclipse.emf.ecore.EObject target = getElementToEdit();
+ org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData data = org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker.getFor(target).getChildAddData(diagram, target.eClass(), «MetaClass(metaClass)»);
+ return data.isPermitted();
+
+ '''
def phantomElementCreation(TypeModelFacet it, GenNode node, String varName) '''
// Uncomment to put "phantom" objects into the diagram file.
@@ -177,15 +204,30 @@ import xpt.OclMigrationProblems_qvto
def normalElementCreation(TypeModelFacet it, GenNode node, String varName) '''
«xptMetaModel.NewInstance(it.metaClass, varName)»
+
+ org.eclipse.emf.ecore.EObject target = getElementToEdit();
+ org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData data = org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker.getFor(target).getChildAddData(diagram, target, «varName»);
+ if (data.isPermitted()) {
+ if (data.isPathDefined()) {
+ if (!data.execute(target, «varName»)) {
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ }
+ } else {
«extraLineBreak»
«IF containmentMetaFeature != null»
- «xptMetaModel.DeclareAndAssign(it.containmentMetaFeature.genClass, 'owner', 'getElementToEdit()')»
- «xptMetaModel.modifyFeature(containmentMetaFeature, 'owner', containmentMetaFeature.genClass, varName)»
+ «xptMetaModel.DeclareAndAssign(it.containmentMetaFeature.genClass, 'qualifiedTarget', 'target')»
+ «xptMetaModel.modifyFeature(containmentMetaFeature, 'qualifiedTarget', containmentMetaFeature.genClass, varName)»
«ELSE»
//
// FIXME no containment feature found in the genmodel, toolsmith need to manually write code here to add «varName» to a parent
//
«ENDIF»
+
+ }
+ } else {
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
+
«IF hasExplicitChildFeature(it)»
«xptMetaModel.DeclareAndAssign(it.childMetaFeature.genClass, 'childHolder', 'getElementToEdit()')»
«xptMetaModel.modifyFeature(it.childMetaFeature, 'childHolder', childMetaFeature.genClass, varName)»
@@ -196,5 +238,4 @@ import xpt.OclMigrationProblems_qvto
'''«xptElementInitializers.initMethodCall(node, it, newElementVar)»'''
def additions(GenNode it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/ReorientLinkUtils.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/ReorientLinkUtils.xtend
index 513ea835dd6..5e4d60c6065 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/ReorientLinkUtils.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/commands/ReorientLinkUtils.xtend
@@ -1,17 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007-2015, 2021 Borland Software Corporation, Montages, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+* Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Anatolyi Tischenko - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.commands
@@ -102,10 +103,10 @@ import xpt.diagram.editpolicies.BaseItemSemanticEditPolicy
«generatedMemberComment()»
public boolean canExecute() {
«checkLinkValidity(it)»
- if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_SOURCE) {
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest.REORIENT_SOURCE) {
return canReorientSource();
}
- if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_TARGET) {
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest.REORIENT_TARGET) {
return canReorientTarget();
}
return false;
@@ -215,10 +216,10 @@ import xpt.diagram.editpolicies.BaseItemSemanticEditPolicy
if (!canExecute()) {
throw new org.eclipse.core.commands.ExecutionException("Invalid arguments in reorient link command"); «nonNLS()»
}
- if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_SOURCE) {
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest.REORIENT_SOURCE) {
return reorientSource();
}
- if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest.REORIENT_TARGET) {
+ if (reorientDirection == org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest.REORIENT_TARGET) {
return reorientTarget();
}
throw new IllegalStateException();
@@ -307,4 +308,4 @@ import xpt.diagram.editpolicies.BaseItemSemanticEditPolicy
«xptMetaModel.moveFeatureValue(it, oldSourceVar, newSourceVar, sourceVarGenClass, targetVar)»
'''
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/BaseEditHelper.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/BaseEditHelper.xtend
index da08d84f74f..0e18f309471 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/BaseEditHelper.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/BaseEditHelper.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2006, 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #368169 - extract common code to GMFT-specific runtime
- * - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #368169 - extract common code to GMFT-specific runtime
+ * - #386838 - migrate to Xtend2
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.edithelpers;
@@ -25,7 +26,7 @@ public class BaseEditHelper {
def extendsClause(GenDiagram it) '''extends «superClass(it)»'''
- def superClass(GenDiagram it) '''org.eclipse.gmf.tooling.runtime.edit.helpers.GeneratedEditHelperBase'''
+ def superClass(GenDiagram it) '''org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.helpers.GeneratedEditHelperBase'''
def className(GenDiagram it) '''«it.baseEditHelperClassName»'''
@@ -60,9 +61,9 @@ public class BaseEditHelper {
}
'''
- def editPolicyCommandConstant(GenDiagram it) '''org.eclipse.gmf.tooling.runtime.edit.helpers.GeneratedEditHelperBase.EDIT_POLICY_COMMAND'''
+ def editPolicyCommandConstant(GenDiagram it) '''org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.helpers.GeneratedEditHelperBase.EDIT_POLICY_COMMAND'''
- def contextElementTypeConstant(GenDiagram it) '''org.eclipse.gmf.tooling.runtime.edit.helpers.GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE'''
+ def contextElementTypeConstant(GenDiagram it) '''org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.helpers.GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE'''
def attributes(GenDiagram it) ''''''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/EditHelper.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/EditHelper.xtend
index e1bc9cc03a8..7cc77d81942 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/EditHelper.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/edithelpers/EditHelper.xtend
@@ -1,27 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2006-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.edithelpers;
import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.MetamodelType
import xpt.Common
+import utils.EditHelperUtils_qvto
public class EditHelper {
@Inject extension Common;
- @Inject BaseEditHelper xptBaseEditHelper;
+ @Inject extension EditHelperUtils_qvto
def className(MetamodelType it) '''«it.editHelperClassName»'''
@@ -36,10 +37,11 @@ public class EditHelper {
package «packageName(it)»;
«generatedClassComment»
- public class «className(it)» extends «xptBaseEditHelper.qualifiedClassName(it.diagramElement.diagram)» {
+ public class «editHelperClassName» extends «getBaseEditHelperFullName(diagramElement.getDiagram())» {
«additions(it)»
}
'''
def additions(MetamodelType it) ''''''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/Common.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/Common.xtend
index 604848ca3fa..c3d75b8d732 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/Common.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/Common.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2021 Borland Software Corporation, CEA LIST, Artal and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Patrick Tessier (CEA LIST)
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editparts
@@ -33,19 +33,19 @@ import impl.diagram.editparts.viewmaps.modeledViewmapProducer
import org.eclipse.emf.ecore.EObject
import org.eclipse.papyrus.gmf.gmfgraph.Label
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenContainerBase
-import xpt.editor.VisualIDRegistry
+import xpt.QualifiedClassNameProvider
@com.google.inject.Singleton class Common {
@Inject extension xpt.Common;
@Inject extension Common_qvto;
+ @Inject QualifiedClassNameProvider qualifiedClassNameProvider;
@Inject TextAware xptTextAware;
@Inject modeledViewmapProducer xptModeledViewmapProducer;
- @Inject VisualIDRegistry xptVisualIDRegistry;
def visualIDConstant(GenCommonBase it) '''
«generatedMemberComment»
- public static final int VISUAL_ID = «visualID»;
+ public static final String VISUAL_ID = "«stringVisualID»";
'''
def behaviour(GenCommonBase it) '''
@@ -202,21 +202,25 @@ import xpt.editor.VisualIDRegistry
«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()»());
+ installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE, new «qualifiedClassNameProvider.getItemSemanticEditPolicyQualifiedClassName(it)»());
«ENDIF»
'''
def installCanonicalEditPolicy(GenContainerBase it) '''
«IF it.needsCanonicalEditPolicy»
- installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new «getCanonicalEditPolicyQualifiedClassName()»());
+ ««« BEGIN: PapyrusGenCode
+ ««« Used to remove at each time canonical editpolicies
+ //in Papyrus diagrams are not strongly synchronised
+ //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new «getCanonicalEditPolicyQualifiedClassName()»());
+ ««« END: PapyrusGenCode
+
«ENDIF»
'''
-
def installCreationEditPolicy(GenCommonBase it) '''
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, «creationEditPolicyNewInstance»);
'''
def creationEditPolicyNewInstance(GenCommonBase it)
- '''new org.eclipse.gmf.tooling.runtime.edit.policies.reparent.CreationEditPolicyWithCustomReparent(«xptVisualIDRegistry.runtimeTypedInstanceCall(it.diagram)»)'''
+ '''new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy()'''
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/EditPartFactory.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/EditPartFactory.xtend
index 4b85259cec7..38c8ef8e7a5 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/EditPartFactory.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editparts/EditPartFactory.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editparts
@@ -119,10 +119,51 @@ import diagram.editparts.DiagramEditPart
'''
def getTextCellEditorLocator(GenDiagram it) '''
- «generatedMemberComment()»
+ «generatedMemberComment»
public static org.eclipse.gef.tools.CellEditorLocator getTextCellEditorLocator(
org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart source) {
- return org.eclipse.gmf.tooling.runtime.directedit.locator.CellEditorLocatorAccess.INSTANCE.getTextCellEditorLocator(source);
+ if (source.getFigure() instanceof org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure){
+ return new MultilineCellEditorLocator(
+ (org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure) source.getFigure());
+ }
+ else {
+ return org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.directedit.locator.CellEditorLocatorAccess.INSTANCE.getTextCellEditorLocator(source);
+
+ }
+ }
+
+
+ «generatedClassComment»
+ static private class MultilineCellEditorLocator implements org.eclipse.gef.tools.CellEditorLocator {
+
+ «generatedClassComment»
+ private org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure multilineEditableFigure;
+
+ «generatedClassComment»
+ public MultilineCellEditorLocator(org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure figure) {
+ this.multilineEditableFigure = figure;
+ }
+
+ «generatedClassComment»
+ public org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure getMultilineEditableFigure() {
+ return multilineEditableFigure;
+ }
+
+ «generatedClassComment»
+ 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 = getMultilineEditableFigure().getBounds().getCopy();
+ rect.x=getMultilineEditableFigure().getEditionLocation().x;
+ rect.y=getMultilineEditableFigure().getEditionLocation().y;
+ getMultilineEditableFigure().translateToAbsolute(rect);
+ if (getMultilineEditableFigure().getText().length() > 0) {
+ rect.setSize(new org.eclipse.draw2d.geometry.Dimension(text.computeSize(rect.width,
+ org.eclipse.swt.SWT.DEFAULT)));
+ }
+ if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
}
'''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
index f9100d7308a..6209b843611 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
@@ -1,17 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2014, 2021 Borland Software Corporation, Christian W. Damus, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
+ * https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Christian W. Damus - bug 451230
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
@@ -42,19 +43,20 @@ import xpt.QualifiedClassNameProvider
@com.google.inject.Singleton class BaseItemSemanticEditPolicy {
@Inject extension Common;
+ @Inject extension VisualIDRegistry
+
@Inject extension Common_qvto;
@Inject extension xpt.diagram.Utils_qvto;
@Inject extension OclMigrationProblems_qvto;
@Inject extension Utils_qvto;
@Inject extension QualifiedClassNameProvider;
-
+
@Inject BaseEditHelper xptBaseEditHelper;
@Inject Activator xptPluginActivator;
@Inject MetaModel xptMetaModel;
@Inject getExpression xptGetExpression;
- @Inject VisualIDRegistry xptVisualIDRegistry;
@Inject ElementTypes xptElementTypes;
-
+
def className(GenDiagram it) '''«it.baseItemSemanticEditPolicyClassName»'''
def packageName(GenDiagram it) '''«it.getDiagram().editPoliciesPackageName»'''
@@ -63,7 +65,7 @@ import xpt.QualifiedClassNameProvider
def fullPath(GenDiagram it) '''«qualifiedClassName(it)»'''
-def BaseItemSemanticEditPolicy(GenDiagram it) '''
+ def BaseItemSemanticEditPolicy(GenDiagram it) '''
«copyright(editorGen)»
package «packageName(it)»;
@@ -75,27 +77,25 @@ public class «className(it)» extends org.eclipse.gmf.runtime.diagram.ui.editpo
«constructor(it)»
«generatedMemberComment(
- 'Extended request data key to hold editpart visual id.\n' +
- 'Add visual id of edited editpart to extended data of the request\n' +
- 'so command switch can decide what kind of diagram element is being edited.\n' +
- 'It is done in those cases when it\'s not possible to deduce diagram\n' +
- 'element kind from domain element.\n'
+ 'Extended request data key to hold editpart visual id.\n' + 'Add visual id of edited editpart to extended data of the request\n' + 'so command switch can decide what kind of diagram element is being edited.\n' + 'It is done in those cases when it\'s not possible to deduce diagram\n' + 'element kind from domain element.\n' + 'Add the reoriented view to the request extended data so that the view\n ' + 'currently edited can be distinguished from other views of the same element\n ' +
+ 'and these latter possibly removed if they become inconsistent after reconnect\n'
+ @SuppressWarnings("unchecked")
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(«xptVisualIDRegistry.getVisualIDMethodCall(it)»((org.eclipse.gmf.runtime.notation.View) view));
+ String id = «getVisualIDMethodCall(it)»((org.eclipse.gmf.runtime.notation.View) view);
request.getExtendedData().put(VISUAL_ID_KEY, id);
+ request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, view);
}
}
return super.getCommand(request);
}
«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;
+ protected String getVisualID(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ return (String) request.getParameter(VISUAL_ID_KEY);
}
«semanticPart(it)»
@@ -107,7 +107,7 @@ public class «className(it)» extends org.eclipse.gmf.runtime.diagram.ui.editpo
«addDestroyShortcutsCommand(it)»
-«IF links.exists(link | !link.sansDomain)»
+«IF links.exists(link|!link.sansDomain)»
«linkConstraints(it)»
«ENDIF»
@@ -115,102 +115,105 @@ public class «className(it)» extends org.eclipse.gmf.runtime.diagram.ui.editpo
}
'''
-def attributes(GenDiagram it) '''
- «generatedMemberComment('Extended request data key to hold editpart visual id.')»
- public static final String VISUAL_ID_KEY = "visual_id"; «nonNLS()»
-
- «generatedMemberComment()»
- private final org.eclipse.gmf.runtime.emf.type.core.IElementType myElementType;
-'''
+ def attributes(GenDiagram it) '''
+ «generatedMemberComment('Extended request data key to hold editpart visual id.')»
+ public static final String VISUAL_ID_KEY = "visual_id"; «nonNLS()»
+ «generatedMemberComment('Extended request data key to hold the edge view during a reconnect request.')»
+ public static final String GRAPHICAL_RECONNECTED_EDGE = "graphical_edge"; «nonNLS»
+ «generatedMemberComment()»
+ private final org.eclipse.gmf.runtime.emf.type.core.IElementType myElementType;
+ '''
-def constructor(GenDiagram it) '''
- «generatedMemberComment()»
- protected «className(it)»(org.eclipse.gmf.runtime.emf.type.core.IElementType elementType) {
- myElementType = elementType;
- }
-'''
+ def constructor(GenDiagram it) '''
+ «generatedMemberComment()»
+ protected «className(it)»(org.eclipse.gmf.runtime.emf.type.core.IElementType elementType) {
+ myElementType = elementType;
+ }
+ '''
-def addDestroyShortcutsCommand(GenDiagram it) '''
- «generatedMemberComment('Clean all shortcuts to the host element from the same diagram')»
- protected void addDestroyShortcutsCommand(org.eclipse.gmf.runtime.common.core.command.ICompositeCommand cmd, org.eclipse.gmf.runtime.notation.View view) {
- «_assert('view.getEAnnotation(\"Shortcut\") == null')»
- 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()) { «nonNLS()»
- continue;
+ def addDestroyShortcutsCommand(GenDiagram it) '''
+ «generatedMemberComment('Clean all shortcuts to the host element from the same diagram')»
+ protected void addDestroyShortcutsCommand(org.eclipse.gmf.runtime.common.core.command.ICompositeCommand cmd, org.eclipse.gmf.runtime.notation.View view) {
+ «_assert('view.getEAnnotation(\"Shortcut\") == null')»
+ 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()) { «nonNLS()»
+ continue;
+ }
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), nextView));
}
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), nextView));
}
- }
-'''
-
-def semanticPart(GenDiagram it) '''
- «getSemanticCommand(it)»
-
- «addDeleteViewCommand(it)»
-
- «getEditHelperCommand(it)»
-
- «getContextElementType(it)»
-
- «getSemanticCommandSwitch(it)»
-
- «getConfigureCommand(it)»
-
- «getCreateRelationshipCommand(it)»
-
- «getCreateCommand(it)»
-
- «getSetCommand(it)»
-
- «getEditContextCommand(it)»
-
- «getDestroyElementCommand(it)»
-
- «getDestroyReferenceCommand(it)»
-
- «getDuplicateCommand(it)»
-
- «getMoveCommand(it)»
-
- «getReorientReferenceRelationshipCommand(it)»
+ '''
- «getReorientRelationshipCommand(it)»
-
- «getGEFWrapper(it)»
-'''
+ def semanticPart(GenDiagram it) '''
+ «getSemanticCommand(it)»
+
+ «addDeleteViewCommand(it)»
+
+ «getEditHelperCommand(it)»
+
+ «getContextElementType(it)»
+
+ «getSemanticCommandSwitch(it)»
+
+ «getConfigureCommand(it)»
+
+ «getCreateRelationshipCommand(it)»
+
+ «getCreateCommand(it)»
+
+ «getCreateSemanticServiceEditCommand(it)»
+
+ «getSetCommand(it)»
+
+ «getEditContextCommand(it)»
+
+ «getDestroyElementCommand(it)»
+
+ «getDestroyReferenceCommand(it)»
+
+ «getDuplicateCommand(it)»
+
+ «getMoveCommand(it)»
+
+ «getReorientReferenceRelationshipCommand(it)»
+
+ «getReorientRelationshipCommand(it)»
+
+ «getGEFWrapper(it)»
+ '''
-def getEditHelperCommand(GenDiagram it) '''
- «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(«xptBaseEditHelper.editPolicyCommandConstant(it)», command);
- }
- org.eclipse.gmf.runtime.emf.type.core.IElementType requestContextElementType = getContextElementType(request);
- request.setParameter(«xptBaseEditHelper.contextElementTypeConstant(it)», requestContextElementType);
- org.eclipse.gmf.runtime.common.core.command.ICommand command = requestContextElementType.getEditCommand(request);
- request.setParameter(«xptBaseEditHelper.editPolicyCommandConstant(it)», null);
- request.setParameter(«xptBaseEditHelper.contextElementTypeConstant(it)», null);
- if (command != null) {
- if (!(command instanceof org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)) {
- command = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), command.getLabel()).compose(command);
+ def getEditHelperCommand(GenDiagram it) '''
+ «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(«xptBaseEditHelper.editPolicyCommandConstant(it)», command);
}
- return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestContextElementType = getContextElementType(request);
+ request.setParameter(«xptBaseEditHelper.contextElementTypeConstant(it)», requestContextElementType);
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = requestContextElementType.getEditCommand(request);
+ request.setParameter(«xptBaseEditHelper.editPolicyCommandConstant(it)», null);
+ request.setParameter(«xptBaseEditHelper.contextElementTypeConstant(it)», null);
+ if (command != null) {
+ if (!(command instanceof org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)) {
+ command = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), command.getLabel()).compose(command);
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ }
+ return editPolicyCommand;
}
- return editPolicyCommand;
- }
-'''
+ '''
-def getContextElementType(GenDiagram it) '''
- «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 = «xptElementTypes.qualifiedClassName(it)».getElementType(getVisualID(request));
- return requestContextElementType != null ? requestContextElementType : myElementType;
- }
-'''
+ def getContextElementType(GenDiagram it) '''
+ «generatedMemberComment()»
+ protected 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 = «xptElementTypes.qualifiedClassName(it)».getElementType(getVisualID(request));
+ return requestContextElementType != null ? requestContextElementType : myElementType;
+ }
+ '''
-def getSemanticCommand(GenDiagram it) '''
+ def getSemanticCommand(GenDiagram it) '''
«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);
@@ -224,7 +227,7 @@ protected org.eclipse.gef.commands.Command getSemanticCommand(org.eclipse.gmf.ru
}
'''
-def addDeleteViewCommand(GenDiagram it) '''
+ def addDeleteViewCommand(GenDiagram it) '''
«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.gef.commands.Command deleteViewCommand = getGEFWrapper(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), (org.eclipse.gmf.runtime.notation.View) getHost().getModel()));
@@ -232,7 +235,7 @@ protected org.eclipse.gef.commands.Command addDeleteViewCommand(org.eclipse.gef.
}
'''
-def getSemanticCommandSwitch(GenDiagram it) '''
+ def getSemanticCommandSwitch(GenDiagram it) '''
«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) {
@@ -262,95 +265,142 @@ protected org.eclipse.gef.commands.Command getSemanticCommandSwitch(org.eclipse.
}
'''
-def getConfigureCommand(GenDiagram it) '''
+ def getConfigureCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest req) {
return null;
}
'''
-def getCreateRelationshipCommand(GenDiagram it) '''
+ def getCreateRelationshipCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ «IF !usingElementTypeCreationCommand»
return null;
+ «ELSE»
+ org.eclipse.papyrus.infra.services.edit.service.IElementEditService commandService = org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)getHost()).resolveSemanticElement());
+ if(req.getElementType() != null) {
+ commandService = org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(req.getElementType(), req.getClientContext());
+ }
+
+ if(commandService == null) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+
+ org.eclipse.gmf.runtime.common.core.command.ICommand semanticCommand = commandService.getEditCommand(req);
+
+ if((semanticCommand != null) && (semanticCommand.canExecute())) {
+ return getGEFWrapper(semanticCommand);
+ }
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ «ENDIF»
}
'''
-def getCreateCommand(GenDiagram it) '''
+ def getCreateCommand(GenDiagram it) '''
«generatedMemberComment()»
-protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
- return null;
-}
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestElementType = req.getElementType();
+ if (requestElementType instanceof org.eclipse.gmf.runtime.emf.type.core.IElementType) {
+ org.eclipse.papyrus.infra.services.edit.service.IElementEditService commandProvider = org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(req.getContainer());
+ if (commandProvider != null) {
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = commandProvider.getEditCommand(req);
+ if (command != null && command.canExecute()) {
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ }
+ }
+ }
+ return null;
+ }
'''
-def getSetCommand(GenDiagram it) '''
+ def getSetCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest req) {
return null;
}
'''
-def getEditContextCommand(GenDiagram it) '''
+ def getEditContextCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getEditContextCommand(org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest req) {
return null;
}
'''
-def getDestroyElementCommand(GenDiagram it) '''
+ def getDestroyElementCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
return null;
}
'''
-def getDestroyReferenceCommand(GenDiagram it) '''
+ def getDestroyReferenceCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
return null;
}
'''
-def getDuplicateCommand(GenDiagram it) '''
+ def getDuplicateCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getDuplicateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest req) {
return null;
}
'''
-def getMoveCommand(GenDiagram it) '''
+ def getMoveCommand(GenDiagram it) '''
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getMoveCommand(org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest req) {
- return null;
+ ««« BEGIN: PapyrusGenCode
+ ««« add move command
+ org.eclipse.emf.ecore.EObject targetCEObject = req.getTargetContainer();
+ if(targetCEObject != null) {
+ org.eclipse.papyrus.infra.services.edit.service.IElementEditService provider = org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(targetCEObject);
+ if(provider != null) {
+ org.eclipse.gmf.runtime.common.core.command.ICommand moveCommand = provider.getEditCommand(req);
+ if(moveCommand != null) {
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(moveCommand);
+ }
+ }
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ } else {
+ return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand(req));
+ }
+ ««« END: PapyrusGenCode
+
}
'''
-def getReorientReferenceRelationshipCommand(GenDiagram it) '''
+ def getReorientReferenceRelationshipCommand(GenDiagram it) '''
«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;
}
'''
-def getReorientRelationshipCommand(GenDiagram it) '''
+ def getReorientRelationshipCommand(GenDiagram it) '''
«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;
}
'''
-def getGEFWrapper(GenDiagram it) '''
- «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);
- }
-'''
+ def getGEFWrapper(GenDiagram it) '''
+ «generatedMemberComment()»
+ protected final org.eclipse.gef.commands.Command getGEFWrapper(org.eclipse.gmf.runtime.common.core.command.ICommand cmd) {
+ return (cmd == null) ? org.eclipse.gef.commands.UnexecutableCommand.INSTANCE : new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(cmd);
+ }
+ '''
-/**
+ /**
* 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
+ *
+ * [Papyrus Quick Fix] Do not generate field when the expression is provided
+ * by a GenJavaExpressionProvider.
*/
-def linkConstraints(GenDiagram it) '''
+ def linkConstraints(GenDiagram it) '''
«generatedMemberComment()»
public static «getLinkCreationConstraintsClassName()» getLinkConstraints() {
@@ -364,8 +414,8 @@ def linkConstraints(GenDiagram it) '''
«generatedClassComment()»
public static class «getLinkCreationConstraintsClassName()» {
- «generatedMemberComment()»
- «getLinkCreationConstraintsClassName()»() {«/*package-local for the BaseItemSemanticEditPolicy to instantiate. Perhaps, protected is better (i.e. if someone subclasses it?)*/»
+ «generatedMemberComment»
+ public «getLinkCreationConstraintsClassName()»() {«««package-local for the BaseItemSemanticEditPolicy to instantiate. Perhaps, protected is better (i.e. if someone subclasses it?)
// use static method #getLinkConstraints() to access instance
}
@@ -379,90 +429,115 @@ public static class «getLinkCreationConstraintsClassName()» {
}
'''
-def canCreate(GenLink it) '''
+ def canCreate(GenLink it) '''
«generatedMemberComment()»
-public boolean canCreate«getUniqueIdentifier()»(«canCreateParameters(it.modelFacet)») {
+public boolean canCreate«stringUniqueIdentifier()»(
+«IF !it.sansDomain»
+«canCreateParameters(it.modelFacet)»
+«ENDIF»
+) {
+ «IF !it.sansDomain»
«checkEMFConstraints(it.modelFacet)»
- return canExist«getUniqueIdentifier()»(«canCreateValues(it.modelFacet)»);
+ «ENDIF»
+ return canExist«stringUniqueIdentifier()»(
+ «IF !it.sansDomain»
+ «canCreateValues(it.modelFacet)»
+ «ENDIF»
+ );
}
-
'''
-/**
- * XXX for now, both constraints are injected into single method
- * which may not 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.
-*/
-def canExist(GenLink it) '''
- «generatedMemberComment()»
- public boolean canExist«getUniqueIdentifier()»(«canExistParameters(it.modelFacet)») {
- «IF creationConstraints != null && creationConstraints.isValid() && it.diagram.editorGen.expressionProviders != null»
- try {
- «IF creationConstraints.sourceEnd != null»
- «checkAdditionalConstraint(creationConstraints.sourceEnd.provider, creationConstraints.sourceEnd, 'source', 'target', creationConstraints.getSourceEndContextClass(), creationConstraints.getTargetEndContextClass())»
- «ENDIF»
- «IF creationConstraints.targetEnd != null»
- «checkAdditionalConstraint(creationConstraints.targetEnd.provider, creationConstraints.targetEnd, 'target', 'source', creationConstraints.getTargetEndContextClass(), creationConstraints.getSourceEndContextClass())»
- «ENDIF»
+ /**
+ * XXX for now, both constraints are injected into single method
+ * which may not 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.
+ */
+ def canExist(GenLink it) '''
+ «generatedMemberComment()»
+ public boolean canExist«stringUniqueIdentifier()»(
+ «IF !it.sansDomain»
+ «canExistParameters(it.modelFacet)»
+ «ENDIF»
+ ) {
+ «IF creationConstraints != null && creationConstraints.isValid() && it.diagram.editorGen.expressionProviders != null»
+ try {
+ «IF creationConstraints.sourceEnd != null»
+ «checkAdditionalConstraint(creationConstraints.sourceEnd.provider, creationConstraints.sourceEnd, 'source', 'target', creationConstraints.getSourceEndContextClass(), creationConstraints.getTargetEndContextClass())»
+ «ENDIF»
+ «IF creationConstraints.targetEnd != null»
+ «checkAdditionalConstraint(creationConstraints.targetEnd.provider, creationConstraints.targetEnd, 'target', 'source', creationConstraints.getTargetEndContextClass(), creationConstraints.getSourceEndContextClass())»
+ «ENDIF»
+ return true;
+ } catch(Exception e) {
+ «xptPluginActivator.instanceAccess(it.diagram.editorGen)».logError("Link constraint evaluation error", e); «nonNLS()»
+ return false;
+ }
+ «ELSE»
return true;
- } catch(Exception e) {
- «xptPluginActivator.instanceAccess(it.diagram.editorGen)».logError("Link constraint evaluation error", e); «nonNLS()»
- return false;
+ «ENDIF»
}
- «ELSE»
- return true;
- «ENDIF»
- }
-'''
+ '''
-/**
- * FIXME XXX mark as private (_) and move to impl::<find proper place>::LinkConstraints.xpt
- */
-def dispatch canCreateParameters(LinkModelFacet it) '''«sourceTargetParameters(it)»'''// source and target are reasonable defaults
-def dispatch canCreateParameters(TypeLinkModelFacet it) '''«IF hasContainerOtherThanSource(it)»«xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» container, «ENDIF»«sourceTargetParameters(it)»'''
+ /**
+ * FIXME XXX mark as private (_) and move to impl::<find proper place>::LinkConstraints.xpt
+ */
+ def dispatch canCreateParameters(LinkModelFacet it) '''«sourceTargetParameters(it)»''' // source and target are reasonable defaults
+
+ def dispatch canCreateParameters(
+ TypeLinkModelFacet it) '''«IF hasContainerOtherThanSource(it)»«xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» container, «ENDIF»«sourceTargetParameters(it)»'''
-def dispatch canExistParameters(LinkModelFacet it) '''«sourceTargetParameters(it)»'''// source and target are reasonable defaults
-def dispatch canExistParameters(TypeLinkModelFacet it) '''«IF hasContainerOtherThanSource(it)»«xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» container, «ENDIF»«xptMetaModel.QualifiedClassName(metaClass)» linkInstance, «sourceTargetParameters(it)»'''
+ def dispatch canExistParameters(LinkModelFacet it) '''«sourceTargetParameters(it)»''' // source and target are reasonable defaults
-def sourceTargetParameters(LinkModelFacet it) '''«xptMetaModel.QualifiedClassName(it.sourceType)» source, «xptMetaModel.QualifiedClassName(it.targetType)» target'''
+ def dispatch canExistParameters(
+ TypeLinkModelFacet it) '''«IF hasContainerOtherThanSource(it)»«xptMetaModel.QualifiedClassName(it.containmentMetaFeature.genClass)» container, «ENDIF»«xptMetaModel.QualifiedClassName(metaClass)» linkInstance, «sourceTargetParameters(it)»'''
+
+ def sourceTargetParameters(
+ LinkModelFacet it) '''«xptMetaModel.QualifiedClassName(it.sourceType)» source, «xptMetaModel.QualifiedClassName(it.targetType)» target'''
// these are in fact 'canExist' values
-def dispatch canCreateValues(LinkModelFacet it) '''source, target''' // defaults
-def dispatch canCreateValues(TypeLinkModelFacet it) '''«IF hasContainerOtherThanSource(it)»container, «ENDIF»null, source, target'''
+ def dispatch canCreateValues(LinkModelFacet it) '''source, target''' // defaults
+ def dispatch canCreateValues(
+ TypeLinkModelFacet it) '''«IF hasContainerOtherThanSource(it)»container, «ENDIF»null, source, target'''
-def dispatch checkEMFConstraints(LinkModelFacet it) '''«ERROR('Unrecognized link model facet in checkEMFConstraints: ' + it)»'''
+ def dispatch checkEMFConstraints(
+ LinkModelFacet it) '''«ERROR('Unrecognized link model facet in checkEMFConstraints: ' + it)»'''
-/**
- * [MG] extracted from LET statement, @see checkEMFConstraints(TypeLinkModelFacet)
- */
-private def checkChildFeatureBounds(TypeLinkModelFacet it) {
- childMetaFeature != containmentMetaFeature && !isUnbounded(childMetaFeature.ecoreFeature)
-}
+ /**
+ * [MG] extracted from LET statement, @see checkEMFConstraints(TypeLinkModelFacet)
+ */
+ private def checkChildFeatureBounds(TypeLinkModelFacet it) {
+ childMetaFeature != containmentMetaFeature && !isUnbounded(childMetaFeature.ecoreFeature)
+ }
+
-def dispatch checkEMFConstraints(TypeLinkModelFacet it) '''
- «IF !isUnbounded(containmentMetaFeature.ecoreFeature) || checkChildFeatureBounds(it)»
-if («getContainerVariable(it)» != null) {
- «checkEMFConstraints(it.containmentMetaFeature, it)»
- «IF checkChildFeatureBounds(it)»
- «checkEMFConstraints(it.childMetaFeature, it)»
+ def dispatch checkEMFConstraints(TypeLinkModelFacet it) '''
+«IF containmentMetaFeature.ecoreFeature != null»
+ «IF ! isUnbounded(containmentMetaFeature.ecoreFeature) || checkChildFeatureBounds(it)»
+ if («getContainerVariable(it)» != null) {
+ «checkEMFConstraints(containmentMetaFeature, it)»
+ «IF checkChildFeatureBounds(it)»
+ «checkEMFConstraints(childMetaFeature, it)»
+ «ENDIF»
+ }
«ENDIF»
-}
- «ENDIF»
+«ENDIF»
'''
-def checkEMFConstraints(GenFeature it, TypeLinkModelFacet modelFacet) '''
-«IF !isUnbounded(it.ecoreFeature)»
+ def checkEMFConstraints(GenFeature it, TypeLinkModelFacet modelFacet) '''
+«IF modelFacet.containmentMetaFeature.ecoreFeature != null»
+«IF ! isUnbounded(ecoreFeature)»
if («featureBoundComparator(it, getContainerVariable(modelFacet), modelFacet.getSourceType())») {
return false;
}
«ENDIF»
+«ENDIF»
'''
-def dispatch checkEMFConstraints(FeatureLinkModelFacet it) '''
+ def dispatch checkEMFConstraints(FeatureLinkModelFacet it) '''
if (source != null) {
if («featureBoundsConditionClause(it.metaFeature, 'source', getSourceType())») {
return false;
@@ -481,35 +556,49 @@ if (target != null && («featureBoundsConditionClause(metaFeature.reverse, 'targ
«extraLineBreak»
'''
-def featureBoundsConditionClause(GenFeature it, String targetVar, GenClass targetType) '''
-«/*Checking upper bounds if was specified in MM */
-IF !isUnbounded(it.ecoreFeature)»«featureBoundComparator(it, targetVar, targetType)»«ENDIF»
-«/*Checking uniqueness in addition if upper bounds != 1 */
-IF !isSingleValued(it.ecoreFeature) && !isUnbounded(it.ecoreFeature)» || «ENDIF»
-«/*Checking uniqueness in if upper bounds !- 1 */
-IF !isSingleValued(it.ecoreFeature)»«featureUniquenessComparator(it, targetVar, targetType)»«ENDIF»
+ def featureBoundsConditionClause(GenFeature it, String targetVar, GenClass targetType) '''
+«««Checking upper bounds if was specified in MM
+«IF ecoreFeature != null»
+ «IF ! isUnbounded(ecoreFeature)»«featureBoundComparator(it, targetVar, targetType)»«ENDIF»
+ ««« Checking uniqueness in addition if upper bounds != 1
+ «IF ! isSingleValued(ecoreFeature) && ! isUnbounded(ecoreFeature)» || «ENDIF»
+ ««« Checking uniqueness in if upper bounds !- 1
+ «IF ! isSingleValued(ecoreFeature)»«featureUniquenessComparator(it, targetVar, targetType)»«ENDIF»
+«ENDIF»
'''
-def featureBoundComparator(GenFeature it, String featureVar, GenClass featureVarGenClass) '''«xptMetaModel.getFeatureValue(it, featureVar, featureVarGenClass)»«IF isSingleValued(ecoreFeature)» != null«ELSE».size() >= «ecoreFeature.upperBound»«ENDIF»'''
-def featureUniquenessComparator(GenFeature it, String featureVar, GenClass featureVarGenClass) '''«xptMetaModel.getFeatureValue(it, featureVar, featureVarGenClass)».contains(target)'''
+ def featureBoundComparator(GenFeature it, String featureVar, GenClass featureVarGenClass) '''
+ «xptMetaModel.getFeatureValue(it, featureVar, featureVarGenClass)»
+ «IF ecoreFeature.upperBound == 1»
+ != null
+ «ELSE»
+ .size() >= «ecoreFeature.upperBound»
+ «ENDIF»
+ '''
+
+ def featureUniquenessComparator(GenFeature it, String featureVar,
+ GenClass featureVarGenClass) '''«xptMetaModel.getFeatureValue(it, featureVar, featureVarGenClass)».contains(target)'''
-def dispatch checkAdditionalConstraint(GenExpressionProviderBase it, ValueExpression valueExpr, String sourceEndVar, String targetEndVar, GenClass context, GenClass oppositeEndContext) '''
+ def dispatch checkAdditionalConstraint(GenExpressionProviderBase it, ValueExpression valueExpr, String sourceEndVar,
+ String targetEndVar, GenClass context, GenClass oppositeEndContext) '''
«ERROR('Have no idea what extra constraints to check for ' + it)»
'''
-def dispatch checkAdditionalConstraint(GenExpressionInterpreter it, ValueExpression valueExpr, String sourceEndVar, String targetEndVar, GenClass context, GenClass oppositeEndContext) '''
- if («sourceEndVar» == null) {
- return true;
- } else {«/** else is important here as it gives scope for the env variable */»
- java.util.Map<String, org.eclipse.emf.ecore.EClassifier> env = java.util.Collections.<String, org.eclipse.emf.ecore.EClassifier>singletonMap(«oppositeEndVariableNameValue(it)», «xptMetaModel.MetaClass(oppositeEndContext)»); «nonNLS()»
- Object «sourceEndVar»Val = «xptGetExpression.getExpression(it, valueExpr, context, 'env')».evaluate(«sourceEndVar», java.util.Collections.singletonMap(«oppositeEndVariableNameValue(it)», «targetEndVar»)); «nonNLS()»
- if (false == «sourceEndVar»Val instanceof Boolean || !((Boolean) «sourceEndVar»Val).booleanValue()) {
- return false;
- } // else fall-through
- }
-'''
+ def dispatch checkAdditionalConstraint(GenExpressionInterpreter it, ValueExpression valueExpr, String sourceEndVar,
+ String targetEndVar, GenClass context, GenClass oppositeEndContext) '''
+ if («sourceEndVar» == null) {
+ return true;
+ } else {«/** else is important here as it gives scope for the env variable */»
+ java.util.Map<String, org.eclipse.emf.ecore.EClassifier> env = java.util.Collections.<String, org.eclipse.emf.ecore.EClassifier>singletonMap(«oppositeEndVariableNameValue(it)», «xptMetaModel.MetaClass(oppositeEndContext)»); «nonNLS()»
+ Object «sourceEndVar»Val = «xptGetExpression.getExpression(it, valueExpr, context, 'env')».evaluate(«sourceEndVar», java.util.Collections.singletonMap(«oppositeEndVariableNameValue(it)», «targetEndVar»)); «nonNLS()»
+ if (false == «sourceEndVar»Val instanceof Boolean || !((Boolean) «sourceEndVar»Val).booleanValue()) {
+ return false;
+ } // else fall-through
+ }
+ '''
-def dispatch checkAdditionalConstraint(GenJavaExpressionProvider it, ValueExpression valueExpr, String sourceEndVar, String targetEndVar, GenClass context, GenClass oppositeEndContext) '''
+ def dispatch checkAdditionalConstraint(GenJavaExpressionProvider it, ValueExpression valueExpr, String sourceEndVar,
+ String targetEndVar, GenClass context, GenClass oppositeEndContext) '''
«IF injectExpressionBody && valueExpr.body != null && !valueExpr.body.empty»
«valueExpr.body»
«ELSEIF throwException || (injectExpressionBody && (valueExpr.body == null || valueExpr.body.empty))»
@@ -526,7 +615,7 @@ def dispatch checkAdditionalConstraint(GenJavaExpressionProvider it, ValueExpres
«ENDIF»
'''
- @MetaDef def canExistCall(FeatureLinkModelFacet xptSelf, GenLink link, String sourceVar, String targetVar) //
+ @MetaDef def canExistCall(FeatureLinkModelFacet xptSelf, GenLink link, String sourceVar, String targetVar) //
'''«_accessLinkConstraints(link.diagram)».canExist«link.uniqueIdentifier»(«sourceVar», «targetVar»)'''
/**
@@ -547,9 +636,10 @@ def dispatch checkAdditionalConstraint(GenJavaExpressionProvider it, ValueExpres
String targetVar) //
'''«_accessLinkConstraints(link.diagram)».canCreate«link.uniqueIdentifier»(«IF hasContainerOtherThanSource(xptSelf)»«containerVar», «ENDIF»«sourceVar», «targetVar»)'''
- @MetaDef private def _accessLinkConstraints(GenDiagram xptSelf) '''«qualifiedClassName(xptSelf)».getLinkConstraints()'''
+ @MetaDef private def _accessLinkConstraints(
+ GenDiagram xptSelf) '''«qualifiedClassName(xptSelf)».getLinkConstraints()'''
- def oppositeEndVariableNameValue(Object any)'''"oppositeEnd"'''
+ def oppositeEndVariableNameValue(Object any) '''"oppositeEnd"'''
def additions(GenDiagram it) ''''''
@@ -559,14 +649,32 @@ def dispatch checkAdditionalConstraint(GenJavaExpressionProvider it, ValueExpres
«defaultConstructorBody(it)»
}
'''
+
/**
* @param genCommon diagram, node or link, which MUST have an element type (genCommon.elementType != null)
*/
def defaultConstructorBody(GenCommonBase genCommon) '''
- «IF genCommon.elementType == null»
- «ERROR("No element type in the passed node. Only diagram, node or link are supported in this template: " + genCommon)»
- «ENDIF»
- super(«xptElementTypes.accessElementType(genCommon)»);
+ «IF genCommon.elementType == null»
+ «ERROR("No element type in the passed node. Only diagram, node or link are supported in this template: " + genCommon)»
+ «ENDIF»
+ super(«xptElementTypes.accessElementType(genCommon)»);
'''
+
+ /**
+ * Generate generic method if using semantic creation command based on element types framework.
+ *
+ */
+ def getCreateSemanticServiceEditCommand(GenDiagram it) '''
+«IF usingElementTypeCreationCommand»
+ «generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.ICommand getSemanticCreationCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+ org.eclipse.papyrus.infra.services.edit.service.IElementEditService commandService = org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(req.getContainer());
+ if(commandService == null) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+ return commandService.getEditCommand(req);
+ }
+«ENDIF»
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend
index bd626b85bfb..15570eef0b4 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xtend
@@ -1,26 +1,32 @@
-/*******************************************************************************
- * Copyright (c) 2006-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCompartment
import xpt.Common
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeModelFacet
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+import metamodel.MetaModel
+import org.eclipse.emf.common.util.EList
@com.google.inject.Singleton class CompartmentItemSemanticEditPolicy {
@Inject extension Common;
+ @Inject extension MetaModel;
@Inject childContainerCreateCommand xptChildContainerCreateCommand;
@Inject BaseItemSemanticEditPolicy xptBaseItemSemanticEditPolicy;
@@ -33,18 +39,18 @@ import xpt.Common
def fullPath(GenCompartment it) '''«qualifiedClassName(it)»'''
- def CompartmentItemSemanticEditPolicy(GenCompartment it) '''
+ def CompartmentItemSemanticEditPolicy(GenCompartment it) '''
«copyright(getDiagram().editorGen)»
package «packageName(it)»;
«generatedClassComment()»
public class «className(it)» extends «xptBaseItemSemanticEditPolicy.qualifiedClassName(getDiagram())» {
- «_constructor(it)»
+ «_constructor(it)»
+
+ «xptChildContainerCreateCommand.childContainerCreateCommand( it.childNodes)»
- «xptChildContainerCreateCommand.childContainerCreateCommand(it.childNodes)»
-
- «additions(it)»
+ «additions(it)»
}
'''
@@ -56,4 +62,73 @@ import xpt.Common
'''
def additions(GenCompartment it) ''''''
+
+def getChildNodeReference (EList<GenChildNode> it) '''
+ «IF !(it.isEmpty)»
+ «generatedMemberComment»
+ private static Set<EReference> compartmentReferences;
+
+ «generatedMemberComment»
+ static {
+ ««« compartmentReferences = new HashSet<EReference>(«it.modelFacet->size()»);
+ compartmentReferences = new HashSet<EReference>();
+
+ «FOR n : it»
+ «childRef(n.modelFacet,n)»
+ «ENDFOR»
+ }
+ «generatedMemberComment»
+ protected Iterable<EReference> getCompartmentReferences() {
+ return compartmentReferences;
+ }
+«ENDIF»
+
+'''
+
+def childRef(TypeModelFacet it ,GenNode node) '''
+ compartmentReferences.add(«MetaFeature (node.modelFacet.containmentMetaFeature)»);
+'''
+
+
+def isCorrectCompartment (GenCompartment it)'''
+ «generatedMemberComment»
+ protected boolean isMovedIntoCorrectCompartment(MoveRequest req){
+ for(Object entry : req.getElementsToMove().entrySet()) {
+ if(entry instanceof Map.Entry<?, ?>) {
+ Map.Entry<?, ?> mapEntry = (Map.Entry<?, ?>)entry;
+ Object key = mapEntry.getKey();
+ if(key instanceof EObject) {
+ EObject dropppedObject = (EObject)key;
+ EObject semanticHost = ((IGraphicalEditPart)getHost()).resolveSemanticElement();
+ boolean foundERefrences = false;
+ if(semanticHost != null) {
+ for(EReference ref : getCompartmentReferences()) {
+ if(ref.isContainment()) {
+ foundERefrences = PackageUtil.canContain(semanticHost.eClass(), ref, dropppedObject.eClass(), false);
+ } else {
+ foundERefrences = PackageUtil.canReference(semanticHost.eClass(), ref, dropppedObject.eClass());
+ }
+ if(foundERefrences) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+'''
+
+def constraintedMoveCommand (GenCompartment it)'''
+ «generatedMemberComment»
+ @Override
+ protected Command getMoveCommand(MoveRequest req) {
+ if (isMovedIntoCorrectCompartment(req)){
+ return super.getMoveCommand(req);
+ } else {
+ return UnexecutableCommand.INSTANCE;
+ }
+ }
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend
index e97daf4558a..24da61c3661 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2007-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007-2012, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Borland) - [243151] explicit source/target for links
- * - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * - #386838 - migrate to Xtend2
+ * Vincent Lorenzo (CEA-LIST) -
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
@@ -24,6 +25,8 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.LinkModelFacet
import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeLinkModelFacet
import xpt.Common
import xpt.Common_qvto
+import utils.UtilsItemSemanticEditPolicy
+
@com.google.inject.Singleton class LinkItemSemanticEditPolicy {
@Inject extension Common;
@@ -33,6 +36,9 @@ import xpt.Common_qvto
@Inject BaseItemSemanticEditPolicy xptBaseItemSemanticEditPolicy;
@Inject linkCommands xptLinkCommands;
@Inject DeleteLinkCommand xptDeleteLinkCommand;
+ @Inject extension DeleteLinkCommand
+ @Inject extension UtilsItemSemanticEditPolicy
+
def className(GenLink it) '''«it.itemSemanticEditPolicyClassName»'''
@@ -74,10 +80,25 @@ import xpt.Common_qvto
'''
def dispatch getDestroySemanticCommand(TypeLinkModelFacet it, GenLink genLink) '''
- «generatedMemberComment()»
- protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
- return getGEFWrapper(«xptDeleteLinkCommand.newDeleteLinkWithClassCommand(it, genLink, 'req')»);
- }
+ ««« Test to know which delete command should be used in the generated code : "Traditional Delete Command" or the Delete Service
+
+ «IF genLink.usingDeleteService»
+
+ «generatedMemberComment»
+ «getDestroyElementCommandByService(it)»
+ «ELSE»
+ «generatedMemberComment»
+ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand cmd = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ java.util.List<org.eclipse.emf.ecore.EObject> todestroy=new java.util.ArrayList<org.eclipse.emf.ecore.EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(),todestroy )));
+ return getGEFWrapper(cmd.reduce());
+ //return getGEFWrapper(«newDeleteLinkWithClassCommand(it,genLink, 'req')»);
+ }
+ «ENDIF»
'''
def additions(GenLink it) ''''''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
index 84fa3819cea..dd56592e20e 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
@@ -1,27 +1,32 @@
-/*******************************************************************************
- * Copyright (c) 2007-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) - [257632] do not rely on EditPart presence for element deletion
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [257632] do not rely on EditPart presence for element deletion
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
import com.google.inject.Inject
-import impl.diagram.commands.DeleteLinkCommand
+import com.google.inject.Singleton
import java.util.List
+import org.eclipse.papyrus.gmf.codegen.gmfgen.FeatureLinkModelFacet
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildNode
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeLinkModelFacet
+import utils.UtilsItemSemanticEditPolicy
import xpt.Common
+import xpt.diagram.editpolicies.childContainerCreateCommand
+import xpt.diagram.editpolicies.Utils_qvto
import xpt.editor.VisualIDRegistry
/**
@@ -29,15 +34,16 @@ import xpt.editor.VisualIDRegistry
* because *ItemSemanticEditPolicy responsible for dealing with semantic model
* elements and meaningless (should not be generated) for pure design nodes.
*/
-@com.google.inject.Singleton class NodeItemSemanticEditPolicy {
+@Singleton class NodeItemSemanticEditPolicy {
@Inject extension Common;
@Inject extension Utils_qvto;
+ @Inject extension UtilsItemSemanticEditPolicy
+
@Inject BaseItemSemanticEditPolicy xptBaseItemSemanticEditPolicy;
@Inject childContainerCreateCommand xptChildContainerCreateCommand;
@Inject linkCommands xptLinkCommands;
- @Inject DeleteLinkCommand xptDeleteLinkCommand;
@Inject VisualIDRegistry xptVisualIDRegistry;
def className(GenNode it) '''«it.itemSemanticEditPolicyClassName»'''
@@ -59,10 +65,19 @@ import xpt.editor.VisualIDRegistry
«xptChildContainerCreateCommand.childContainerCreateCommand(it.childNodes)»
+ ««« Papyrus REM :
+ ««« Test to know how the delete of this EditPart is done : we used the DeleteService or the "Traditional method"
+
+ «IF usingDeleteService»
+ «generatedMemberComment»
+ «getDestroyElementCommandByService(it)»
+ «ELSE»
«getDestroyElementCommand(it)»
«IF hasChildrenOrCompartments(it)»
«addDestroyChildNodesCommand(it)»
«ENDIF»
+ «ENDIF»
+
«xptLinkCommands.linkCommands(it)»
«additions(it)»
@@ -71,49 +86,58 @@ import xpt.editor.VisualIDRegistry
def getDestroyElementCommand(GenNode it) '''
«generatedMemberComment()»
- protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand cmd = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), null);
- cmd.setTransactionNestingEnabled(false);
- «destroyEdges(it, 'view')»
- org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «nonNLS()»
- if (annotation == null) {
- // there are indirectly referenced children, need extra commands: «it.childNodes.union(compartments.map(c | c.childNodes).flatten).exists[GenChildNode gcn | !isDirectlyOwned(gcn, it)]»
+protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand cmd = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(true);
+ ««« «destroyEdges('view')»
+ org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut");«nonNLS»
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: «it.childNodes.union(compartments.map(c | c.childNodes).flatten).exists[GenChildNode gcn | !isDirectlyOwned(gcn, it)]»
«IF hasChildrenOrCompartments(it)»
addDestroyChildNodesCommand(cmd);
«ENDIF»
- addDestroyShortcutsCommand(cmd, view);
- // delete host element
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
- } else { «/*Here, we may play smart and don't generate else for non-toplevel nodes(which can't be shortcuts). Is it worth doing?*/»
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
- }
- return getGEFWrapper(cmd.reduce());
+ addDestroyShortcutsCommand(cmd, view);
+ // delete host element
+ java.util.List<org.eclipse.emf.ecore.EObject> todestroy=new java.util.ArrayList<org.eclipse.emf.ecore.EObject>();
+ todestroy.add(req.getElementToDestroy());
+ //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ cmd.add(new org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(),todestroy )));
+ } else {«««Here, we may play smart and don't generate else for non-toplevel nodes(which can't be shortcuts). Is it worth doing?
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
}
+ return getGEFWrapper(cmd.reduce());
+}
'''
def addDestroyChildNodesCommand(GenNode it) '''
«generatedMemberComment()»
- private void addDestroyChildNodesCommand(org.eclipse.gmf.runtime.common.core.command.ICompositeCommand cmd) {
+ protected void addDestroyChildNodesCommand(org.eclipse.gmf.runtime.common.core.command.ICompositeCommand cmd) {
org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
for (java.util.Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) nit.next();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(node)) {
- «FOR cn : it.childNodes»
- «destroyChildNodes(cn, 'node', it)»
- «ENDFOR»
- «FOR compartment : it.compartments»
- «xptVisualIDRegistry.caseVisualID(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 («xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(cnode)) {
- «FOR cn : compartment.childNodes»
- «destroyChildNodes(cn, 'cnode', it)»
- «ENDFOR»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(node);
+ if (vid != null) {
+ switch (vid) {
+ «FOR cn : it.childNodes»
+ «destroyChildNodes(cn, 'node', it)»
+ «ENDFOR»
+ «FOR compartment : it.compartments»
+ «xptVisualIDRegistry.caseVisualID(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();
+ String cvid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(cnode);
+ if (cvid != null) {
+ switch (cvid) {
+ «FOR cn : compartment.childNodes»
+ «destroyChildNodes(cn, 'cnode', it)»
+ «ENDFOR»
+ }
+ }
}
+ break;
+ «ENDFOR»
}
- break;
- «ENDFOR»
}
}
}
@@ -133,40 +157,105 @@ import xpt.editor.VisualIDRegistry
* assumes 'cmd' to point to composite command
*/
def destroyEdges(GenNode it, String view) '''
- «/*
- * XXX: Though semantic editpolicy is supposed to create commands that operate with semantic elements only,
- * old code used to delegate child/link deletion to respective editparts, which in turn led to semantic commands
- * being combined with notational commands (BaseItemSemanticEditPolicy#addDeleteViewCommand()).
- * ---
- * Use DiagramUpdater.get[Incoming|Outgoing]View instead, to clean links that are not present on a diagram
- * (but don't forget to clean corresponding Edge, if any)
- */
- IF !genIncomingLinks.empty»
- for (java.util.Iterator<?> it = «view».getTargetEdges().iterator(); it.hasNext();) {
- org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
- «FOR il : it.genIncomingLinks»
- if («xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(incomingLink) == «VisualIDRegistry::visualID(il)») {
- «xptDeleteLinkCommand.newRequest(il, 'r', 'incomingLink')»
- cmd.add(«xptDeleteLinkCommand.newInstance(il, 'r')»);
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- continue;
+
+««« XXX: Though semantic editpolicy is supposed to create commands that operate with semantic elements only,
+««« old code used to delegate child/link deletion to respective editparts, which in turn led to semantic commands
+««« being combined with notational commands (BaseItemSemanticEditPolicy#addDeleteViewCommand()).
+««« ---
+««« Use DiagramUpdater.get[Incoming|Outgoing]View instead, to clean links that are not present on a diagram
+««« (but don't forget to clean corresponding Edge, if any)
+
+
+«««// This part is commented for Papyrus
+«««// Some Papyrus diagrams with lots of elements are reaching the 65K Java limit for method size.
+«««// The following change is not supposed to modify the method behavior, just propose a slight more
+«««// compact code to avoid size limit.
+«««
+««««IF genIncomingLinks->notEmpty()-»
+««« for («EXPAND CodeStyle::G('java.util.Iterator', '?' /*FIXME Refactor once Notation model is Java5*/)» it = «view».getTargetEdges().iterator(); it.hasNext();) {
+««« org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
+««««FOREACH genIncomingLinks AS il-»
+««« if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(incomingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR il») {
+««« «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'incomingLink') FOR il-»
+««« cmd.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR il»);
+««« cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+««« continue;
+««« }
+««««ENDFOREACH-»
+««« }
+««««ENDIF-»
+««««IF genOutgoingLinks->notEmpty()-»
+««« for («EXPAND CodeStyle::G('java.util.Iterator', '?' /*FIXME Refactor once Notation model is Java5*/)» it = «view».getSourceEdges().iterator(); it.hasNext();) {
+««« org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
+««««FOREACH genOutgoingLinks AS ol-»
+««« if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(outgoingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR ol») {
+««« «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'outgoingLink') FOR ol-»
+««« cmd.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR ol»);
+««« cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
+««« continue;
+««« }
+««««ENDFOREACH-»
+««« }
+««««ENDIF-»
+
+
+«IF !genIncomingLinks.isEmpty()»
+ for (java.util.Iterator<?> it = «view».getTargetEdges().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(incomingLink);
+ if (vid != null) {
+ switch(vid) {
+«IF !genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty»
+«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]»
+ case «VisualIDRegistry.visualID(il)»:
+«ENDFOR»
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+«ENDIF»
+«IF !genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty»
+«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]»
+ case «VisualIDRegistry.visualID(il)»:
+«ENDFOR»
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
+«ENDIF»
}
- «ENDFOR»
}
- «ENDIF»
- «IF !genOutgoingLinks.empty»
- for (java.util.Iterator<?> it = «view».getSourceEdges().iterator(); it.hasNext();) {
- org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
- «FOR ol : it.genOutgoingLinks»
- if («xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(outgoingLink) == «VisualIDRegistry::visualID(ol)») {
- «xptDeleteLinkCommand.newRequest(ol, 'r', 'outgoingLink')»
- cmd.add(«xptDeleteLinkCommand.newInstance(ol, 'r')»);
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
- continue;
+ }
+«ENDIF»
+
+«IF genOutgoingLinks.isEmpty()»
+ for (java.util.Iterator<?> it = «view».getSourceEdges().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(outgoingLink);
+ if (vid != null) {
+ switch(vid) {
+«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty»
+«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]»
+ case «VisualIDRegistry.visualID(ol)»:
+«ENDFOR»
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(outgoingLink.getSource().getElement(), null, outgoingLink.getTarget().getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
+ break;
+«ENDIF»
+«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty»
+«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]»
+ case «VisualIDRegistry.visualID(ol)»:
+«ENDFOR»
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(outgoingLink.getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
+ break;
+«ENDIF»
}
- «ENDFOR»
}
- «ENDIF»
+ }
+«ENDIF»
'''
def additions(GenNode it) ''''''
@@ -177,5 +266,5 @@ import xpt.editor.VisualIDRegistry
result.addAll(listB);
return result;
}
-
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/OpenDiagram.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/OpenDiagram.xtend
index 5ffb37ab082..22d676e718a 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/OpenDiagram.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/OpenDiagram.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
@@ -173,7 +173,7 @@ import xpt.editor.DiagramEditorUtil
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();) {
+ 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(«xptDiagramEditorUtil.qualifiedClassName(subject.diagram)».getSaveOptions());
@@ -199,6 +199,7 @@ import xpt.editor.DiagramEditorUtil
}
'''
+
def openCommandClass_getDiagramDomainElement(OpenDiagramBehaviour it) '''
«generatedMemberComment»
protected org.eclipse.emf.ecore.EObject getDiagramDomainElement() {
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend
index 5e19ee62cd3..a0cd7abfe1c 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextNonResizableEditPolicy.xtend
@@ -1,16 +1,17 @@
-/******************************************************************************
- * Copyright (c) 2013, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2013, 2017 , 2021 Borland Software Corporation, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Svyatoslav Kovalsky (Montages) - initial API and implementation
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Svyatoslav Kovalsky (Montages) - initial API and implementation
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - #510281 change dependency to replace gmft-runtime
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
@@ -55,11 +56,11 @@ import xpt.Common
def TextNonResizableEditPolicy_extendsClause(GenDiagram it) '''extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx'''
- def TextNonResizableEditPolicy_implementsClause(GenDiagram it) '''implements org.eclipse.gmf.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy'''
+ def TextNonResizableEditPolicy_implementsClause(GenDiagram it) '''implements org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy'''
def TextNonResizableEditPolicy_createSelectionHandles(GenDiagram it) '''
«generatedMemberComment»
- protected java.util.List createSelectionHandles() {
+ 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);
@@ -67,6 +68,6 @@ import xpt.Common
return java.util.Collections.singletonList(moveHandle);
}
'''
-
def TextNonResizableEditPolicy_additions(GenDiagram it) ''''''
+
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend
index 4060af5d4f2..c73e19e6750 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/TextSelectionEditPolicy.xtend
@@ -1,16 +1,16 @@
-/******************************************************************************
- * Copyright (c) 2013, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2013, 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Svyatoslav Kovalsky (Montages) - initial API and implementation
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Svyatoslav Kovalsky (Montages) - initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
@@ -26,7 +26,7 @@ import xpt.CodeStyle
@Inject extension Common;
- @Inject CodeStyle xptCodeStyle;
+ @Inject extension CodeStyle xptCodeStyle;
def className(GenDiagram it) '''«it.textSelectionEditPolicyClassName»'''
@@ -38,7 +38,7 @@ import xpt.CodeStyle
def TextSelectionEditPolicy_extendsClause(GenDiagram it) '''extends org.eclipse.gef.editpolicies.SelectionEditPolicy'''
- def TextSelectionEditPolicy_implementsClause(GenDiagram it) '''implements org.eclipse.gmf.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy'''
+ def TextSelectionEditPolicy_implementsClause(GenDiagram it) '''implements org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.labels.IRefreshableFeedbackEditPolicy'''
def TextSelectionEditPolicy_additions(GenDiagram it) ''''''
@@ -210,6 +210,7 @@ import xpt.CodeStyle
protected org.eclipse.draw2d.IFigure createFocusFeedbackFigure() {
return new org.eclipse.draw2d.Figure() {
+ «overrideC»
protected void paintFigure(org.eclipse.draw2d.Graphics graphics) {
graphics.drawFocus(getBounds().getResized(-1, -1));
}
@@ -264,6 +265,7 @@ import xpt.CodeStyle
private org.eclipse.draw2d.FigureListener getHostPositionListener() {
if (hostPositionListener == null) {
hostPositionListener = new org.eclipse.draw2d.FigureListener() {
+ «overrideI»
public void figureMoved(org.eclipse.draw2d.IFigure source) {
refreshFeedback();
}
@@ -272,4 +274,5 @@ import xpt.CodeStyle
return hostPositionListener;
}
'''
+
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/Utils_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/Utils_qvto.xtend
index 39336745449..ae95a3737d6 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/Utils_qvto.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/Utils_qvto.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program && the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, && is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API && implementation
- * Michael Golubev (Borland) - [243151] explicit source/target for links
- * - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API && implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
@@ -129,4 +129,27 @@ import xpt.GenModelUtils_qvto
return childFacet.containmentMetaFeature.genClass.isSuperTypeOf(genNode.modelFacet.metaClass)
}
+
+
+def Boolean containsCreateStartLinkCommand(GenLinkEnd it){
+ for (l : getAllPotentialLinks(it)){
+ if(createStartLinkCommand(l, it)){
+ return true;
+ }
+ }
+
+ return false;
+}
+
+def Boolean containsCreateCompleteLinkCommand(GenLinkEnd it){
+ for (l : getAllPotentialLinks(it)){
+ if(createCompleteLinkCommand(l, it)){
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/childContainerCreateCommand.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/childContainerCreateCommand.xtend
index 26d00e0649d..7bf4733af26 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/childContainerCreateCommand.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/childContainerCreateCommand.xtend
@@ -1,40 +1,54 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeModelFacet
import xpt.Common
-import xpt.providers.ElementTypes
import xpt.QualifiedClassNameProvider
+import xpt.providers.ElementTypes
+import metamodel.MetaModel
-@com.google.inject.Singleton class childContainerCreateCommand {
+@Singleton class childContainerCreateCommand {
@Inject extension Common;
@Inject extension QualifiedClassNameProvider;
@Inject ElementTypes xptElementTypes;
+ @Inject extension ElementTypes;
+ @Inject extension MetaModel;
def childContainerCreateCommand(Iterable<? extends GenNode> nodes) '''
- «IF !nodes.empty»
+ «IF ! nodes.empty»
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
- «FOR n : nodes»
- «childNodeCreateCommand(n)»
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestElementType = req.getElementType();
+ if(requestElementType == null) {
+ return super.getCreateCommand(req);
+ }
+
+
+ «FOR n : nodes»
+ «IF !n.sansDomain»
+ «childNodeCreateCommand(n.modelFacet, n)»
+ «ENDIF»
«ENDFOR»
return super.getCreateCommand(req);
}
@@ -48,4 +62,21 @@ import xpt.QualifiedClassNameProvider
}
'''
+ def childNodeCreateCommand(TypeModelFacet it,GenNode node)'''
+ if («accessElementType(node)» == requestElementType) {
+ «IF it.eResource.allContents.filter(typeof (GenDiagram)).filter[genDiagram | genDiagram.usingElementTypeCreationCommand].size>0»
+ // adjust the containment feature
+ org.eclipse.emf.ecore.EReference containmentFeature = «MetaFeature(it.childMetaFeature)»;
+ req.setContainmentFeature(containmentFeature);
+ «ENDIF»
+
+ «IF it.eResource.allContents.filter(typeof (GenDiagram)).filter[genDiagram | genDiagram.usingElementTypeCreationCommand].size>0»
+ return getGEFWrapper(getSemanticCreationCommand(req));
+ «ELSE»
+ return getGEFWrapper(new «node.getCreateCommandQualifiedClassName()»(req, org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getDiagramFrom(getHost())));
+ «ENDIF»
+
+ }
+ '''
+
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/linkCommands.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/linkCommands.xtend
index 7fdff96e50a..4154d0c244d 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/linkCommands.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/editpolicies/linkCommands.xtend
@@ -1,30 +1,34 @@
-/*******************************************************************************
- * Copyright (c) 2007-2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007-2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * 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
- * - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * 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
+ * - #386838 - migrate to Xtend2
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.editpolicies
import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLink
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLinkEnd
import xpt.Common
-import xpt.providers.ElementTypes
import xpt.QualifiedClassNameProvider
+import xpt.diagram.commands.CreateLinkCommand
import xpt.diagram.commands.ReorientLinkCommand
import xpt.editor.VisualIDRegistry
+import xpt.providers.ElementTypes
/**
* Start start of link creation.
@@ -47,17 +51,18 @@ import xpt.editor.VisualIDRegistry
* because RefLinks don't have underlying semantic identity
*
*/
-@com.google.inject.Singleton class linkCommands {
- @Inject extension Utils_qvto;
+@Singleton class linkCommands {
+ @Inject extension Utils_qvto;
+
@Inject extension Common;
@Inject extension QualifiedClassNameProvider;
@Inject ElementTypes xptElementTypes;
@Inject ReorientLinkCommand xptReorientLinkCommand;
@Inject VisualIDRegistry xptVisualIDRegistry;
+ @Inject CreateLinkCommand xptCreateLinkCommand;
+
- def aaa() '''aaa'''
-
def linkCommands(GenLinkEnd it) '''
«IF getAllPotentialLinks(it).size > 0»
«createLinkCommands(it)»
@@ -72,6 +77,8 @@ import xpt.editor.VisualIDRegistry
def createLinkCommands(GenLinkEnd it) '''
+ «IF it.eResource.allContents.filter(typeof (GenDiagram)).filter[genDiagram | genDiagram.usingElementTypeCreationCommand].size<1»
+
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(
org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
@@ -79,10 +86,17 @@ import xpt.editor.VisualIDRegistry
getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
return command != null ? command : super.getCreateRelationshipCommand(req);
}
+ «ENDIF»
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getStartCreateRelationshipCommand(
org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestElementType = req.getElementType();
+ if(requestElementType == null) {
+ return null;
+ }
+ org.eclipse.gmf.runtime.emf.type.core.IElementType baseElementType = requestElementType;
+
«FOR l : getAllPotentialLinks(it)»
«startLinkCommands(l, it)»
«ENDFOR»
@@ -92,6 +106,12 @@ import xpt.editor.VisualIDRegistry
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getCompleteCreateRelationshipCommand(
org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestElementType = req.getElementType();
+ if(requestElementType == null) {
+ return null;
+ }
+ org.eclipse.gmf.runtime.emf.type.core.IElementType baseElementType = requestElementType;
+
«FOR l : getAllPotentialLinks(it)»
«completeLinkCommands(l, it)»
«ENDFOR»
@@ -100,9 +120,10 @@ import xpt.editor.VisualIDRegistry
'''
def startLinkCommands(GenLink it, GenLinkEnd linkEnd) '''
- if («xptElementTypes.accessElementType(it)» == req.getElementType()) {
- «IF createStartLinkCommand(it, linkEnd)»
- return getGEFWrapper(new «getCreateCommandQualifiedClassName(it)»(req,
+ if («xptElementTypes.accessElementType(it)» == baseElementType) {
+ «IF createStartLinkCommand(it, linkEnd)»
+
+ return getGEFWrapper(new «xptCreateLinkCommand.qualifiedClassName(it)»(req,
«IF createStartIncomingLinkCommand(it, linkEnd)»
req.getTarget(), req.getSource()
«ELSE»
@@ -112,13 +133,13 @@ import xpt.editor.VisualIDRegistry
«ELSE»
return null;
«ENDIF»
- }
'''
def completeLinkCommands(GenLink it, GenLinkEnd linkEnd) '''
- if («xptElementTypes.accessElementType(it)» == req.getElementType()) {
+ if («xptElementTypes.accessElementType(it)» == baseElementType) {
«IF createCompleteLinkCommand(it, linkEnd)»
- return getGEFWrapper(new «getCreateCommandQualifiedClassName(it)»(req,
+
+ return getGEFWrapper(new «xptCreateLinkCommand.qualifiedClassName(it)»(req,
«IF createCompleteOutgoingLinkCommand(it, linkEnd)»
req.getTarget(), req.getSource()
«ELSE»
@@ -128,25 +149,29 @@ import xpt.editor.VisualIDRegistry
«ELSE»
return null;
«ENDIF»
- }
'''
def reorientTypeLinkCommands(GenLinkEnd it) '''
-
«generatedMemberComment(
- 'Returns command to reorient EClass based link. New link target or source\n' +
- 'should be the domain model element associated with this node.\n'
+ 'Returns command to reorient EClass based link. New link target or source\n' + 'should be the domain model element associated with this node.\n'
- protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
- org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- «FOR l : getReroutableTypeLinks(it)»
- «reorientLinkCommand(l)»
- «ENDFOR»
- }
- return super.getReorientRelationshipCommand(req);
- }
- '''
+ protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
+ String vid = getVisualID(req);
+ if (vid != null) {
+ switch (vid) {
+ «FOR link : getReroutableTypeLinks(it)»
+ «reorientLinkCommandWithService(link) »
+ «ENDFOR»
+ «callReorientCommand(it)»
+ «FOR link : getReroutableTypeLinks(it)»
+ «reorientLinkCommandWithoutService(link) »
+ «ENDFOR»
+ }
+ }
+ return super.getReorientRelationshipCommand(req);
+ }
+ '''
def reorientRefLinkCommands(GenLinkEnd it) '''
@@ -169,5 +194,39 @@ import xpt.editor.VisualIDRegistry
«xptVisualIDRegistry.caseVisualID(it)»
return getGEFWrapper(new «xptReorientLinkCommand.qualifiedClassName(it)»(req));
'''
+
+ //This function writes only : "case myLinkEditPart.VISUAL_ID:"
+ //for the link which uses the ReorientCommand provided by the EditService
+ def reorientLinkCommandWithService(GenLink it) '''
+ «IF usingReorientService»
+ «xptVisualIDRegistry.caseVisualID(it)»
+ «ENDIF»
+ '''
+
+ // This function writes the code to call the ReorientCommand provided by the ReorientService
+ def callReorientCommand(GenLinkEnd it) '''
+ «var views = getReroutableTypeLinks(it)»
+ «IF views !== null && !views.empty»
+ «IF !views.filter[view| view.usingReorientService].empty»
+ org.eclipse.papyrus.infra.services.edit.service.IElementEditService provider =org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils.getCommandProvider(req.getRelationship());
+ if(provider == null) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ // Retrieve re-orient command from the Element Edit service
+ org.eclipse.gmf.runtime.common.core.command.ICommand reorientCommand = provider.getEditCommand(req);
+ if(reorientCommand == null) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+ }
+ return getGEFWrapper(reorientCommand.reduce());
+ «ENDIF»
+ «ENDIF»
+ '''
+
+ // This function writes the code for the Links which uses their own ReorientCommand (the initial code)
+ def reorientLinkCommandWithoutService(GenLink it) '''
+ «IF !usingReorientService»
+ «reorientLinkCommand(it)»
+ «ENDIF»
+ '''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/preferences/extensions.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/preferences/extensions.xtend
index 453c32116c5..99c89a04314 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/preferences/extensions.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/preferences/extensions.xtend
@@ -1,17 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.preferences
@@ -26,11 +27,14 @@ import impl.preferences.CustomPage
import impl.preferences.StandardPage
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCustomPreferencePage
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenStandardPreferencePage
+import utils.PrefsConstant_qvto
+import org.eclipse.papyrus.gmf.codegen.gmfgen.StandardPreferencePages
@com.google.inject.Singleton class extensions {
@Inject extension Common;
@Inject extension Common_qvto;
@Inject extension Utils_qvto;
+ @Inject extension PrefsConstant_qvto;
@Inject PreferenceInitializer xptPreferenceInitializer;
@Inject CustomPage xptCustomPage;
@@ -43,13 +47,15 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenStandardPreferencePage
«tripleSpace(2)»<initializer class="«xptPreferenceInitializer.qualifiedClassName(it)»"/>
«tripleSpace(1)»</extension>
- «IF it.preferencePages.notEmpty»
- «tripleSpace(1)»<extension point="org.eclipse.ui.preferencePages" id="prefpages">
- «tripleSpace(2)»«xmlGeneratedTag»
- «FOR pref : allPreferencePages(it)»
- «preferencePage(pref)»
- «ENDFOR»
- «tripleSpace(1)»</extension>
+ «IF ! it.preferencePages.empty»
+ «tripleSpace(1)»<extension point="org.eclipse.ui.preferencePages" id="prefpages">
+ «tripleSpace(2)»«xmlGeneratedTag»
+ «FOR pref : allPreferencePages(it)»
+ «IF pref instanceof GenStandardPreferencePage»
+ «papyrusPreferencePage(pref as GenStandardPreferencePage)»
+ «ENDIF»
+ «ENDFOR»
+ «tripleSpace(1)»</extension>
«ENDIF»
'''
@@ -76,4 +82,24 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenStandardPreferencePage
def dispatch getQualifiedPageName(GenPreferencePage it) ''''''
def dispatch getQualifiedPageName(GenCustomPreferencePage it) '''«xptCustomPage.qualifiedClassName(it)»'''
def dispatch getQualifiedPageName(GenStandardPreferencePage it) '''«xptStandardPage.qualifiedClassName(it)»'''
+
+ def papyrusPreferencePage(GenStandardPreferencePage it) '''
+ «IF StandardPreferencePages.GENERAL_LITERAL == kind»
+ <page
+ id="«getDiagramPreferencePageCategory()».«getDiagram().editorGen.modelID»"
+ name="«getDiagram().editorGen.modelID» Diagram"
+ category="«getDiagramPreferencePageCategory()»"
+ class="«getQualifiedClassName()»">
+ </page>
+ «ELSEIF StandardPreferencePages.PRINTING_LITERAL == kind ||
+ StandardPreferencePages.RULERS_AND_GRID_LITERAL == kind»
+ <page
+ id="«getQualifiedClassName()»"
+ name="%prefpage.«ID»"
+ category="«getDiagramPreferencePageCategory()».«getDiagram().editorGen.modelID»"
+ class="«getQualifiedClassName()»">
+ </page>
+ «ENDIF»
+ '''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/DiagramUpdater.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/DiagramUpdater.xtend
index ec1f253e108..5411e2b36b0 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/DiagramUpdater.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/DiagramUpdater.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2014, 2021 Borland Software Corporation, CEA, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Borland) - [243151] explicit source/target for links
- * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime, template migrated to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime, template migrated to Xtend2
+ * Christian W. Damus (CEA) - bug 426732: override the cross-reference searches for views to use the CrossReferenceAdapter
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.updater
@@ -22,6 +23,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.FeatureLinkModelFacet
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCompartment
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenContainerBase
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagramUpdater
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLink
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLinkEnd
@@ -35,6 +37,10 @@ import xpt.Common_qvto
import xpt.GenModelUtils_qvto
import xpt.editor.VisualIDRegistry
import xpt.providers.ElementTypes
+import xpt.diagram.updater.UpdaterLinkType
+import xpt.diagram.updater.Utils_qvto
+import java.util.Set
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature
@com.google.inject.Singleton class DiagramUpdater {
@Inject extension Common;
@@ -45,14 +51,14 @@ import xpt.providers.ElementTypes
@Inject VisualIDRegistry xptVisualIDRegistry;
@Inject MetaModel xptMetaModel;
@Inject ElementTypes xptElementTypes;
- @Inject CodeStyle xptCodeStyle;
@Inject NodeDescriptor nodeDescriptor;
@Inject LinkDescriptor linkDescriptor;
-
-
- @MetaDef def getSemanticChildrenMethodName(GenContainerBase it) '''get«getUniqueIdentifier()»SemanticChildren'''
- @MetaDef def getSemanticChildrenMethodCall(GenContainerBase it) '''«qualifiedClassName(getDiagram().editorGen.diagramUpdater)».«getSemanticChildrenMethodName(it)»'''
+ @MetaDef def getSemanticChildrenMethodName(GenContainerBase it) '''get«stringUniqueIdentifier()»_SemanticChildren'''
+
+ @MetaDef def getSemanticChildrenMethodCall(GenContainerBase it) '''«diagramUpdaterInstanceToUse(it.diagramUpdater)».«getSemanticChildrenMethodName(
+ it)»'''
+
@MetaDef def getContainedLinksMethodCall(GenCommonBase it) '''«doGetSomeLinksMethodCall(it, UpdaterLinkType::CONTAINED)»'''
@@ -60,9 +66,10 @@ import xpt.providers.ElementTypes
@MetaDef def getOutgoingLinksMethodCall(GenCommonBase it) '''«doGetSomeLinksMethodCall(it, UpdaterLinkType::OUTGOING)»'''
- @MetaDef protected def doGetSomeLinksMethodCall(GenCommonBase it, UpdaterLinkType linkType) '''«qualifiedClassName(it.getDiagram().diagramUpdater)».«linkGetterName(linkType)»'''
+ @MetaDef protected def doGetSomeLinksMethodCall(GenCommonBase it, UpdaterLinkType linkType) '''«diagramUpdaterInstanceToUse(
+ it.getDiagram().diagramUpdater)».«linkGetterName(linkType)»'''
- @MetaDef protected def linkGetterName(GenCommonBase it, UpdaterLinkType linkType) '''get«it.uniqueIdentifier»«linkType.linkMethodSuffix»Links'''
+ @MetaDef protected def linkGetterName(GenCommonBase it, UpdaterLinkType linkType) '''get«stringUniqueIdentifier()»_«linkType.linkMethodSuffix»Links'''
@MetaDef def runtimeTypedInstanceName(GenDiagramUpdater it) '''TYPED_INSTANCE'''
@@ -77,48 +84,50 @@ import xpt.providers.ElementTypes
def fullPath(GenDiagramUpdater it) '''«qualifiedClassName(it)»'''
def DiagramUpdater(GenDiagramUpdater it) '''
- «copyright(editorGen)»
- package «packageName(it)»;
-
- «generatedClassComment»
- public class «className(it)» {
- «isShortcutOrphaned(it)»
- «var semanticContainers = it.editorGen.diagram.allContainers.filter[container | hasSemanticChildren(container)]»
- «getGenericSemanticChildrenOfView(it, semanticContainers)»
- «FOR next : semanticContainers»
- «getSemanticChildrenOfView(next)»
- «ENDFOR»
-
- «getPhantomNodesIterator(it)»
-
- «getGenericConnectedLinks(it, getAllSemanticElements(editorGen.diagram), UpdaterLinkType::CONTAINED)»
-
- «getGenericConnectedLinks(it, getAllSemanticDiagramElements(editorGen.diagram), UpdaterLinkType::INCOMING)»
-
- «getGenericConnectedLinks(it, getAllSemanticDiagramElements(editorGen.diagram), UpdaterLinkType::OUTGOING)»
- «FOR e : getAllSemanticElements(editorGen.diagram)»
+ «copyright(editorGen)»
+ package «packageName(it)»;
+
+ «generatedClassComment»
+ public class «className(it)» implements org.eclipse.papyrus.infra.gmfdiag.common.updater.DiagramUpdater {
+ «classSingleton(it)»
+ «_constructor(it)»
+ «isShortcutOrphaned(it)»
+ «var semanticContainers = it.editorGen.diagram.allContainers.filter[container|hasSemanticChildren(container)]»
+ «getGenericSemanticChildrenOfView(it, semanticContainers)»
+ «FOR next : semanticContainers»
+ «getSemanticChildrenOfView(next)»
+ «ENDFOR»
+
+ «getPhantomNodesIterator(it)»
+
+ «getGenericConnectedLinks(it, getAllSemanticElements(editorGen.diagram), UpdaterLinkType::CONTAINED)»
+
+ «getGenericConnectedLinks(it, getAllSemanticDiagramElements(editorGen.diagram), UpdaterLinkType::INCOMING)»
+
+ «getGenericConnectedLinks(it, getAllSemanticDiagramElements(editorGen.diagram), UpdaterLinkType::OUTGOING)»
+ «FOR e : getAllSemanticElements(editorGen.diagram)»
«getContainedLinks(e)»
- «ENDFOR»
- «FOR e : getAllSemanticDiagramElements(editorGen.diagram)»
+ «ENDFOR»
+ «FOR e : getAllSemanticDiagramElements(editorGen.diagram)»
«getIncomingLinks(e)»
- «ENDFOR»
- «FOR e : getAllSemanticDiagramElements(editorGen.diagram)»
+ «ENDFOR»
+ «FOR e : getAllSemanticDiagramElements(editorGen.diagram)»
«getOutgoingLinks(e)»
- «ENDFOR»
- «FOR link : getAllContainedLinks(editorGen.diagram)»
+ «ENDFOR»
+ «FOR link : getAllContainedLinks(editorGen.diagram)»
«getContainedLinksByTypeMethod(link)»
- «ENDFOR»
- «FOR link : getAllIncomingLinks(editorGen.diagram)»
+ «ENDFOR»
+ «FOR link : getAllIncomingLinks(editorGen.diagram)»
«getIncomingLinksByTypeMethod(link)»
- «ENDFOR»
- «FOR link : getAllOutgoingLinks(editorGen.diagram)»
+ «ENDFOR»
+ «FOR link : getAllOutgoingLinks(editorGen.diagram)»
«getOutgoingLinksByTypeMethod(link)»
- «ENDFOR»
-
- «runtimeTypedInstance(it)»
-
- «additions(it)»
- }
+ «ENDFOR»
+
+ «runtimeTypedInstance(it)»
+
+ «additions(it)»
+ }
'''
/**
@@ -149,18 +158,22 @@ import xpt.providers.ElementTypes
protected def typeOfCrossReferenceMap() '''java.util.Map<org.eclipse.emf.ecore.EObject, java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting>>'''
def getGenericSemanticChildrenOfView(GenDiagramUpdater it, Iterable<GenContainerBase> semanticContainers) '''
-
- «generatedMemberComment»
- public static «listOfNodeDescriptors» getSemanticChildren(org.eclipse.gmf.runtime.notation.View view) {
- «IF semanticContainers.notEmpty»
- switch («xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»(view)) {
- «FOR next : semanticContainers»
- «getSemanticChildrenCase(next)»
- «ENDFOR»
+
+ «generatedMemberComment»
+ ««« remove static modifier
+ public «listOfNodeDescriptors» getSemanticChildren(org.eclipse.gmf.runtime.notation.View view) {
+ «IF semanticContainers.notEmpty»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»(view);
+ if (vid != null) {
+ switch (vid) {
+ «FOR next : semanticContainers»
+ «getSemanticChildrenCase(next)»
+ «ENDFOR»
+ }
+ }
+ «ENDIF»
+ return «newEmptyList()»;
}
- «ENDIF»
- return «newEmptyList()»;
- }
'''
def getSemanticChildrenCase(GenContainerBase it) '''
@@ -169,46 +182,55 @@ import xpt.providers.ElementTypes
'''
def getSemanticChildrenOfView(GenContainerBase it) '''
-
- «generatedMemberComment»
- public static «listOfNodeDescriptors» «getSemanticChildrenMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
- «IF getSemanticChildrenChildFeatures(it).notEmpty || it.getPhantomNodes().notEmpty»
- «defineModelElement(it)»
- «newLinkedListOfNodeDescriptors(it.diagramUpdater, 'result')»();
- «/* childMetaFeature can be null here! */
- FOR childMetaFeature : getSemanticChildrenChildFeatures(it)»
- «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 childMetaFeature.listType»
- for (java.util.Iterator<?> it = «xptMetaModel.getFeatureValue(childMetaFeature, 'modelElement', it.getModelElementType())».iterator(); it.hasNext();) {
- «xptMetaModel.DeclareAndAssign(childMetaFeature.typeGenClass, 'childElement', 'it.next()', true)»
- «ELSE»
- { «xptMetaModel.DeclareAndAssign(childMetaFeature.typeGenClass, 'childElement', 'modelElement', it.getModelElementType(), childMetaFeature)»
- «ENDIF»
- int visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it.diagram)»(view, «xptMetaModel.DowncastToEObject(childMetaFeature.typeGenClass, 'childElement')»);
- «FOR next : getSemanticChildren(it, childMetaFeature)»
- «checkChildElementVisualID(next, null != childMetaFeature && childMetaFeature.listType)»
- «ENDFOR»
+ «««remove static modifier
+ «IF specificDiagramUpdaterClassName !== null»
+ «generatedMemberComment»
+ public «listOfNodeDescriptors» «getSemanticChildrenMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
+ «getICustomDiagramUpdater(it)» customUpdater = new «specificDiagramUpdaterClassName»();
+ return customUpdater.getSemanticChildren(view);
}
- «ENDFOR»
- «IF it.getPhantomNodes.notEmpty»
- org.eclipse.emf.ecore.resource.Resource resource = modelElement.eResource();
- for (java.util.Iterator<org.eclipse.emf.ecore.EObject> it = getPhantomNodesIterator(resource); it.hasNext();) {
- org.eclipse.emf.ecore.EObject childElement = it.next();
- if (childElement == modelElement) {
- continue;
- }
- «FOR phantom : it.phantomNodes»
- «addNextIfPhantom(phantom)»
+ «ELSE»
+ «generatedMemberComment»
+ public «listOfNodeDescriptors» «getSemanticChildrenMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
+ «IF getSemanticChildrenChildFeatures(it).notEmpty || it.getPhantomNodes().notEmpty»
+ «defineModelElement(it)»
+ «newLinkedListOfNodeDescriptors(it.diagramUpdater, 'result')»();
+ «/* childMetaFeature can be null here! */FOR childMetaFeature : getSemanticChildrenChildFeatures(it)»
+ «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 childMetaFeature.listType»
+ for (java.util.Iterator<?> it = «xptMetaModel.getFeatureValue(childMetaFeature, 'modelElement', it.getModelElementType())».iterator(); it.hasNext();) {
+ «xptMetaModel.DeclareAndAssign(childMetaFeature.typeGenClass, 'childElement', 'it.next()', true)»
+ «ELSE»
+ { «xptMetaModel.DeclareAndAssign(childMetaFeature.typeGenClass, 'childElement', 'modelElement',
+ it.getModelElementType(), childMetaFeature)»
+ «ENDIF»
+ String visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it.diagram)»(view, «xptMetaModel.
+ DowncastToEObject(childMetaFeature.typeGenClass, 'childElement')»);
+ «FOR next : getSemanticChildren(it, childMetaFeature)»
+ «checkChildElementVisualID(next, null != childMetaFeature && childMetaFeature.listType)»
+ «ENDFOR»
+ }
«ENDFOR»
- }
- «ENDIF»
- return result;
- «ELSE»
- return «newEmptyList()»;
- «ENDIF»
- }
+ «IF it.getPhantomNodes.notEmpty»
+ org.eclipse.emf.ecore.resource.Resource resource = modelElement.eResource();
+ for (java.util.Iterator<org.eclipse.emf.ecore.EObject> it = getPhantomNodesIterator(resource); it.hasNext();) {
+ org.eclipse.emf.ecore.EObject childElement = it.next();
+ if (childElement == modelElement) {
+ continue;
+ }
+ «FOR phantom : it.phantomNodes»
+ «addNextIfPhantom(phantom)»
+ «ENDFOR»
+ }
+ «ENDIF»
+ return result;
+ «ELSE»
+ return «newEmptyList()»;
+ «ENDIF»
+ }
+ «ENDIF»
'''
def dispatch defineModelElement(GenContainerBase it) '''
@@ -235,7 +257,7 @@ import xpt.providers.ElementTypes
* Need to check with case when it.modelFacet.childMetaFeature == null
*/
def checkChildElementVisualID(GenNode it, Boolean inLoop) '''
- if (visualID == «VisualIDRegistry::visualID(it)») {
+ if («VisualIDRegistry::visualID(it)».equals(visualID)) {
result.add(new «nodeDescriptor.qualifiedClassName(it.getDiagram().diagramUpdater)»(«IF null != modelFacet.childMetaFeature»«xptMetaModel.DowncastToEObject(modelFacet.childMetaFeature.typeGenClass, 'childElement')», «ENDIF»visualID));
«IF inLoop»
continue;
@@ -243,6 +265,7 @@ import xpt.providers.ElementTypes
}
'''
+
def addNextIfPhantom(GenNode it) '''
if («xptVisualIDRegistry.getNodeVisualIDMethodCall(it.diagram)»(view, childElement) == «VisualIDRegistry::visualID(it)») {
result.add(new «nodeDescriptor.qualifiedClassName(it.getDiagram().diagramUpdater)»(childElement, «VisualIDRegistry::visualID(it)»));
@@ -262,17 +285,22 @@ import xpt.providers.ElementTypes
'''
def getGenericConnectedLinks(GenDiagramUpdater it, Iterable<? extends GenCommonBase> linkContainers, UpdaterLinkType linkType) '''
- «generatedMemberComment»
- public static «listOfLinkDescriptors» get«linkType.linkMethodSuffix»Links(org.eclipse.gmf.runtime.notation.View view) {
- «IF linkContainers.notEmpty»
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view)) {
- «FOR next : linkContainers»
- «getContainedLinksCase(next, linkType)»
- «ENDFOR»
+
+ «generatedMemberComment»
+ ««« remove static modifier
+ public «listOfLinkDescriptors» get«linkType.linkMethodSuffix»Links(org.eclipse.gmf.runtime.notation.View view) {
+ «IF linkContainers.notEmpty»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view);
+ if (vid != null) {
+ switch (vid) {
+ «FOR next : linkContainers»
+ «getContainedLinksCase(next, linkType)»
+ «ENDFOR»
+ }
+ }
+ «ENDIF»
+ return «newEmptyList»;
}
- «ENDIF»
- return «newEmptyList»;
- }
'''
def getContainedLinksCase(GenCommonBase it, UpdaterLinkType linkType) '''
@@ -297,36 +325,38 @@ import xpt.providers.ElementTypes
'''
def getConnectedLinks(GenCommonBase it, Iterable<GenLink> genLinks, UpdaterLinkType linkType, boolean needCrossReferencer) '''
-
- «generatedMemberComment»
- public static «listOfLinkDescriptors(it)» «linkGetterName(it, linkType)»(org.eclipse.gmf.runtime.notation.View view) {
- «IF genLinks.notEmpty»
- «xptMetaModel.DeclareAndAssign(it.metaClass, 'modelElement', 'view.getElement()')»
- «IF needCrossReferencer»
- «typeOfCrossReferenceMap» crossReferences = org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+
+ «generatedMemberComment»
+ «««remove static modifier
+ public «listOfLinkDescriptors(it)» «linkGetterName(it, linkType)»(org.eclipse.gmf.runtime.notation.View view) {
+ «IF genLinks.notEmpty»
+ «xptMetaModel.DeclareAndAssign(it.metaClass, 'modelElement', 'view.getElement()')»
+ «IF needCrossReferencer»
+ «typeOfCrossReferenceAdapter» crossReferencer = «typeOfCrossReferenceAdapter».getCrossReferenceAdapter(view.eResource().getResourceSet());
+ «ENDIF»
+ «newLinkedListOfLinkDescriptors(it.diagramUpdater, 'result')»();
+ «FOR link : genLinks»
+ «colectConnectedLinks(link, linkType, needCrossReferencer, isExternalInterface(it.metaClass))»
+ «ENDFOR»
+ return result;
+ «ELSE»
+ return «newEmptyList()»;
«ENDIF»
- «newLinkedListOfLinkDescriptors(it.diagramUpdater, 'result')»();
- «FOR link : genLinks»
- «colectConnectedLinks(link, linkType, needCrossReferencer, isExternalInterface(it.metaClass))»
- «ENDFOR»
- return result;
- «ELSE»
- return «newEmptyList()»;
- «ENDIF»
- }
+ }
'''
def colectConnectedLinks(GenLink it, UpdaterLinkType linkType, boolean needCrossReferencer, boolean isExternalInterface) '''
- «IF it.modelFacet != null»
- «IF isExternalInterface && !it.modelFacet.oclIsKindOf(typeof(FeatureLinkModelFacet))»
- if («xptMetaModel.IsInstance(it.modelFacet.getLinkEndType(linkType), 'modelElement')») {
- «ENDIF»
+ «IF it.modelFacet != null»
+ «IF isExternalInterface && !it.modelFacet.oclIsKindOf(typeof(FeatureLinkModelFacet))»
+ if («xptMetaModel.IsInstance(it.modelFacet.getLinkEndType(linkType), 'modelElement')») {
+ «ENDIF»
result.addAll(«chooseConnectedLinksByTypeMethodName(it.modelFacet, linkType, it)»(« //
- IF isExternalInterface && !it.modelFacet.oclIsKindOf(typeof(FeatureLinkModelFacet))»«xptMetaModel.CastEObject(it.modelFacet.getLinkEndType(linkType), 'modelElement')»«ELSE»modelElement«ENDIF»«IF needCrossReferencer», crossReferences«ENDIF»));
- «IF isExternalInterface && !it.modelFacet.oclIsKindOf(typeof(FeatureLinkModelFacet))»
- }
+ IF isExternalInterface && !it.modelFacet.oclIsKindOf(typeof(FeatureLinkModelFacet))»«xptMetaModel.
+ CastEObject(it.modelFacet.getLinkEndType(linkType), 'modelElement')»«ELSE»modelElement«ENDIF»«IF needCrossReferencer», crossReferencer«ENDIF»));
+ «IF isExternalInterface && !it.modelFacet.oclIsKindOf(typeof(FeatureLinkModelFacet))»
+ }
+ «ENDIF»
«ENDIF»
- «ENDIF»
'''
def dispatch chooseConnectedLinksByTypeMethodName(LinkModelFacet it, UpdaterLinkType type, GenLink genLink) '''«incorrectLinkModelFacet(it)»'''
@@ -355,11 +385,11 @@ import xpt.providers.ElementTypes
def getContainedLinksByTypeMethod(GenLink it) '''«getContainedLinksByTypeMethod(it.modelFacet, it)»'''
- def getConnectedLinksByTypeMethodName(GenLink it, UpdaterLinkType linkType) '''get«linkType.linkMethodSuffix»«getConnectedLinksByTypeMethodFragment(modelFacet)»_«visualID»'''
+ def getConnectedLinksByTypeMethodName(GenLink it, UpdaterLinkType linkType) '''get«linkType.linkMethodSuffix»«getConnectedLinksByTypeMethodFragment(modelFacet)»_«stringVisualID»'''
- def dispatch getConnectedLinksByTypeMethodFragment(TypeLinkModelFacet it) '''TypeModelFacetLinks_«metaClass.ecoreClass.name»'''
+ def dispatch getConnectedLinksByTypeMethodFragment(TypeLinkModelFacet it) '''TypeModelFacetLinks'''
- def dispatch getConnectedLinksByTypeMethodFragment(FeatureLinkModelFacet it) '''FeatureModelFacetLinks_«metaFeature.genClass.ecoreClass.name»_«metaFeature.ecoreFeature.name.toFirstUpper()»'''
+ def dispatch getConnectedLinksByTypeMethodFragment(FeatureLinkModelFacet it) '''FeatureModelFacetLinks'''
def dispatch getConnectedLinksByTypeMethodFragment(LinkModelFacet it) '''«incorrectLinkModelFacet(it)»'''
@@ -368,11 +398,13 @@ import xpt.providers.ElementTypes
def dispatch getContainedLinksByTypeMethod(FeatureLinkModelFacet it, GenLink genLink) ''''''
def dispatch getContainedLinksByTypeMethod(TypeLinkModelFacet it, GenLink genLink) '''
-
- «generatedMemberComment»
- private static java.util.Collection<«linkDescriptor.qualifiedClassName(genLink.diagramUpdater)»> «getConnectedLinksByTypeMethodName(genLink, UpdaterLinkType::CONTAINED)»(«xptMetaModel.QualifiedClassName(childMetaFeature.genClass)» container) {
- «getContainedLinksByTypeMethodBody(it, genLink, false)»
- }
+
+ «generatedMemberComment»
+ ««« remove static modifier + private->protected
+ protected java.util.Collection<«linkDescriptor.qualifiedClassName(genLink.diagramUpdater)»> «getConnectedLinksByTypeMethodName(
+ genLink, UpdaterLinkType::CONTAINED)»(«xptMetaModel.QualifiedClassName(childMetaFeature.genClass)» container) {
+ «getContainedLinksByTypeMethodBody(it, genLink, false)»
+ }
'''
def getContainedLinksByTypeMethodBody(TypeLinkModelFacet it, GenLink genLink, boolean sourceVarDefined) '''
@@ -422,21 +454,21 @@ import xpt.providers.ElementTypes
'''
def checkLinkVisualID(TypeLinkModelFacet it, GenLink genLink, boolean inLoop) '''
- if («VisualIDRegistry::visualID(genLink)» != «xptVisualIDRegistry.getLinkWithClassVisualIDMethodCall(genLink.diagram)»(«xptMetaModel.DowncastToEObject(metaClass, 'link')»)) {
+ if (!«VisualIDRegistry::visualID(genLink)».equals(«xptVisualIDRegistry.getLinkWithClassVisualIDMethodCall(genLink.diagram)»(«xptMetaModel.DowncastToEObject(metaClass, 'link')»))) {
«stopLinkProcessing(inLoop)»
}
'''
def defineLinkSource(TypeLinkModelFacet it, boolean inLoop) '''
«IF sourceMetaFeature.listType»
- java.util.List sources = «xptMetaModel.getFeatureValue(sourceMetaFeature, 'link', metaClass)»;
- Object theSource = sources.size() == 1 ? sources.get(0) : null;
- if («xptMetaModel.NotInstance(it.sourceType, 'theSource')») {
- «stopLinkProcessing(inLoop)»
- }
- «xptMetaModel.DeclareAndAssign(it.sourceType, 'src', 'theSource', true)»
+ java.util.List<?> sources = «xptMetaModel.getFeatureValue(sourceMetaFeature, 'link', metaClass)»;
+ Object theSource = sources.size() == 1 ? sources.get(0) : null;
+ if («xptMetaModel.NotInstance(it.sourceType, 'theSource')») {
+ «stopLinkProcessing(inLoop)»
+ }
+ «xptMetaModel.DeclareAndAssign(it.sourceType, 'src', 'theSource', true)»
«ELSE»
- «xptMetaModel.DeclareAndAssign(it.sourceType, 'src', 'link', metaClass, sourceMetaFeature)»
+ «xptMetaModel.DeclareAndAssign(it.sourceType, 'src', 'link', metaClass, sourceMetaFeature)»
«ENDIF»
'''
@@ -448,17 +480,18 @@ import xpt.providers.ElementTypes
def defineLinkDestination(TypeLinkModelFacet it, Boolean inLoop) '''
«IF targetMetaFeature.listType»
- java.util.List targets = «xptMetaModel.getFeatureValue(it.targetMetaFeature, 'link', metaClass)»;
- Object theTarget = targets.size() == 1 ? targets.get(0) : null;
- if («xptMetaModel.NotInstance(it.targetType, 'theTarget')») {
- «stopLinkProcessing(inLoop)»
- }
- «xptMetaModel.DeclareAndAssign(it.targetType, 'dst', 'theTarget', true)»
+ java.util.List<?> targets = «xptMetaModel.getFeatureValue(it.targetMetaFeature, 'link', metaClass)»;
+ Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+ if («xptMetaModel.NotInstance(it.targetType, 'theTarget')») {
+ «stopLinkProcessing(inLoop)»
+ }
+ «xptMetaModel.DeclareAndAssign(it.targetType, 'dst', 'theTarget', true)»
«ELSE»
- «xptMetaModel.DeclareAndAssign(it.targetType, 'dst', 'link', metaClass, targetMetaFeature)»
+ «xptMetaModel.DeclareAndAssign(it.targetType, 'dst', 'link', metaClass, targetMetaFeature)»
«ENDIF»
'''
+
def stopLinkProcessing(boolean inLoop) '''
«IF inLoop»
continue;
@@ -468,16 +501,17 @@ import xpt.providers.ElementTypes
'''
def getIncomingLinksByTypeMethod(GenLink it) '''
-
- «generatedMemberComment»
- private static java.util.Collection<«linkDescriptor.qualifiedClassName(it.diagramUpdater)»> «getConnectedLinksByTypeMethodName(UpdaterLinkType::INCOMING)»(«xptMetaModel.QualifiedClassName(it.modelFacet.targetType)» target, «typeOfCrossReferenceMap» crossReferences) {
- «newLinkedListOfLinkDescriptors(it.diagramUpdater, 'result')»();
- java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> settings = crossReferences.get(target);
- for (org.eclipse.emf.ecore.EStructuralFeature.Setting setting : settings) {
- «getIncomingLinksByTypeMethodBody(it.modelFacet, it)»
+ «generatedMemberComment»
+ «««remove static modifier + private->protected
+ protected java.util.Collection<«linkDescriptor.qualifiedClassName(it.diagramUpdater)»> «getConnectedLinksByTypeMethodName(
+ UpdaterLinkType::INCOMING)»(«xptMetaModel.QualifiedClassName(it.modelFacet.targetType)» target, «typeOfCrossReferenceAdapter» crossReferencer) {
+ «newLinkedListOfLinkDescriptors(it.diagramUpdater, 'result')»();
+ java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target);
+ for (org.eclipse.emf.ecore.EStructuralFeature.Setting setting : settings) {
+ «getIncomingLinksByTypeMethodBody(it.modelFacet, it)»
+ }
+ return result;
}
- return result;
- }
'''
def dispatch getIncomingLinksByTypeMethodBody(TypeLinkModelFacet it, GenLink genLink) '''
@@ -519,8 +553,9 @@ import xpt.providers.ElementTypes
«getOutgoingLinksByTypeMethod(it.modelFacet, it)»
'''
- def getOutgoingLinksByTypeMethodSignature(GenLink it) //
- '''private static java.util.Collection<«linkDescriptor.qualifiedClassName(it.diagramUpdater)»> «getConnectedLinksByTypeMethodName(UpdaterLinkType::OUTGOING)»(«xptMetaModel.QualifiedClassName(it.modelFacet.sourceType)» source)'''
+ def getOutgoingLinksByTypeMethodSignature(GenLink it) '''protected java.util.Collection<«linkDescriptor.
+ qualifiedClassName(it.diagramUpdater)»> «getConnectedLinksByTypeMethodName(UpdaterLinkType::OUTGOING)»(«xptMetaModel.
+ QualifiedClassName(it.modelFacet.sourceType)» source)'''
def dispatch getOutgoingLinksByTypeMethod(FeatureLinkModelFacet it, GenLink genLink) '''
«generatedMemberComment»
@@ -572,33 +607,40 @@ import xpt.providers.ElementTypes
def incorrectLinkModelFacet(LinkModelFacet it) '''«ERROR('Incorrect LinkModelFacet: ' + it)»'''
def runtimeTypedInstance(GenDiagramUpdater it) '''
- «generatedMemberComment»
- public static final org.eclipse.gmf.tooling.runtime.update.DiagramUpdater «runtimeTypedInstanceName(it)» = new org.eclipse.gmf.tooling.runtime.update.DiagramUpdater() {
- «generatedMemberComment»
- «xptCodeStyle.overrideI(it.editorGen.diagram)»
- public java.util.List<«nodeDescriptor.qualifiedClassName(it)»> getSemanticChildren(org.eclipse.gmf.runtime.notation.View view) {
- return «className(it)».getSemanticChildren(view);
- }
-
- «generatedMemberComment»
- «xptCodeStyle.overrideI(it.editorGen.diagram)»
- public java.util.List<«linkDescriptor.qualifiedClassName(it)»> getContainedLinks(org.eclipse.gmf.runtime.notation.View view) {
- return «className(it)».getContainedLinks(view);
- }
-
- «generatedMemberComment»
- «xptCodeStyle.overrideI(it.editorGen.diagram)»
- public java.util.List<«linkDescriptor.qualifiedClassName(it)»> getIncomingLinks(org.eclipse.gmf.runtime.notation.View view) {
- return «className(it)».getIncomingLinks(view);
- }
-
- «generatedMemberComment»
- «xptCodeStyle.overrideI(it.editorGen.diagram)»
- public java.util.List<«linkDescriptor.qualifiedClassName(it)»> getOutgoingLinks(org.eclipse.gmf.runtime.notation.View view) {
- return «className(it)».getOutgoingLinks(view);
- }
- };
- '''
+ '''
def additions(GenDiagramUpdater it) ''''''
+
+ def diagramUpdaterInstanceToUse(GenDiagramUpdater it) '''
+ «IF customDiagramUpdaterSingletonPath !== null»
+ «customDiagramUpdaterSingletonPath»
+ «ELSE»
+ «diagramUpdaterQualifiedClassName».INSTANCE
+ «ENDIF»
+ '''
+
+ def typeOfCrossReferenceAdapter() '''org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter'''
+
+ def _constructor(GenDiagramUpdater it) '''
+ «generatedMemberComment()»
+ protected «diagramUpdaterClassName»(){
+ //to prevent instantiation allowing the override
+ }
+ '''
+
+ //create the singleton using custom class defined in GMFGen
+ def classSingleton(GenDiagramUpdater it) '''
+ «««we create the singleton only in the case where there is no custom diagram updater
+ «IF customDiagramUpdaterSingletonPath === null»
+ «generatedMemberComment()»
+ public static final «diagramUpdaterQualifiedClassName» INSTANCE = new «diagramUpdaterClassName»();
+ «ENDIF»
+ '''
+
+ def CharSequence getICustomDiagramUpdater(GenContainerBase it) '''org.eclipse.papyrus.uml.diagram.common.part.ICustomDiagramUpdater<«nodeDescriptor.
+ qualifiedClassName(it.diagramUpdater)»>'''
+
+
+ def isDiagram(GenDiagram it) ''''''
+
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/LinkDescriptor.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/LinkDescriptor.xtend
index 5281a327cc0..288a2e302ff 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/LinkDescriptor.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/LinkDescriptor.xtend
@@ -1,18 +1,20 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime (#372479)
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime, template migrated to Xtend2
+ * Christian W. Damus (CEA) - bug 426732: override the cross-reference searches for views to use the CrossReferenceAdapter
* - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.updater
@@ -45,21 +47,22 @@ import xpt.Common
}
'''
- def extendsList(GenDiagramUpdater it) '''extends org.eclipse.gmf.tooling.runtime.update.UpdaterLinkDescriptor'''
+ def extendsList(GenDiagramUpdater it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.updater.UpdaterLinkDescriptor'''
def refOnlyLinkConstructor(GenDiagramUpdater it) '''
«generatedMemberComment»
- public «className(it)»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.gmf.runtime.emf.type.core.IElementType elementType, int linkVID) {
+ public «className(it)»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.gmf.runtime.emf.type.core.IElementType elementType, String linkVID) {
super(source, destination, elementType, linkVID);
}
'''
def typeLinkConstructor(GenDiagramUpdater it) '''
«generatedMemberComment»
- public «className(it)»(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) {
+ public «className(it)»(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, String linkVID) {
super(source, destination, linkElement, elementType, linkVID);
}
'''
def additions(GenDiagramUpdater it) ''''''
-}
+
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/NodeDescriptor.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/NodeDescriptor.xtend
index 459aa649bb1..e5b9fe76fd9 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/NodeDescriptor.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/NodeDescriptor.xtend
@@ -1,18 +1,21 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime (#372479)
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime, template migrated to Xtend2
+ * Christian W. Damus (CEA) - bug 426732: override the cross-reference searches for views to use the CrossReferenceAdapter
+* Michael Golubev (Montages) - API extracted to gmf.tooling.runtime (#372479)
* - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.updater
@@ -43,11 +46,11 @@ import xpt.Common
}
'''
- def extendsList(GenDiagramUpdater it) '''extends org.eclipse.gmf.tooling.runtime.update.UpdaterNodeDescriptor'''
+ def extendsList(GenDiagramUpdater it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.updater.UpdaterNodeDescriptor'''
def constructor(GenDiagramUpdater it) '''
«generatedMemberComment»
- public «className(it)»(org.eclipse.emf.ecore.EObject modelElement, int visualID) {
+ public «className(it)»(org.eclipse.emf.ecore.EObject modelElement, String visualID) {
super(modelElement, visualID);
}
'''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/extensions.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/extensions.xtend
index a03b639e9bd..d376c0e7c0d 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/extensions.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/updater/extensions.xtend
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*****************************************************************************
* Copyright (c) 2007, 2020, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
* Contributors:
* Alexander Shatalin (Borland) - initial API and implementation
* Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Gabriel Pascual (ALL4TEC) - Bug 372322 : [Diagram - Refresh] The refresh action is not correctly binded to F5
* Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : PapyrusGmfExtension epackage merge into gmfgen
*****************************************************************************/
package xpt.diagram.updater
@@ -21,29 +21,8 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagramUpdater
@Singleton class extensions {
- def extensions(GenDiagramUpdater it) '''
-««« !!! was overriden by papyrus to remove this !!!
-«««
-««« «extraLineBreak»
-««« «extraLineBreak»
-««« «tripleSpace(1)»<extension point="org.eclipse.ui.commands" id="update-cmd">
-««« «tripleSpace(2)»«xmlGeneratedTag»
-««« «tripleSpace(2)»<command
-««« «tripleSpace(3)»categoryId="org.eclipse.ui.category.edit"
-««« «tripleSpace(3)»defaultHandler="«getUpdateCommandQualifiedClassName()»"
-««« «tripleSpace(3)»description="%update.diagram.description"
-««« «tripleSpace(3)»id="«updateCommandID»"
-««« «tripleSpace(3)»name="%update.diagram.name"/>
-««« «tripleSpace(1)»</extension>
-««« «extraLineBreak»«outTab»
-««« «tripleSpace(1)»<extension point="org.eclipse.ui.bindings" id="update-cmd-binding">
-««« «tripleSpace(2)»«xmlGeneratedTag»
-««« «tripleSpace(2)»<key
-««« «tripleSpace(3)»commandId="«updateCommandID»"
-««« «tripleSpace(3)»contextId="«editorGen.editor.contextID»"
-««« «tripleSpace(3)»schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
-««« «tripleSpace(3)»sequence="F5"/>
-««« «tripleSpace(1)»</extension>
- '''
+ def extensions(GenDiagramUpdater it) {
+ // Override Refresh contribution
+ }
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/views/ViewStyles.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/views/ViewStyles.xtend
index 5f390764949..ec41a55f582 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/views/ViewStyles.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/diagram/views/ViewStyles.xtend
@@ -1,18 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.diagram.views
@@ -120,20 +120,24 @@ import xpt.diagram.ViewmapAttributesUtils_qvto
'''
def dispatch offset(GenExternalNodeLabel it, String viewVar) '''
- «offset(viewVar, 0, 5)»
+ «IF labelOffsetX(viewmap, 0) != 0 || labelOffsetY(viewmap, 0) != 0»
+ «offset(it,viewVar, labelOffsetX(viewmap, 0), labelOffsetY(viewmap, 0))»
+ «ELSE»
+ «offset(it,viewVar, 0, 15)»
+ «ENDIF»
'''
-
/**
* viewVar must be already inserted into a diagram (view.getDiagram() should be meaningful)
*/
def offset(GenLabel it, String viewVar, int x, int y) '''
- org.eclipse.gmf.runtime.notation.Location location«visualID» = (org.eclipse.gmf.runtime.notation.Location) «viewVar».getLayoutConstraint();
+ «val location = stringUniqueIdentifier.toFirstLower+'_Location'»
+ org.eclipse.gmf.runtime.notation.Location «location» = (org.eclipse.gmf.runtime.notation.Location) «viewVar».getLayoutConstraint();
«IF it.getDiagram().isPixelMapMode()»
- location«visualID».setX(«x»);
- location«visualID».setY(«y»);
+ «location».setX(«x»);
+ «location».setY(«y»);
«ELSE»
- location«visualID».setX(org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(«viewVar».getDiagram().getMeasurementUnit()).DPtoLP(«x»));
- location«visualID».setY(org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(«viewVar».getDiagram().getMeasurementUnit()).DPtoLP(«y»));
+ «location».setX(org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(«viewVar».getDiagram().getMeasurementUnit()).DPtoLP(«x»));
+ «location».setY(org.eclipse.gmf.runtime.diagram.ui.util.MeasurementUnitHelper.getMapMode(«viewVar».getDiagram().getMeasurementUnit()).DPtoLP(«y»));
«ENDIF»
'''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ActionBarContributor.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ActionBarContributor.xtend
index 4b7014d5a44..9a7c764f779 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ActionBarContributor.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ActionBarContributor.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
@@ -50,7 +50,8 @@ import xpt.providers.MetricProvider
public class «className(it)» «extendsList(it)» {
«generatedMemberComment»
- protected Class getEditorClass() {
+
+ protected Class<«xptEditor.qualifiedClassName(it)»> getEditorClass() {
return «xptEditor.qualifiedClassName(it)».class;
}
@@ -96,5 +97,4 @@ import xpt.providers.MetricProvider
'''
def additions(GenEditorView it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/CreationWizard.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/CreationWizard.xtend
index 30dc3690739..968ffa7e311 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/CreationWizard.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/CreationWizard.xtend
@@ -1,17 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2014, 2021 Borland Software Corporation, Montages, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Anatloyi Tischenko - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
@@ -22,9 +23,11 @@ import xpt.Common
import xpt.Externalizer
import xpt.ExternalizerUtils_qvto
import plugin.Activator
+import xpt.CodeStyle
@com.google.inject.Singleton class CreationWizard {
@Inject extension Common;
+ @Inject extension CodeStyle;
@Inject extension GenDiagram_qvto;
@Inject extension ExternalizerUtils_qvto;
@@ -122,6 +125,7 @@ import plugin.Activator
domainModelFilePage = new «xptCreationWizardPage.qualifiedClassName(it)»(
"DomainModelFile", getSelection(), "«editorGen.domainFileExtension»") { //$NON-NLS-1$ //$NON-NLS-2$
+ «overrideC»
public void setVisible(boolean visible) {
if (visible) {
String fileName = diagramModelFilePage.getFileName();
@@ -146,6 +150,7 @@ import plugin.Activator
«IF editorGen.application == null»
new org.eclipse.ui.actions.WorkspaceModifyOperation(null) {
+ «overrideC»
protected void execute(org.eclipse.core.runtime.IProgressMonitor monitor)
throws org.eclipse.core.runtime.CoreException, InterruptedException {
«ELSE»
@@ -240,4 +245,4 @@ import plugin.Activator
return '' + className(diagram) + 'CreationError'
}
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramContentInitializer.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramContentInitializer.xtend
index b54f519d9a0..bd77748947c 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramContentInitializer.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramContentInitializer.xtend
@@ -1,17 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2016, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Florian Noyrit - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
@@ -102,7 +103,7 @@ import xpt.diagram.updater.LinkDescriptor
}
'''
- @MetaDef def createChildrenMethodName(GenContainerBase it) '''create«it.uniqueIdentifier»Children'''
+ @MetaDef def createChildrenMethodName(GenContainerBase it) '''create«it.stringUniqueIdentifier»_Children'''
def createChildren(GenContainerBase it) '''
«generatedMemberComment»
@@ -202,7 +203,7 @@ import xpt.diagram.updater.LinkDescriptor
def getCompartment(GenDiagram it) '''
«generatedMemberComment»
- private org.eclipse.gmf.runtime.notation.Node getCompartment(org.eclipse.gmf.runtime.notation.View node, int visualID) {
+ private org.eclipse.gmf.runtime.notation.Node getCompartment(org.eclipse.gmf.runtime.notation.View node, String visualID) {
String type = «xptVisualIDRegistry.typeMethodCall(it, '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();
@@ -215,5 +216,4 @@ import xpt.diagram.updater.LinkDescriptor
'''
def additions(GenDiagram it) ''''''
-
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorContextMenuProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorContextMenuProvider.xtend
index 64b2f4e2b7e..2e05a24e831 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorContextMenuProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorContextMenuProvider.xtend
@@ -1,31 +1,35 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2008, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.MetaDef
-import xpt.Common
import plugin.Activator
+import xpt.CodeStyle
+import xpt.Common
-@com.google.inject.Singleton class DiagramEditorContextMenuProvider {
+//We remove the dependency with DeleteElementAction. Now this action is added to the popup menu with the extension point org.eclipse.ui.popup
+//in org.eclipse.papyrus.uml.diagram.common
+@Singleton class DiagramEditorContextMenuProvider {
@Inject extension Common;
+ @Inject extension CodeStyle
@Inject Activator xptActivator;
- @Inject DeleteElementAction xptDeleteElementAction;
@MetaDef def className(GenDiagram it) '''DiagramEditorContextMenuProvider'''
@@ -35,6 +39,7 @@ import plugin.Activator
def fullPath(GenDiagram it) '''«qualifiedClassName(it)»'''
+
def DiagramEditorContextMenuProvider(GenDiagram it) '''
«copyright(editorGen)»
package «packageName(it)»;
@@ -45,25 +50,25 @@ import plugin.Activator
«generatedMemberComment»
private org.eclipse.ui.IWorkbenchPart part;
- «generatedMemberComment»
- private «xptDeleteElementAction.qualifiedClassName(it)» deleteAction;
+ ««« «generatedMemberComment»
+ ««« private «xptDeleteElementAction.qualifiedClassName(it)» deleteAction;
«generatedMemberComment»
public DiagramEditorContextMenuProvider(org.eclipse.ui.IWorkbenchPart part, org.eclipse.gef.EditPartViewer viewer) {
super(part, viewer);
this.part = part;
- deleteAction = new «xptDeleteElementAction.qualifiedClassName(it)»(part);
- deleteAction.init();
+ ««« deleteAction = new «xptDeleteElementAction.qualifiedClassName(it)»(part);
+ ««« deleteAction.init();
}
- «generatedMemberComment»
- public void dispose() {
- if (deleteAction != null) {
- deleteAction.dispose();
- deleteAction = null;
- }
- super.dispose();
- }
+ ««« «generatedMemberComment»
+ ««« public void dispose() {
+ ««« if (deleteAction != null) {
+ ««« deleteAction.dispose();
+ ««« deleteAction = null;
+ ««« }
+ ««« super.dispose();
+ ««« }
«generatedMemberComment»
public void buildContextMenu(final org.eclipse.jface.action.IMenuManager menu) {
@@ -72,11 +77,12 @@ import plugin.Activator
org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(
(org.eclipse.emf.ecore.EObject) getViewer().getContents().getModel()).runExclusive(new Runnable() {
+ «overrideI(it.editorGen.diagram)»
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);
+ ««« menu.appendToGroup("editGroup", deleteAction);
}
});
} catch (Exception e) {
@@ -86,7 +92,6 @@ import plugin.Activator
«additions(it)»
}
'''
-
def additions(GenDiagram it) ''''''
-
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorUtil.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorUtil.xtend
index f097f959924..cf4e01cf889 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorUtil.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DiagramEditorUtil.xtend
@@ -1,32 +1,36 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2007, 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - #510281 change dependency to replace gmft-runtime
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
+import com.google.inject.Singleton
import metamodel.MetaModel
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.MetaDef
import plugin.Activator
+import xpt.CodeStyle
import xpt.Common
import xpt.Externalizer
import xpt.ExternalizerUtils_qvto
-@com.google.inject.Singleton class DiagramEditorUtil {
+@Singleton class DiagramEditorUtil {
@Inject extension Common;
+ @Inject extension CodeStyle;
@Inject extension GenDiagram_qvto;
@Inject extension ExternalizerUtils_qvto;
@@ -193,8 +197,8 @@ import xpt.ExternalizerUtils_qvto
def getUniqueFileNameMethod(GenDiagram it) '''
«generatedMemberComment»
public static String getUniqueFileName(org.eclipse.core.runtime.IPath containerFullPath, String fileName, String extension) {
- return org.eclipse.gmf.tooling.runtime.part.DefaultDiagramEditorUtil.getUniqueFileName(containerFullPath, fileName, extension, «»
- org.eclipse.gmf.tooling.runtime.part.DefaultDiagramEditorUtil.«IF editorGen.application == null»EXISTS_IN_WORKSPACE«ELSE»EXISTS_AS_IO_FILE«ENDIF»);
+ return org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.part.DefaultDiagramEditorUtil.getUniqueFileName(containerFullPath, fileName, extension, «»
+ org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.part.DefaultDiagramEditorUtil.«IF editorGen.application == null»EXISTS_IN_WORKSPACE«ELSE»EXISTS_AS_IO_FILE«ENDIF»);
}
'''
@@ -203,7 +207,7 @@ import xpt.ExternalizerUtils_qvto
(if(editorGen.application == null) 'This method should be called within a workspace modify operation since it creates resources.' else ''))»
public static org.eclipse.emf.ecore.resource.Resource createDiagram(org.eclipse.emf.common.util.URI diagramURI,«IF standaloneDomainModel(
it)» 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();
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.emf.workspace.WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
progressMonitor.beginTask(«xptExternalizer.accessorCall(editorGen, i18nKeyForCreateDiagramProgressTask(it))», 3);
final org.eclipse.emf.ecore.resource.Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI);
«IF standaloneDomainModel(it)»
@@ -215,6 +219,7 @@ import xpt.ExternalizerUtils_qvto
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, «xptExternalizer.
accessorCall(editorGen, i18nKeyForCreateDiagramCommandLabel(it))», java.util.Collections.EMPTY_LIST) {
+ «overrideC»
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»
«xptMetaModel.QualifiedClassName(domainDiagramElement)» model = createInitialModel();
@@ -458,4 +463,4 @@ import xpt.ExternalizerUtils_qvto
«xptExternalizer.messageEntry(i18nKeyForCreateDiagramCommandLabel(it), 'Creating diagram and model')»
'''
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DocumentProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DocumentProvider.xtend
index 4fc5385d897..ae173c3ce0e 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DocumentProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/DocumentProvider.xtend
@@ -1,21 +1,29 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+import plugin.Activator
+import xpt.Common
+import xpt.Externalizer
+import xpt.CodeStyle
+import xpt.editor.DiagramEditorUtil
+import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
import xpt.Common
@@ -24,6 +32,7 @@ import plugin.Activator
@com.google.inject.Singleton class DocumentProvider {
@Inject extension Common;
+ @Inject extension CodeStyle
@Inject Activator xptActivator;
@Inject Externalizer xptExternalizer;
@@ -225,14 +234,17 @@ import plugin.Activator
private org.eclipse.emf.common.notify.Notifier myTarger;
+ «overrideI»
public org.eclipse.emf.common.notify.Notifier getTarget() {
return myTarger;
}
+ «overrideI»
public boolean isAdapterForType(Object type) {
return false;
}
+ «overrideI»
public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
if (diagramResourceModifiedFilter.matches(notification)) {
Object value = notification.getNewValue();
@@ -242,6 +254,7 @@ import plugin.Activator
}
}
+ «overrideI»
public void setTarget(org.eclipse.emf.common.notify.Notifier newTarget) {
myTarger = newTarget;
}
@@ -271,7 +284,8 @@ import plugin.Activator
}
if (!resource.isLoaded()) {
try {
- java.util.Map options = new java.util.HashMap(org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory.getDefaultLoadOptions());
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ 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);
@@ -283,14 +297,14 @@ import plugin.Activator
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);
+ document.setContent(rootElement);
return;
}
} else {
- for (java.util.Iterator it = resource.getContents().iterator(); it.hasNext();) {
+ for (java.util.Iterator<org.eclipse.emf.ecore.EObject> 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);
+ document.setContent(rootElement);
return;
}
}
@@ -375,7 +389,7 @@ import plugin.Activator
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);
+ org.eclipse.core.resources.ResourcesPlugin.getWorkspace().validateEdit(files2Validate.toArray(new org.eclipse.core.resources.IFile[files2Validate.size()]), computationContext);
}
super.doValidateState(element, computationContext);
@@ -470,7 +484,7 @@ import plugin.Activator
}
'''
- def getResetRule(GenDiagram it) '''
+ def getResetRule(GenDiagram it)'''
«generatedMemberComment»
protected org.eclipse.core.runtime.jobs.ISchedulingRule getResetRule(Object element) {
ResourceSetInfo info = getResourceSetInfo(element);
@@ -483,7 +497,7 @@ import plugin.Activator
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 new org.eclipse.core.runtime.jobs.MultiRule(rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
}
return null;
}
@@ -502,7 +516,7 @@ import plugin.Activator
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 new org.eclipse.core.runtime.jobs.MultiRule(rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
}
return null;
}
@@ -521,7 +535,7 @@ import plugin.Activator
rules.add(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file));
}
}
- return new org.eclipse.core.runtime.jobs.MultiRule((org.eclipse.core.runtime.jobs.ISchedulingRule[]) rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
+ return new org.eclipse.core.runtime.jobs.MultiRule(rules.toArray(new org.eclipse.core.runtime.jobs.ISchedulingRule[rules.size()]));
}
return null;
}
@@ -540,7 +554,7 @@ import plugin.Activator
files.add(file);
}
}
- return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule((org.eclipse.core.resources.IFile[]) files.toArray(new org.eclipse.core.resources.IFile[files.size()]));
+ return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule(files.toArray(new org.eclipse.core.resources.IFile[files.size()]));
}
return null;
}
@@ -549,9 +563,9 @@ import plugin.Activator
def computeSchedulingRule(GenDiagram it) '''
«generatedMemberComment»
private org.eclipse.core.runtime.jobs.ISchedulingRule computeSchedulingRule(org.eclipse.core.resources.IResource toCreateOrModify) {
- if (toCreateOrModify.exists())
+ if (toCreateOrModify.exists()) {
return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify);
-
+ }
org.eclipse.core.resources.IResource parent = toCreateOrModify;
do {«/*FIXME [MG] the bug is closed long ago, still need? */»
/*
@@ -676,9 +690,10 @@ import plugin.Activator
}
org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument diagramDocument = (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) document;
final org.eclipse.emf.ecore.resource.Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI);
- final org.eclipse.gmf.runtime.notation.Diagram diagramCopy = (org.eclipse.gmf.runtime.notation.Diagram) org.eclipse.emf.ecore.util.EcoreUtil.copy(diagramDocument.getDiagram());
+ final org.eclipse.gmf.runtime.notation.Diagram diagramCopy = org.eclipse.emf.ecore.util.EcoreUtil.copy(diagramDocument.getDiagram());
try {
new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(diagramDocument.getEditingDomain(), org.eclipse.osgi.util.NLS.bind(«xptExternalizer.accessorCall(editorGen, i18nKeyForDocumentSaveAs(it))», diagramCopy.getName()), affectedFiles) {
+ «overrideC»
protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
newResource.getContents().add(diagramCopy);
return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
@@ -695,7 +710,7 @@ import plugin.Activator
newResource.unload();
}
}
- '''
+ '''
def handleElementMoved(GenDiagram it) '''
«generatedMemberComment»
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/Editor.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/Editor.xtend
index f29487c024f..f73a8e911c2 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/Editor.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/Editor.xtend
@@ -1,36 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Emilien Perico (Atos Origin) - add code to refactor some classes
+ * Christian W. Damus (CEA) - bug 430648
+ * Christian W. Damus (CEA) - bug 431023
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 512343
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
+
package xpt.editor
import com.google.inject.Inject
-import java.util.List
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorView
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
import org.eclipse.papyrus.gmf.codegen.gmfgen.Palette
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
-import plugin.Activator
+import xpt.CodeStyle
import xpt.Common
import xpt.Common_qvto
import xpt.Externalizer
import xpt.ExternalizerUtils_qvto
-import xpt.navigator.NavigatorLinkHelper
import xpt.editor.palette.PaletteFactory
-import xpt.navigator.NavigatorItem import xpt.CodeStyle
+import xpt.navigator.NavigatorItem
+import xpt.navigator.NavigatorLinkHelper
+import xpt.navigator.Utils_qvto
+import plugin.Activator
+import java.util.List
-@com.google.inject.Singleton class Editor {
+@Singleton class Editor {
@Inject extension Common;
@Inject extension Common_qvto;
@Inject extension CodeStyle;
@@ -43,6 +51,8 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
@Inject DiagramEditorContextMenuProvider xptDiagramEditorContextMenuProvider;
@Inject PaletteFactory pallette;
+ @Inject extension Utils_qvto;
+
def className(GenEditorView it) '''«it.className»'''
def packageName(GenEditorView it) '''«it.packageName»'''
@@ -51,111 +61,9 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
def fullPath(GenEditorView it) '''«qualifiedClassName(it)»'''
- def extendsList(GenEditorView it) '''extends org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor'''
def implementsList(GenEditorView it) '''«implementsList(buildImplementsList(it))»'''
- def implementsList(Iterable<String> list) '''«IF list.notEmpty»implements «FOR next : list SEPARATOR ', '»«next»«ENDFOR»«ENDIF»'''
-
- def Editor(GenEditorView it) '''
- «copyright(editorGen)»
- package «packageName(it)»;
-
- «generatedClassComment»
- public class «className(it)» «extendsList(it)» «implementsList(it)» {
-
- «attributes(it)»
-
- «constructor(it)»
-
- «getContextID(it)»
-
- «IF editorGen.diagram.palette != null»
- «createPaletteRoot(editorGen.diagram.palette)»
- «ENDIF»
-
- «getPreferencesHint(it)»
-
- «getContributorId(it)»
-
- «getAdapter(it)»
-
- «getDocumentProvider(it)»
-
- «getEditingDomain(it)»
-
- «setDocumentProvider(it)»
- «IF isIDEMode(it)»
-
- «gotoMarker(it)»
-
- «isSaveAsAllowed(it)»
-
- «doSaveAs(it)»
-
- «performSaveAs(it)»
-
- «getShowInContext(it)»
-
- «IF hasNavigator(it)»
- «getNavigatorSelection(it.editorGen.navigator)»
- «ENDIF»
- «ENDIF»
-
- «configureGraphicalViewer(it)»
-
- «IF editorGen.diagram.generateCreateShortcutAction»
-
- «initializeGraphicalViewer(it)»
-
- «controlLastClickPositionProviderService»
-
- «dispose»
-
- «DropTargetListener(it)»
- «ENDIF»
-
- «additions(it)»
- }
- '''
-
- def attributes(GenEditorView it) '''
- «generatedMemberComment»
- public static final String ID = "«ID»"; «nonNLS(1)»
-
- «generatedMemberComment»
- public static final String CONTEXT_ID = "«contextID»"; «nonNLS(1)»
-
- «IF editorGen.diagram.generateCreateShortcutAction()»
- «generatedMemberComment»
- private org.eclipse.gmf.tooling.runtime.part.LastClickPositionProvider myLastClickPositionProvider;
- «ENDIF»
- '''
-
- def constructor(GenEditorView it) '''
- «generatedMemberComment»
- public «className(it)»() {
- super(«null != editorGen.diagram.palette && editorGen.diagram.palette.flyout»);
- }
- '''
-
- def getContextID(GenEditorView it) '''
- «generatedMemberComment»
- protected String getContextID() {
- return CONTEXT_ID;
- }
- '''
-
- def createPaletteRoot(Palette it) '''
-
- «generatedMemberComment»
- protected org.eclipse.gef.palette.PaletteRoot createPaletteRoot(org.eclipse.gef.palette.PaletteRoot existingPaletteRoot) {
- org.eclipse.gef.palette.PaletteRoot root = super.createPaletteRoot(existingPaletteRoot);
- new «pallette.qualifiedClassName(it)»().fillPalette(root);
- return root;
- }
- '''
-
def getPreferencesHint(GenEditorView it) '''
«generatedMemberComment»
protected org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint getPreferencesHint() {
@@ -172,63 +80,7 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
}
'''
- def getAdapter(GenEditorView it) '''
- «IF !hasPropertySheet(it) || hasNavigator(it)»
-
- «generatedMemberComment»
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class type) {
- «IF !hasPropertySheet(it)»
- if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) {
- return null;
- }
- «ENDIF»
- «IF hasNavigator(it)»
- if (type == org.eclipse.ui.part.IShowInTargetList.class) {
- return new org.eclipse.ui.part.IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { org.eclipse.ui.navigator.resources.ProjectExplorer.VIEW_ID };
- }
- };
- }
- «ENDIF»
- return super.getAdapter(type);
- }
- «ENDIF»
- '''
-
- def getDocumentProvider(GenEditorView it) '''
- «generatedMemberComment»
- protected org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider getDocumentProvider(org.eclipse.ui.IEditorInput input) {
- if («checkEditorInput(it)») {
- return «xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().getDocumentProvider();
- }
- return super.getDocumentProvider(input);
- }
- '''
-
- def getEditingDomain(GenEditorView it) '''
- «generatedMemberComment»
- public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain() {
- org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document = getEditorInput() != null ? getDocumentProvider().getDocument(getEditorInput()) : null;
- if (document instanceof org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) {
- return ((org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) document).getEditingDomain();
- }
- return super.getEditingDomain();
- }
- '''
-
- def setDocumentProvider(GenEditorView it) '''
- «generatedMemberComment»
- protected void setDocumentProvider(org.eclipse.ui.IEditorInput input) {
- if («checkEditorInput(it)») {
- setDocumentProvider(«xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().getDocumentProvider());
- } else {
- super.setDocumentProvider(input);
- }
- }
- '''
-
+
def checkEditorInput(GenEditorView it) '''«IF isIDEMode(it)»input instanceof org.eclipse.ui.IFileEditorInput || «ENDIF»input instanceof org.eclipse.emf.common.ui.URIEditorInput'''
def gotoMarker(GenEditorView it) '''
@@ -252,79 +104,7 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
}
'''
- def performSaveAs(GenEditorView it) '''
- «generatedMemberComment»
- protected void performSaveAs(org.eclipse.core.runtime.IProgressMonitor progressMonitor) {
- org.eclipse.swt.widgets.Shell shell = getSite().getShell();
- org.eclipse.ui.IEditorInput input = getEditorInput();
- org.eclipse.ui.dialogs.SaveAsDialog dialog = new org.eclipse.ui.dialogs.SaveAsDialog(shell);
- org.eclipse.core.resources.IFile original = input instanceof org.eclipse.ui.IFileEditorInput ? ((org.eclipse.ui.IFileEditorInput) input).getFile() : null;
- if (original != null) {
- dialog.setOriginalFile(original);
- }
- dialog.create();
- org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider provider = getDocumentProvider();
- if (provider == null) {
- // editor has been programmatically closed while the dialog was open
- return;
- }
- if (provider.isDeleted(input) && original != null) {
- String message = org.eclipse.osgi.util.NLS.bind(«xptExternalizer.accessorCall(editorGen,
- i18nKeyForSavingDeletedFile(it))», original.getName());
- dialog.setErrorMessage(null);
- dialog.setMessage(message, org.eclipse.jface.dialogs.IMessageProvider.WARNING);
- }
- if (dialog.open() == org.eclipse.jface.window.Window.CANCEL) {
- if (progressMonitor != null) {
- progressMonitor.setCanceled(true);
- }
- return;
- }
- org.eclipse.core.runtime.IPath filePath = dialog.getResult();
- if (filePath == null) {
- if (progressMonitor != null) {
- progressMonitor.setCanceled(true);
- }
- return;
- }
- org.eclipse.core.resources.IWorkspaceRoot workspaceRoot = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot();
- org.eclipse.core.resources.IFile file = workspaceRoot.getFile(filePath);
- final org.eclipse.ui.IEditorInput newInput = new org.eclipse.ui.part.FileEditorInput(file);
- // Check if the editor is already open
- org.eclipse.ui.IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
- org.eclipse.ui.IEditorReference[] editorRefs = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
- for (int i = 0; i < editorRefs.length; i++) {
- if (matchingStrategy.matches(editorRefs[i], newInput)) {
- org.eclipse.jface.dialogs.MessageDialog.openWarning(shell, «xptExternalizer.accessorCall(editorGen,
- titleKey(i18nKeyForSaveAsProblems(it)))», «xptExternalizer.accessorCall(editorGen,
- messageKey(i18nKeyForSaveAsProblems(it)))»);
- return;
- }
- }
- boolean success = false;
- try {
- provider.aboutToChange(newInput);
- getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
- success = true;
- } catch (org.eclipse.core.runtime.CoreException x) {
- org.eclipse.core.runtime.IStatus status = x.getStatus();
- if (status == null || status.getSeverity() != org.eclipse.core.runtime.IStatus.CANCEL) {
- org.eclipse.jface.dialogs.ErrorDialog.openError(shell, «xptExternalizer.accessorCall(editorGen,
- titleKey(i18nKeyForSaveProblems(it)))», «xptExternalizer.accessorCall(editorGen,
- messageKey(i18nKeyForSaveProblems(it)))», x.getStatus());
- }
- } finally {
- provider.changed(newInput);
- if (success) {
- setInput(newInput);
- }
- }
- if (progressMonitor != null) {
- progressMonitor.setCanceled(!success);
- }
- }
- '''
-
+
def getShowInContext(GenEditorView it) '''
«generatedMemberComment»
public org.eclipse.ui.part.ShowInContext getShowInContext() {
@@ -332,14 +112,6 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
}
'''
- def getNavigatorSelection(GenNavigator it) '''
-
- «generatedMemberComment»
- private org.eclipse.jface.viewers.ISelection getNavigatorSelection() {
- org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document = getDiagramDocument();
- «xptNavigatorLinkHelper.findSelectionBody(it)»
- }
- '''
def configureGraphicalViewer(GenEditorView it) '''
«generatedMemberComment»
@@ -352,16 +124,6 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
}
'''
- def initializeGraphicalViewer(GenEditorView it) '''
- «generatedMemberComment»
- protected void initializeGraphicalViewer() {
- super.initializeGraphicalViewer();
- «addDropTargetListener('org.eclipse.jface.util.LocalSelectionTransfer.getTransfer()')»
- «addDropTargetListener('org.eclipse.emf.edit.ui.dnd.LocalTransfer.getInstance()')»
- startupLastClickPositionProvider();
- }
- '''
-
def controlLastClickPositionProviderService(GenEditorView it)'''
«generatedMemberComment»
protected void startupLastClickPositionProvider() {
@@ -381,15 +143,6 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
}
'''
- def dispose(GenEditorView it)'''
- «generatedMemberComment»
- «overrideC(editorGen.diagram)»
- public void dispose() {
- shutDownLastClickPositionProvider();
- super.dispose();
- }
- '''
-
def addDropTargetListener(GenEditorView it, String transferAccessor) '''
getDiagramGraphicalViewer().addDropTargetListener(new DropTargetListener(getDiagramGraphicalViewer(), «transferAccessor») {
@@ -468,7 +221,6 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
def DTL_additions(GenEditorView it) ''''''
- def additions(GenEditorView it) ''''''
@Localization def i18nValues(GenEditorView it) '''
«xptExternalizer.messageEntry(i18nKeyForSavingDeletedFile(it), 'The original file \"{0}\" has been deleted.')»
@@ -526,4 +278,583 @@ import xpt.navigator.NavigatorItem import xpt.CodeStyle
def boolean hasNavigator(GenEditorView it) {
return it.editorGen.navigator != null
}
+
+ def extendsList(GenEditorView it) '''extends org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor'''
+
+ def attributes(GenEditorView it) '''
+ «generatedMemberComment»
+ public static final String ID = "«ID»"; «nonNLS»
+
+ «generatedMemberComment»
+public static final String CONTEXT_ID = "«contextID»"; «nonNLS»
+
+
+ ««« Documentation. adds listener for papyrus editors
+ «generatedMemberComment»
+ private org.eclipse.gef.KeyHandler paletteKeyHandler = null;
+
+ «generatedMemberComment»
+ private org.eclipse.swt.events.MouseListener paletteMouseListener = null;
+
+ ««« Helps to handle correctly the dirty state
+ «generatedMemberComment»
+ private org.eclipse.papyrus.commands.util.OperationHistoryDirtyState dirtyState;
+
+ «generatedMemberComment»
+ private org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain;
+
+ «generatedMemberComment»
+ private org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider documentProvider;
+ '''
+
+ def constructor(GenEditorView it) '''
+ «generatedMemberComment»
+ public «className»(org.eclipse.papyrus.infra.core.services.ServicesRegistry servicesRegistry, org.eclipse.gmf.runtime.notation.Diagram diagram) throws org.eclipse.papyrus.infra.core.services.ServiceException{
+ super(servicesRegistry, diagram);
+
+ ««« Documentation. adds listener for papyrus palette service
+ // adds a listener to the palette service, which reacts to palette customizations
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().addProviderChangeListener(this);
+
+ «««Share the same editing domain
+ // Share the same editing provider
+ editingDomain = servicesRegistry.getService(org.eclipse.emf.transaction.TransactionalEditingDomain.class);
+ documentProvider = new org.eclipse.papyrus.infra.gmfdiag.common.GmfMultiDiagramDocumentProvider(editingDomain);
+
+ // overrides editing domain created by super constructor
+ setDocumentProvider(documentProvider);
+
+ «««end of listeners addition
+ }
+ '''
+
+ def getNavigatorSelection(GenNavigator it) '''
+
+ «generatedMemberComment»
+ private org.eclipse.jface.viewers.ISelection getNavigatorSelection() {
+ «IF getDiagramTopReference(it) !==null »
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument document = getDiagramDocument();
+ «ENDIF»
+ «xptNavigatorLinkHelper.findSelectionBody(it)»
+ }
+ '''
+
+def createPaletteRoot (Palette it)'''
+ «generatedMemberComment»
+ protected org.eclipse.gef.palette.PaletteRoot createPaletteRoot(org.eclipse.gef.palette.PaletteRoot existingPaletteRoot) {
+ org.eclipse.gef.palette.PaletteRoot paletteRoot;
+ if (existingPaletteRoot == null) {
+ paletteRoot = org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().createPalette(this, getDefaultPaletteContent());
+ } else {
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent());
+ paletteRoot = existingPaletteRoot;
+ }
+ applyCustomizationsToPalette(paletteRoot);
+ return paletteRoot;
+ }
+'''
+
+// FIXME - This has been overrided to comment the test on the palette tag in the gmfgen
+ def Editor(GenEditorView it) '''
+ «copyright(editorGen)»
+ package «packageName(it)»;
+
+ «generatedClassComment»
+ public class «className(it)» «extendsList(it)» «implementsList(it)» {
+
+ «attributes(it)»
+
+ «constructor(it)»
+
+ «getContextID(it)»
+
+««« «IF editorGen.diagram.palette != null»
+ «createPaletteRoot(editorGen.diagram.palette)»
+««« «ENDIF»
+
+ «getPreferencesHint(it)»
+
+ «getContributorId(it)»
+
+ «getAdapter(it)»
+
+ «getDocumentProvider(it)»
+
+ «getEditingDomain(it)»
+
+ «setDocumentProvider(it)»
+ «IF isIDEMode(it)»
+
+ «gotoMarker(it)»
+
+ «isSaveAsAllowed(it)»
+
+ «doSaveAs(it)»
+
+ «performSaveAs(it)»
+
+ «getShowInContext(it)»
+
+ «IF hasNavigator(it)»
+ «getNavigatorSelection(it.editorGen.navigator)»
+ «ENDIF»
+ «ENDIF»
+
+ «configureGraphicalViewer(it)»
+
+ «IF editorGen.diagram.generateCreateShortcutAction»
+
+ «initializeGraphicalViewer(it)»
+
+ «controlLastClickPositionProviderService»
+
+ «dispose»
+
+ «DropTargetListener(it)»
+ «ENDIF»
+
+ «additions(it)»
+ }
+ '''
+
+def createPaletteCustomizer (GenEditorView it)'''
+ «generatedMemberComment»
+ protected org.eclipse.gef.ui.palette.PaletteCustomizer createPaletteCustomizer() {
+ return new org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteCustomizer(getPreferenceStore());
+ }
+'''
+
+def additions (GenEditorView it)'''
+
+ «createEditingDomain(it)»
+
+ « configureDiagramEditDomain(it)»
+
+ « doSave(it)»
+
+ « getDirtyState(it)»
+
+ « setUndoContext(it)»
+
+ « isDirty(it)»
+
+ «««Documentation. adds method to handle palette changes
+ « handlePaletteChange(it)»
+
+ « dispose(it)»
+
+ « getPaletteViewer(it)»
+
+ ««« Documentation: (RS) advanced customization abilities
+ ««« « createPaletteCustomizer»
+
+ « constructPaletteViewer(it)»
+
+ « createPaletteviewerProvider(it)»
+
+ «getGraphicalViewer(it)»
+
+ «initializeGraphicalViewer(it)»
+
+ «selectionChanged(it)»
+
+'''
+
+def handlePaletteChange (GenEditorView it) '''
+ «generatedMemberComment»
+ public void providerChanged(org.eclipse.gmf.runtime.common.core.service.ProviderChangeEvent event) {
+ // update the palette if the palette service has changed
+ if (org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().equals(event.getSource())) {
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this,
+ getDefaultPaletteContent());
+ }
+ }
+'''
+
+def constructPaletteViewer (GenEditorView it) '''
+ «generatedMemberComment»
+ protected org.eclipse.gef.ui.palette.PaletteViewer constructPaletteViewer() {
+ return new org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteViewer();
+ }
+'''
+
+def dispose(GenEditorView it)'''
+ «generatedMemberComment»
+ public void dispose() {
+ // remove palette service listener
+ // remove preference listener
+ org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.dispose();
+ }
+'''
+
+def getPaletteViewer (GenEditorView it)'''
+ «generatedMemberComment»
+ protected org.eclipse.gef.ui.palette.PaletteViewer getPaletteViewer() {
+ return getEditDomain().getPaletteViewer();
+ }
+'''
+
+def implementsList(Iterable<String> it)'''
+ implements org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener
+ «IF ! it.isEmpty»,
+ «FOR string : it SEPARATOR ', '»
+ «implementsListEntry(string)»
+ «ENDFOR»
+ «ENDIF»
+'''
+
+def implementsListEntry (String it)'''«it»'''
+
+def createPaletteviewerProvider (GenEditorView it)'''
+«generatedMemberComment»
+protected org.eclipse.gef.ui.palette.PaletteViewerProvider createPaletteViewerProvider() {
+ getEditDomain().setPaletteRoot(createPaletteRoot(null));
+ return new org.eclipse.gef.ui.palette.PaletteViewerProvider(getEditDomain()) {
+
+ /**
+ * Override to provide the additional behavior for the tools. Will intialize with a
+ * PaletteEditPartFactory that has a TrackDragger that understand how to handle the
+ * mouseDoubleClick event for shape creation tools. Also will initialize the palette
+ * with a defaultTool that is the SelectToolEx that undestands how to handle the enter
+ * key which will result in the creation of the shape also.
+ */
+ «overrideC(it.editorGen.diagram)»
+ protected void configurePaletteViewer(org.eclipse.gef.ui.palette.PaletteViewer viewer) {
+ super.configurePaletteViewer(viewer);
+
+ // customize menu...
+ viewer.setContextMenu(new org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteContextMenuProvider(viewer));
+
+ viewer.getKeyHandler().setParent(getPaletteKeyHandler());
+ viewer.getControl().addMouseListener(getPaletteMouseListener());
+
+ // Add a transfer drag target listener that is supported on
+ // palette template entries whose template is a creation tool.
+ // This will enable drag and drop of the palette shape creation
+ // tools.
+ viewer.addDragSourceListener(new org.eclipse.gmf.runtime.diagram.ui.internal.parts.PaletteToolTransferDragSourceListener(viewer));
+ viewer.setCustomizer(createPaletteCustomizer());
+ }
+
+ «overrideC(it.editorGen.diagram)»
+ public org.eclipse.gef.ui.palette.PaletteViewer createPaletteViewer(org.eclipse.swt.widgets.Composite parent) {
+ org.eclipse.gef.ui.palette.PaletteViewer pViewer = constructPaletteViewer();
+ pViewer.createControl(parent);
+ configurePaletteViewer(pViewer);
+ hookPaletteViewer(pViewer);
+ return pViewer;
+ }
+
+ /**
+ * @return Palette Key Handler for the palette
+ */
+ private org.eclipse.gef.KeyHandler getPaletteKeyHandler() {
+
+ if (paletteKeyHandler == null) {
+
+ paletteKeyHandler = new org.eclipse.gef.KeyHandler() {
+
+ /**
+ * Processes a <i>key released </i> event. This method is called by the Tool
+ * whenever a key is released, and the Tool is in the proper state. Override
+ * to support pressing the enter key to create a shape or connection
+ * (between two selected shapes)
+ *
+ * @param event
+ * the KeyEvent
+ * @return <code>true</code> if KeyEvent was handled in some way
+ */
+ «overrideC(it.editorGen.diagram)»
+ public boolean keyReleased(org.eclipse.swt.events.KeyEvent event) {
+
+ if (event.keyCode == org.eclipse.swt.SWT.Selection) {
+
+ org.eclipse.gef.Tool tool = getPaletteViewer().getActiveTool().createTool();
+
+ if (toolSupportsAccessibility(tool)) {
+
+ tool.keyUp(event, getDiagramGraphicalViewer());
+
+ // deactivate current selection
+ getPaletteViewer().setActiveTool(null);
+
+ return true;
+ }
+
+ }
+ return super.keyReleased(event);
+ }
+
+ };
+
+ }
+ return paletteKeyHandler;
+ }
+
+ /**
+ * @return Palette Mouse listener for the palette
+ */
+ private org.eclipse.swt.events.MouseListener getPaletteMouseListener() {
+
+ if (paletteMouseListener == null) {
+
+ paletteMouseListener = new org.eclipse.swt.events.MouseListener() {
+
+ /**
+ * Flag to indicate that the current active tool should be cleared after a
+ * mouse double-click event.
+ */
+ private boolean clearActiveTool = false;
+
+ /**
+ * Override to support double-clicking a palette tool entry to create a
+ * shape or connection (between two selected shapes).
+ *
+ * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
+ */
+ «overrideI(it.editorGen.diagram)»
+ public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) {
+ org.eclipse.gef.Tool tool = getPaletteViewer().getActiveTool().createTool();
+
+ if (toolSupportsAccessibility(tool)) {
+
+ tool.setViewer(getDiagramGraphicalViewer());
+ tool.setEditDomain(getDiagramGraphicalViewer().getEditDomain());
+ tool.mouseDoubleClick(e, getDiagramGraphicalViewer());
+
+ // Current active tool should be deactivated,
+ // but if it is down here it will get
+ // reactivated deep in GEF palette code after
+ // receiving mouse up events.
+ clearActiveTool = true;
+ }
+ }
+
+ «overrideI(it.editorGen.diagram)»
+ public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
+ // do nothing
+ }
+
+ «overrideI(it.editorGen.diagram)»
+ public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
+ // Deactivate current active tool here if a
+ // double-click was handled.
+ if (clearActiveTool) {
+ getPaletteViewer().setActiveTool(null);
+ clearActiveTool = false;
+ }
+
+ }
+ };
+
+ }
+ return paletteMouseListener;
+ }
+
+ };
+ }
+'''
+
+//Not used
+def performSaveAs (GenEditorView it)'''
+ «generatedMemberComment»
+protected void performSaveAs(org.eclipse.core.runtime.IProgressMonitor progressMonitor) {
+ // Nothing
+}
+'''
+
+//Share the same editing domain
+def getEditingDomain (GenEditorView it)'''
+ «generatedMemberComment»
+ public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+'''
+
+def createEditingDomain (GenEditorView it)'''
+«generatedMemberComment»
+ protected org.eclipse.emf.transaction.TransactionalEditingDomain createEditingDomain() {
+ // Already configured
+ return editingDomain;
+ }
+'''
+
+
+def configureDiagramEditDomain (GenEditorView it)'''
+«generatedMemberComment»
+ protected void configureDiagramEditDomain() {
+ super.configureDiagramEditDomain();
+ getDiagramEditDomain().getDiagramCommandStack().addCommandStackListener(new org.eclipse.gef.commands.CommandStackListener() {
+
+ «overrideI(it.editorGen.diagram)»
+ public void commandStackChanged(java.util.EventObject event) {
+ if (org.eclipse.swt.widgets.Display.getCurrent() == null) {
+ org.eclipse.swt.widgets.Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ firePropertyChange(org.eclipse.ui.IEditorPart.PROP_DIRTY);
+ }
+ });
+ } else {
+ firePropertyChange(org.eclipse.ui.IEditorPart.PROP_DIRTY);
+ }
+ }
+ });
+ }
+'''
+
+def doSave (GenEditorView it)'''
+«generatedMemberComment»
+ public void doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor) {
+ // The saving of the resource is done by the CoreMultiDiagramEditor
+ getDirtyState().saved();
+ }
+'''
+
+def getDirtyState (GenEditorView it)'''
+«generatedMemberComment»
+ protected org.eclipse.papyrus.commands.util.OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = org.eclipse.papyrus.commands.util.OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
+ }
+'''
+
+def setUndoContext (GenEditorView it)'''
+«generatedMemberComment»
+ protected void setUndoContext(org.eclipse.core.commands.operations.IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+'''
+
+//Fix the dirty state
+def isDirty (GenEditorView it)'''
+«generatedMemberComment»
+ public boolean isDirty() {
+ return getDirtyState().isDirty();
+ }
+'''
+
+//Code refactoring moved in UMLDiagramEditor
+def getDocumentProvider (GenEditorView it)'''
+ «generatedMemberComment»
+ protected final org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider getDocumentProvider(org.eclipse.ui.IEditorInput input) {
+ return documentProvider;
+ }
+'''
+
+def setDocumentProvider (GenEditorView it)'''
+ «generatedMemberComment»
+ protected final void setDocumentProvider(org.eclipse.ui.IEditorInput input) {
+ // Already set in the constructor
+ }
+'''
+
+def getGraphicalViewer (GenEditorView it)'''
+«generatedMemberComment»
+ @Override
+ public org.eclipse.gef.GraphicalViewer getGraphicalViewer() {
+ return super.getGraphicalViewer();
+ }
+'''
+
+
+def initializeGraphicalViewer (GenEditorView it)'''
+«generatedMemberComment»
+ @Override
+ protected void initializeGraphicalViewer() {
+ super.initializeGraphicalViewer();
+
+ // Enable Drop
+ getDiagramGraphicalViewer().addDropTargetListener(
+ new org.eclipse.papyrus.uml.diagram.common.listeners.DropTargetListener(getDiagramGraphicalViewer(), org.eclipse.jface.util.LocalSelectionTransfer.getTransfer()) {
+
+ @Override
+ protected Object getJavaObject(org.eclipse.swt.dnd.TransferData data) {
+ // It is usual for the transfer data not to be set because it is available locally
+ return LocalSelectionTransfer.getTransfer().getSelection();
+ }
+
+ @Override
+ protected org.eclipse.emf.transaction.TransactionalEditingDomain getTransactionalEditingDomain() {
+ return getEditingDomain();
+ }
+ });
+
+ }
+'''
+
+def selectionChanged (GenEditorView it)'''
+«generatedMemberComment»
+ @Override
+ public void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection) {
+ if (getSite().getPage().getActiveEditor() instanceof org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor) {
+ org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor editor = (org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor) getSite().getPage().getActiveEditor();
+ // If not the active editor, ignore selection changed.
+ if (this.equals(editor.getActiveEditor())) {
+ updateActions(getSelectionActions());
+ super.selectionChanged(part, selection);
+ } else {
+ super.selectionChanged(part, selection);
+ }
+ } else {
+ super.selectionChanged(part, selection);
+ }
+ // from
+ // org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.selectionChanged(IWorkbenchPart,
+ // ISelection)
+ if (part == this) {
+ rebuildStatusLine();
+ }
+ }
+'''
+
+def getContextID (GenEditorView it)'''
+ «generatedMemberComment»
+protected String getContextID() {
+ return CONTEXT_ID;
+}
+'''
+
+ def getAdapter(GenEditorView it) '''
+ «IF !hasPropertySheet(it) || hasNavigator(it)»
+
+ «generatedMemberComment»
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class type) {
+ «IF !hasPropertySheet(it)»
+ if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) {
+ return null;
+ }
+ «ENDIF»
+ «IF hasNavigator(it)»
+ if (type == org.eclipse.ui.part.IShowInTargetList.class) {
+ return new org.eclipse.ui.part.IShowInTargetList() {
+
+ «overrideI(it.editorGen.diagram)»
+ public String[] getShowInTargetIds() {
+ return new String[] { org.eclipse.ui.navigator.resources.ProjectExplorer.VIEW_ID };
+ }
+ };
+ }
+ «ENDIF»
+ return super.getAdapter(type);
+ }
+ «ENDIF»
+ '''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/InitDiagramFileAction.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/InitDiagramFileAction.xtend
index ea94a0d51bb..7f6f22f228f 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/InitDiagramFileAction.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/InitDiagramFileAction.xtend
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2007, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,10 +9,10 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Dmitry Stadnik (Borland) - rewritten in xpand
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Dmitry Stadnik (Borland) - rewritten in xpand
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
@@ -158,7 +158,7 @@ import plugin.Activator
«generatedMemberComment»
public void run(org.eclipse.jface.action.IAction action) {
org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain =
- org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+ org.eclipse.emf.workspace.WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();
«IF editorGen.sameFileForDiagramAndModel»
org.eclipse.emf.ecore.resource.ResourceSet resourceSet = new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
«ELSE»
@@ -167,7 +167,7 @@ import plugin.Activator
org.eclipse.emf.ecore.EObject diagramRoot = null;
try {
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(domainModelURI, true);
- diagramRoot = (org.eclipse.emf.ecore.EObject) resource.getContents().get(0);
+ diagramRoot = resource.getContents().get(0);
} catch (org.eclipse.emf.common.util.WrappedException ex) {
«xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().logError(
"Unable to load resource: " + domainModelURI, ex); «nonNLS(1)»
@@ -186,7 +186,6 @@ import plugin.Activator
1)»
}
'''
-
def i18nAccessors(GenDiagram it) '''
«xptExternalizer.accessorField(titleKey(i18nKeyForInitDiagramFileResourceErrorDialog()))»
«xptExternalizer.accessorField(messageKey(i18nKeyForInitDiagramFileResourceErrorDialog()))»
@@ -212,5 +211,4 @@ import plugin.Activator
@Localization def String i18nKeyForInitDiagramOpenFileDialogTitle() {
return 'InitDiagramFile.OpenModelFileDialogTitle'
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ModelElementSelectionPage.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ModelElementSelectionPage.xtend
index 1aeaf16ff40..d1110c97959 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ModelElementSelectionPage.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ModelElementSelectionPage.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2007, 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Svyatoslav Kovalsky (Montages) - #410477 "same-generated" code extracted to GMFT-runtime
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Svyatoslav Kovalsky (Montages) - #410477 "same-generated" code extracted to GMFT-runtime
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
@@ -39,7 +40,7 @@ import plugin.Activator
def fullPath(GenDiagram it) '''«qualifiedClassName(it)»'''
- def extendsList(GenDiagram it) '''extends org.eclipse.gmf.tooling.runtime.part.DefaultModelElementSelectionPage'''
+ def extendsList(GenDiagram it) '''extends org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.part.DefaultModelElementSelectionPage'''
def ModelElementSelectionPage(GenDiagram it) '''
«copyright(editorGen)»
@@ -130,5 +131,4 @@ import plugin.Activator
@Localization def String i18nKeyForModelElementSelectionPage(GenDiagram diagram) {
return className(diagram).toString
}
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/NewDiagramFileWizard.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/NewDiagramFileWizard.xtend
index e5f2858c680..a6152f12e85 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/NewDiagramFileWizard.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/NewDiagramFileWizard.xtend
@@ -1,31 +1,36 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
-import plugin.Activator
-import xpt.Common
import xpt.Externalizer
import xpt.ExternalizerUtils_qvto
+import xpt.Common
+import xpt.editor.ModelElementSelectionPage
+import plugin.Activator
+import xpt.editor.DiagramContentInitializer
+import xpt.CodeStyle
-@com.google.inject.Singleton class NewDiagramFileWizard {
+@Singleton class NewDiagramFileWizard {
@Inject extension Common;
-
+ @Inject extension CodeStyle;
@Inject extension ExternalizerUtils_qvto;
@Inject Externalizer xptExternalizer;
@Inject Activator xptActivator;
@@ -123,11 +128,12 @@ import xpt.ExternalizerUtils_qvto
new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(
myEditingDomain, «xptExternalizer.accessorCall(editorGen, i18nKeyForNewDiagramFileWizardInitDiagramCommand(it))», affectedFiles) {
+ «overrideC»
protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(
org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
throws org.eclipse.core.commands.ExecutionException {
- int diagramVID = «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(diagramRootElementSelectionPage.getModelElement());
- if (diagramVID != «VisualIDRegistry::visualID(it)») {
+ String diagramVID = «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(diagramRootElementSelectionPage.getModelElement());
+ if (diagramVID.equals(«VisualIDRegistry::visualID(it)»)) {
return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult(
«xptExternalizer.accessorCall(editorGen, i18nKeyForNewDiagramFileWizardIncorrectRootError(it))»);
}
@@ -224,7 +230,7 @@ import xpt.ExternalizerUtils_qvto
'Select diagram root element')»
«xptExternalizer.messageEntry(titleKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(it)), 'Diagram root element')»
«xptExternalizer.messageEntry(descriptionKey(i18nKeyForNewDiagramFileWizardRootSelectionPage(it)),
- 'Select semantic model element to be depicted on diagram')»"Select diagram root element:"
+ 'Select semantic model element to be depicted on diagram')»
«xptExternalizer.messageEntry(i18nKeyForNewDiagramFileWizardRootSelectionPageSelectionTitle(it),
'Select diagram root element:')»
«xptExternalizer.messageEntry(i18nKeyForNewDiagramFileWizardRootSelectionPageNoSelectionMessage(it),
@@ -236,6 +242,7 @@ import xpt.ExternalizerUtils_qvto
'Incorrect model object stored as a root resource object')»
'''
+
@Localization def String i18nKeyForNewDiagramFileWizard(GenDiagram diagram) {
return '' + className(diagram)
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetInfo.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetInfo.xtend
index 1595d0a1754..7df8b8c5e4c 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetInfo.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetInfo.xtend
@@ -1,26 +1,31 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2015, 2021 Borland Software Corporation, Montages, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Anatoliy Tischenko - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import xpt.Common
+import xpt.CodeStyle
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+import com.google.inject.Singleton
-@com.google.inject.Singleton class ResourceSetInfo {
+@Singleton class ResourceSetInfo {
+
@Inject extension Common;
+ @Inject extension CodeStyle
/**
* Inner class of DocumentProvider
@@ -293,6 +298,7 @@ import xpt.Common
public boolean handleResourceChanged(final org.eclipse.emf.ecore.resource.Resource resource) {
«updateSynchStateSD(it)»
org.eclipse.swt.widgets.Display.getDefault().asyncExec(new java.lang.Runnable() {
+ «overrideI»
public void run() {
handleElementChanged(ResourceSetInfo.this, resource, null);
}
@@ -301,11 +307,13 @@ import xpt.Common
}
'''
+
def handleResourceDeletedSD(GenDiagram it) '''
«generatedMemberComment»
public boolean handleResourceDeleted(org.eclipse.emf.ecore.resource.Resource resource) {
«updateSynchStateSD(it)»
org.eclipse.swt.widgets.Display.getDefault().asyncExec(new java.lang.Runnable() {
+ «overrideI»
public void run() {
fireElementDeleted(ResourceSetInfo.this.getEditorInput());
}
@@ -320,6 +328,7 @@ import xpt.Common
«updateSynchStateSD(it)»
if (myDocument.getDiagram().eResource() == resource) {
org.eclipse.swt.widgets.Display.getDefault().asyncExec(new java.lang.Runnable() {
+ «overrideI»
public void run() {
handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI);
}
@@ -343,5 +352,5 @@ import xpt.Common
def additionsSD(GenDiagram it) ''''''
def additions(GenDiagram it) ''''''
-
+
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetModificationListener.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetModificationListener.xtend
index 3bf0dc48853..24f142ec028 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetModificationListener.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ResourceSetModificationListener.xtend
@@ -1,25 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import xpt.Common
-@com.google.inject.Singleton class ResourceSetModificationListener {
+@Singleton class ResourceSetModificationListener {
+
@Inject extension Common;
def extendsList(GenDiagram it) '''extends org.eclipse.emf.ecore.util.EContentAdapter'''
@@ -68,8 +70,8 @@ import xpt.Common
org.eclipse.emf.ecore.resource.Resource resource = (org.eclipse.emf.ecore.resource.Resource) notification.getNotifier();
if (resource.isLoaded()) {
boolean modified = false;
- for (java.util.Iterator/*<org.eclipse.emf.ecore.resource.Resource>*/ it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
- org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ for (java.util.Iterator<org.eclipse.emf.ecore.resource.Resource> it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = it.next();
if (nextResource.isLoaded()) {
modified = nextResource.isModified();
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ValidateAction.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ValidateAction.xtend
index 54e9d4ee56f..df9e7c2f708 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ValidateAction.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/ValidateAction.xtend
@@ -1,21 +1,30 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+import xpt.Common
+import xpt.editor.DiagramEditorUtil
+import xpt.CodeStyle
+import plugin.Activator
+import xpt.providers.ValidationProvider
+
+import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.MetaDef
@@ -28,16 +37,19 @@ import xpt.providers.ValidationProvider
import xpt.providers.MarkerNavigationProvider
import xpt.providers.ValidationDecoratorProvider
-@com.google.inject.Singleton class ValidateAction {
+@Singleton class ValidateAction {
@Inject extension Common;
+ @Inject extension CodeStyle
+
+ @Inject DiagramEditorUtil xptDiagramEditorUtil;
+ @Inject Activator xptActivator
+ @Inject ValidationProvider xptValidationProvider
+
@Inject extension GenAuditRoot_qvto;
@Inject extension ExternalizerUtils_qvto;
- @Inject Activator xptActivator;
@Inject ValidationMarker xptValidationMarker;
@Inject Externalizer xptExternalizer;
- @Inject DiagramEditorUtil xptDiagramEditorUtil;
- @Inject ValidationProvider xptValidationProvider;
@Inject MarkerNavigationProvider xptMarkerNavigationProvider;
@Inject ValidationDecoratorProvider xptValidationDecoratorProvider;
@@ -101,6 +113,7 @@ import xpt.providers.ValidationDecoratorProvider
«ENDIF»
new org.eclipse.jface.operation.IRunnableWithProgress() {
+ «overrideI»
public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
throws InterruptedException, java.lang.reflect.InvocationTargetException {
runValidation(part.getDiagramEditPart(), part.getDiagram());
@@ -115,7 +128,7 @@ import xpt.providers.ValidationDecoratorProvider
}
}
}
- '''
+ '''
def runValidation(GenDiagram it) '''
@@ -139,17 +152,23 @@ import xpt.providers.ValidationDecoratorProvider
}
'''
- def runNonUIValidation(GenDiagram it) '''
+ def runNonUIValidation(GenDiagram it)'''
«generatedMemberComment»
public static void runNonUIValidation(org.eclipse.gmf.runtime.notation.View view) {
+ org.eclipse.swt.widgets.Shell shell = org.eclipse.swt.widgets.Display.getCurrent().getActiveShell();
+ if (shell == null) {
+ shell = new org.eclipse.swt.widgets.Shell();
+ }
+
org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart =
org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory.getInstance().createDiagramEditPart(
- view.getDiagram());
+ view.getDiagram(),shell);
runValidation(diagramEditPart, view);
}
'''
+
def runValidationWithEP(GenDiagram it) '''
«generatedMemberComment»
@@ -159,6 +178,7 @@ import xpt.providers.ValidationDecoratorProvider
org.eclipse.emf.transaction.TransactionalEditingDomain txDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(view);
«xptValidationProvider.qualifiedClassName(it)».runWithConstraints(txDomain, new Runnable() {
+ «overrideI»
public void run() {
validate(fpart, fview);
}
@@ -174,6 +194,7 @@ import xpt.providers.ValidationDecoratorProvider
if (target.isSetElement() && target.getElement() != null) {
return new org.eclipse.emf.ecore.util.Diagnostician() {
+ «overrideC»
public String getObjectLabel(org.eclipse.emf.ecore.EObject eObject) {
return org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getQualifiedName(eObject, true);
}
@@ -242,9 +263,10 @@ import xpt.providers.ValidationDecoratorProvider
}
final org.eclipse.core.runtime.IStatus rootStatus = validationStatus;
java.util.List allStatuses = new java.util.ArrayList();
- «xptDiagramEditorUtil.qualifiedClassName(it)».LazyElement2ViewMap element2ViewMap = new «xptDiagramEditorUtil.qualifiedClassName(it)».LazyElement2ViewMap(
- diagramEditPart.getDiagramView(),
- collectTargetElements(rootStatus, new java.util.HashSet<org.eclipse.emf.ecore.EObject>(), allStatuses));
+ «xptDiagramEditorUtil.qualifiedClassName(it)».LazyElement2ViewMap element2ViewMap = new «xptDiagramEditorUtil.
+ qualifiedClassName(it)».LazyElement2ViewMap(
+ diagramEditPart.getDiagramView(),
+ collectTargetElements(rootStatus, new java.util.HashSet<org.eclipse.emf.ecore.EObject>(), allStatuses));
for (java.util.Iterator it = allStatuses.iterator(); it.hasNext();) {
org.eclipse.emf.validation.model.IConstraintStatus nextStatus =
(org.eclipse.emf.validation.model.IConstraintStatus) it.next();
@@ -269,14 +291,14 @@ import xpt.providers.ValidationDecoratorProvider
return;
}
final org.eclipse.emf.common.util.Diagnostic rootStatus = emfValidationStatus;
- java.util.List allDiagnostics = new java.util.ArrayList();
+ java.util.List<org.eclipse.emf.common.util.Diagnostic> allDiagnostics = new java.util.ArrayList<org.eclipse.emf.common.util.Diagnostic>();
«xptDiagramEditorUtil.qualifiedClassName(it)».LazyElement2ViewMap element2ViewMap =
new «xptDiagramEditorUtil.qualifiedClassName(it)».LazyElement2ViewMap(
diagramEditPart.getDiagramView(),
collectTargetElements(rootStatus, new java.util.HashSet<org.eclipse.emf.ecore.EObject>(), allDiagnostics));
- for (java.util.Iterator it = emfValidationStatus.getChildren().iterator(); it.hasNext();) {
- org.eclipse.emf.common.util.Diagnostic nextDiagnostic = (org.eclipse.emf.common.util.Diagnostic) it.next();
- java.util.List data = nextDiagnostic.getData();
+ for (java.util.Iterator<org.eclipse.emf.common.util.Diagnostic> it = emfValidationStatus.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.emf.common.util.Diagnostic nextDiagnostic = it.next();
+ java.util.List<?> data = nextDiagnostic.getData();
if (data != null && !data.isEmpty() && data.get(0) instanceof org.eclipse.emf.ecore.EObject) {
org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) data.get(0);
org.eclipse.gmf.runtime.notation.View view = «xptDiagramEditorUtil.qualifiedClassName(it)».findView(
@@ -331,10 +353,10 @@ import xpt.providers.ValidationDecoratorProvider
«generatedMemberComment»
private static java.util.Set<org.eclipse.emf.ecore.EObject> collectTargetElements(org.eclipse.core.runtime.IStatus status,
- java.util.Set<org.eclipse.emf.ecore.EObject> targetElementCollector, java.util.List allConstraintStatuses) {
+ java.util.Set<org.eclipse.emf.ecore.EObject> targetElementCollector, java.util.List<org.eclipse.emf.validation.model.IConstraintStatus> allConstraintStatuses) {
if (status instanceof org.eclipse.emf.validation.model.IConstraintStatus) {
targetElementCollector.add(((org.eclipse.emf.validation.model.IConstraintStatus) status).getTarget());
- allConstraintStatuses.add(status);
+ allConstraintStatuses.add((org.eclipse.emf.validation.model.IConstraintStatus)status);
}
if (status.isMultiStatus()) {
org.eclipse.core.runtime.IStatus[] children = status.getChildren();
@@ -350,19 +372,18 @@ import xpt.providers.ValidationDecoratorProvider
«generatedMemberComment»
private static java.util.Set<org.eclipse.emf.ecore.EObject> collectTargetElements(org.eclipse.emf.common.util.Diagnostic diagnostic,
- java.util.Set<org.eclipse.emf.ecore.EObject> targetElementCollector, java.util.List allDiagnostics) {
- java.util.List data = diagnostic.getData();
+ java.util.Set<org.eclipse.emf.ecore.EObject> targetElementCollector, java.util.List<org.eclipse.emf.common.util.Diagnostic> allDiagnostics) {
+ java.util.List<?> data = diagnostic.getData();
org.eclipse.emf.ecore.EObject target = null;
if (data != null && !data.isEmpty() && data.get(0) instanceof org.eclipse.emf.ecore.EObject) {
- target = (org.eclipse.emf.ecore.EObject) data.get(0);
- targetElementCollector.add(target);
- allDiagnostics.add(diagnostic);
+ target = (org.eclipse.emf.ecore.EObject) data.get(0);
+ targetElementCollector.add(target);
+ allDiagnostics.add(diagnostic);
}
if (diagnostic.getChildren() != null && !diagnostic.getChildren().isEmpty()) {
- for (java.util.Iterator it = diagnostic.getChildren().iterator(); it.hasNext();) {
- collectTargetElements((org.eclipse.emf.common.util.Diagnostic) it.next(),
- targetElementCollector, allDiagnostics);
- }
+ for (java.util.Iterator<org.eclipse.emf.common.util.Diagnostic> it = diagnostic.getChildren().iterator(); it.hasNext();) {
+ collectTargetElements(it.next(), targetElementCollector, allDiagnostics);
+ }
}
return targetElementCollector;
}
@@ -381,5 +402,4 @@ import xpt.providers.ValidationDecoratorProvider
@Localization def String i18nKeyForValidateAction(GenDiagram diagram) {
return className(diagram).toString
}
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/VisualIDRegistry.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/VisualIDRegistry.xtend
index 73991678caf..c10c66c8865 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/VisualIDRegistry.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/VisualIDRegistry.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #372479, #386838
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #372479, #386838
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
@@ -36,7 +36,6 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExpressionInterpreter
import xpt.diagram.updater.Utils_qvto
import xpt.CodeStyle
import xpt.diagram.editpolicies.LinkUtils_qvto
-import plugin.Activator
//XXX: [MG] decide what to do with @MetaDef methods
@com.google.inject.Singleton class VisualIDRegistry {
@@ -44,8 +43,8 @@ import plugin.Activator
@Inject extension Common_qvto;
@Inject extension Utils_qvto;
@Inject extension LinkUtils_qvto;
+ @Inject extension MetaModel;
- @Inject Activator xptActivator
@Inject CodeStyle xptCodeStyle;
@Inject MetaModel xptMetaModel;
@Inject xpt.expressions.getExpression xptGetExpression;
@@ -99,7 +98,7 @@ import plugin.Activator
@MetaDef def getLinkWithClassVisualIDMethodName(GenDiagram it) '''getLinkWithClassVisualID'''
- @MetaDef def domainElementConstraintMethodName(GenCommonBase it) '''is«getUniqueIdentifier()»'''
+ @MetaDef def domainElementConstraintMethodName(GenCommonBase it) '''is«stringUniqueIdentifier()»'''
@MetaDef def checkNodeVisualIDMethodName(GenDiagram it) '''checkNodeVisualID'''
@@ -210,7 +209,7 @@ import plugin.Activator
def getViewVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static int «getVisualIdMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
+ public static String «getVisualIdMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
if (view instanceof org.eclipse.gmf.runtime.notation.Diagram) {
if («modelID(it)».equals(view.getType())) {
return «visualID(it)»;
@@ -229,7 +228,7 @@ import plugin.Activator
while (view != diagram) {
org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «nonNLS(1)»
if (annotation != null) {
- return (String) annotation.getDetails().get("modelID"); «nonNLS(1)»
+ return annotation.getDetails().get("modelID"); «nonNLS(1)»
}
view = (org.eclipse.gmf.runtime.notation.View) view.eContainer();
}
@@ -239,35 +238,25 @@ import plugin.Activator
def getVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static int «getVisualIdMethodName(it)»(String type) {
- try {
- return Integer.parseInt(type);
- } catch (NumberFormatException e) {
- if (Boolean.TRUE.toString().equalsIgnoreCase(org.eclipse.core.runtime.Platform.getDebugOption(DEBUG_KEY))) {
- «xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().logError("Unable to parse view type as a visualID number: " + type);
- }
- }
- «unrecognizedVID(it)»
+ public static String «getVisualIdMethodName(it)»(String type) {
+ return type;
}
'''
def getType(GenDiagram it) '''
«generatedMemberComment()»
- public static String «getTypeMethodName(it)»(int visualID) {
- return Integer.toString(visualID);
+ public static String «getTypeMethodName(it)»(String visualID) {
+ return visualID;
}
'''
def getDiagramVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static int «getDiagramVisualIDMethodName(it)»(org.eclipse.emf.ecore.EObject domainElement) {
+ public static String «getDiagramVisualIDMethodName(it)»(org.eclipse.emf.ecore.EObject domainElement) {
if (domainElement == null) {
«unrecognizedVID(it)»
}
- «IF null != domainDiagramElement»
- «returnVisualID(it)»
- «ENDIF»
- «unrecognizedVID(it)»
+ return «visualID(it)»;
}
'''
@@ -288,7 +277,23 @@ import plugin.Activator
def checkDomainElementMetaclass(GenClass it) '''«xptMetaModel.MetaClass(it)».isSuperTypeOf(domainElement.eClass())'''
def checkDomainElementConstraints(TypeModelFacet it, GenCommonBase commonBase)
- '''«IF null != modelElementSelector» && «domainElementConstraintMethodName(commonBase)»(«xptMetaModel.CastEObject(metaClass, 'domainElement')»)«ENDIF»'''
+ '''
+««« «IF null != modelElementSelector»
+««« //«it.eContainer»
+««« //->«modelElementSelector»
+««« «ENDIF»
+ ««« [ExtendedConstraint] START Testing the kind of ModelFacet (GenLink or Default case)
+ «IF null != modelElementSelector»
+ «IF commonBase instanceof GenLink || !(modelElementSelector.provider instanceof GenJavaExpressionProvider)»
+ ««« [ExtendedConstraint] END Testing the kind of ModelFacet (GenLink or Default case)
+ && «domainElementConstraintMethodName(commonBase)»(«CastEObject(metaClass,'domainElement')»)
+ ««« [ExtendedConstraint] START Testing the kind of ModelFacet (GenLink or Default case)
+ «ELSE»
+ && «domainElementConstraintMethodName(commonBase)»(containerView, «CastEObject(metaClass, 'domainElement')»)
+ «ENDIF»
+ «ENDIF»
+ ««« [ExtendedConstraint] END Testing the kind of ModelFacet (GenLink or Default case)
+ '''
def dispatch checkSemanticElement(LinkModelFacet it, GenLink genLink) '''«ERROR('checkSemanticElement is supported only for TypeLinkModelFacet: ' + it)»'''
def dispatch checkSemanticElement(TypeLinkModelFacet it, GenLink genLink) '''«checkDomainElementMetaclass(metaClass)»«checkDomainElementConstraints(it, genLink)»'''
@@ -296,7 +301,7 @@ import plugin.Activator
def getNodeVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static int «getNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
+ public static String «getNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
if (domainElement == null) {
«unrecognizedVID(it)»
}
@@ -304,7 +309,7 @@ import plugin.Activator
if (!«modelID(it)».equals(containerModelID)«FOR spf : shortcutsProvidedFor»«checkContainerModelID(spf)»«ENDFOR») { «nonNLS_All(shortcutsProvidedFor)»
«unrecognizedVID(it)»
}
- int containerVisualID;
+ String containerVisualID;
if («modelID(it)».equals(containerModelID)) {
containerVisualID = «getVisualIDMethodCall(it)»(containerView);
} else {
@@ -314,10 +319,12 @@ import plugin.Activator
«unrecognizedVID(it)»
}
}
- switch (containerVisualID) {
- «FOR container : allContainers»
- «caseDomainContainerVisualID(container)»
- «ENDFOR»
+ if (containerVisualID != null) {
+ switch (containerVisualID) {
+ «FOR container : allContainers»
+ «caseDomainContainerVisualID(container)»
+ «ENDFOR»
+ }
}
«unrecognizedVID(it)»
}
@@ -333,12 +340,12 @@ import plugin.Activator
def canCreateNode(GenDiagram it) '''
«generatedMemberComment()»
- public static boolean «canCreateNodeMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, int nodeVisualID) {
+ public static boolean «canCreateNodeMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, String nodeVisualID) {
String containerModelID = «getModelIDMethodCall(it)»(containerView);
if (!«modelID(it)».equals(containerModelID)«FOR spf : shortcutsProvidedFor»«checkContainerModelID(spf)»«ENDFOR») { «nonNLS_All(shortcutsProvidedFor)»
return false;
}
- int containerVisualID;
+ String containerVisualID;
if («modelID(it)».equals(containerModelID)) {
containerVisualID = «getVisualIDMethodCall(it)»(containerView);
} else {
@@ -348,9 +355,11 @@ import plugin.Activator
return false;
}
}
- switch (containerVisualID) {
- «FOR container : allContainers.filter[e|getEssentialVisualChildren(e).notEmpty]»«checkEssentialChildren(container)»«ENDFOR»
- «FOR link : links.filter[l|getEssentialVisualChildren(l).notEmpty]»«checkEssentialChildren(link)»«ENDFOR»
+ if (containerVisualID != null) {
+ switch (containerVisualID) {
+ «FOR container : allContainers.filter[e|getEssentialVisualChildren(e).notEmpty]»«checkEssentialChildren(container)»«ENDFOR»
+ «FOR link : links.filter[l|getEssentialVisualChildren(l).notEmpty]»«checkEssentialChildren(link)»«ENDFOR»
+ }
}
return false;
}
@@ -365,14 +374,14 @@ import plugin.Activator
'''
def checkEssentialChild(GenCommonBase it) '''
- if («visualID(it)» == nodeVisualID) {
+ if («visualID(it)».equals(nodeVisualID)) {
return true;
}
'''
def getLinkWithClassVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static int «getLinkWithClassVisualIDMethodName(it)»(org.eclipse.emf.ecore.EObject domainElement) {
+ public static String «getLinkWithClassVisualIDMethodName(it)»(org.eclipse.emf.ecore.EObject domainElement) {
if (domainElement == null) {
«unrecognizedVID(it)»
}
@@ -402,12 +411,14 @@ import plugin.Activator
* FIXME don't use static fields, replace with instance/separate cache (e.g. accessible from Activator)
*/
def constraintMethods(GenDiagram it) '''
- «IF null != editorGen.expressionProviders»
- «FOR topNode : topLevelNodes.filter[n | n.modelFacet.modelElementSelector != null]»«constraintMethod(topNode)»«ENDFOR»
- «FOR childNode : childNodes.filter[n | n.modelFacet.modelElementSelector != null]»«constraintMethod(childNode)»«ENDFOR»
- «FOR link : links»«constraintMethod(link.modelFacet, link)»«ENDFOR»
- «ENDIF»
- '''
+ «IF null != editorGen.expressionProviders»
+ «FOR topNode : topLevelNodes.filter[n|!n.sansDomain].filter[n|n.modelFacet.modelElementSelector != null]»«constraintMethod(
+ topNode)»«ENDFOR»
+ «FOR childNode : childNodes.filter[n|!n.sansDomain].filter[n|n.modelFacet.modelElementSelector != null]»«constraintMethod(
+ childNode)»«ENDFOR»
+ «FOR link : links.filter[n|!n.sansDomain]»«constraintMethod(link.modelFacet, link)»«ENDFOR»
+ «ENDIF»
+ '''
def constraintMethod(GenNode it)
'''«domainElementConstraintMethod(modelFacet.modelElementSelector.provider, it, modelFacet.modelElementSelector, modelFacet.metaClass)»'''
@@ -421,18 +432,27 @@ import plugin.Activator
'''«ERROR('Constraint method is not supported for ' + it)»'''
def dispatch domainElementConstraintMethod(GenJavaExpressionProvider it, GenCommonBase diagramElement, ValueExpression expression, GenClass context) '''
- «generatedMemberComment()»
- private static boolean «domainElementConstraintMethodName(diagramElement)»(«xptMetaModel.QualifiedClassName(context)» domainElement) {
- «IF injectExpressionBody && (expression.body != null && !expression.body.empty)»
+ «generatedMemberComment»
+ ««« [ExtendedConstraint] START Testing the kind of ModelFacet (GenLink or Default case)
+ «IF diagramElement instanceof GenLink»
+ ««« [ExtendedConstraint] END Testing the kind of ModelFacet (GenLink or Default case)
+ private static boolean «domainElementConstraintMethodName(diagramElement)»(«QualifiedClassName(context)» domainElement) {
+ ««« [ExtendedConstraint] START Testing the kind of ModelFacet (GenLink or Default case)
+ «ELSE»
+ private static boolean «domainElementConstraintMethodName(diagramElement)»(org.eclipse.gmf.runtime.notation.View containerView, «QualifiedClassName(
+ context)» domainElement) {
+ «ENDIF»
+ ««« [ExtendedConstraint] END Testing the kind of ModelFacet (GenLink or Default case)
+ «IF injectExpressionBody && (expression.body != null && expression.body.length() != 0)»
«expression.body»
- «ELSEIF throwException || (injectExpressionBody && (expression.body == null || expression.body.empty))»
+ «ELSEIF throwException || (injectExpressionBody && (expression.body == null || expression.body.length() == 0))»
// FIXME: implement this method
// Ensure that you remove @generated or mark it @generated NOT
- throw new java.lang.UnsupportedOperationException("No java implementation provided in '«domainElementConstraintMethodName(diagramElement)»' operation");«nonNLS(1)»
+ throw new java.lang.UnsupportedOperationException("No java implementation provided in '« domainElementConstraintMethodName(diagramElement)»' operation");«nonNLS»
«ELSE»
return false;
«ENDIF»
- }
+ }
'''
// FIXME move these methods to ElementInitializers or any other more suitable place
@@ -447,31 +467,31 @@ import plugin.Activator
def unrecognizedVID(GenDiagram it) '''
- return -1;
+ return "";
'''
def checkNodeVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static boolean «checkNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, int candidate) {
- if (candidate == -1){
+ public static boolean «checkNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, String candidate) {
+ if (candidate == null){
//unrecognized id is always bad
return false;
}
- int basic = «getNodeVisualIDMethodName(it)»(containerView, domainElement);
- return basic == candidate;
+ String basic = «getNodeVisualIDMethodName(it)»(containerView, domainElement);
+ return candidate.equals(basic);
}
'''
def isCompartmentVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static boolean «isCompartmentVisualIDMethodName(it)»(int visualID) {
+ public static boolean «isCompartmentVisualIDMethodName(it)»(String visualID) {
«IF compartments.notEmpty»
- switch (visualID) {
- «FOR compartment : compartments»«caseVisualID(compartment)»«ENDFOR»
- return true;
- default:
- break;
+ if (visualID != null) {
+ switch (visualID) {
+ «FOR compartment : compartments»«caseVisualID(compartment)»«ENDFOR»
+ return true;
+ }
}
«ENDIF»
return false;
@@ -482,17 +502,17 @@ import plugin.Activator
var leafs = it.allNodes.filter[n | getSemanticChildren(n).empty && n.compartments.forall[c | getSemanticChildren(c).empty]].sortBy[n|n.visualID]
return '''
«generatedMemberComment()»
- public static boolean «isSemanticLeafVisualIDMethodName(it)»(int visualID) {
- switch (visualID) {
- «/*We need to ensure at last one case, this is legitimate way*/
- caseVisualID(it)»
- return false;
- «IF leafs.notEmpty»
- «FOR leaf : leafs»«caseVisualID(leaf)»«ENDFOR»
- return true;
- «ENDIF»
- default:
- break;
+ public static boolean «isSemanticLeafVisualIDMethodName(it)»(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ «/*We need to ensure at last one case, this is legitimate way*/
+ caseVisualID(it)»
+ return false;
+ «IF leafs.notEmpty»
+ «FOR leaf : leafs»«caseVisualID(leaf)»«ENDFOR»
+ return true;
+ «ENDIF»
+ }
}
return false;
}
@@ -501,40 +521,40 @@ import plugin.Activator
def runtimeTypedInstance(GenDiagram it) '''
«generatedClassComment()»
- public static final org.eclipse.gmf.tooling.runtime.structure.DiagramStructure «runtimeTypedInstanceName(it)» = new org.eclipse.gmf.tooling.runtime.structure.DiagramStructure() {
+ public static final org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure «runtimeTypedInstanceName(it)» = new org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure() {
«generatedMemberComment()»
- «xptCodeStyle.overrideI(it)»
- public int «getVisualIdMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
+ «xptCodeStyle.overrideC(it)»
+ public String «getVisualIdMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
return «getVisualIDMethodCall(it)»(view);
}
«generatedMemberComment()»
- «xptCodeStyle.overrideI(it)»
+ «xptCodeStyle.overrideC(it)»
public String «getModelIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
return «getModelIDMethodCall(it)»(view);
}
«generatedMemberComment()»
- «xptCodeStyle.overrideI(it)»
- public int «getNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
+ «xptCodeStyle.overrideC(it)»
+ public String «getNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
return «getNodeVisualIDMethodCall(it)»(containerView, domainElement);
}
«generatedMemberComment()»
- «xptCodeStyle.overrideI(it)»
- public boolean «checkNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, int candidate) {
+ «xptCodeStyle.overrideC(it)»
+ public boolean «checkNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, String candidate) {
return «checkNodeVisualIDMethodCall(it)»(containerView, domainElement, candidate);
}
«generatedMemberComment()»
- «xptCodeStyle.overrideI(it)»
- public boolean «isCompartmentVisualIDMethodName(it)»(int visualID) {
+ «xptCodeStyle.overrideC(it)»
+ public boolean «isCompartmentVisualIDMethodName(it)»(String visualID) {
return «isCompartmentVisualIDMethodCall(it)»(visualID);
}
«generatedMemberComment()»
- «xptCodeStyle.overrideI(it)»
- public boolean «isSemanticLeafVisualIDMethodName(it)»(int visualID) {
+ «xptCodeStyle.overrideC(it)»
+ public boolean «isSemanticLeafVisualIDMethodName(it)»(String visualID) {
return «isSemanticLeafVisualIDMethodCall(it)»(visualID);
}
};
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/extensions.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/extensions.xtend
index d5085124717..4774b89bb3b 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/extensions.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/extensions.xtend
@@ -1,48 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
import xpt.Common
-@com.google.inject.Singleton class extensions {
+@Singleton class extensions {
@Inject extension Common;
- @Inject MatchingStrategy xptMatching;
- @Inject ActionBarContributor xptActionBarContributor;
- @Inject Editor xptEditor;
- @Inject CreationWizard xptCreationWizard;
- @Inject InitDiagramFileAction xptInitDiagramFileAction;
def extensions(GenEditorGenerator it) '''
«extraLineBreak»
- «tripleSpace(1)»<extension point="org.eclipse.ui.editors" id="gmf-editor">
- «tripleSpace(2)»«xmlGeneratedTag()»
- «tripleSpace(2)»<editor
- «tripleSpace(3)»id="«editor.ID»"
- «tripleSpace(3)»name="%editorName"
- «tripleSpace(3)»icon="«editor.iconPathX»"
- «tripleSpace(3)»extensions="«diagramFileExtension»"
- «tripleSpace(3)»default="true"
- «tripleSpace(3)»class="«xptEditor.qualifiedClassName(editor)»"
- «tripleSpace(3)»matchingStrategy="«xptMatching.qualifiedClassName(diagram)»"
- «tripleSpace(3)»contributorClass="«xptActionBarContributor.qualifiedClassName(editor)»">
- «tripleSpace(2)»</editor>
- «tripleSpace(1)»</extension>
+ ««« YT (not used):
+ ««« «tripleSpace(1)»<extension point="org.eclipse.ui.editors" id="gmf-editor">
+ ««« «tripleSpace(2)»«xmlGeneratedTag()»
+ ««« «tripleSpace(2)»<editor
+ ««« «tripleSpace(3)»id="«editor.ID»"
+ ««« «tripleSpace(3)»name="%editorName"
+ ««« «tripleSpace(3)»icon="«editor.iconPathX»"
+ ««« «tripleSpace(3)»extensions="«diagramFileExtension»"
+ ««« «tripleSpace(3)»default="true"
+ ««« «tripleSpace(3)»class="«xptEditor.qualifiedClassName(editor)»"
+ ««« «tripleSpace(3)»matchingStrategy="«xptMatching.qualifiedClassName(diagram)»"
+ ««« «tripleSpace(3)»contributorClass="«xptActionBarContributor.qualifiedClassName(editor)»">
+ ««« «tripleSpace(2)»</editor>
+ ««« «tripleSpace(1)»</extension>
+
«extraLineBreak»«outTab»
«tripleSpace(1)»<extension point="org.eclipse.ui.contexts" id="ui-context">
«tripleSpace(2)»«xmlGeneratedTag()»
@@ -54,53 +52,55 @@ import xpt.Common
«tripleSpace(2)»</context>
«tripleSpace(1)»</extension>
- «tripleSpace(1)»<extension point="org.eclipse.ui.newWizards" id="creation-wizard">
- «tripleSpace(2)»«xmlGeneratedTag()»
- «tripleSpace(2)»<wizard
- «tripleSpace(3)»name="%newWizardName"
- «tripleSpace(3)»icon="«diagram.creationWizardIconPathX»"
- «tripleSpace(3)»category="«diagram.creationWizardCategoryID»"
- «tripleSpace(3)»class="«xptCreationWizard.qualifiedClassName(diagram)»"
- «tripleSpace(3)»id="«xptCreationWizard.qualifiedClassName(diagram)»ID">
- «tripleSpace(3)»<description>%newWizardDesc</description>
- «tripleSpace(2)»</wizard>
- «tripleSpace(1)»</extension>
-
- «IF diagram.generateInitDiagramAction()»
- «IF null == application»
- «tripleSpace(1)»<extension point="org.eclipse.ui.popupMenus" id="init-diagram-action">
- «tripleSpace(2)»«xmlGeneratedTag()»
- «tripleSpace(2)»<objectContribution
- «tripleSpace(4)»id="«plugin.ID».InitDiagram"
- «tripleSpace(4)»nameFilter="*.«domainFileExtension»"
- «tripleSpace(4)»objectClass="org.eclipse.core.resources.IFile">
- «tripleSpace(3)»<action
- «tripleSpace(5)»label="%initDiagramActionLabel"
- «tripleSpace(5)»class="«xptInitDiagramFileAction.qualifiedClassName(diagram)»"
- «tripleSpace(5)»menubarPath="additions"
- «tripleSpace(5)»enablesFor="1"
- «tripleSpace(5)»id="«plugin.ID».InitDiagramAction">
- «tripleSpace(3)»</action>
- «tripleSpace(2)»</objectContribution>
- «tripleSpace(1)»</extension>
- «ELSE»
- «tripleSpace(1)»<extension point="org.eclipse.ui.actionSets" id="init-diagram-action">
- «tripleSpace(2)»«xmlGeneratedTag()»
- «tripleSpace(2)»<actionSet
- «tripleSpace(4)»label="%initDiagramActionLabel"
- «tripleSpace(4)»visible="true"
- «tripleSpace(4)»id="«plugin.ID».InitDiagram">
- «tripleSpace(3)»<action
- «tripleSpace(5)»label="%initDiagramActionLabel"
- «tripleSpace(5)»class="«xptInitDiagramFileAction.qualifiedClassName(diagram)»"
- «tripleSpace(5)»menubarPath="file/additions"
- «tripleSpace(5)»id="«plugin.ID».InitDiagramAction">
- «tripleSpace(3)»</action>
- «tripleSpace(2)»</actionSet>
- «tripleSpace(1)»</extension>
- «ENDIF»
- «extraLineBreak» «tripleSpace(1)»
- «ENDIF»
+ ««« YT (not used):
+ ««« «tripleSpace(1)»<extension point="org.eclipse.ui.newWizards" id="creation-wizard">
+ ««« «tripleSpace(2)»«xmlGeneratedTag()»
+ ««« «tripleSpace(2)»<wizard
+ ««« «tripleSpace(3)»name="%newWizardName"
+ ««« «tripleSpace(3)»icon="«diagram.creationWizardIconPathX»"
+ ««« «tripleSpace(3)»category="«diagram.creationWizardCategoryID»"
+ ««« «tripleSpace(3)»class="«xptCreationWizard.qualifiedClassName(diagram)»"
+ ««« «tripleSpace(3)»id="«xptCreationWizard.qualifiedClassName(diagram)»ID">
+ ««« «tripleSpace(3)»<description>%newWizardDesc</description>
+ ««« «tripleSpace(2)»</wizard>
+ ««« «tripleSpace(1)»</extension>
+ «««
+ ««« «IF diagram.generateInitDiagramAction()»
+ ««« «IF null == application»
+ ««« «tripleSpace(1)»<extension point="org.eclipse.ui.popupMenus" id="init-diagram-action">
+ ««« «tripleSpace(2)»«xmlGeneratedTag()»
+ ««« «tripleSpace(2)»<objectContribution
+ ««« «tripleSpace(4)»id="«plugin.ID».InitDiagram"
+ ««« «tripleSpace(4)»nameFilter="*.«domainFileExtension»"
+ ««« «tripleSpace(4)»objectClass="org.eclipse.core.resources.IFile">
+ ««« «tripleSpace(3)»<action
+ ««« «tripleSpace(5)»label="%initDiagramActionLabel"
+ ««« «tripleSpace(5)»class="«xptInitDiagramFileAction.qualifiedClassName(diagram)»"
+ ««« «tripleSpace(5)»menubarPath="additions"
+ ««« «tripleSpace(5)»enablesFor="1"
+ ««« «tripleSpace(5)»id="«plugin.ID».InitDiagramAction">
+ ««« «tripleSpace(3)»</action>
+ ««« «tripleSpace(2)»</objectContribution>
+ ««« «tripleSpace(1)»</extension>
+ ««« «ELSE»
+ ««« «tripleSpace(1)»<extension point="org.eclipse.ui.actionSets" id="init-diagram-action">
+ ««« «tripleSpace(2)»«xmlGeneratedTag()»
+ ««« «tripleSpace(2)»<actionSet
+ ««« «tripleSpace(4)»label="%initDiagramActionLabel"
+ ««« «tripleSpace(4)»visible="true"
+ ««« «tripleSpace(4)»id="«plugin.ID».InitDiagram">
+ ««« «tripleSpace(3)»<action
+ ««« «tripleSpace(5)»label="%initDiagramActionLabel"
+ ««« «tripleSpace(5)»class="«xptInitDiagramFileAction.qualifiedClassName(diagram)»"
+ ««« «tripleSpace(5)»menubarPath="file/additions"
+ ««« «tripleSpace(5)»id="«plugin.ID».InitDiagramAction">
+ ««« «tripleSpace(3)»</action>
+ ««« «tripleSpace(2)»</actionSet>
+ ««« «tripleSpace(1)»</extension>
+ ««« «ENDIF»
+ ««« «extraLineBreak» «tripleSpace(1)»
+ ««« «ENDIF»
+ «««
'''
def outTab() {
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteConfiguration.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteConfiguration.xtend
new file mode 100644
index 00000000000..5c5163696c4
--- /dev/null
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteConfiguration.xtend
@@ -0,0 +1,116 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST, ALL4TEC and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+package xpt.editor.palette
+
+import javax.inject.Inject
+import javax.inject.Singleton
+import org.eclipse.emf.ecore.xmi.XMLResource
+import org.eclipse.papyrus.gmf.codegen.gmfgen.AbstractToolEntry
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolEntry
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolGroup
+import xpt.Common
+import xpt.Common_qvto
+
+/**
+ * Template for generation of palette configuration model from gmfgen.
+ */
+@Singleton class PaletteConfiguration {
+
+ @Inject extension Common
+ @Inject extension Common_qvto;
+ @Inject extension Utils_qvto;
+
+ /**
+ * Generate a palette configuration.
+ */
+ def PaletteConfiguration(GenEditorGenerator it) '''
+<?xml version="1.0" encoding="ASCII"?>
+«xmlGeneratedTag»
+<paletteconfiguration:PaletteConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.8"
+ xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2"
+ id="«plugin.ID».paletteconfiguration"
+ label="«plugin.name» Palette"
+ description="This is the palette of «plugin.name»">
+ «FOR tool : diagram.palette.groups»
+ «addDrawerConfigurations(tool)»
+ «ENDFOR»
+</paletteconfiguration:PaletteConfiguration>
+ '''
+
+ /**
+ * Generate drawer configurations.
+ */
+ def addDrawerConfigurations(ToolGroup it) '''
+<drawerConfigurations
+ id=«IF isQuoted(id,'"')»«id»«ELSE»"«id»"«ENDIF»
+ label="«it.title»"
+ description="«description»">
+ <icon pluginID="«retrieveBundleId(smallIconPath,palette.diagram.editorGen.plugin.ID)»" iconPath="«retrieveLocalPath(smallIconPath)»"/>
+ «FOR entry : entries»
+ «IF entry instanceof ToolEntry && isValidTool(entry as AbstractToolEntry)»
+ «addToolConfiguration(entry as ToolEntry)»
+ «ENDIF»
+ «IF entry instanceof ToolGroup»
+ «addStackConfiguration(entry as ToolGroup)»
+ «ENDIF»
+ «ENDFOR»
+</drawerConfigurations>
+'''
+
+ /**
+ * Add tool configuration.
+ */
+ def addToolConfiguration(ToolEntry it) '''
+<ownedConfigurations xsi:type="paletteconfiguration:ToolConfiguration"
+ id=«IF isQuoted(id,'"')»«id»«ELSE»"«id»"«ENDIF»
+ label="«title»"
+ «IF null!=qualifiedToolName && !qualifiedToolName.empty»
+ toolClassName="«qualifiedToolName»"
+ «ENDIF»
+ description="«description»"«IF genNodes.empty && !genLinks.empty» kind="ConnectionTool"«ENDIF»>
+ <icon pluginID="«retrieveBundleId(smallIconPath,group.palette.diagram.editorGen.plugin.ID)»" iconPath="«retrieveLocalPath(smallIconPath)»"/>
+ «IF elements.empty && (null==qualifiedToolName || qualifiedToolName.empty)»
+ «ERROR('No elements for tool generation (Palette):'+title)»
+ «ENDIF»
+ «FOR e : elements»
+ «val href = getElementTypeConfHRef(e.elementType.uniqueIdentifier,eResource as XMLResource)»
+ «IF null!=href && !href.empty»
+ <elementDescriptors>
+ <elementType
+ xsi:type="«getConfigurationXsiType(e.elementType.uniqueIdentifier,eResource as XMLResource)»"
+ href="«href»"/>
+ </elementDescriptors>
+ «ELSEIF null==qualifiedToolName || qualifiedToolName.empty»
+ «ERROR('No element type configuration or classToolName for tool generation (Palette):' + title)»
+ «ENDIF»
+ «ENDFOR»
+</ownedConfigurations>
+ '''
+
+ /**
+ * Add stack configuration.
+ */
+ def addStackConfiguration(ToolGroup it) '''
+<ownedConfigurations xsi:type="paletteconfiguration:StackConfiguration" id=«IF isQuoted(id,'"')»«id»«ELSE»"«id»"«ENDIF» label="«title»">
+ «FOR entry : entries»
+ «IF entry instanceof ToolEntry && isValidTool(entry as AbstractToolEntry)»
+ «addToolConfiguration(entry as ToolEntry)»
+ «ENDIF»
+ «ENDFOR»
+</ownedConfigurations>
+ '''
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteFactory.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteFactory.xtend
index 6e5c8bc5def..98d09ce5605 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteFactory.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/PaletteFactory.xtend
@@ -1,42 +1,41 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor.palette
import com.google.inject.Inject
-import java.util.Map
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.AbstractToolEntry
-import org.eclipse.papyrus.gmf.codegen.gmfgen.EntryBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.Palette
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolEntry
+import xpt.Common
+import xpt.Common_qvto
+import xpt.providers.ElementTypes
+import java.util.Map
+import org.eclipse.papyrus.gmf.codegen.gmfgen.EntryBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.Separator
import org.eclipse.papyrus.gmf.codegen.gmfgen.StandardEntry
import org.eclipse.papyrus.gmf.codegen.gmfgen.StandardEntryKind
-import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolEntry
import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolGroup
import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolGroupItem
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
-import xpt.Common
-import xpt.Common_qvto
import xpt.Externalizer
-import xpt.providers.ElementTypes
-
-@com.google.inject.Singleton class PaletteFactory {
+@Singleton class PaletteFactory {
@Inject extension Common;
@Inject extension Common_qvto;
@Inject extension Utils_qvto;
-
@Inject ElementTypes xptElementTypes;
@Inject Externalizer xptExternalizer;
@@ -53,35 +52,36 @@ import xpt.providers.ElementTypes
def PaletteFactory(Palette it) '''
«copyright(diagram.editorGen)»
- package «packageName(it)»;
+ package «packageName»;
«generatedClassComment»
- public class «className(it)» {
+ public class «factoryClassName» extends org.eclipse.gmf.runtime.diagram.ui.services.palette.PaletteFactory.Adapter {
+ //RS: New Palette generation
- «generatedMemberComment»
- public void fillPalette(org.eclipse.gef.palette.PaletteRoot paletteRoot) {
- «IF definesStandardTools()»
- cleanStandardTools(paletteRoot);
- «ENDIF»
- «FOR group : it.groups»
- «addEntry(group, 'paletteRoot')»
- «ENDFOR»
+ //Generates the ID for the tool elements
+ //Generate the tool factory (if(ID) createtool...)
+ «FOR tool : collectTools(it)»
+ «generateIDAttribute(tool)»
+ «ENDFOR»
+
+ «««Generates the default constructor
+ «generatedMemberComment»
+ public «factoryClassName»() {
+
}
+
+ «««Generates the main method to create tool
+ «generateCreateTool(it)»
- «IF it.definesStandardTools»
- «cleanStandardToolsHack(it)»
- «ENDIF»
+ «««Generates the main method to create template
+ «generateGetTemplate(it)»
+
+ «««Generates each method for tool creation
- «FOR group : collectGroups(it)»
- «createGroup(group)»
- «ENDFOR»
«FOR tool : collectTools(it)»
- «createEntry(tool)»
+ «createTool(tool)»
«ENDFOR»
- «IF needsNodeToolEntryClass(it) && shouldGenerateToolEntryClasses()»«nodeToolEntry(it)»«ENDIF»
- «IF needsLinkToolEntryClass(it) && shouldGenerateToolEntryClasses()»«linkToolEntry(it)»«ENDIF»
- «additions(it)»
}
'''
@@ -363,4 +363,57 @@ import xpt.providers.ElementTypes
def additions(Palette it) ''''''
+
+ def generateCreateTool(Palette it) '''
+ «generatedMemberComment»
+ public org.eclipse.gef.Tool createTool(String toolId) {
+ «FOR tool : collectTools(it)»
+ «checkToolID(tool)»
+ «ENDFOR»
+ // default return: null
+ return null;
+ }
+ '''
+
+ def checkToolID(AbstractToolEntry it) '''
+ if (toolId.equals(«getConstantIDName(id)»)) {
+ return «createMethodName»();
+ }
+ '''
+
+ def generateGetTemplate(Palette it) '''
+ «generatedMemberComment»
+ public Object getTemplate(String templateId) {
+
+ // default return: null
+ return null;
+ }
+ '''
+
+ def generateIDAttribute(AbstractToolEntry it) '''
+ «generatedMemberComment»
+ private final static String «getConstantIDName(id)» = «id»;«IF isQuoted(id,'"')»«nonNLS»«ENDIF»
+ '''
+
+ def createTool(AbstractToolEntry it) '''
+ «generatedMemberComment»
+ private org.eclipse.gef.Tool «createMethodName»() {
+ «newTool(it as ToolEntry, 'entry')»
+ }
+ '''
+
+ def newTool(ToolEntry it, String toolVarName) '''
+ «IF elements.isEmpty()»
+ «ERROR('no elements for tool generation (Palette)')»
+ «ELSE»
+ java.util.List<org.eclipse.gmf.runtime.emf.type.core.IElementType> types = new java.util.ArrayList<org.eclipse.gmf.runtime.emf.type.core.IElementType>(«elements.size»);
+ «FOR e : elements»
+ types.add(«xptElementTypes.accessElementType(e)»);
+ «ENDFOR»
+ ««« RS: modified tool creation to have stereotypes-aware tools
+ org.eclipse.gef.Tool tool = new org.eclipse.papyrus.uml.diagram.common.service.«IF it.genNodes.isEmpty()»AspectUnspecifiedTypeConnectionTool«ELSE»AspectUnspecifiedTypeCreationTool«ENDIF»(types);
+ return tool;
+ «ENDIF»
+ '''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/Utils_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/Utils_qvto.xtend
index 48a5f72f460..86d9a51d84b 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/Utils_qvto.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/editor/palette/Utils_qvto.xtend
@@ -1,31 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
+ * https://www.eclipse.org/legal/epl-2.0/
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 510587
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.editor.palette
-import com.google.inject.Inject
-import java.util.Collection
+import com.google.inject.Singleton
+import org.eclipse.core.runtime.IPath
+import org.eclipse.core.runtime.Path
+import org.eclipse.emf.common.util.URI
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.xmi.XMLResource
+import org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl
import org.eclipse.papyrus.gmf.codegen.gmfgen.AbstractToolEntry
import org.eclipse.papyrus.gmf.codegen.gmfgen.Palette
import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolEntry
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry
+import org.eclipse.papyrus.infra.types.ExternallyRegisteredType
+import org.eclipse.papyrus.infra.types.MetamodelTypeConfiguration
+import org.eclipse.papyrus.infra.types.SpecializationTypeConfiguration
+import org.eclipse.papyrus.infra.types.core.IConfiguredHintedElementType
+import java.util.HashMap
+import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl
+import com.google.inject.Inject
+import java.util.Collection
import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolGroup
import xpt.Common_qvto
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
import org.eclipse.papyrus.gmf.codegen.gmfgen.EntryBase
-@com.google.inject.Singleton class Utils_qvto {
+@Singleton class Utils_qvto {
@Inject extension Common_qvto;
def dispatch String activatorFQN(Palette palette) {
@@ -84,7 +99,9 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.EntryBase
}
def Iterable<AbstractToolEntry> collectTools(Palette palette) {
- return collectGroups(palette).map[g|g.entries.filter(typeof(AbstractToolEntry))].flatten
+ return collectGroups(palette).map[g|g.entries.filter(typeof(AbstractToolEntry))].flatten.filter [ tool |
+ isValidTool(tool)
+ ]
}
def boolean needsNodeToolEntryClass(Palette palette) {
@@ -95,4 +112,165 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.EntryBase
return collectTools(palette).filter(typeof(ToolEntry)).exists[e|e.genLinks.notEmpty]
}
+
+ def boolean isValidTool(AbstractToolEntry entry) {
+
+ if (entry instanceof ToolEntry) {
+ if (null != entry.qualifiedToolName && !entry.qualifiedToolName.empty) {
+ return true;
+ }
+
+ val links = (entry as ToolEntry).genLinks.size;
+ val nodes = (entry as ToolEntry).genNodes.size;
+ return nodes + links != 0;
+ } else {
+ return true;
+ }
+ }
+
+ def String getToolPath(String it) {
+ var String result = null
+
+ /** returns the '/' separator and then the id of the parent group path */
+ if (isQuoted(it, '"')) {
+ result = it.substring(1, it.length - 1)
+ } else {
+ result = it
+ }
+
+ return "/" + result;
+ }
+
+ def boolean isQuoted(String source, String quoteStr) {
+
+ if (quoteStr == null) {
+ return false;
+ }
+
+ return source.length() >= (quoteStr.length() * 2) && source.startsWith(quoteStr) && source.endsWith(quoteStr);
+
+ }
+
+ def getConstantIDName(String it) {
+ if (isQuoted(it, '"')) {
+ return getUpperAndUnderscoreString(it.substring(1, it.length() - 1))
+ } else {
+ return getUpperAndUnderscoreString(it)
+ }
+ }
+
+ def String getUpperAndUnderscoreString(String value) {
+ return value.toUpperCase.replace(".", "_")
+ }
+
+ /**
+ * The plateform protocol prefix.
+ */
+ var static String PLUGIN_PROTOCOL = "platform:/plugin/"
+
+ /**
+ * Retrieve the bundle id of a platform/plug-in path.
+ *
+ * @param initialValue
+ * The initial value from which the bundle has to be retrieved
+ * @param defaultValue
+ * The default bundle id value if bundle id not found
+ * @return the bundle id
+ */
+ def String retrieveBundleId(String initialValue, String defaultValue) {
+ var String result = null
+ if (initialValue.startsWith(PLUGIN_PROTOCOL)) {
+ var String tmp = initialValue.substring(PLUGIN_PROTOCOL.length())
+ var int bundleIdEndIndex = tmp.indexOf("/")
+ result = tmp.substring(0, bundleIdEndIndex)
+ } else {
+ result = defaultValue
+ }
+ return result
+ }
+
+ /**
+ * Retrieve the local path of a platform/plug-in path.
+ *
+ * @param initialValue
+ * the initial value from which the local path has to be retrieved
+ * @return the local path
+ */
+ def String retrieveLocalPath(String initialValue) {
+ var String result = ""
+ if (initialValue.startsWith(PLUGIN_PROTOCOL)) {
+ var String tmp = initialValue.substring(PLUGIN_PROTOCOL.length())
+ var int bundleIdEndIndex = tmp.indexOf("/")
+ result = tmp.substring(bundleIdEndIndex)
+ } else {
+ result = initialValue
+ }
+ return result
+ }
+
+ /**
+ * @return The relative path of the model's resource
+ *
+ * @param it
+ * the EObject to get the relative path
+
+ */
+ def String getRelativePath(EObject it) {
+ var String path = null;
+ var URI resourceURI = eResource().getURI()
+ if (resourceURI.isPlatformResource()) {
+ var String platformString = resourceURI.toPlatformString(true)
+ var IPath workspacePath = new Path(platformString)
+ workspacePath = workspacePath.removeFirstSegments(1)
+ workspacePath = workspacePath.removeLastSegments(1)
+ path = workspacePath.toString()
+ } else {
+ path = "model"
+ }
+ return path;
+ }
+
+ /**
+ * Get the href string for the elementTypeConfiguration model of the unique identifier.
+ */
+ def String getElementTypeConfHRef(String uniqueIdentifier, XMLResource resource) {
+
+ //Load element type registry
+ org.eclipse.papyrus.infra.types.core.registries.ElementTypeSetConfigurationRegistry.getInstance().getClass()
+
+ var String href = null
+ val type = ElementTypeRegistry.getInstance().getType(uniqueIdentifier)
+
+ if (type instanceof IConfiguredHintedElementType) {
+ val xmlHelper = new XMLHelperImpl(resource)
+ val options = new HashMap<Object, Object>()
+ //Set option to have platform:/ sheme instead of ../../..
+ options.put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware())
+ xmlHelper.options = options;
+ href = xmlHelper.getHREF(type.configuration as EObject)
+ }
+ return href;
+
+ }
+
+ /**
+ * Get the href string for the elementTypeConfiguration model of the unique identifier.
+ */
+ def String getConfigurationXsiType(String uniqueIdentifier, XMLResource resource) {
+ var String type = null
+ val eltype = ElementTypeRegistry.getInstance().getType(uniqueIdentifier)
+ if (eltype instanceof IConfiguredHintedElementType) {
+ var configuration = eltype.configuration
+ if (configuration instanceof SpecializationTypeConfiguration) {
+ type = "elementtypesconfigurations:SpecializationTypeConfiguration"
+ } else if (configuration instanceof MetamodelTypeConfiguration) {
+ type = "elementtypesconfigurations:MetamodelTypeConfiguration"
+ } else if (configuration instanceof ExternallyRegisteredType) {
+ type = "elementtypesconfigurations:ExternallyRegisteredType"
+ }
+ }
+ return type;
+
+ }
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/expressions/AbstractExpression.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/expressions/AbstractExpression.xtend
index 2ceacb9e9ca..9831ef48eb3 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/expressions/AbstractExpression.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/expressions/AbstractExpression.xtend
@@ -1,17 +1,18 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2014 , 2021 Borland Software Corporation, Montages, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - API extracted to GMF-T runtime, migrated to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - API extracted to GMF-T runtime, migrated to Xtend2
+ * Anatoliy Tischenko - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.expressions
@@ -158,17 +159,33 @@ import plugin.Activator
return value;
}
if (Number.class.isAssignableFrom(targetWrapperClass)) {
- if (targetWrapperClass.equals(Byte.class)) return new Byte(num.byteValue());
- if (targetWrapperClass.equals(Integer.class)) return new Integer(num.intValue());
- if (targetWrapperClass.equals(Short.class)) return new Short(num.shortValue());
- if (targetWrapperClass.equals(Long.class)) return new Long(num.longValue());
- if (targetWrapperClass.equals(java.math.BigInteger.class)) return java.math.BigInteger.valueOf(num.longValue());
- if (targetWrapperClass.equals(Float.class)) return new Float(num.floatValue());
- if (targetWrapperClass.equals(Double.class)) return new Double(num.doubleValue());
- if (targetWrapperClass.equals(java.math.BigDecimal.class)) return new java.math.BigDecimal(num.doubleValue());
+ if (targetWrapperClass.equals(Byte.class)) {
+ return new Byte(num.byteValue());
+ }
+ if (targetWrapperClass.equals(Integer.class)) {
+ return new Integer(num.intValue());
+ }
+ if (targetWrapperClass.equals(Short.class)) {
+ return new Short(num.shortValue());
+ }
+ if (targetWrapperClass.equals(Long.class)) {
+ return new Long(num.longValue());
+ }
+ if (targetWrapperClass.equals(java.math.BigInteger.class)) {
+ return java.math.BigInteger.valueOf(num.longValue());
+ }
+ if (targetWrapperClass.equals(Float.class)) {
+ return new Float(num.floatValue());
+ }
+ if (targetWrapperClass.equals(Double.class)) {
+ return new Double(num.doubleValue());
+ }
+ if (targetWrapperClass.equals(java.math.BigDecimal.class)) {
+ return new java.math.BigDecimal(num.doubleValue());
+ }
}
return value;
}
'''
-}
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/AbstractNavigatorItem.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/AbstractNavigatorItem.xtend
index a16a94ec115..315fbf03ff4 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/AbstractNavigatorItem.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/AbstractNavigatorItem.xtend
@@ -1,26 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
-import xpt.Common
+import xpt.Common import xpt.CodeStyle
-@com.google.inject.Singleton class AbstractNavigatorItem {
+@Singleton class AbstractNavigatorItem {
@Inject extension Common;
+ @Inject extension CodeStyle
def className(GenNavigator it) '''«it.abstractNavigatorItemClassName»'''
@@ -54,14 +56,18 @@ import xpt.Common
def registerAdapterFactory(GenNavigator it) '''
«generatedMemberComment()»
static {
+ @SuppressWarnings("rawtypes")
final Class[] supportedTypes = new Class[] { org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor.class };
final org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor propertySheetPageContributor = new org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor() {
+ «overrideI(it.editorGen.diagram)»
public String getContributorId() {
return "«editorGen.plugin.ID»"; «nonNLS(1)»
}
};
org.eclipse.core.runtime.Platform.getAdapterManager().registerAdapters(new org.eclipse.core.runtime.IAdapterFactory() {
+ «overrideI(it.editorGen.diagram)»
+ @SuppressWarnings("rawtypes")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof «qualifiedClassName(it)» && adapterType == org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor.class) {
return propertySheetPageContributor;
@@ -69,6 +75,8 @@ import xpt.Common
return null;
}
+ «overrideI(it.editorGen.diagram)»
+ @SuppressWarnings("rawtypes")
public Class[] getAdapterList() {
return supportedTypes;
}
@@ -76,6 +84,7 @@ import xpt.Common
}
'''
+
def attributes(GenNavigator it) '''
«generatedMemberComment()»
private Object myParent;
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorContentProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorContentProvider.xtend
index 43b27ce617f..649c0fa5f0e 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorContentProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorContentProvider.xtend
@@ -1,26 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
-import xpt.Common
import plugin.Activator
+import xpt.Common
-@com.google.inject.Singleton class DomainNavigatorContentProvider {
+@Singleton class DomainNavigatorContentProvider {
@Inject extension Common;
@Inject Activator xptActivator
@@ -108,7 +109,7 @@ import plugin.Activator
def wrapEObjects(GenNavigator it) '''
«generatedMemberComment()»
public Object[] wrapEObjects(Object[] objects, Object parentElement) {
- java.util.Collection result = new java.util.ArrayList();
+ java.util.Collection<«xptDomainNavigatorItem.qualifiedClassName(it)»> result = new java.util.ArrayList<«xptDomainNavigatorItem.qualifiedClassName(it)»>();
for (int i = 0; i < objects.length; i++) {
if (objects[i] instanceof org.eclipse.emf.ecore.EObject) {
result.add(new «xptDomainNavigatorItem.qualifiedClassName(it)»((org.eclipse.emf.ecore.EObject) objects[i], parentElement, myAdapterFctoryContentProvier));
@@ -119,5 +120,4 @@ import plugin.Activator
'''
def additions(GenNavigator it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorItem.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorItem.xtend
index 963f80d112b..e591cc8f8c4 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorItem.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/DomainNavigatorItem.xtend
@@ -1,28 +1,30 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
import xpt.Common
+import xpt.CodeStyle
@com.google.inject.Singleton class DomainNavigatorItem {
@Inject extension Common;
@Inject AbstractNavigatorItem xptAbstractNavigatorItem;
+ @Inject extension CodeStyle
def className(GenNavigator it) '''«it.domainNavigatorItemClassName»'''
@@ -64,9 +66,12 @@ import xpt.Common
def registerAdapterFactory(GenNavigator it) '''
«generatedMemberComment()»
static {
+ @SuppressWarnings("rawtypes")
final Class[] supportedTypes = new Class[] { org.eclipse.emf.ecore.EObject.class, org.eclipse.ui.views.properties.IPropertySource.class };
org.eclipse.core.runtime.Platform.getAdapterManager().registerAdapters(new org.eclipse.core.runtime.IAdapterFactory() {
+ «overrideI(it.editorGen.diagram)»
+ @SuppressWarnings("rawtypes")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof «qualifiedClassName(it)») {
«qualifiedClassName(it)» domainNavigatorItem = («qualifiedClassName(it)») adaptableObject;
@@ -82,6 +87,8 @@ import xpt.Common
return null;
}
+ «overrideI(it.editorGen.diagram)»
+ @SuppressWarnings("rawtypes")
public Class[] getAdapterList() {
return supportedTypes;
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorContentProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorContentProvider.xtend
index 00fbc36505a..8b351fe3813 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorContentProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorContentProvider.xtend
@@ -1,39 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Modified by Patrick Tessier (CEA LIST)
+ * Emilien Perico (Atos Origin) - update template for GMF 2.2 compliance
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
-import xpt.editor.VisualIDRegistry
import com.google.inject.Inject
-import xpt.Externalizer
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorChildReference
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
+import com.google.inject.Singleton
import org.eclipse.emf.codegen.util.CodeGenUtil
-import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorReferenceType
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLink
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorChildReference
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorReferenceType
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
+import org.eclipse.papyrus.gmf.codegen.xtend.annotations.Localization
+import xpt.CodeStyle
+import xpt.Common
+import xpt.Common_qvto
+import xpt.Externalizer
+import xpt.editor.VisualIDRegistry
-@com.google.inject.Singleton class NavigatorContentProvider {
- @Inject extension xpt.Common;
- @Inject extension xpt.Common_qvto;
- @Inject extension xpt.navigator.Utils_qvto;
-
+@Singleton class NavigatorContentProvider {
+ @Inject extension Common;
+ @Inject extension Common_qvto;
+ @Inject extension Utils_qvto;
+ @Inject extension CodeStyle
+
@Inject VisualIDRegistry xptVisualIDRegistry;
@Inject Externalizer xptExternalizer;
@Inject NavigatorGroup navigatorGroup;
@@ -58,6 +65,8 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
«attributes(it)»
«constructor(it)»
+
+ «genAllMethodNodeCase»
«iContentProvider(it)»
@@ -72,7 +81,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
«additions(it)»
}
'''
-
+
def attributes(GenNavigator it) '''
«generatedMemberComment()»
private static final Object[] EMPTY_ARRAY = new Object[0];
@@ -92,7 +101,6 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
def constructor(GenNavigator it) '''
«generatedMemberComment()»
- @SuppressWarnings({ "unchecked", "serial", "rawtypes" })
public «className(it)»() {
«initCommonAttributes(it)»
}
@@ -101,15 +109,23 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
def initCommonAttributes(GenNavigator it) '''
org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = «createEditingDomain(it)»;
myEditingDomain = (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) editingDomain;
- myEditingDomain.setResourceToReadOnlyMap(new java.util.HashMap() {
- public Object get(Object key) {
+ @SuppressWarnings("serial")
+ java.util.Map<org.eclipse.emf.ecore.resource.Resource, java.lang.Boolean> map = new java.util.HashMap<org.eclipse.emf.ecore.resource.Resource, java.lang.Boolean>() {
+
+ «overrideI(it.editorGen.diagram)»
+ public java.lang.Boolean get(java.lang.Object key) {
if (!containsKey(key)) {
- put(key, Boolean.TRUE);
+ if (key instanceof org.eclipse.emf.ecore.resource.Resource) {
+ put((org.eclipse.emf.ecore.resource.Resource) key, java.lang.Boolean.TRUE);
+ }
}
return super.get(key);
}
- });
+ };
+ myEditingDomain.setResourceToReadOnlyMap(map);
myViewerRefreshRunnable = new Runnable() {
+
+ «overrideI(it.editorGen.diagram)»
public void run() {
if (myViewer != null) {
myViewer.refresh();
@@ -117,17 +133,22 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
}
};
myWorkspaceSynchronizer = new org.eclipse.emf.workspace.util.WorkspaceSynchronizer(editingDomain, new org.eclipse.emf.workspace.util.WorkspaceSynchronizer.Delegate() {
+
+ «overrideC(it.editorGen.diagram)»
public void dispose() {
}
+ «overrideC(it.editorGen.diagram)»
public boolean handleResourceChanged(final org.eclipse.emf.ecore.resource.Resource resource) {
«processChanges(it)»
}
+ «overrideC(it.editorGen.diagram)»
public boolean handleResourceDeleted(org.eclipse.emf.ecore.resource.Resource resource) {
«processChanges(it)»
}
+ «overrideC(it.editorGen.diagram)»
public boolean handleResourceMoved(org.eclipse.emf.ecore.resource.Resource resource, final org.eclipse.emf.common.util.URI newURI) {
«processChanges(it)»
}
@@ -135,8 +156,13 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
'''
def processChanges(GenNavigator it) '''
- unloadAllResources();
- asyncRefresh();
+ for (java.util.Iterator<org.eclipse.emf.ecore.resource.Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = it.next();
+ nextResource.unload();
+ }
+ if (myViewer != null) {
+ myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable);
+ }
return true;
'''
@@ -166,8 +192,12 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
myWorkspaceSynchronizer.dispose();
myWorkspaceSynchronizer = null;
myViewerRefreshRunnable = null;
- myViewer = null;
- unloadAllResources();
+
+ for (java.util.Iterator<org.eclipse.emf.ecore.resource.Resource> it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource resource = it.next();
+ resource.unload();
+ }
+
((org.eclipse.emf.transaction.TransactionalEditingDomain) myEditingDomain).dispose();
myEditingDomain = null;
}
@@ -258,19 +288,18 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
def getFileChildren(GenNavigator it) '''
«var references = getChildReferencesFrom(it, null)»
«getFileResource(it)»
- java.util.ArrayList<«xptNavigatorItem.qualifiedClassName(it)»> result = new java.util.ArrayList<«xptNavigatorItem.qualifiedClassName(it)»>();
+ java.util.Collection<Object> result = new java.util.ArrayList<Object>();
«FOR groupName : getGroupNames(references)»
«initGroupVariables(groupName, it, references, 'file', null)»
«ENDFOR»
- java.util.ArrayList<org.eclipse.gmf.runtime.notation.View> topViews = new java.util.ArrayList<org.eclipse.gmf.runtime.notation.View>(resource.getContents().size());
+ java.util.List<org.eclipse.gmf.runtime.notation.View> topViews = new java.util.ArrayList<org.eclipse.gmf.runtime.notation.View>(resource.getContents().size());
for (org.eclipse.emf.ecore.EObject o : resource.getContents()) {
if (o instanceof org.eclipse.gmf.runtime.notation.View) {
topViews.add((org.eclipse.gmf.runtime.notation.View) o);
}
}
«FOR ref : references»
- «addNavigatorItemsPrefix(ref)»selectViewsByType(topViews, «getChildViewType(ref.child)»)«addNavigatorItemsSuffix(ref,
- 'file', false)»
+ «addNavigatorItemsPrefix(ref)»selectViewsByType(resource.getContents(), «getChildViewType(ref.child)»)«addNavigatorItemsSuffix(ref, 'file', false)»
«ENDFOR»
«FOR groupName : getGroupNames(references)»
«addGroups(groupName, references)»
@@ -317,32 +346,41 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
def getViewChildren(GenNavigator it) '''
«generatedMemberComment()»
private Object[] getViewChildren(org.eclipse.gmf.runtime.notation.View view, Object parentElement) {
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view)) {
- «FOR node : getNavigatorContainerNodes(it)»
- «caseNavigatorNode(node, it)»
- «ENDFOR»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view);
+ if (vid != null) {
+ switch (vid) {
+ ««« BEGIN: PapyrusGenCode
+ ««« Restructuration of the case
+ «FOR node : getNavigatorContainerNodes(it)»
+ «caseNavigatorNode(node, it)»
+ «ENDFOR»
+ «««BEGIN: PapyrusGenCode
+ }
}
return EMPTY_ARRAY;
}
'''
def utilityMethods(GenNavigator it) '''
- «generatedMemberComment()»
- private java.util.Collection<org.eclipse.gmf.runtime.notation.View> getLinksSourceByType(java.util.Collection<org.eclipse.gmf.runtime.notation.Edge> edges, String type) {
- java.util.LinkedList<org.eclipse.gmf.runtime.notation.View> result = new java.util.LinkedList<org.eclipse.gmf.runtime.notation.View>();
- for (org.eclipse.gmf.runtime.notation.Edge nextEdge : edges) {
- org.eclipse.gmf.runtime.notation.View nextEdgeSource = nextEdge.getSource();
- if (type.equals(nextEdgeSource.getType()) && isOwnView(nextEdgeSource)) {
- result.add(nextEdgeSource);
- }
- }
- return result;
+ «IF getNavigatorContainerNodes(it).notEmpty»
+ «generatedMemberComment»
+ private java.util.Collection getLinksSourceByType(java.util.Collection edges, String type) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = edges.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge nextEdge = (org.eclipse.gmf.runtime.notation.Edge) it.next();
+ org.eclipse.gmf.runtime.notation.View nextEdgeSource = nextEdge.getSource();
+ if (type.equals(nextEdgeSource.getType()) && isOwnView(nextEdgeSource)) {
+ result.add(nextEdgeSource);
+ }
+ }
+ return result;
}
- «generatedMemberComment()»
- private java.util.Collection<org.eclipse.gmf.runtime.notation.View> getLinksTargetByType(java.util.Collection<org.eclipse.gmf.runtime.notation.Edge> edges, String type) {
- java.util.LinkedList<org.eclipse.gmf.runtime.notation.View> result = new java.util.LinkedList<org.eclipse.gmf.runtime.notation.View>();
- for (org.eclipse.gmf.runtime.notation.Edge nextEdge : edges) {
+ «generatedMemberComment»
+ private java.util.Collection getLinksTargetByType(java.util.Collection edges, String type) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = edges.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge nextEdge = (org.eclipse.gmf.runtime.notation.Edge) it.next();
org.eclipse.gmf.runtime.notation.View nextEdgeTarget = nextEdge.getTarget();
if (type.equals(nextEdgeTarget.getType()) && isOwnView(nextEdgeTarget)) {
result.add(nextEdgeTarget);
@@ -350,48 +388,50 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
}
return result;
}
-
- «generatedMemberComment()»
- private java.util.Collection<org.eclipse.gmf.runtime.notation.View> getOutgoingLinksByType(java.util.Collection<? extends org.eclipse.gmf.runtime.notation.View> nodes, String type) {
- java.util.LinkedList<org.eclipse.gmf.runtime.notation.View> result = new java.util.LinkedList<org.eclipse.gmf.runtime.notation.View>();
- for (org.eclipse.gmf.runtime.notation.View nextNode : nodes) {
- result.addAll(selectViewsByType(nextNode.getSourceEdges(), type));
+ «generatedMemberComment»
+ private java.util.Collection getOutgoingLinksByType(java.util.Collection nodes, String type) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = nodes.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextNode = (org.eclipse.gmf.runtime.notation.View) it.next();
+ result.addAll(selectViewsByType(nextNode.getSourceEdges(), type));
}
- return result;
+ return result;
}
- «generatedMemberComment()»
- private java.util.Collection<org.eclipse.gmf.runtime.notation.View> getIncomingLinksByType(java.util.Collection<? extends org.eclipse.gmf.runtime.notation.View> nodes, String type) {
- java.util.LinkedList<org.eclipse.gmf.runtime.notation.View> result = new java.util.LinkedList<org.eclipse.gmf.runtime.notation.View>();
- for (org.eclipse.gmf.runtime.notation.View nextNode : nodes) {
+ «generatedMemberComment»
+ private java.util.Collection getIncomingLinksByType(java.util.Collection nodes, String type) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = nodes.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextNode = (org.eclipse.gmf.runtime.notation.View) it.next();
result.addAll(selectViewsByType(nextNode.getTargetEdges(), type));
- }
- return result;
+ }
+ return result;
}
-
- «generatedMemberComment()»
- private java.util.Collection<org.eclipse.gmf.runtime.notation.View> getChildrenByType(java.util.Collection<? extends org.eclipse.gmf.runtime.notation.View> nodes, String type) {
- java.util.LinkedList<org.eclipse.gmf.runtime.notation.View> result = new java.util.LinkedList<org.eclipse.gmf.runtime.notation.View>();
- for (org.eclipse.gmf.runtime.notation.View nextNode : nodes) {
+«««
+ «generatedMemberComment»
+ private java.util.Collection getChildrenByType(java.util.Collection nodes, String type) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = nodes.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextNode = (org.eclipse.gmf.runtime.notation.View) it.next();
result.addAll(selectViewsByType(nextNode.getChildren(), type));
}
return result;
}
- «generatedMemberComment()»
- private java.util.Collection<org.eclipse.gmf.runtime.notation.View> getDiagramLinksByType(java.util.Collection<org.eclipse.gmf.runtime.notation.Diagram> diagrams, String type) {
- java.util.ArrayList<org.eclipse.gmf.runtime.notation.View> result = new java.util.ArrayList<org.eclipse.gmf.runtime.notation.View>();
- for (org.eclipse.gmf.runtime.notation.Diagram nextDiagram : diagrams) {
+ «generatedMemberComment»
+ private java.util.Collection getDiagramLinksByType(java.util.Collection diagrams, String type) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = diagrams.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Diagram nextDiagram = (org.eclipse.gmf.runtime.notation.Diagram) it.next();
result.addAll(selectViewsByType(nextDiagram.getEdges(), type));
}
return result;
}
-
- // TODO refactor as static method
- «generatedMemberComment()»
- private java.util.Collection<org.eclipse.gmf.runtime.notation.View> selectViewsByType(java.util.Collection<org.eclipse.gmf.runtime.notation.View> views, String type) {
- java.util.ArrayList<org.eclipse.gmf.runtime.notation.View> result = new java.util.ArrayList<org.eclipse.gmf.runtime.notation.View>();
- for (org.eclipse.gmf.runtime.notation.View nextView : views) {
+ «generatedMemberComment»
+ private java.util.Collection selectViewsByType(java.util.Collection views, String type) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = views.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
if (type.equals(nextView.getType()) && isOwnView(nextView)) {
result.add(nextView);
}
@@ -399,20 +439,23 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
return result;
}
- «generatedMemberComment()»
- private boolean isOwnView(org.eclipse.gmf.runtime.notation.View view) {
- return «VisualIDRegistry::modelID(editorGen.diagram)».equals(«xptVisualIDRegistry.
- getModelIDMethodCall(editorGen.diagram)»(view));
- }
-
- «generatedMemberComment()»
- private java.util.Collection<«xptNavigatorItem.qualifiedClassName(it)»> createNavigatorItems(java.util.Collection<org.eclipse.gmf.runtime.notation.View> views, Object parent, boolean isLeafs) {
- java.util.ArrayList<«xptNavigatorItem.qualifiedClassName(it)»> result = new java.util.ArrayList<«xptNavigatorItem.qualifiedClassName(it)»>(views.size());
- for (org.eclipse.gmf.runtime.notation.View nextView : views) {
- result.add(new «xptNavigatorItem.qualifiedClassName(it)»(nextView, parent, isLeafs));
+ «generatedMemberComment»
+ private java.util.Collection createNavigatorItems(java.util.Collection views, Object parent, boolean isLeafs) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = views.iterator(); it.hasNext();) {
+ result.add(new «getNavigatorItemQualifiedClassName()»((org.eclipse.gmf.runtime.notation.View) it.next(), parent, isLeafs));
}
return result;
}
+ «ENDIF»
+
+ «generatedMemberComment()»
+ private boolean isOwnView(org.eclipse.gmf.runtime.notation.View view) {
+ return «VisualIDRegistry::modelID(editorGen.diagram)».equals(«xptVisualIDRegistry.
+ getModelIDMethodCall(editorGen.diagram)»(view));
+ }
+
+
«getForeignShortcuts(it)»
'''
@@ -420,11 +463,11 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
«IF editorGen.diagram.generateCreateShortcutAction() && getChildReferencesFrom(it, editorGen.diagram).notEmpty»
«generatedMemberComment()»
- private java.util.Collection<«xptNavigatorItem.qualifiedClassName(it)»> getForeignShortcuts(org.eclipse.gmf.runtime.notation.Diagram diagram, Object parent) {
- java.util.LinkedList<org.eclipse.gmf.runtime.notation.View> result = new java.util.LinkedList<org.eclipse.gmf.runtime.notation.View>();
- for (java.util.Iterator<org.eclipse.gmf.runtime.notation.View> it = diagram.getChildren().iterator(); it.hasNext();) {
- org.eclipse.gmf.runtime.notation.View nextView = it.next();
- if (!isOwnView(nextView) && nextView.getEAnnotation("Shortcut") != null) { «nonNLS(1)»
+ private java.util.Collection getForeignShortcuts(org.eclipse.gmf.runtime.notation.Diagram diagram, Object parent) {
+ java.util.Collection result = new java.util.ArrayList();
+ for (java.util.Iterator it = diagram.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (!isOwnView(nextView) && nextView.getEAnnotation("Shortcut") != null) { «nonNLS»
result.add(nextView);
}
}
@@ -433,7 +476,16 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
«ENDIF»
'''
- def createEditingDomain(GenNavigator it) '''org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory.INSTANCE.createEditingDomain()'''
+ def createEditingDomain(GenNavigator it) '''org.eclipse.emf.workspace.WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain()'''
+
+//BEGIN: PapyrusGenCode
+//Loop to call generator of each method
+def genAllMethodNodeCase(GenNavigator it)'''
+«FOR container :getNavigatorContainerNodes(it)»
+« caseMethodNodeNode(container,it) »
+«ENDFOR»
+
+'''
def initGroupVariables(String groupName, GenNavigator navigator, Iterable<GenNavigatorChildReference> references,
String parentVarName, GenCommonBase contextElement) '''
@@ -443,9 +495,9 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
'''
@Localization def String i18nKeyForGroup(String groupName, GenCommonBase contextElement) {
- return 'NavigatorGroupName.' + (if(null != contextElement) contextElement.uniqueIdentifier else 'File') + '.' +
- CodeGenUtil::validJavaIdentifier(groupName)
- }
+ return 'NavigatorGroupName.' + (if(null != contextElement) contextElement.stringUniqueIdentifier else 'File') + '.' +
+ CodeGenUtil::validJavaIdentifier(groupName)
+}
def addNavigatorItemsPrefix(GenNavigatorChildReference it) '''«IF isInsideGroup()»«CodeGenUtil::validJavaIdentifier(
groupName)».addChildren(«ELSE»result.addAll(«ENDIF»createNavigatorItems('''
@@ -469,36 +521,14 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
def dispatch getChildViewType(GenCommonBase it) '''«xptVisualIDRegistry.typeMethodCall(it)»'''
def caseNavigatorNode(GenCommonBase it, GenNavigator navigator) '''
-
- case «VisualIDRegistry::visualID(it)»: {
- java.util.LinkedList<«abstractNavigatorItem.qualifiedClassName(navigator)»> result = new java.util.LinkedList<«abstractNavigatorItem.
- qualifiedClassName(navigator)»>();
- «addForeignShortcuts(it)»
- «nailedDownVariable(it, 'sv', 'view')»
- «var references = getChildReferencesFrom(navigator, it)»
- «FOR groupName : getGroupNames(references)»
- «initGroupVariables(groupName, navigator, references, 'parentElement', it)»
- «ENDFOR»
- «IF references.notEmpty && references.map[r|r.findConnectionPaths()].flatten.notEmpty»
- java.util.Collection<org.eclipse.gmf.runtime.notation.View> connectedViews;
- «FOR reference : references»
- «FOR path : reference.findConnectionPaths()»
- «IF path.segments.notEmpty»
- connectedViews = «childrenMethodName(path.segments.head.from, reference.referenceType, path.segments.head)»(java.util.Collections.singleton(sv), «xptVisualIDRegistry.typeMethodCall(path.segments.head.to)»);
- «FOR segment : path.segments.drop(1)»
- connectedViews = «childrenMethodName(segment.from, reference.referenceType, segment)»(connectedViews, «xptVisualIDRegistry.typeMethodCall(segment.to)»);
- «ENDFOR»
- «ENDIF»
- «addNavigatorItemsPrefix(reference)»connectedViews«addNavigatorItemsSuffix(reference, 'parentElement',
- reference.referenceType != GenNavigatorReferenceType::CHILDREN_LITERAL)»
- «ENDFOR»
- «ENDFOR»
- «ENDIF»
- «FOR groupName : getGroupNames(references)»
- «addGroups(groupName, references)»
- «ENDFOR»
- return result.toArray();
- }
+
+ case «VisualIDRegistry::visualID(it)»: {
+ «««BEGIN: PapyrusGenCode
+ ««« this code has been modified to call directly submethods
+ //modification of the template to avoid mistake of 65kb.
+ return getViewChildrenFor«it.editPartClassName»(view, parentElement);
+ «««END: PapyrusGenCode
+ }
'''
def dispatch nailedDownVariable(GenCommonBase it, String varName, String expressionToCast) '''«/* NO-OP, all specific subclasses should be handled */»'''
@@ -564,4 +594,55 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigatorPathSegment
@Localization def internal_i18nValues(String groupName, GenCommonBase contextElement) '''«IF null != groupName»«xptExternalizer.
messageEntry(i18nKeyForGroup(groupName, contextElement), groupName)»«ENDIF»'''
+//END: PapyrusGenCode
+//BEGIN: PapyrusGenCode
+//this template has been modified to fixe bug generation by GMF framework.
+//Is avoid generated method that are greater than 64Kb
+def caseMethodNodeNode(GenCommonBase it, GenNavigator navigator) '''
+/**
+ *
+ *Papyrus Template
+ *this method is a modification of gmf code in order to avoid getViewChidreen() method becoming greater than 64kb.
+ *@generated
+**/
+private Object[] getViewChildrenFor«it.editPartClassName»(org.eclipse.gmf.runtime.notation.View view, Object parentElement){
+ java.util.Collection result = new java.util.ArrayList();
+ «addForeignShortcuts(it)»
+ «var _references = getChildReferencesFrom(navigator, it)»
+ «FOR groupNames : getGroupNames(_references)»
+ «initGroupVariables(groupNames,navigator, _references, 'parentElement', it)»
+ «ENDFOR»
+
+
+
+ «IF ! _references.empty»
+ «FOR referencesIterator : 1.._references.size»
+ «var reference = _references.get(referencesIterator-1)»
+ «IF ! reference.findConnectionPaths.empty»
+ «FOR pathsIterator : 1..reference.findConnectionPaths.size»
+ «var path = reference.findConnectionPaths.get(pathsIterator-1)»
+ «IF ! path.segments.empty»
+ «FOR segmentsIterator : 1..path.segments.size»
+ «var segment = path.segments.get(segmentsIterator-1)»
+ «IF referencesIterator==1 && pathsIterator==1 && segmentsIterator==1»java.util.Collection «ENDIF»
+ connectedViews = «childrenMethodName(segment.from,reference.referenceType, segment) »
+ («IF segmentsIterator==1»java.util.Collections.singleton(view)«ELSE»connectedViews«ENDIF»
+ , «xptVisualIDRegistry.typeMethodCall(segment.to)»);
+
+ «ENDFOR»
+ «ENDIF»
+ «addNavigatorItemsPrefix(reference)»connectedViews«addNavigatorItemsSuffix(reference,'parentElement', reference.referenceType != GenNavigatorReferenceType.CHILDREN_LITERAL) »
+ «ENDFOR»
+ «ENDIF»
+ «ENDFOR»
+ «ENDIF»
+
+ «FOR groupNames : getGroupNames(_references)»
+ « addGroups(groupNames,_references) »
+ «ENDFOR»
+
+
+ return result.toArray();
+}
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorGroup.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorGroup.xtend
index 1998481c826..508011021f5 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorGroup.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorGroup.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
@@ -19,7 +19,8 @@ import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
import xpt.Common
-@com.google.inject.Singleton class NavigatorGroup {
+@com.google.inject.Singleton class NavigatorGroup{
+
@Inject extension Common;
def className(GenNavigator it) '''«it.navigatorGroupClassName»'''
@@ -71,7 +72,7 @@ import xpt.Common
private String myIcon;
«generatedMemberComment()»
- private java.util.Collection myChildren = new java.util.LinkedList();
+ private java.util.Collection<java.lang.Object> myChildren = new java.util.LinkedList<java.lang.Object>();
'''
def constructor(GenNavigator it) '''
@@ -104,9 +105,9 @@ import xpt.Common
}
'''
- def addChildren(GenNavigator it) '''
+ def addChildren(GenNavigator it) '''
«generatedMemberComment()»
- public void addChildren(java.util.Collection children) {
+ public void addChildren(java.util.Collection<java.lang.Object> children) {
myChildren.addAll(children);
}
'''
@@ -146,5 +147,4 @@ import xpt.Common
'''
def additions(GenNavigator it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorItem.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorItem.xtend
index 31231570ee1..d608940264e 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorItem.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorItem.xtend
@@ -1,26 +1,30 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
-import xpt.Common
+import xpt.Common import xpt.CodeStyle
-@com.google.inject.Singleton class NavigatorItem {
+@Singleton class NavigatorItem {
+
@Inject extension Common;
+ @Inject extension CodeStyle
+
def className(GenNavigator it) '''«it.navigatorItemClassName»'''
@@ -60,16 +64,21 @@ import xpt.Common
def registerAdapterFactory(GenNavigator it) '''
«generatedMemberComment()»
static {
+ @SuppressWarnings("rawtypes")
final Class[] supportedTypes = new Class[] { org.eclipse.gmf.runtime.notation.View.class, org.eclipse.emf.ecore.EObject.class };
org.eclipse.core.runtime.Platform.getAdapterManager().registerAdapters(new org.eclipse.core.runtime.IAdapterFactory() {
+ «overrideI(it.editorGen.diagram)»
+ @SuppressWarnings("rawtypes")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof «qualifiedClassName(it)» && (adapterType == org.eclipse.gmf.runtime.notation.View.class || adapterType == org.eclipse.emf.ecore.EObject.class)) {
return ((«qualifiedClassName(it)») adaptableObject).getView();
}
return null;
}
-
+
+ «overrideI(it.editorGen.diagram)»
+ @SuppressWarnings("rawtypes")
public Class[] getAdapterList() {
return supportedTypes;
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLabelProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLabelProvider.xtend
index d3c68988fe7..ea6a5568627 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLabelProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLabelProvider.xtend
@@ -1,17 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Modified by Patrick Tessier (CEA LIST)
+ * Emilien Perico (Atos Origin) - update template for GMF 2.2 compliance
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
@@ -284,7 +286,7 @@ import plugin.Activator
return «getTextMethodName(it)»(view);
'''
- @MetaDef def getTextMethodName(GenCommonBase it) '''get«getUniqueIdentifier()»Text'''
+ @MetaDef def getTextMethodName(GenCommonBase it) '''get«stringUniqueIdentifier»Text'''
def getTextMethod(GenCommonBase it) '''
«generatedMemberComment()»
@@ -361,7 +363,7 @@ import plugin.Activator
if (parser != null) {
return parser.getPrintString(new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(view.getElement() != null ? view.getElement() : view), org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions.NONE.intValue());
} else {
- «xptActivator.qualifiedClassName(getDiagram().editorGen.plugin)».getInstance().logError("Parser was not found for label " + «visualID»); «nonNLS(1)»
+ «xptActivator.qualifiedClassName(getDiagram().editorGen.plugin)».getInstance().logError("Parser was not found for label «stringVisualID»"); «nonNLS(1)»
«returnEmptyString()»
}
'''
@@ -371,9 +373,9 @@ import plugin.Activator
«IF null != genClass && null != genClass.labelFeature»
«xptMetaModel.DeclareAndAssign(genClass, 'domainModelElement', 'view.getElement()')»
if (domainModelElement != null) {
- return «IF !isStringFeature(genClass.labelFeature)»String.valueOf(«ENDIF»«xptMetaModel.getFeatureValue(genClass.labelFeature, 'domainModelElement', genClass)»«IF !isStringFeature(genClass.labelFeature)»)«ENDIF»;
+ return «IF !isStringFeature(genClass.labelFeature)»String.valueOf(«ENDIF»UMLLabelInternationalization.getInstance().getLabel(domainModelElement)«IF !isStringFeature(genClass.labelFeature)»)«ENDIF»;
} else {
- «xptActivator.qualifiedClassName(getDiagram().editorGen.plugin)».getInstance().logError("No domain element for view with visualID = " + «visualID»); «nonNLS(1)»
+ «xptActivator.qualifiedClassName(getDiagram().editorGen.plugin)».getInstance().logError("No domain element for view with visualID = «stringVisualID»"); «nonNLS(1)»
«returnEmptyString()»
}
«ELSE»
@@ -485,5 +487,4 @@ import plugin.Activator
def additions(GenNavigator it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLinkHelper.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLinkHelper.xtend
index d24e36fd030..a3ec0778ff4 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLinkHelper.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorLinkHelper.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
@@ -63,7 +63,9 @@ import plugin.Activator
def findSelection(GenNavigator it) '''
«generatedMemberComment()»
public org.eclipse.jface.viewers.IStructuredSelection findSelection(org.eclipse.ui.IEditorInput anInput) {
+ «IF getDiagramTopReference(it) !=null»
«defineDiagramDocument(editorGen.plugin)»
+ «ENDIF»
«findSelectionBody(it)»
}
'''
@@ -73,7 +75,9 @@ import plugin.Activator
'''
def findSelectionBody(GenNavigator it) '''
+ «IF getDiagramTopReference(it) !=null»
«getDiagramSelection(getDiagramTopReference(it))»
+ «ENDIF»
return org.eclipse.jface.viewers.StructuredSelection.EMPTY;
'''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorSorter.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorSorter.xtend
index 67640cf5647..d0d15894c20 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorSorter.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/navigator/NavigatorSorter.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.navigator
@@ -70,12 +70,11 @@ import xpt.editor.VisualIDRegistry
return SHORTCUTS_CATEGORY;
}
«ENDIF»
- return «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»(item.getView());
+ return «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»(item.getView()).hashCode();
}
return GROUP_CATEGORY;
}
'''
def additions(GenNavigator it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/ActivatorImpl.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/ActivatorImpl.xtend
index c36387ce6d3..0bcd2d81485 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/ActivatorImpl.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/ActivatorImpl.xtend
@@ -1,16 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2013, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Michael Golubev (Montages) - initial API and implementation
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Michael Golubev (Montages) - initial API and implementation
+ * Florian Noyrit - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.plugin
@@ -42,37 +43,39 @@ import xpt.providers.ElementInitializers
«generatedClassComment»
public class «xptActivator.className(it)» extends org.eclipse.ui.plugin.AbstractUIPlugin {
- «attrs»
- «constructor»
- «start»
+ «attrs(it)»
+ «constructor(it)»
+ «start(it)»
«stop(editorGen)»
- «getInstance»
- «createAdapterFactory(editorGen.diagram)»
- «fillItemProviderFactories(editorGen)»
- «getItemProvidersAdaptorFactory»
- «getItemImageDescriptor»
- «getBundleDescriptorImage»
- «findImageDescriptor»
- «getBundleImage»
- «getString»
+ «getInstance(it)»
+
+ «getPreferenceStore»
+
+ «getItemProvidersAdaptorFactory(it)»
+ «getItemImageDescriptor(it)»
+ «getBundleDescriptorImage(it)»
+ «findImageDescriptor(it)»
+ «getBundleImage(it)»
+ «getString(it)»
«documentProviderGetter(editorGen.diagram)»
«linkConstraint(editorGen.diagram)»
«initializerGetter(editorGen.diagram)»
«initializerSetter(editorGen.diagram)»
- «providersAccessMethods»
+ «providersAccessMethods(it)»
«logError(it)»
- «logInfo»
+ «logInfo(it)»
«getLogError(it)»
- «additions»
+ «additions(it)»
}
'''
+
def attrs(GenPlugin it)'''
«generatedMemberComment»
public static final String ID = "«ID»"; //$NON-NLS-1$
«generatedMemberComment»
- private org.eclipse.gmf.tooling.runtime.LogHelper myLogHelper;
+ private org.eclipse.papyrus.infra.core.log.LogHelper myLogHelper;
«generatedMemberComment»
public static final org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint DIAGRAM_PREFERENCES_HINT =
@@ -82,7 +85,7 @@ def attrs(GenPlugin it)'''
private static «xptActivator.className(it)» instance;
«generatedMemberComment»
- private org.eclipse.emf.edit.provider.ComposedAdapterFactory adapterFactory;
+ private org.eclipse.emf.common.notify.AdapterFactory adapterFactory;
«generatedMemberComment»
private «xptDocProvider.qualifiedClassName(editorGen.diagram)» documentProvider;
@@ -114,29 +117,31 @@ def start(GenPlugin it)'''
public void start(org.osgi.framework.BundleContext context) throws Exception {
super.start(context);
instance = this;
- myLogHelper = new org.eclipse.gmf.tooling.runtime.LogHelper(this);
+ myLogHelper = new org.eclipse.papyrus.infra.core.log.LogHelper(this);
org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore());
- adapterFactory = createAdapterFactory();
+ adapterFactory = org.eclipse.papyrus.infra.gmfdiag.common.Activator.getInstance().getItemProvidersAdapterFactory();
+ «it.editorGen.diagram.preferencesPackageName».DiagramPreferenceInitializer diagramPreferenceInitializer = new «it.editorGen.diagram.preferencesPackageName».DiagramPreferenceInitializer();
+ diagramPreferenceInitializer.initializeDefaultPreferences();
+
}
'''
def stop(GenEditorGenerator it)'''
- «generatedMemberComment»
- public void stop(org.osgi.framework.BundleContext context) throws Exception {
- adapterFactory.dispose();
- adapterFactory = null;
- «IF diagram.links.exists(l| !l.sansDomain)»
- linkConstraints = null;
- «ENDIF»
- initializers = null;
- «IF expressionProviders != null»
- «FOR p : expressionProviders.providers.filter(typeof(GenExpressionInterpreter))»
- «p.language»Factory = null;
- «ENDFOR»
- «ENDIF»
- instance = null;
- super.stop(context);
- }
+ «generatedMemberComment»
+ public void stop(org.osgi.framework.BundleContext context) throws Exception {
+ adapterFactory = null;
+ «IF diagram.links.exists(l| !l.sansDomain)»
+ linkConstraints = null;
+ «ENDIF»
+ initializers = null;
+ «IF expressionProviders != null»
+ «FOR p : expressionProviders.providers.filter(typeof(GenExpressionInterpreter))»
+ «p.language»Factory = null;
+ «ENDFOR»
+ «ENDIF»
+ instance = null;
+ super.stop(context);
+ }
'''
def getInstance(GenPlugin it)'''
@@ -316,35 +321,35 @@ def providerSetter(GenExpressionInterpreter it)'''
'''
def logError(GenPlugin it)'''
- «generatedMemberComment»
- public void logError(String error) {
- getLogHelper().logError(error, null);
- }
+ «generatedMemberComment»
+ public void logError(String error) {
+ getLogHelper().warn(error);
+ }
+
+ «generatedMemberComment»
+ public void logError(String error, Throwable throwable) {
+ getLogHelper().error(error, throwable);
+ }
+ '''
- «generatedMemberComment»
- public void logError(String error, Throwable throwable) {
- getLogHelper().logError(error, throwable);
- }
-'''
-
def logInfo(GenPlugin it)'''
- «generatedMemberComment»
- public void logInfo(String message) {
- getLogHelper().logInfo(message, null);
- }
-
- «generatedMemberComment»
- public void logInfo(String message, Throwable throwable) {
- getLogHelper().logInfo(message, throwable);
- }
-'''
+ «generatedMemberComment»
+ public void logInfo(String message) {
+ getLogHelper().info(message);
+ }
+
+ «generatedMemberComment»
+ public void logInfo(String message, Throwable throwable) {
+ getLogHelper().error(message, throwable);
+ }
+ '''
def getLogError(GenPlugin it) '''
- «generatedMemberComment»
- public org.eclipse.gmf.tooling.runtime.LogHelper getLogHelper() {
- return myLogHelper;
- }
-'''
+ «generatedMemberComment»
+ public org.eclipse.papyrus.infra.core.log.LogHelper getLogHelper() {
+ return myLogHelper;
+ }
+ '''
// Perhaps, xpt:editor::Editor or some xpt::CommonCode would be better place for
// this accessor.
@@ -352,4 +357,15 @@ def getLogError(GenPlugin it) '''
def preferenceHintAccess(GenEditorGenerator it)'''«xptActivator.qualifiedClassName(plugin)».DIAGRAM_PREFERENCES_HINT'''
def additions(GenPlugin it)''''''
+
+def getPreferenceStore()'''
+ «generatedMemberComment»
+ public org.eclipse.jface.preference.IPreferenceStore getPreferenceStore() {
+ org.eclipse.jface.preference.IPreferenceStore store=org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore();
+ return store;
+ }
+
+'''
+
+
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/manifest.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/manifest.xtend
index dc58cb43a6d..894af892993 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/manifest.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/manifest.xtend
@@ -1,16 +1,20 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2013, 2015, 2021 Borland Software Corporation, Christian W. Damus, CEA LIST, Artal and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Michael Golubev (Montages) - initial API and implementation
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Michael Golubev (Montages) - initial API and implementation
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Thibault Landre (Atos Origin) - add Papyrus dependencies to Papyrus GMF diagram
+ * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr : add the dependencyorg.eclipse.papyrus.infra.services.edit
+ * Christian W. Damus - bug 477384
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.plugin
@@ -18,6 +22,7 @@ import com.google.inject.Inject
import xpt.GenEditorGenerator_qvto
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenPlugin
import xpt.Common
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
@com.google.inject.Singleton class manifest {
@@ -79,6 +84,12 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.gmf.runtime.emf.commands.core,
org.eclipse.gmf.runtime.emf.ui.properties,
org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.papyrus.uml.diagram.common,
+ org.eclipse.papyrus.infra.gmfdiag.common,
+ org.eclipse.papyrus.uml.service.types,
+ org.eclipse.papyrus.infra.widgets,
+ org.eclipse.papyrus.infra.ui,
+ org.eclipse.papyrus.infra.core.sashwindows.di,
«IF printingEnabled» org.eclipse.gmf.runtime.diagram.ui.printing,
org.eclipse.gmf.runtime.diagram.ui.printing.render,
«ENDIF»
@@ -90,14 +101,21 @@ Require-Bundle: org.eclipse.core.runtime,
«IF editorGen.application == null» org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide,
«ENDIF»
«var reqPlugins = getAllRequiredPlugins()»
-«IF !reqPlugins.contains('org.eclipse.gmf.tooling.runtime')»
-«var notUsetBooleanVar = reqPlugins.add('org.eclipse.gmf.tooling.runtime')»
+«IF !reqPlugins.contains('org.eclipse.papyrus.infra.gmfdiag.tooling.runtime')»
+«var notUsetBooleanVar = reqPlugins.add('org.eclipse.papyrus.infra.gmfdiag.tooling.runtime')»
«ENDIF»
«FOR reqId : reqPlugins» «reqId»;visibility:=reexport,«extraLineBreak»
-«ENDFOR» org.eclipse.gef;visibility:=reexport
+«ENDFOR» org.eclipse.gef,
+ org.eclipse.papyrus.infra.gmfdiag.preferences,
+ «IF it.eResource.allContents.filter(typeof (GenCommonBase)).filter[node | node.usingDeleteService || node.usingReorientService].size != 0»
+ org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors,
+ org.eclipse.papyrus.infra.services.edit
+ «ELSE»
+ org.eclipse.papyrus.extensionpoints.editors
+«ENDIF»
'''
def executionEnvironment(GenPlugin it) '''
-Bundle-RequiredExecutionEnvironment: «IF editorGen.jdkComplianceLevel() > 5»JavaSE-1.6«ELSE»J2SE-1.«editorGen.jdkComplianceLevel()»«ENDIF»
+Bundle-RequiredExecutionEnvironment: «IF editorGen.jdkComplianceLevel() > 8»JavaSE-«editorGen.jdkComplianceLevel()»«ELSE»J2SE-1.«editorGen.jdkComplianceLevel()»«ENDIF»
'''
} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/plugin.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/plugin.xtend
index c85cec62ce1..182d1057fbe 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/plugin.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/plugin/plugin.xtend
@@ -1,33 +1,48 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2013, 2017, 2021 Borland Software Corporation, CEA LIST, ALL4TEC, Artal and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Michael Golubev (Montages) - initial API and implementation
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Michael Golubev (Montages) - initial API and implementation
+ * CEA LIST - initial API and implementation
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 510587: the palette must not be generated by using GMF gen
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.plugin
import com.google.inject.Inject
-import xpt.GenEditorGenerator_qvto
+import com.google.inject.Singleton
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.papyrus.gmf.codegen.gmfgen.AbstractToolEntry
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCompartment
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExternalNodeLabel
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLink
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenLinkLabel
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenMetricContainer
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenPlugin
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolEntry
+import org.eclipse.papyrus.gmf.codegen.gmfgen.ToolGroup
import xpt.Common
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenMetricContainer
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+import xpt.GenEditorGenerator_qvto
+import xpt.editor.extensions
+import xpt.editor.palette.Utils_qvto
-@com.google.inject.Singleton class plugin {
+@Singleton class plugin {
@Inject extension GenEditorGenerator_qvto
@Inject extension Common
- @Inject extension xpt.plugin.pluginUtils
-
- @Inject xpt.editor.extensions xptEditorExtension
+ @Inject extension pluginUtils
+ @Inject extension Utils_qvto
+
+ @Inject extensions xptEditorExtension
@Inject xpt.diagram.preferences.extensions xptPreferencesExtension
@Inject xpt.propsheet.extensions xptPropsheetExtension
@Inject xpt.navigator.extensions xptNavigatorExtension
@@ -41,27 +56,33 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
def fullPath(GenPlugin it) '''«qualifiedClassName(it)»'''
def plugin(GenPlugin it) '''
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-«it.editorGen.xcopyright»
-<plugin>
-«fileTypes()»
-«extension_parser()»
-«xptEditorExtension.extensions(it.editorGen)»
-«pluginMenu()»
-«validation(it.editorGen.diagram)»
-«IF it.editorGen.metrics != null»«metrics(it.editorGen.metrics)»«ENDIF»
-«xptPreferencesExtension.extensions(it.editorGen.diagram)»
-«IF it.editorGen.propertySheet != null»«xptPropsheetExtension.extensions(it.editorGen.propertySheet)»«ENDIF»
-«xptProvidersExtension.extensions(it.editorGen.diagram)»
-«IF it.editorGen.navigator != null»«xptNavigatorExtension.extensions(it.editorGen.navigator)»«ENDIF»
-«IF it.editorGen.application != null»«xptApplicationExtension.extensions(it.editorGen.application)»«ENDIF»
-«extensionsConstraintProviders(it.editorGen)»
-«xptUpdaterExtension.extensions(it.editorGen.diagramUpdater)»
-«xptActionExtension.Main(it.editorGen)»
-«additions»
-</plugin>
-'''
+ <?xml version="1.0" encoding="UTF-8"?>
+ <?eclipse version="3.0"?>
+ «xcopyright(it.editorGen)»
+ <plugin>
+ ««««fileTypes()»
+ ««««extension_parser()»
+ «xptEditorExtension.extensions(it.editorGen)»
+ «««global actions handled in the diagram.common plugin
+ ««««pluginMenu()»
+ «validation(it.editorGen.diagram)»
+ «IF it.editorGen.metrics != null»«metrics(it.editorGen.metrics)»«ENDIF»
+ «««RS: redefine palette generation
+««« «palettePredefinedEntries(editorGen)»
+««« «paletteEntries(editorGen)»
+ «xptPreferencesExtension.extensions(it.editorGen.diagram)»
+ «IF it.editorGen.propertySheet != null»«xptPropsheetExtension.extensions(it.editorGen.propertySheet)»«ENDIF»
+ «xptProvidersExtension.extensions(it.editorGen.diagram)»
+ «IF it.editorGen.navigator != null»«xptNavigatorExtension.extensions(it.editorGen.navigator)»«ENDIF»
+ «IF it.editorGen.application != null»«xptApplicationExtension.extensions(it.editorGen.application)»«ENDIF»
+ «extensionsConstraintProviders(it.editorGen)»
+ «xptUpdaterExtension.extensions(it.editorGen.diagramUpdater)»
+ «xptActionExtension.Main(it.editorGen)»
+ «additions(it)»
+ «notationTypesMap(editorGen)»
+««« «paletteConfiguration(editorGen)»
+ </plugin>
+ '''
def fileTypes(GenPlugin it) '''
«extraLineBreak»
@@ -189,8 +210,217 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
'''
def additions(GenPlugin it) ''''''
+
+ // def category(GenDiagram it) '''«getDiagramPreferencePageCategory()».«editorGen.modelID»'''
+
+ //RS: redefine palette generation, using predefined entries
+ def palettePredefinedEntries(GenEditorGenerator it) '''
+ «xmlGeneratedTag»
+ <extension
+ id="«plugin.name».palettedefinition"
+ name="«plugin.name» Predefined Entries"
+ point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders">
+
+ «xmlGeneratedTag»
+ <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider">
+ <Priority name="Lowest"/>
+ <contribution
+ factoryClass="«it.diagram.palette.packageName».«it.diagram.palette.factoryClassName»">
+ <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/>
+
+ «FOR tool : collectTools(diagram.palette)»
+ «predefinedEntryDefinition(tool)»
+ «ENDFOR»
+
+ </contribution>
+ </paletteProvider>
+
+ </extension>
+ '''
+
def outTab() {
return ' ';
}
+
+
+ /**
+ * deprecated: palette configuration are now declared through architecture model.
+ */
+ def paletteConfiguration(GenEditorGenerator it) '''
+<extension point="org.eclipse.papyrus.infra.gmfdiag.common.paletteDefinition">
+ «xmlGeneratedTag»
+ <paletteDefinition
+ ID="«plugin.ID».paletteconfiguration"
+ class="org.eclipse.papyrus.infra.gmfdiag.common.service.palette.ExtendedPluginPaletteProvider"
+ name="«plugin.name» Palette"
+ path="«relativePath»/«modelID».paletteconfiguration"
+ provider="Eclipse Modeling Project">
+ <Priority
+ name="Lowest">
+ </Priority>
+ <!-- Specify diagram to which this palette tool relates -->
+ <editor
+ id="«plugin.ID»">
+ </editor>
+ </paletteDefinition>
+</extension>
+ '''
+
+ //RS: redefine palette generation, using predefined entries
+ def paletteEntries(GenEditorGenerator it) '''
+ «xmlGeneratedTag»
+ <extension
+ id="«plugin.name».standard"
+ name="«plugin.name» Standard Palette"
+ point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders">
+
+ «xmlGeneratedTag»
+ <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider">
+ <Priority name="Low"/>
+ <contribution
+ factoryClass="«it.diagram.palette.packageName».«it.diagram.palette.factoryClassName»">
+ <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/>
+ <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/>
+
+ «FOR tool : diagram.palette.groups»
+ «groupUsage(tool)»
+ «ENDFOR»
+ </contribution>
+ <editor id="«plugin.ID»"/>
+ </paletteProvider>
+
+ </extension>
+ '''
+
+ def groupUsage(ToolGroup it) '''
+ <entry
+ description="«it.description»"
+ id=«IF isQuoted(id,'"')»«id»«ELSE»"«id»"«ENDIF»
+ kind="«IF it.stack && it.toolsOnly»stack«ELSE»drawer«ENDIF»"
+ label="«it.title»"
+ large_icon="«largeIconPath»"
+ path="«getPath(it)»"
+ small_icon="«smallIconPath»">
+ <expand
+ force="true">
+ </expand>
+ </entry>
+ ««« TODO: call sub entries...
+ «FOR entry : it.entries.filter[e| e instanceof ToolEntry]»
+ «toolUsage(entry, it)»
+ «ENDFOR»
+ «FOR entry : it.entries.filter[e| e instanceof ToolGroup]»
+ «toolUsage(entry, it)»
+ «ENDFOR»
+ '''
+
+ private def getPath(ToolEntry it) {
+ return buildPath(it.eContainer);
+ }
+
+ private def getPath(ToolGroup it) {
+ return buildPath(it.eContainer);
+ }
+
+ private def buildPath(EObject it) {
+ var path = new StringBuilder();
+ var container = it;
+ while (container instanceof ToolGroup) {
+ path.insert(0, getToolPath((container as ToolGroup).id));
+ container = container.eContainer;
+ }
+ return if(path.length() != 0) path.toString else "/" ;
+ }
+
+ def dispatch toolUsage(ToolEntry it, ToolGroup group) '''
+ <predefinedEntry
+ id=«IF isQuoted(id,'"')»«id»«ELSE»"«id»"«ENDIF»
+ path="«getPath(it)»">
+ </predefinedEntry>
+ '''
+
+ def dispatch toolUsage(ToolGroup it, ToolGroup group) '''
+ «groupUsage(it)»
+ '''
+
+ def predefinedEntryDefinition(AbstractToolEntry it) '''
+ <entry
+ defineOnly="true"
+ description="«it.description»"
+ id=«IF isQuoted(id,'"')»«id»«ELSE»"«id»"«ENDIF»
+ kind="tool"
+ label="«it.title»"
+ large_icon="«largeIconPath»"
+ path=""
+ small_icon="«smallIconPath»">
+ </entry>
+ '''
+
+ // set notation type mapping extension point
+ def notationTypesMap(GenEditorGenerator it) '''
+«tripleSpace(0)»<extension point="org.eclipse.papyrus.infra.gmfdiag.common.notationTypesMapping">
+«tripleSpace(1)»«xmlGeneratedTag»
+«tripleSpace(1)»<diagramMappings diagramID="«modelID»">
+«tripleSpace(1)» <mapping type="«modelID»" humanReadableType="«modelID.replaceAll('Papyrus|UML|Diagram', '')»Diagram"/>
+ «FOR compartment : diagram.compartments»
+ «compartmentToTypeMap(compartment)»
+ «ENDFOR»
+ «FOR link : diagram.links»
+ «linksToTypeMap(link)»
+ «ENDFOR»
+ «FOR externalLabel : diagram.eResource.allContents.filter(typeof (GenExternalNodeLabel)).toIterable»
+ «floatingLabelToTypeMap(externalLabel)»
+ «externalNodeLabelToTypeMap(externalLabel)»
+ «ENDFOR»
+«tripleSpace(1)»</diagramMappings>
+«tripleSpace(0)»</extension>
+ '''
+ def compartmentToTypeMap(GenCompartment it) '''
+ <mapping
+ humanReadableType="«title.replaceAll('Compartment', '')»"
+ type="«stringVisualID»">
+ </mapping>
+ '''
+
+ def linksToTypeMap(GenLink it) '''
+ «FOR label : labels»
+ «linkLabelToTypeMap(label)»
+ «ENDFOR»
+ '''
+
+ def linkLabelToTypeMap(GenLinkLabel it)'''
+ ««« it is used on a LabelVisibilityPreference...
+ «IF labelVisibilityPreference !== null »
+ <mapping
+ humanReadableType="«labelVisibilityPreference.role»"
+ type="«stringVisualID»">
+ </mapping>
+ «ENDIF»
+ '''
+
+ def externalNodeLabelToTypeMap(GenExternalNodeLabel it)'''
+ «IF labelVisibilityPreference !== null »
+ <mapping
+ humanReadableType="«labelVisibilityPreference.role»"
+ type="«stringVisualID»">
+ </mapping>
+ «ENDIF»
+ '''
+
+ def floatingLabelToTypeMap(GenExternalNodeLabel it)'''
+ ««« it is used on a ExtensionGenView...
+ «IF superEditPart !== null»
+ «««...to be extended as floatingLabel
+ «IF "FloatingLabelEditPart".equals(name) »
+ <mapping
+ humanReadableType="Floating Label"
+ type="«stringVisualID»">
+ </mapping>
+ «ENDIF»
+ «ENDIF»
+ '''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend
index a19cf81a844..60225716c3c 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend
@@ -1,17 +1,17 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.propsheet
@@ -103,7 +103,7 @@ import xpt.providers.ElementTypes
private org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(org.eclipse.gmf.runtime.notation.View view) {
// For intermediate views climb up the containment hierarchy to find the one associated with an element type.
while (view != null) {
- int vid = «visualId.qualifiedClassName(editorGen.diagram)».getVisualID(view);
+ String vid = «visualId.qualifiedClassName(editorGen.diagram)».getVisualID(view);
org.eclipse.gmf.runtime.emf.type.core.IElementType etype =
«xptElementTypes.qualifiedClassName(editorGen.diagram)».getElementType(vid);
if (etype != null) {
@@ -117,5 +117,4 @@ import xpt.providers.ElementTypes
'''
def additions(GenPropertySheet it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/PropertySection.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/PropertySection.xtend
index 0a602a6c288..41e0912915c 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/PropertySection.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/PropertySection.xtend
@@ -1,18 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
- *
+/*****************************************************************************
+ * Copyright (c) 2007, 2017, 2021 Borland Software Corporation, Montages, CEA LIST, Artal and others
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - [407242] - common code extracted to gmft.runtime,
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - [407242] - common code extracted to gmft.runtime,
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
*****************************************************************************/
package xpt.propsheet
@@ -50,7 +51,7 @@ import xpt.Common
}
'''
- def extendsList(GenCustomPropertyTab it) '''extends org.eclipse.gmf.tooling.runtime.sheet.DefaultPropertySection'''
+ def extendsList(GenCustomPropertyTab it) '''extends org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.sheet.DefaultPropertySection'''
def implementsClause(GenCustomPropertyTab it) '''implements org.eclipse.ui.views.properties.IPropertySourceProvider'''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/EditPartProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/EditPartProvider.xtend
index f8456119b43..3f002f89d12 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/EditPartProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/EditPartProvider.xtend
@@ -1,17 +1,23 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, Montages, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - API extracted to GMF-T runtime, migrated to Xtend2
- */
+ * Contributors:
+ * Alexander Shatalin/Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - API extracted to GMF-T runtime, migrated to Xtend2
+ * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) Add a line to initialize the display of the compartments to true
+ * Vincent Lorenzo (CEA-LIST) - Add lines to initialize the display of the labels - Bug 335987 [General][Enhancement] Show/Hide Connectors Labels and External Nodes Labels
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
@@ -47,7 +53,7 @@ import xpt.diagram.editparts.EditPartFactory
}
'''
- def extendsList(GenDiagram it) '''extends org.eclipse.gmf.tooling.runtime.providers.DefaultEditPartProvider'''
+ def extendsList(GenDiagram it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.providers.DefaultEditPartProvider'''
def implementsList(GenDiagram it) ''''''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers.xtend
index 0cec4411d9e..2a49e11f771 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers.xtend
@@ -1,20 +1,22 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) - refactored javaInitilizers not to use methods from GMFGen model
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - refactored javaInitilizers not to use methods from GMFGen model
* [221347] Got rid of generated interfaces
* (IObjectInitializer, IFeatureInitializer) and implementation thereof
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Christian W. Damus (CEA) - bug 440263
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
@@ -58,7 +60,7 @@ import xpt.expressions.AbstractExpression
@MetaDef def initMethodCall(GenCommonBase linkOrNode, TypeModelFacet modelFacet, String newElementVar) '''
«IF modelFacet.modelElementInitializer != null»
- «elementInitializersInstanceCall(linkOrNode)».init_«linkOrNode.uniqueIdentifier»(«newElementVar»);
+ «elementInitializersInstanceCall(linkOrNode)».init_«linkOrNode.stringUniqueIdentifier»(«newElementVar»);
«ENDIF»
'''
@@ -139,13 +141,13 @@ import xpt.expressions.AbstractExpression
def dispatch CharSequence initMethod(GenFeatureSeqInitializer it, GenCommonBase diagramElement) '''
«generatedMemberComment»
- public void init_«diagramElement.getUniqueIdentifier()»(«xptMetaModel.QualifiedClassName(elementClass)» instance) {
+ public void init_«diagramElement.stringUniqueIdentifier()»(«xptMetaModel.QualifiedClassName(elementClass)» instance) {
try {
«FOR i : it.initializers»
«performInit(i, diagramElement, 'instance', elementClass, <Integer>newLinkedList(initializers.indexOf(i)))»
«ENDFOR»
} catch(RuntimeException e) {
- «xptActivator.qualifiedClassName(diagramElement.getDiagram().editorGen.plugin)».getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
+ «xptActivator.qualifiedClassName(diagramElement.getDiagram().editorGen.plugin)».getInstance().logError("Element initialization failed", e); //$NON-NLS-1$
}
}
'''
@@ -158,45 +160,47 @@ import xpt.expressions.AbstractExpression
*/
def dispatch CharSequence performInit(GenFeatureValueSpec it, GenCommonBase diagramElement, String instanceVar,
GenClass instanceClass, List<Integer> counters) '''
- «IF it.value.provider.getLanguage() == GenLanguage::LITERAL_LITERAL»
- «xptMetaModel.modifyFeature(feature, instanceVar, instanceClass, value.body)»
- «extraLineBreak»
- «ELSE»
- «var expressionVarName = getVariableName('value', counters)»
- Object «expressionVarName» = «evaluateExpr(value.provider, diagramElement, it, instanceVar)»;
- «IF feature.listType»
- if («expressionVarName» instanceof java.util.Collection) {
- «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».clear();
- «IF feature.typeGenClassifier.expressionResultNeedsCast()»
- for (java.util.Iterator it = ((java.util.Collection) «expressionVarName»).iterator(); it.hasNext(); ) {
- Object next = «xptAbstractExpression.qualifiedClassName(diagramElement.getDiagram())».performCast(it.next(), «xptMetaModel.
- MetaClass(feature.typeGenClassifier)»);
- «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».add((«xptMetaModel.
- QualifiedClassName(feature.typeGenClassifier/*XXX sorta hack, better would be MM::setFeatureValue that supports lists*/)») next);
- }
- «ELSE»
- «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».addAll(((java.util.Collection) «expressionVarName»));
- «ENDIF»
- } else {
- «IF feature.typeGenClassifier.expressionResultNeedsCast()»
- «expressionVarName» = «xptAbstractExpression
- .qualifiedClassName(diagramElement.getDiagram())».performCast(«expressionVarName», «xptMetaModel.MetaClass(
- feature.typeGenClassifier)»);
- «ENDIF»
- «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».add((«xptMetaModel.
- QualifiedClassName(feature.typeGenClassifier/*XXX sorta hack, better would be MM::setFeatureValue that supports lists*/)») «expressionVarName»);
- }
- «ELSE»
- «IF feature.typeGenClassifier.expressionResultNeedsCast()»
- «extraLineBreak»
- «expressionVarName» = «
- xptAbstractExpression.qualifiedClassName(diagramElement.getDiagram())».performCast(«expressionVarName», «xptMetaModel.MetaClass(
- feature.typeGenClassifier)»);
- «ENDIF»
- «xptMetaModel.setFeatureValue(feature, instanceVar, instanceClass, expressionVarName, true)»;
- «ENDIF/*isListType*/»
- «ENDIF/*is literal expression*/»
- '''
+ «IF it.value.provider.getLanguage() == GenLanguage::LITERAL_LITERAL»
+ «xptMetaModel.modifyFeature(feature, instanceVar, instanceClass, value.body)»
+ «extraLineBreak»
+ «ELSE»
+ «var expressionVarName = getVariableName('value', counters)»
+ Object «expressionVarName» = «evaluateExpr(value.provider, diagramElement, it, instanceVar)»;
+ «IF feature.listType»
+ if («expressionVarName» instanceof java.util.Collection) {
+ «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».clear();
+ «IF feature.typeGenClassifier.expressionResultNeedsCast()»
+ for (java.util.Iterator it = ((java.util.Collection) «expressionVarName»).iterator(); it.hasNext(); ) {
+ Object next = «xptAbstractExpression.qualifiedClassName(diagramElement.getDiagram())».performCast(it.next(), «xptMetaModel.
+ MetaClass(feature.typeGenClassifier)»);
+ «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».add((«xptMetaModel.
+ QualifiedClassName(feature.typeGenClassifier/*XXX sorta hack, better would be MM::setFeatureValue that supports lists*/)») next);
+ }
+ «ELSE»
+ «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».addAll(((java.util.Collection) «expressionVarName»));
+ «ENDIF»
+ } else if(«expressionVarName» != null) {
+ «IF feature.typeGenClassifier.expressionResultNeedsCast()»
+ «expressionVarName» = «xptAbstractExpression
+ .qualifiedClassName(diagramElement.getDiagram())».performCast(«expressionVarName», «xptMetaModel.MetaClass(
+ feature.typeGenClassifier)»);
+ «ENDIF»
+ «xptMetaModel.getFeatureValue(feature, instanceVar, instanceClass, true)».add((«xptMetaModel.
+ QualifiedClassName(feature.typeGenClassifier/*XXX sorta hack, better would be MM::setFeatureValue that supports lists*/)») «expressionVarName»);
+ }
+ «ELSE»
+ if(«expressionVarName» != null) {
+ «IF feature.typeGenClassifier.expressionResultNeedsCast()»
+ «extraLineBreak»
+ «expressionVarName» = «
+ xptAbstractExpression.qualifiedClassName(diagramElement.getDiagram())».performCast(«expressionVarName», «xptMetaModel.MetaClass(
+ feature.typeGenClassifier)»);
+ «ENDIF»
+ «xptMetaModel.setFeatureValue(feature, instanceVar, instanceClass, expressionVarName, true)»;
+ }
+ «ENDIF/*isListType*/»
+ «ENDIF/*is literal expression*/»
+ '''
def dispatch CharSequence performInit(GenReferenceNewElementSpec it, GenCommonBase diagramElement,
String instanceVar, GenClass instanceClass, List<Integer> counters) '''
@@ -233,9 +237,17 @@ import xpt.expressions.AbstractExpression
'''
/////////////////////////////////
- def dispatch CharSequence javaMethod(GenNode it) '''«javaMethod(it.modelFacet, it)»'''
+ def dispatch CharSequence javaMethod(GenNode it) '''
+ «IF !it.sansDomain»
+ «javaMethod(it.modelFacet, it)»
+ «ENDIF»
+ '''
- def dispatch CharSequence javaMethod(GenLink it) '''«javaMethod(it.modelFacet, it)»'''
+ def dispatch CharSequence javaMethod(GenLink it) '''
+ «IF !it.sansDomain»
+ «javaMethod(it.modelFacet, it)»
+ «ENDIF»
+ '''
def dispatch CharSequence javaMethod(ModelFacet it, GenCommonBase diagramElement) ''''''
@@ -274,5 +286,4 @@ import xpt.expressions.AbstractExpression
«ENDIF»
}
'''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers_qvto.xtend
index 1dd40dc8c7f..2bd28c122f9 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers_qvto.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementInitializers_qvto.xtend
@@ -1,35 +1,42 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2008, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Michael Golubev (Montages) - API extracted to GMF-T runtime, migrated to Xtend2
- */
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - refactored javaInitilizers not to use methods from GMFGen model
+ * [221347] Got rid of generated interfaces
+ * (IObjectInitializer, IFeatureInitializer) and implementation thereof
+ * Michael Golubev (Montages) - API extracted to GMF-T runtime, #386838 migrate to Xtend2
+ * Christian W. Damus (CEA) - bug 440263
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
-import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.util.Collection
+import java.util.List
import org.eclipse.emf.codegen.ecore.genmodel.GenClass
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier
import org.eclipse.emf.codegen.ecore.genmodel.GenDataType
import org.eclipse.emf.codegen.ecore.genmodel.GenEnum
-import org.eclipse.papyrus.gmf.codegen.gmfgen.GenFeatureValueSpec
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenFeatureSeqInitializer
-import java.util.Collection
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenFeatureValueSpec
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenReferenceNewElementSpec
-import java.util.List
+import xpt.Common
-/**
- * FIXME: [MG] commented getSuffixes below
- */
-@com.google.inject.Singleton class ElementInitializers_qvto { //
+@Singleton class ElementInitializers_qvto { //
+ @Inject extension Common
+
def List<Integer> newListAppending(List<Integer> list, int toAppend) {
var result = <Integer>newLinkedList()
result.addAll(list)
@@ -74,7 +81,7 @@ import java.util.List
if (valueSpec.featureSeqInitializer.creatingInitializer != null) {
middlePart = valueSpec.featureSeqInitializer.creatingInitializer.feature.ecoreFeature.name + '_'
}
- return valueSpec.feature.ecoreFeature.name + '_' + middlePart + de.uniqueIdentifier
+ return valueSpec.feature.ecoreFeature.name + '_' + middlePart + de.stringUniqueIdentifier
}
def Iterable<GenFeatureValueSpec> recurseCollectValueSpec(GenFeatureSeqInitializer si) {
@@ -149,5 +156,4 @@ import java.util.List
def String combinedSuffix(Iterable<Integer> suffixes) {
return '_' + suffixes.join('_')
}
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementTypes.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementTypes.xtend
index c5a4c29ca06..44fdb721f16 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementTypes.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ElementTypes.xtend
@@ -1,17 +1,20 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2006, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Christian W. Damus - bug 451230
+ * Benoit Maggi (CEA LIST) -#510281 change dependency to replace gmft-runtime
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
@@ -41,7 +44,7 @@ import xpt.editor.VisualIDRegistry
@Inject MetaModel xptMetaModel;
@Inject VisualIDRegistry xptVisualIDRegistry;
- @MetaDef def accessElementType(GenCommonBase it) '''«it.diagram.elementTypesQualifiedClassName».«it.uniqueIdentifier»'''
+ @MetaDef def accessElementType(GenCommonBase it) '''«it.diagram.elementTypesQualifiedClassName».«stringUniqueIdentifier»'''
def className(GenDiagram it) '''«it.elementTypesClassName»'''
@@ -99,7 +102,7 @@ import xpt.editor.VisualIDRegistry
private static java.util.Map<org.eclipse.gmf.runtime.emf.type.core.IElementType, org.eclipse.emf.ecore.ENamedElement> elements;
«generatedMemberComment»
- private static org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypeImages elementTypeImages = new org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypeImages(« //
+ private static org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.providers.DiagramElementTypeImages elementTypeImages = new org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.providers.DiagramElementTypeImages(« //
xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().getItemProvidersAdapterFactory());
«generatedMemberComment»
@@ -145,19 +148,19 @@ import xpt.editor.VisualIDRegistry
def getElement(GenDiagram it) '''
«generatedMemberComment('Returns \'type\' of the ecore object associated with the hint.\n')»
- public static org.eclipse.emf.ecore.ENamedElement getElement(org.eclipse.core.runtime.IAdaptable hint) {
+ public static synchronized org.eclipse.emf.ecore.ENamedElement getElement(org.eclipse.core.runtime.IAdaptable hint) {
Object type = hint.getAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
if (elements == null) {
elements = new java.util.IdentityHashMap<org.eclipse.gmf.runtime.emf.type.core.IElementType, org.eclipse.emf.ecore.ENamedElement>();
- «IF domainDiagramElement != null»«bindUniqueIdentifierToNamedElement(domainDiagramElement, getUniqueIdentifier())»«ENDIF»
+ «IF domainDiagramElement != null»«bindUniqueIdentifierToNamedElement(domainDiagramElement, stringUniqueIdentifier())»«ENDIF»
«FOR node : getAllNodes()»
- «IF node.modelFacet != null»«bindUniqueIdentifierToNamedElement(node.modelFacet, node.getUniqueIdentifier())»«ENDIF»
+ «IF node.modelFacet != null»«bindUniqueIdentifierToNamedElement(node.modelFacet, node.stringUniqueIdentifier())»«ENDIF»
«ENDFOR»
«FOR link : it.links»
- «IF link.modelFacet != null»«bindUniqueIdentifierToNamedElement(link.modelFacet, link.getUniqueIdentifier())»«ENDIF»
+ «IF link.modelFacet != null»«bindUniqueIdentifierToNamedElement(link.modelFacet, link.stringUniqueIdentifier())»«ENDIF»
«ENDFOR»
}
- return (org.eclipse.emf.ecore.ENamedElement) elements.get(type);
+ return elements.get(type);
}
'''
@@ -183,44 +186,55 @@ import xpt.editor.VisualIDRegistry
def elementTypeField(GenCommonBase it) '''
«IF null != elementType»
«generatedMemberComment»
- public static final org.eclipse.gmf.runtime.emf.type.core.IElementType «getUniqueIdentifier()» = getElementType("«elementType.
+ public static final org.eclipse.gmf.runtime.emf.type.core.IElementType «stringUniqueIdentifier» = getElementTypeByUniqueId("«elementType.
uniqueIdentifier»"); «nonNLS(1)»
«ENDIF»
'''
- def getElementType(GenDiagram it) '''
+ def getElementType(GenDiagram it)'''
«generatedMemberComment»
- private static org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(String id) {
+ private static org.eclipse.gmf.runtime.emf.type.core.IElementType getElementTypeByUniqueId(String id) {
return org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry.getInstance().getType(id);
}
'''
-
- def isKnownElementType(GenDiagram it) '''
+ def isKnownElementType(GenDiagram it) '''
«generatedMemberComment»
- public static boolean isKnownElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType elementType) {
+ public static synchronized boolean isKnownElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType elementType) {
if (KNOWN_ELEMENT_TYPES == null) {
KNOWN_ELEMENT_TYPES = new java.util.HashSet<org.eclipse.gmf.runtime.emf.type.core.IElementType>();
«FOR e : it.getAllTypedElements()»
«addKnownElementType(e)»
«ENDFOR»
}
- return KNOWN_ELEMENT_TYPES.contains(elementType);
+
+ boolean result = KNOWN_ELEMENT_TYPES.contains(elementType);
+
+ if (!result) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType[] supertypes = elementType.getAllSuperTypes();
+ for (int i = 0; !result && (i < supertypes.length); i++) {
+ result = KNOWN_ELEMENT_TYPES.contains(supertypes[i]);
+ }
+ }
+
+ return result;
}
'''
def addKnownElementType(GenCommonBase it) '''
«IF null != elementType»
- KNOWN_ELEMENT_TYPES.add(«getUniqueIdentifier()»);
+ KNOWN_ELEMENT_TYPES.add(«stringUniqueIdentifier()»);
«ENDIF»
'''
def getElementTypeByVisualID(GenDiagram it) '''
«generatedMemberComment»
- public static org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(int visualID) {
- switch (visualID) {
- «FOR e : it.getAllTypedElements().filter[el|el.elementType != null]»
- «caseElementType(e)»
- «ENDFOR»
+ public static org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ «FOR e : it.getAllTypedElements().filter[el|el.elementType != null]»
+ «caseElementType(e)»
+ «ENDFOR»
+ }
}
return null;
}
@@ -228,7 +242,7 @@ import xpt.editor.VisualIDRegistry
def caseElementType(GenCommonBase it) '''
«xptVisualIDRegistry.caseVisualID(it)»
- return «getUniqueIdentifier()»;
+ return «stringUniqueIdentifier()»;
'''
@MetaDef def typedInstanceName(GenDiagram it) '''TYPED_INSTANCE'''
@@ -237,8 +251,8 @@ import xpt.editor.VisualIDRegistry
def typedInstance(GenDiagram it) '''
«generatedClassComment»
- public static final org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypes TYPED_INSTANCE
- = new org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypes(elementTypeImages) {
+ public static final org.eclipse.papyrus.infra.gmfdiag.common.providers.DiagramElementTypes TYPED_INSTANCE
+ = new org.eclipse.papyrus.infra.gmfdiag.common.providers.DiagramElementTypes(elementTypeImages) {
«generatedMemberComment»
«xptCodeStyle.overrideC(it)»
@@ -248,7 +262,7 @@ import xpt.editor.VisualIDRegistry
«generatedMemberComment»
«xptCodeStyle.overrideC(it)»
- public org.eclipse.gmf.runtime.emf.type.core.IElementType getElementTypeForVisualId(int visualID) {
+ public org.eclipse.gmf.runtime.emf.type.core.IElementType getElementTypeForVisualId(String visualID) {
return «qualifiedClassName(it)».getElementType(visualID);
}
@@ -260,6 +274,19 @@ import xpt.editor.VisualIDRegistry
};
'''
- def additions(GenDiagram it) ''''''
+ def additions(GenDiagram it) '''
+ «generatedMemberComment»
+ public static boolean isKindOf(org.eclipse.gmf.runtime.emf.type.core.IElementType subtype, org.eclipse.gmf.runtime.emf.type.core.IElementType supertype) {
+ boolean result = subtype == supertype;
+
+ if (!result) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType[] supertypes = subtype.getAllSuperTypes();
+ for (int i = 0; !result && (i < supertypes.length); i++) {
+ result = supertype == supertypes[i];
+ }
+ }
-}
+ return result;
+ }
+ '''
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/IconProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/IconProvider.xtend
index 74dbd7f90ea..47c714f685b 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/IconProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/IconProvider.xtend
@@ -1,25 +1,31 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - [407332] common API for XXXElementTypes extracted to GMFT-runtime
- * - [386838] migration to Xtend2
- */
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - refactored javaInitilizers not to use methods from GMFGen model
+ * [221347] Got rid of generated interfaces
+ * (IObjectInitializer, IFeatureInitializer) and implementation thereof
+ * Michael Golubev (Montages) - [407332] common API for XXXElementTypes extracted to GMFT-runtime
+ * - [386838] migration to Xtend2
+ * Christian W. Damus (CEA) - bug 440263
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import xpt.Common
-@com.google.inject.Singleton class IconProvider {
+@Singleton class IconProvider {
@Inject extension Common;
@Inject ElementTypes xptElementTypes;
@@ -45,7 +51,7 @@ import xpt.Common
}
'''
- def extendsList(GenDiagram it) '''extends org.eclipse.gmf.tooling.runtime.providers.DefaultElementTypeIconProvider'''
+ def extendsList(GenDiagram it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.providers.DefaultElementTypeIconProvider'''
def implementsList(GenDiagram it) '''implements org.eclipse.gmf.runtime.common.ui.services.icon.IIconProvider'''
@@ -57,4 +63,5 @@ import xpt.Common
'''
def additions(GenDiagram it) ''''''
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/MarkerNavigationProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/MarkerNavigationProvider.xtend
index 0693636e2a6..795f4bdb200 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/MarkerNavigationProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/MarkerNavigationProvider.xtend
@@ -1,27 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
import xpt.Common
-@com.google.inject.Singleton class MarkerNavigationProvider {
+@Singleton class MarkerNavigationProvider {
@Inject extension Common;
-
- def className(GenDiagram it) '''«it.markerNavigationProviderClassName»'''
+def className(GenDiagram it) '''«it.markerNavigationProviderClassName»'''
def packageName(GenDiagram it) '''«it.providersPackageName»'''
@@ -29,7 +30,7 @@ import xpt.Common
def fullPath(GenDiagram it) '''«qualifiedClassName(it)»'''
- def MarkerNavigationProvider(GenDiagram it) '''
+ def MarkerNavigationProvider(GenDiagram it) '''
«copyright(editorGen)»
package «packageName(it)»;
@@ -49,7 +50,7 @@ import xpt.Common
}
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor editor =
(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor) getEditor();
- java.util.Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
+ java.util.Map<?, ?> editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
org.eclipse.emf.ecore.EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
if (targetView == null) {
return;
@@ -79,7 +80,7 @@ import xpt.Common
marker = file.createMarker(MARKER_TYPE);
marker.setAttribute(org.eclipse.core.resources.IMarker.MESSAGE, message);
marker.setAttribute(org.eclipse.core.resources.IMarker.LOCATION, location);
- marker.setAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, elementId);
+ marker.setAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, elementId);
int markerSeverity = org.eclipse.core.resources.IMarker.SEVERITY_INFO;
if (statusSeverity == org.eclipse.core.runtime.IStatus.WARNING) {
markerSeverity = org.eclipse.core.resources.IMarker.SEVERITY_WARNING;
@@ -99,5 +100,4 @@ import xpt.Common
'''
def additions(GenDiagram it) ''''''
-
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ParserUtils_qvto.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ParserUtils_qvto.xtend
index d098b8d966c..4fd4fd057d3 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ParserUtils_qvto.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ParserUtils_qvto.xtend
@@ -1,30 +1,39 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2014, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Artem Tikhomirov (Borland) - refactored javaInitilizers not to use methods from GMFGen model
+ * [221347] Got rid of generated interfaces
+ * (IObjectInitializer, IFeatureInitializer) and implementation thereof
+ * Christian W. Damus (CEA) - bug 440263
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
+import xpt.Common
+import com.google.inject.Inject
+import com.google.inject.Singleton
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.xtend.annotations.MetaDef
-@com.google.inject.Singleton class ParserUtils_qvto {
+@Singleton class ParserUtils_qvto {
+ @Inject extension Common
- @MetaDef def String parserFieldName(GenCommonBase element) {
- return element.uniqueIdentifier.toFirstLower + 'Parser'
+ @MetaDef def String parserFieldName(GenCommonBase element) {
+ return element.stringUniqueIdentifier.toFirstLower + '_Parser'
}
- @MetaDef def String parserAccessorName(GenCommonBase element) {
- return 'get' + element.uniqueIdentifier.toFirstUpper + 'Parser'
+ @MetaDef def String parserAccessorName(GenCommonBase element) {
+ return 'get' + element.stringUniqueIdentifier.toFirstUpper + '_Parser'
}
-
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationDecoratorProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationDecoratorProvider.xtend
index c8892885ad3..1a54114f63a 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationDecoratorProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationDecoratorProvider.xtend
@@ -1,17 +1,19 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2009, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Ansgar Radermacher (CEA LIST) - added support for EMF validation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
@@ -47,25 +49,10 @@ package «packageName(it)»;
«generatedClassComment»
public class «className(it)»
- extends org.eclipse.gmf.runtime.common.core.service.AbstractProvider
+ extends org.eclipse.papyrus.uml.diagram.common.providers.ValidationDecoratorProvider
implements org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider {
«generatedMemberComment»
- private static final String KEY = "validationStatus"; «nonNLS(1)»
- «IF editorGen.application == null»
-
- «generatedMemberComment»
- private static final String MARKER_TYPE = «xptActivator.qualifiedClassName(editorGen.plugin)».ID +
- ".«getValidationDiagnosticMarkerType()»"; «nonNLS(1)»
-
- «generatedMemberComment»
- private static MarkerObserver fileObserver;
- «ENDIF»
-
- «generatedMemberComment»
- private static java.util.Map/*<String, List<IDecorator>>*/ allDecorators = new java.util.HashMap();
-
- «generatedMemberComment»
public void createDecorators(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget decoratorTarget) {
org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) decoratorTarget.getAdapter(org.eclipse.gef.EditPart.class);
if (editPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart ||
@@ -100,319 +87,7 @@ public class «className(it)»
return view != null && «VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(view));
}
- «generatedMemberComment»
- public static void refreshDecorators(org.eclipse.gmf.runtime.notation.View view) {
- refreshDecorators(org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.getIdStr(view), view.getDiagram());
- }
-
- «generatedMemberComment»
- private static void refreshDecorators(String viewId, org.eclipse.gmf.runtime.notation.Diagram diagram) {
- final java.util.List decorators = viewId != null ? (java.util.List) allDecorators.get(viewId) : null;
- if (decorators == null || decorators.isEmpty() || diagram == null) {
- return;
- }
- final org.eclipse.gmf.runtime.notation.Diagram fdiagram = diagram;
- org.eclipse.ui.PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
-
- public void run() {
- try {
- org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(fdiagram).runExclusive(new Runnable() {
-
- public void run() {
- for (java.util.Iterator it = decorators.iterator(); it.hasNext();) {
- org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator decorator =
- (org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator) it.next();
- decorator.refresh();
- }
- }
- });
- } catch (Exception e) {
- «xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().logError(
- "Decorator refresh failure", e); «nonNLS(1)»
- }
- }
- });
- }
-
- «generatedMemberComment»
- public static class StatusDecorator extends org.eclipse.gmf.runtime.diagram.ui.services.decorator.AbstractDecorator {
-
- «generatedMemberComment»
- private String viewId;
-
- «generatedMemberComment»
- public StatusDecorator(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget decoratorTarget) {
- super(decoratorTarget);
- try {
- final org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getDecoratorTarget().getAdapter(
- org.eclipse.gmf.runtime.notation.View.class);
- org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(view).runExclusive(new Runnable() {
- public void run() {
- StatusDecorator.this.viewId = view != null ?
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.getIdStr(view) : null;
- }
- });
- } catch (Exception e) {
- «xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().logError(
- "ViewID access failure", e); «nonNLS(1)»
- }
- }
-
- «generatedMemberComment»
- public void refresh() {
- removeDecoration();
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getDecoratorTarget().getAdapter(
- org.eclipse.gmf.runtime.notation.View.class);
- if (view == null || view.eResource() == null) {
- return;
- }
- org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) getDecoratorTarget().getAdapter(org.eclipse.gef.EditPart.class);
- if (editPart == null || editPart.getViewer() == null) {
- return;
- }
-
- // query for all the validation markers of the current resource
- «IF editorGen.application == null»
- String elementId = org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.getIdStr(view);
- if (elementId == null) {
- return;
- }
- int severity = org.eclipse.core.resources.IMarker.SEVERITY_INFO;
- org.eclipse.core.resources.IMarker foundMarker = null;
- org.eclipse.core.resources.IResource resource = org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(view.eResource());
- if (resource == null || !resource.exists()) {
- return;
- }
- org.eclipse.core.resources.IMarker[] markers = null;
- try {
- markers = resource.findMarkers(MARKER_TYPE, true, org.eclipse.core.resources.IResource.DEPTH_INFINITE);
- } catch (org.eclipse.core.runtime.CoreException e) {
- «xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().logError(
- "Validation markers refresh failure", e); «nonNLS(1)»
- }
- «ELSE»
- int severity = org.eclipse.core.runtime.IStatus.INFO;
- «xptValidationMarker.qualifiedClassName(it)» foundMarker = null;
- «xptValidationMarker.qualifiedClassName(it)»[] markers =
- «xptValidationMarker.qualifiedClassName(it)».getMarkers(editPart.getViewer(), viewId);
- «ENDIF»
- if (markers == null || markers.length == 0) {
- return;
- }
- org.eclipse.draw2d.Label toolTip = null;
- for (int i = 0; i < markers.length; i++) {
- «IF editorGen.application == null»
- org.eclipse.core.resources.IMarker marker = markers[i];
- String attribute = marker.getAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, ""); «nonNLS(1)»
- if (attribute.equals(elementId)) {
- int nextSeverity = marker.getAttribute(org.eclipse.core.resources.IMarker.SEVERITY,
- org.eclipse.core.resources.IMarker.SEVERITY_INFO);
- «ELSE»
- «xptValidationMarker.qualifiedClassName(it)» marker = markers[i];
- int nextSeverity = marker.getStatusSeverity();
- «ENDIF»
- org.eclipse.swt.graphics.Image nextImage = getImage(nextSeverity);
- if (foundMarker == null) {
- foundMarker = marker;
- toolTip = new org.eclipse.draw2d.Label(
- «IF editorGen.application == null»
- marker.getAttribute(org.eclipse.core.resources.IMarker.MESSAGE, ""), «nonNLS(1)»
- «ELSE»
- marker.getMessage(),
- «ENDIF»
- nextImage);
- } else {
- if (toolTip.getChildren().isEmpty()) {
- org.eclipse.draw2d.Label comositeLabel = new org.eclipse.draw2d.Label();
- org.eclipse.draw2d.FlowLayout fl = new org.eclipse.draw2d.FlowLayout(false);
- fl.setMinorSpacing(0);
- comositeLabel.setLayoutManager(fl);
- comositeLabel.add(toolTip);
- toolTip = comositeLabel;
- }
- toolTip.add(new org.eclipse.draw2d.Label(
- «IF editorGen.application == null»
- marker.getAttribute(org.eclipse.core.resources.IMarker.MESSAGE, ""), «nonNLS(1)»
- «ELSE»
- marker.getMessage(),
- «ENDIF»
- nextImage));
- }
- severity = (nextSeverity > severity) ? nextSeverity : severity;
- «IF editorGen.application == null»
- }
- «ENDIF»
- }
- if (foundMarker == null) {
- return;
- }
-
- // add decoration
- if (editPart instanceof org.eclipse.gef.GraphicalEditPart) {
- if (view instanceof org.eclipse.gmf.runtime.notation.Edge) {
- setDecoration(getDecoratorTarget().addConnectionDecoration(getImage(severity), 50, true));
- } else {
- int margin = -1;
- if (editPart instanceof org.eclipse.gef.GraphicalEditPart) {
- margin = org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil.getMapMode(
- ((org.eclipse.gef.GraphicalEditPart) editPart).getFigure()).DPtoLP(margin);
- }
- setDecoration(getDecoratorTarget().addShapeDecoration(getImage(severity),
- org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget.Direction.NORTH_EAST, margin, true));
- }
- getDecoration().setToolTip(toolTip);
- }
- }
-
- «generatedMemberComment»
- private org.eclipse.swt.graphics.Image getImage(int severity) {
- String imageName = org.eclipse.ui.ISharedImages.IMG_OBJS_ERROR_TSK;
- switch (severity) {
- «IF editorGen.application == null»
- case org.eclipse.core.resources.IMarker.SEVERITY_ERROR:
- imageName = org.eclipse.ui.ISharedImages.IMG_OBJS_ERROR_TSK;
- break;
- case org.eclipse.core.resources.IMarker.SEVERITY_WARNING:
- imageName = org.eclipse.ui.ISharedImages.IMG_OBJS_WARN_TSK;
- break;
- «ELSE»
- case org.eclipse.core.runtime.IStatus.ERROR:
- imageName = org.eclipse.ui.ISharedImages.IMG_OBJS_ERROR_TSK;
- break;
- case org.eclipse.core.runtime.IStatus.WARNING:
- imageName = org.eclipse.ui.ISharedImages.IMG_OBJS_WARN_TSK;
- break;
- «ENDIF»
- default:
- imageName = org.eclipse.ui.ISharedImages.IMG_OBJS_INFO_TSK;
- }
- return org.eclipse.ui.PlatformUI.getWorkbench().getSharedImages().getImage(imageName);
- }
-
- «generatedMemberComment»
- public void activate() {
- if (viewId == null) {
- return;
- }
-
- // add self to global decorators registry
- java.util.List list = (java.util.List) allDecorators.get(viewId);
- if (list == null) {
- list = new java.util.ArrayList(2);
- list.add(this);
- allDecorators.put(viewId, list);
- } else if (!list.contains(this)) {
- list.add(this);
- }
- «IF editorGen.application == null»
-
- // start listening to changes in resources
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getDecoratorTarget().getAdapter(
- org.eclipse.gmf.runtime.notation.View.class);
- if (view == null) {
- return;
- }
- org.eclipse.gmf.runtime.notation.Diagram diagramView = view.getDiagram();
- if (diagramView == null) {
- return;
- }
- if (fileObserver == null) {
- org.eclipse.gmf.runtime.common.ui.resources.FileChangeManager.getInstance().addFileObserver(
- fileObserver = new MarkerObserver(diagramView));
- }
- «ENDIF»
- }
-
- «generatedMemberComment»
- public void deactivate() {
- if (viewId == null) {
- return;
- }
-
- // remove self from global decorators registry
- java.util.List list = (java.util.List) allDecorators.get(viewId);
- if (list != null) {
- list.remove(this);
- if (list.isEmpty()) {
- allDecorators.remove(viewId);
- }
- }
- «IF editorGen.application == null»
-
- // stop listening to changes in resources if there are no more decorators
- if (fileObserver != null && allDecorators.isEmpty()) {
- org.eclipse.gmf.runtime.common.ui.resources.FileChangeManager.getInstance().removeFileObserver(fileObserver);
- fileObserver = null;
- }
- «ENDIF»
- super.deactivate();
- }
- }
- «IF editorGen.application == null»
-
- «generatedMemberComment»
- static class MarkerObserver implements org.eclipse.gmf.runtime.common.ui.resources.IFileObserver {
-
- «generatedMemberComment»
- private org.eclipse.gmf.runtime.notation.Diagram diagram;
-
- «generatedMemberComment»
- private MarkerObserver(org.eclipse.gmf.runtime.notation.Diagram diagram) {
- this.diagram = diagram;
- }
-
- «generatedMemberComment»
- public void handleFileRenamed(org.eclipse.core.resources.IFile oldFile, org.eclipse.core.resources.IFile file) {
- }
-
- «generatedMemberComment»
- public void handleFileMoved(org.eclipse.core.resources.IFile oldFile, org.eclipse.core.resources.IFile file) {
- }
-
- «generatedMemberComment»
- public void handleFileDeleted(org.eclipse.core.resources.IFile file) {
- }
-
- «generatedMemberComment»
- public void handleFileChanged(org.eclipse.core.resources.IFile file) {
- }
-
- «generatedMemberComment»
- public void handleMarkerAdded(org.eclipse.core.resources.IMarker marker) {
- if (marker.getAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, null) != null) {
- handleMarkerChanged(marker);
- }
- }
-
- «generatedMemberComment»
- public void handleMarkerDeleted(org.eclipse.core.resources.IMarker marker, java.util.Map attributes) {
- String viewId = (String) attributes.get(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID);
- refreshDecorators(viewId, diagram);
- }
-
- «generatedMemberComment»
- public void handleMarkerChanged(org.eclipse.core.resources.IMarker marker) {
- if (!MARKER_TYPE.equals(getType(marker))) {
- return;
- }
- String viewId = marker.getAttribute(
- org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, ""); «nonNLS(1)»
- refreshDecorators(viewId, diagram);
- }
-
- «generatedMemberComment»
- private String getType(org.eclipse.core.resources.IMarker marker) {
- try {
- return marker.getType();
- } catch (org.eclipse.core.runtime.CoreException e) {
- «xptActivator.qualifiedClassName(editorGen.plugin)».getInstance().logError(
- "Validation marker refresh failure", e); «nonNLS(1)»
- return ""; «nonNLS(1)»
- }
- }
- }
- «ENDIF»
«additions(it)»
}
'''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationProvider.xtend
index efcf5484774..9cf01ae5974 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ValidationProvider.xtend
@@ -1,22 +1,24 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) - introduced GenAuditContext entity
- * straightforward and simple #validate() implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - introduced GenAuditContext entity
+ * straightforward and simple #validate() implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
+import com.google.inject.Singleton
import metamodel.MetaModel
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenAuditRoot
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenAuditRule
@@ -29,14 +31,15 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExpressionInterpreter
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExpressionProviderBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenExpressionProviderContainer
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenJavaExpressionProvider
+import plugin.Activator
+import xpt.CodeStyle
import xpt.Common
import xpt.Common_qvto
import xpt.GenAuditRoot_qvto
import xpt.editor.VisualIDRegistry
import xpt.expressions.getExpression
-import plugin.Activator
-@com.google.inject.Singleton class ValidationProvider {
+@Singleton class ValidationProvider {
@Inject extension Common;
@Inject extension Common_qvto;
@Inject extension GenAuditRoot_qvto;
@@ -46,6 +49,8 @@ import plugin.Activator
@Inject getExpression xptGetExpression;
@Inject MetricProvider xptMetricProvider;
@Inject VisualIDRegistry xptVisualIDRegistry;
+ @Inject extension CodeStyle
+
def className(GenDiagram it) '''«it.validationProviderClassName»'''
@@ -97,6 +102,7 @@ import plugin.Activator
public static void runWithConstraints(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, Runnable operation) {
final Runnable op = operation;
Runnable task = new Runnable() {
+ «overrideI»
public void run() {
try {
constraintsActive = true;
@@ -121,6 +127,8 @@ import plugin.Activator
def additions(GenDiagram it) ''''''
def selectors(GenAuditRoot it) '''
+ «IF it !=null»
+ «IF it.clientContexts !=null»
«FOR ctx : it.clientContexts»
«generatedMemberComment»
public static class «ctx.className» implements org.eclipse.emf.validation.model.IClientSelector {
@@ -129,10 +137,10 @@ import plugin.Activator
public boolean selects(Object object) {
«IF ctx.ruleTargets.filter(typeof(GenDiagramElementTarget)).notEmpty»
if (isInDefaultEditorContext(object) && object instanceof org.eclipse.gmf.runtime.notation.View) {
- final int id = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»((org.eclipse.gmf.runtime.notation.View) object);
+ final String id = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»((org.eclipse.gmf.runtime.notation.View) object);
boolean result = false;
«FOR e : getTargetDiagramElements(ctx)»
- result = result || id == «VisualIDRegistry::visualID(e)»;
+ result = result || «VisualIDRegistry::visualID(e)».equals(id);
«ENDFOR»
return result;
}
@@ -143,6 +151,8 @@ import plugin.Activator
}
}
«ENDFOR»
+ «ENDIF»
+ «ENDIF»
'''
def isInDefaultEditorContext(GenDiagram it) '''
@@ -174,7 +184,7 @@ import plugin.Activator
private org.eclipse.emf.validation.service.ITraversalStrategy defaultStrategy;
«generatedMemberComment»
- private int currentSemanticCtxId = -1;
+ private String currentSemanticCtxId;
«generatedMemberComment»
private boolean ctxChanged = true;
@@ -186,12 +196,12 @@ import plugin.Activator
private org.eclipse.emf.ecore.EObject preFetchedNextTarget;
«generatedMemberComment»
- private final int[] contextSwitchingIdentifiers;
+ private final String[] contextSwitchingIdentifiers;
«generatedMemberComment»
CtxSwitchStrategy(org.eclipse.emf.validation.service.IBatchValidator validator) {
this.defaultStrategy = validator.getDefaultTraversalStrategy();
- this.contextSwitchingIdentifiers = new int[] {
+ this.contextSwitchingIdentifiers = new String[] {
«FOR e : getAllTargetDiagramElements(editorGen.audits) SEPARATOR ','»«VisualIDRegistry::visualID(e)»«ENDFOR»
};
java.util.Arrays.sort(this.contextSwitchingIdentifiers);
@@ -236,17 +246,17 @@ import plugin.Activator
private void prepareNextClientContext(org.eclipse.emf.ecore.EObject nextTarget) {
if (nextTarget != null && currentTarget != null) {
if (nextTarget instanceof org.eclipse.gmf.runtime.notation.View) {
- final int id = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»((org.eclipse.gmf.runtime.notation.View) nextTarget);
- int nextSemanticId = (id != -1 && java.util.Arrays.binarySearch(contextSwitchingIdentifiers, id) >= 0) ? id : -1;
- if ((currentSemanticCtxId != -1 && currentSemanticCtxId != nextSemanticId)
- || (nextSemanticId != -1 && nextSemanticId != currentSemanticCtxId)) {
+ final String id = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»((org.eclipse.gmf.runtime.notation.View) nextTarget);
+ String nextSemanticId = (id != null && java.util.Arrays.binarySearch(contextSwitchingIdentifiers, id) >= 0) ? id : null;
+ if ((currentSemanticCtxId != null && currentSemanticCtxId != nextSemanticId)
+ || (nextSemanticId != null && nextSemanticId != currentSemanticCtxId)) {
this.ctxChanged = true;
}«/*[artem] not sure why not ctxChanged = <expr>, is it intentional not to reset ctxChanged if condition did not match? I doubt. FIXME?*/»
currentSemanticCtxId = nextSemanticId;
} else {
// context of domain model
- this.ctxChanged = currentSemanticCtxId != -1;
- currentSemanticCtxId = -1;
+ this.ctxChanged = currentSemanticCtxId != null;
+ currentSemanticCtxId = null;
}
} else {
this.ctxChanged = false;
@@ -257,6 +267,7 @@ import plugin.Activator
'''
def constraintAdapters(GenAuditRoot it, GenDiagram diagram) '''
+ «IF it !=null»
«IF diagram.editorGen.expressionProviders != null»
«FOR next : it.rules.filter[a | a.requiresConstraintAdapter]»
«constraintAdapter(next, diagram.editorGen.expressionProviders)»
@@ -266,6 +277,7 @@ import plugin.Activator
«constraintAdapters_formatMethod(it)»
«ENDIF»
«ENDIF»
+ «ENDIF»
'''
def constraintAdapter(GenAuditRule it, GenExpressionProviderContainer container) '''
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ViewProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ViewProvider.xtend
index 61008af7af8..310ae5bd46b 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ViewProvider.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/ViewProvider.xtend
@@ -1,24 +1,35 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+/*****************************************************************************
+ * Copyright (c) 2007, 2010, 2013, 2017, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) Add a line to initialize the display of the compartments to true
+ * Vincent Lorenzo (CEA-LIST) - Add lines to initialize the display of the labels - Bug 335987 [General][Enhancement] Show/Hide Connectors Labels and External Nodes Labels
+ * Vincent Lorenzo (CEA-LIST) - Bug 520733
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.runtime.notation.FillStyle
+import org.eclipse.gmf.runtime.notation.FontStyle
+import org.eclipse.gmf.runtime.notation.LineStyle
+import org.eclipse.gmf.runtime.notation.Style
import org.eclipse.papyrus.gmf.codegen.gmfgen.ColorAttributes
import org.eclipse.papyrus.gmf.codegen.gmfgen.ElementType
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildLabelNode
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenChildNode
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCompartment
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
@@ -38,21 +49,16 @@ import xpt.diagram.ViewmapAttributesUtils_qvto
import xpt.diagram.editpolicies.LinkUtils_qvto
import xpt.diagram.views.ViewStyles
import xpt.editor.VisualIDRegistry
-import org.eclipse.gmf.runtime.notation.FontStyle
-import org.eclipse.gmf.runtime.notation.LineStyle
-import org.eclipse.gmf.runtime.notation.FillStyle
-import org.eclipse.gmf.runtime.notation.Style
-@com.google.inject.Singleton class ViewProvider {
+@Singleton class ViewProvider {
@Inject extension Common;
@Inject extension Common_qvto;
@Inject extension Utils_qvto;
@Inject extension LinkUtils_qvto;
@Inject extension ViewmapAttributesUtils_qvto;
+ @Inject extension VisualIDRegistry xptVisualIDRegistry;
- @Inject ElementTypes xptElementTypes
- @Inject VisualIDRegistry xptVisualIDRegistry;
@Inject ViewStyles xptViewStyles;
def className(GenDiagram it) '''«it.notationViewProviderClassName»'''
@@ -68,293 +74,346 @@ import org.eclipse.gmf.runtime.notation.Style
def ViewProvider(GenDiagram it) '''
- «copyright(editorGen)»
- package «packageName(it)»;
-
- «generatedClassComment»
- public class «className(it)» «extendsList(it)»«implementsList(it)» {
-
- «generatedMemberComment»
- public final boolean provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation) {
- if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation) {
- return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation) operation);
+ «copyright(editorGen)»
+ package «packageName(it)»;
+
+ «generatedClassComment»
+ public class «className(it)» «extendsList(it)»«implementsList(it)» {
+
+ «generatedMemberComment»
+ public final boolean provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation) {
+ if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation) operation);
+ }
+ «_assert('operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation')»
+
+ /* we check this view provider is the good one for the currently edited diagram */
+ if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateChildViewOperation) {
+ View container = ((org.eclipse.gmf.runtime.diagram.core.services.view.CreateChildViewOperation) operation).getContainerView();
+ Diagram diagram = container.getDiagram();
+ if(!getDiagramProvidedId().equals(diagram.getType())) {
+ return false;
+ }
+ }
+
+ if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation) operation);
+ } else if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation) operation);
+ } else if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation) {
+ return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation) operation);
+ }
+ return false;
}
- «_assert('operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation')»
- if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation) {
- return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation) operation);
- } else if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation) {
- return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation) operation);
- } else if (operation instanceof org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation) {
- return provides((org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation) operation);
+
+ «generatedMemberComment»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation op) {
+ /*
+ if (op.getViewKind() == Node.class)
+ return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ if (op.getViewKind() == Edge.class)
+ return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ */
+
+ // check Diagram Type should be the class diagram
+ String modelID = «getModelIDMethodCall(it)»(op.getContainerView());
+ if(!getDiagramProvidedId().equals(modelID)) {
+ return false;
+ }
+
+ String visualID = «getVisualIDMethodCall(it)»(op.getSemanticHint());
+ if(org.eclipse.gmf.runtime.notation.Node.class.isAssignableFrom(op.getViewKind())) {
+ return «canCreateNodeMethodCall(it)»(op.getContainerView(), visualID);
+ }
+
+ return true;
}
- return false;
- }
-
- «generatedMemberComment»
- protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation op) {
- /*
- if (op.getViewKind() == Node.class)
- return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
- if (op.getViewKind() == Edge.class)
- return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
- */
- return true;
- }
-
- «generatedMemberComment»«/* When diagram domain element is null only diagram kind is checked */»
- protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation op) {
- return «VisualIDRegistry::modelID(it)».equals(op.getSemanticHint())«IF domainDiagramElement != null» && «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(getSemanticElement(op.getSemanticAdapter())) != -1«ENDIF»;
- }
-
+
«generatedMemberComment»
- protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation op) {
- if (op.getContainerView() == null) {
- return false;
+ protected String getDiagramProvidedId() {
+ /*
+ * Indicates for which diagram this provider works for.
+ * <p>
+ * This method can be overloaded when diagram editor inherits from another one, but should never be <code>null</code>
+ * </p>
+ *
+ * @return the unique identifier of the diagram for which views are provided.
+ */
+ return «VisualIDRegistry::modelID(it)»;
+ }
+
+ «generatedMemberComment»«/* When diagram domain element is null only diagram kind is checked */»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation op) {
+ return «VisualIDRegistry::modelID(it)».equals(op.getSemanticHint())«IF domainDiagramElement != null» && «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(getSemanticElement(op.getSemanticAdapter())) != null && !«xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(getSemanticElement(op.getSemanticAdapter())).isEmpty()«ENDIF»;
}
- org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
- org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
- int visualID;
- if (op.getSemanticHint() == null) {
- // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
- // In this situation there should be NO elementType, visualID will be determined
- // by VisualIDRegistry.getNodeVisualID() for domainElement.
- if (elementType != null || domainElement == null) {«/* XXX Perhaps, better to fix CanonicalEP instead of this hack? */»
+
+ «generatedMemberComment»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation op) {
+ if (op.getContainerView() == null) {
return false;
}
- visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement);
- } else {
- visualID = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(op.getSemanticHint());
- if (elementType != null) {«/*
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+ org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ String visualID;
+ if (op.getSemanticHint() == null) {
+ // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
+ // In this situation there should be NO elementType, visualID will be determined
+ // by VisualIDRegistry.getNodeVisualID() for domainElement.
+ if (elementType != null || domainElement == null) {«/* XXX Perhaps, better to fix CanonicalEP instead of this hack? */»
+ return false;
+ }
+ visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement);
+ } else {
+ visualID = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(op.getSemanticHint());
+ if (elementType != null) {«/*
Semantic hint is specified together with element type.
Both parameters should describe exactly the same diagram element.
In addition we check that visualID returned by VisualIDRegistry.getNodeVisualID() for
domainElement (if specified) is the same as in element type. */»
- if (!«xptElementTypes.qualifiedClassName(it)».isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
+
+ if (!«getElementTypesQualifiedClassName()».isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
return false; // foreign element type
}
- String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
- if (!op.getSemanticHint().equals(elementTypeHint)) {
- return false; // if semantic hint is specified it should be the same as in element type
- }
- if (domainElement != null && visualID != «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement)) {
- return false; // visual id for node EClass should match visual id from element type
- }
- } else {«/*
+
+ String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
+ if (!op.getSemanticHint().equals(elementTypeHint)) {
+ return false; // if semantic hint is specified it should be the same as in element type
+ }
+ //if (domainElement != null && !visualID.equals(«getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement))) {
+ // return false; // visual id for node EClass should match visual id from element type
+ //}
+ } else {«/*
Element type is not specified. Domain element should be present (except pure design elements).
This method is called with EObjectAdapter as parameter from:
- ViewService.createNode(View container, EObject eObject, String type, PreferencesHint preferencesHint)
- generated ViewFactory.decorateView() for parent element */»
- «IF getAllTypedElements().filter[e | e.elementType != null].notEmpty»
+ «IF ! getAllTypedElements(it).filter[e|e.elementType != null].empty»
if (!«VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(op.getContainerView()))) {
return false; // foreign diagram
}
- switch (visualID) {
- «IF getAllNodes().exists[e|e.elementType.oclIsKindOf(typeof(NotationType))]»
- «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(NotationType))»
- «localCaseVisualID(e)»
- «ENDFOR»
- break; // pure design element
- «ENDIF»
- «IF getAllNodes().exists[e|e.elementType.oclIsKindOf(typeof(MetamodelType)) || e.elementType.oclIsKindOf(typeof(SpecializationType))]»
- «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(MetamodelType))»
- «localCaseVisualID(e)»
- «ENDFOR»
- «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(SpecializationType))»
- «localCaseVisualID(e)»
- «ENDFOR»
- if (domainElement == null || visualID != «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement)) {
- return false; // visual id in semantic hint should match visual id for domain element
+ if (visualID != null) {
+ switch (visualID) {
+ «IF getAllNodes().exists[e|e.elementType instanceof NotationType]»
+ «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(NotationType))»
+ «localCaseVisualID(e)»
+ «ENDFOR»
+ break; // pure design element
+ «ENDIF»
+ «IF getAllNodes().exists[e|e.elementType instanceof MetamodelType || e.elementType instanceof SpecializationType]»
+ «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(MetamodelType))»
+ «localCaseVisualID(e)»
+ «ENDFOR»
+ «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(SpecializationType))»
+ «localCaseVisualID(e)»
+ «ENDFOR»
+ if (domainElement == null || !visualID.equals(«xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement))) {
+ return false; // visual id in semantic hint should match visual id for domain element
+ }
+ break;«/*FIXME: Perhaps, can return true or false right away, without any further check?*/»
+ «ENDIF»
+ default:
+ return false;
}
- break;«/*FIXME: Perhaps, can return true or false right away, without any further check?*/»
- «ENDIF»
- default:
- return false;
}
- «ELSE»
+ «ELSE»
return false;
- «ENDIF»
+ «ENDIF»
}
+ }
+
+ return «canCreateNodeMethodCall(it)»(op.getContainerView(), visualID);
}
- return «FOR n : getAllNodes() SEPARATOR '||'»«VisualIDRegistry::visualID(n)» == visualID«ENDFOR»;
+
+ «generatedMemberComment»«/* XXX: unlike createNode, we don't check op.containerView() for null here. On purpose? */»
+ protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation op) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+
+ if (!«getElementTypesQualifiedClassName()».isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
+ return false; // foreign element type
}
-
- «generatedMemberComment»«/* XXX: unlike createNode, we don't check op.containerView() for null here. On purpose? */»
- protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation op) {
- org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
- if (!«xptElementTypes.qualifiedClassName(it)».isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) {
- return false; // foreign element type
- }
- String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
- if (elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
- return false; // our hint is visual id and must be specified, and it should be the same as in element type
- }
- int visualID = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(elementTypeHint);
- org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
- if (domainElement != null && visualID != «xptVisualIDRegistry.getLinkWithClassVisualIDMethodCall(it)»(domainElement)) {
- return false; // visual id for link EClass should match visual id from element type
- }
- return true; «/* Does it make sense to check visualID here, like we did for nodes? */»
+
+ String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
+ if (elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
+ return false; // our hint is visual id and must be specified, and it should be the same as in element type
}
-
- «generatedMemberComment»
- public org.eclipse.gmf.runtime.notation.Diagram createDiagram(org.eclipse.core.runtime.IAdaptable semanticAdapter, String diagramKind, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
- org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagram();«/* FIXME instantiate diagramRunTimeClass instead */»
- diagram.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagramStyle());
- «xptViewStyles.addCustomStyles(it, 'diagram.getStyles()')»
- diagram.setType(«VisualIDRegistry::modelID(it)»);
- diagram.setElement(«IF domainDiagramElement != null»getSemanticElement(semanticAdapter)«ELSE»null«ENDIF»);
- «IF units != null»
- diagram.setMeasurementUnit(org.eclipse.gmf.runtime.notation.MeasurementUnit.«units.toUpperCase»_LITERAL);
- «ENDIF»
- «IF styles.notEmpty»
- // initializeFromPreferences
- org.eclipse.jface.preferences.IPreferenceStore store = (org.eclipse.jface.preferences.IPreferenceStore) preferencesHint.getPreferenceStore();
- «initializeStyles(it, 'diagram', 'store', false, false, false)»
- «ENDIF»
+ //String visualID = «getVisualIDMethodCall(it)»(elementTypeHint);
+ //org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ //if (domainElement != null && !visualID.equals(«getLinkWithClassVisualIDMethodCall(it)»(domainElement))) {
+ // return false; // visual id for link EClass should match visual id from element type
+ //}
+ return true; «««Does it make sense to check visualID here, like we did for nodes?
+ }
+
+
+ «generatedMemberComment»
+ @SuppressWarnings("unchecked")
+ public org.eclipse.gmf.runtime.notation.Diagram createDiagram(org.eclipse.core.runtime.IAdaptable semanticAdapter, String diagramKind, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ org.eclipse.gmf.runtime.notation.Diagram diagram = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagram();«/* FIXME instantiate diagramRunTimeClass instead */»
+ org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils.stampCurrentVersion(diagram);«/* Papyrus specific diagram versioning */»
+ diagram.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDiagramStyle());
+ «xptViewStyles.addCustomStyles(it, 'diagram.getStyles()')»
+ diagram.setType(«VisualIDRegistry::modelID(it)»);
+ diagram.setElement(«IF domainDiagramElement != null»getSemanticElement(semanticAdapter)«ELSE»null«ENDIF»);
+ «IF units != null»
+ diagram.setMeasurementUnit(org.eclipse.gmf.runtime.notation.MeasurementUnit.«units.toUpperCase»_LITERAL);
+ «ENDIF»
+ «IF ! styles.empty»
+ // initializeFromPreferences
+ org.eclipse.jface.preferences.IPreferenceStore store = (org.eclipse.jface.preferences.IPreferenceStore) preferencesHint.getPreferenceStore();
+ «initializeStyles(it, 'diagram', 'store', false, false, false)»
+ «ENDIF»
return diagram;
- }
-
- «generatedMemberComment»
- public org.eclipse.gmf.runtime.notation.Node createNode(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) {
- final org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(semanticAdapter);
- final int visualID;
- if (semanticHint == null) {
- visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(containerView, domainElement);
- } else {
- visualID = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(semanticHint);
- }
- switch(visualID) {
- «FOR n : getAllNodes()»
- «xptVisualIDRegistry.caseVisualID(n)»
- return create«n.uniqueIdentifier»(domainElement, containerView, index, persisted, preferencesHint);
- «ENDFOR»
- }
- // can't happen, provided #provides(CreateNodeViewOperation) is correct
- return null;
- }
-
- «generatedMemberComment»
- public org.eclipse.gmf.runtime.notation.Edge createEdge(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.emf.type.core.IElementType elementType = getSemanticElementType(semanticAdapter);
- String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it)»(elementTypeHint)) {
- «FOR link : links»
- «xptVisualIDRegistry.caseVisualID(link)»
- return create«link.uniqueIdentifier»(«IF link.isTypeLink()» getSemanticElement(semanticAdapter), «ENDIF»containerView, index, persisted, preferencesHint);
- «ENDFOR»
}
- // can never happen, provided #provides(CreateEdgeViewOperation) is correct
- return null;
- }
-
- «FOR next : getAllNodes()»
- «createNodeMethod(next)»
- «ENDFOR»
- «FOR next : links»
- «createEdgeMethod(next)»
- «ENDFOR»
-
- «IF topLevelNodes.notEmpty»
+
«generatedMemberComment»
- private void stampShortcut(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.Node target) {
- if (!«VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(containerView))) {
- «addShortcutAnnotation(it, 'target')»
+ public org.eclipse.gmf.runtime.notation.Node createNode(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) {
+ final org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(semanticAdapter);
+ final String visualID;
+ if (semanticHint == null) {
+ visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(containerView, domainElement);
+ } else {
+ visualID = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(semanticHint);
}
+ if (visualID != null) {
+ switch(visualID) {
+ «FOR n : getAllNodes()»
+ «xptVisualIDRegistry.caseVisualID(n)»
+ return create«n.stringUniqueIdentifier»(domainElement, containerView, index, persisted, preferencesHint);
+ «ENDFOR»
+ }
+ }
+ // can't happen, provided #provides(CreateNodeViewOperation) is correct
+ return null;
}
- «ENDIF»
-
- «IF links.map[l|l.labels].flatten.notEmpty || topLevelNodes.map[n|n.labels].flatten.notEmpty || childNodes.map[n|n.labels].flatten.notEmpty»
- «generatedMemberComment»
- private org.eclipse.gmf.runtime.notation.Node createLabel(org.eclipse.gmf.runtime.notation.View owner, String hint) {
- org.eclipse.gmf.runtime.notation.DecorationNode rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDecorationNode();
- rv.setType(hint);
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(owner, rv, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true);
- return rv;
- }
- «ENDIF»
-
- «IF getAllNodes().map[n|n.compartments].flatten.notEmpty»
+
«generatedMemberComment»
- private org.eclipse.gmf.runtime.notation.Node createCompartment(org.eclipse.gmf.runtime.notation.View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) {
- //SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment();
- //rv.setShowTitle(showTitle);
- //rv.setCollapsed(isCollapsed);
- org.eclipse.gmf.runtime.notation.Node rv;
- if (canCollapse) {
- rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBasicCompartment();
- } else {
- rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDecorationNode();
+ public org.eclipse.gmf.runtime.notation.Edge createEdge(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.emf.type.core.IElementType elementType = getSemanticElementType(semanticAdapter);
+ String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(elementTypeHint);
+ if (vid != null) {
+ switch (vid) {
+ «FOR link : links»
+ «xptVisualIDRegistry.caseVisualID(link)»
+ return create«link.stringUniqueIdentifier»(«IF isTypeLink(link)» getSemanticElement(semanticAdapter), «ENDIF»containerView, index, persisted, preferencesHint);
+ «ENDFOR»
+ }
}
- if (hasTitle) {
- org.eclipse.gmf.runtime.notation.TitleStyle ts = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createTitleStyle();
- ts.setShowTitle(true);
- rv.getStyles().add(ts);
+ // can never happen, provided #provides(CreateEdgeViewOperation) is correct
+ return null;
+ }
+
+ «FOR next : getAllNodes()»
+ «createNodeMethod(next)»
+ «ENDFOR»
+ «FOR next : links»
+ «createEdgeMethod(next)»
+ «ENDFOR»
+
+ «IF ! topLevelNodes.empty»
+ «generatedMemberComment»
+ protected void stampShortcut(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.gmf.runtime.notation.Node target) {
+ if (!«VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(containerView))) {
+ «addShortcutAnnotation(it, 'target')»
+ }
}
- if (canSort) {
- rv.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createSortingStyle());
+ «ENDIF»
+
+ «IF links.map[l|l.labels].flatten.notEmpty || topLevelNodes.map[n|n.labels].flatten.notEmpty || childNodes.map[n|n.labels].flatten.notEmpty»
+ «generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.Node createLabel(org.eclipse.gmf.runtime.notation.View owner, String hint) {
+ org.eclipse.gmf.runtime.notation.DecorationNode rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDecorationNode();
+ rv.setType(hint);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(owner, rv, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true);
+ return rv;
}
- if (canFilter) {
- rv.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFilteringStyle());
+ «ENDIF»
+
+ «IF getAllNodes().map[n|n.compartments].flatten.notEmpty»
+ «generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.Node createCompartment(org.eclipse.gmf.runtime.notation.View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) {
+ //SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment();
+ //rv.setShowTitle(showTitle);
+ //rv.setCollapsed(isCollapsed);
+ org.eclipse.gmf.runtime.notation.Node rv = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBasicCompartment();
+
+ rv.setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBounds());
+
+ if (hasTitle) {
+ org.eclipse.gmf.runtime.notation.TitleStyle ts = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createTitleStyle();
+ rv.getStyles().add(ts);
+ }
+ if (canSort) {
+ rv.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createSortingStyle());
+ }
+ if (canFilter) {
+ rv.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFilteringStyle());
+ }
+ rv.setType(hint);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(owner, rv, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true);
+ return rv;
}
- rv.setType(hint);
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(owner, rv, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true);
- return rv;
- }
- «ENDIF»
-
- «getSemanticElementMethod(it)»
- «getSemanticElementTypeMethod(it)»
- «additions(it)»
- }
+ «ENDIF»
+
+ «getSemanticElementMethod(it)»
+ «getSemanticElementTypeMethod(it)»
+ «additions(it)»
+ }
'''
def dispatch createNodeMethod(GenNode it) '''
- «generatedMemberComment»
- public org.eclipse.gmf.runtime.notation.Node create«uniqueIdentifier»(org.eclipse.emf.ecore.EObject domainElement, org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
- «IF viewmap.canUseShapeStyle()»
- org.eclipse.gmf.runtime.notation.Shape node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShape();
- «ELSE»
- org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createNode();
- node.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());«/* FIXME Contionally add this style, whether toolsmith needs Notes or not */»
- «xptViewStyles.addFontLineFillStylesConditionally(it.viewmap, 'node.getStyles()')»
- «ENDIF»
- «xptViewStyles.addLinkedDiagramStyle(it, 'node.getStyles()')»
- «xptViewStyles.addCustomStyles(it, 'node.getStyles()')»
- node.setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBounds());
- node.setType(«xptVisualIDRegistry.typeMethodCall(it)»);
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(containerView, node, index, persisted);
- node.setElement(domainElement);
- «IF it.oclIsKindOf(typeof(GenTopLevelNode))»
- stampShortcut(containerView, node);
- «ENDIF»
- // initializeFromPreferences «/* XXX Perhaps, do init only once, for complete figure? */»
- final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
- «initializeStyles(it, 'node', 'prefStore', !viewmap.isFixedForeground(), !viewmap.isFixedBackground(), !viewmap.isFixedFont())»
- «FOR label : it.labels»
- «initLabel(label, 'node', 'prefStore')»
- «ENDFOR»
- «FOR comp : it.compartments»
- «initCompartment(comp, 'node', 'prefStore')»
- «ENDFOR»
- return node;
- }
+ «generatedMemberComment»
+ public org.eclipse.gmf.runtime.notation.Node create«stringUniqueIdentifier»(org.eclipse.emf.ecore.EObject domainElement, org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ «IF canUseShapeStyle(viewmap)»
+ org.eclipse.gmf.runtime.notation.Shape node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShape();
+ «ELSE»
+ org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createNode();
+ node.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle());«/* FIXME Contionally add this style, whether toolsmith needs Notes or not */»
+ «xptViewStyles.addFontLineFillStylesConditionally(it.viewmap, 'node.getStyles()')»
+ «ENDIF»
+ «xptViewStyles.addLinkedDiagramStyle(it, 'node.getStyles()')»
+ «xptViewStyles.addCustomStyles(it, 'node.getStyles()')»
+ node.setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createBounds());
+ node.setType(«xptVisualIDRegistry.typeMethodCall(it)»);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ «IF it instanceof GenTopLevelNode»
+ stampShortcut(containerView, node);
+ «ENDIF»
+ // initializeFromPreferences «/* XXX Perhaps, do init only once, for complete figure? */»
+ final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
+ «initializeStyles(it, 'node', 'prefStore', !isFixedForeground(viewmap), !isFixedBackground(viewmap), !isFixedFont(viewmap))»
+ «FOR label : it.labels»
+ «initLabel(label, 'node', 'prefStore')»
+ «ENDFOR»
+ «FOR comp : it.compartments»
+ «initCompartment(comp, 'node', 'prefStore')»
+ «ENDFOR»
+ ««« BEGIN Papyrus Modification
+ «IF compartments.size != 0»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(«'node'», «'prefStore'», "«elementType.displayName»");
+ «ENDIF»
+ ««« END Papyrus Modification
+ «initLabelVisibility(it,'node', 'prefStore')»
+ return node;
+ }
'''
// Location as layoutConstraint, no children
def dispatch createNodeMethod(GenChildLabelNode it) '''
«generatedMemberComment»
- public org.eclipse.gmf.runtime.notation.Node create«uniqueIdentifier»(org.eclipse.emf.ecore.EObject domainElement, org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
- org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createNode();
+ public org.eclipse.gmf.runtime.notation.Node create«stringUniqueIdentifier»(org.eclipse.emf.ecore.EObject domainElement, org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ org.eclipse.gmf.runtime.notation.Node node = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShape();
node.setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLocation());«/* [artem] XXX not sure, why LabelNode needs location */»
«xptViewStyles.addLinkedDiagramStyle(it, 'node.getStyles()')»
«xptViewStyles.addCustomStyles(it, 'node.getStyles()')»
node.setType(«xptVisualIDRegistry.typeMethodCall(it)»);
org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(containerView, node, index, persisted);
node.setElement(domainElement);
- «IF styles.notEmpty»
- final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
- «initializeStyles(it, 'node', 'prefStore', false, false, false)»
- «ENDIF»
+
+ final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
+ «initFontFromPrefs(it,'node', 'prefStore')»
+ «initForegroundFromPrefs(it,'node', 'prefStore')»
return node;
}
'''
@@ -386,9 +445,11 @@ import org.eclipse.gmf.runtime.notation.Style
* FIXME check if there's need for a variable name, see initCompartment for a hint
*/
def initLabel(GenLabel it, String nodeVar, String prefStoreVar) '''
- «var String labelVar = 'label' + it.visualID»
+ «var String labelVar = it.stringUniqueIdentifier.toFirstLower»
org.eclipse.gmf.runtime.notation.Node «labelVar» = createLabel(«nodeVar», «xptVisualIDRegistry.typeMethodCall(it)»);
+ «IF it.modelFacet !=null»
«xptViewStyles.addTextStyle(it.modelFacet, labelVar + '.getStyles()')»
+ «ENDIF»
«xptViewStyles.addCustomStyles(it, labelVar + '.getStyles()')»
«IF it.oclIsKindOf(typeof(GenExternalNodeLabel)) || it.oclIsKindOf(typeof(GenLinkLabel))»
«labelVar».setLayoutConstraint(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLocation());
@@ -398,7 +459,7 @@ import org.eclipse.gmf.runtime.notation.Style
'''
def initCompartment(GenCompartment it, String nodeVar, String prefStoreVar) '''
- «var String compartmentVar= 'compartment' + it.visualID»
+ «var String compartmentVar= it.stringUniqueIdentifier.toFirstLower»
«IF it.styles.notEmpty || isStoringChildPositions(it.layoutType)»org.eclipse.gmf.runtime.notation.Node «compartmentVar» = «ENDIF»createCompartment(«nodeVar», «xptVisualIDRegistry.typeMethodCall(it)», «canCollapse», «needsTitle», «listLayout», «listLayout»);
«xptViewStyles.addCustomStyles(it, compartmentVar + '.getStyles()')»
«IF isStoringChildPositions(it.layoutType)»
@@ -415,68 +476,59 @@ import org.eclipse.gmf.runtime.notation.Style
'''
def initForegroundFromPrefs(GenCommonBase it, String viewVar, String prefStoreVar) '''
- org.eclipse.swt.graphics.RGB lineRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_COLOR);
- 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.RGBToInteger(lineRGB));
- '''
+ «specificInitForegroundFromPrefs(it,viewVar, prefStoreVar)»
+'''
def initBackgroundFromPrefs(GenCommonBase it, String viewVar, String prefStoreVar) '''
- org.eclipse.swt.graphics.RGB fillRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_FILL_COLOR);
- 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.RGBToInteger(fillRGB));
- '''
+ «specificInitForegroundFromPrefs(it,viewVar, prefStoreVar)»
+'''
def initFontFromPrefs(GenCommonBase it, String viewVar, String prefStoreVar) '''
- org.eclipse.gmf.runtime.notation.FontStyle «viewVar»FontStyle = (org.eclipse.gmf.runtime.notation.FontStyle) «viewVar».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.Literals.FONT_STYLE);
- if («viewVar»FontStyle != null) {«/* Given this template is invoked only when FontStyle is present, no need to check fontStyle for null, but at least this gives a scope for fontData var */»
- org.eclipse.swt.graphics.FontData fontData = org.eclipse.jface.preference.PreferenceConverter.getFontData(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_DEFAULT_FONT);
- «viewVar»FontStyle.setFontName(fontData.getName());
- «viewVar»FontStyle.setFontHeight(fontData.getHeight());
- «viewVar»FontStyle.setBold((fontData.getStyle() & org.eclipse.swt.SWT.BOLD) != 0);
- «viewVar»FontStyle.setItalic((fontData.getStyle() & org.eclipse.swt.SWT.ITALIC) != 0);
- org.eclipse.swt.graphics.RGB fontRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_FONT_COLOR);
- «viewVar»FontStyle.setFontColor(org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fontRGB).intValue());
- }
- '''
+ «specificInitFontFromPrefs(it,viewVar, prefStoreVar)»
+'''
def createEdgeMethod(GenLink it) '''
«generatedMemberComment»
- public org.eclipse.gmf.runtime.notation.Edge create«uniqueIdentifier»(«IF it.isTypeLink()»org.eclipse.emf.ecore.EObject domainElement, «ENDIF»org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
- «IF viewmap.isFixedForeground()»
+ public org.eclipse.gmf.runtime.notation.Edge create«stringUniqueIdentifier»(«IF isTypeLink(it)»org.eclipse.emf.ecore.EObject domainElement, «ENDIF»org.eclipse.gmf.runtime.notation.View containerView, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
+ «IF isFixedForeground(viewmap)»
org.eclipse.gmf.runtime.notation.Edge edge = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createEdge();
edge.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createRoutingStyle());
«ELSE»
org.eclipse.gmf.runtime.notation.Connector edge = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createConnector();
«ENDIF»
- «IF !viewmap.isFixedFont()»
+ «IF !isFixedFont(viewmap)»
edge.getStyles().add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFontStyle());
«ENDIF»
«xptViewStyles.addCustomStyles(it, 'edge.getStyles()')»
org.eclipse.gmf.runtime.notation.RelativeBendpoints bendpoints = org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createRelativeBendpoints();
- java.util.ArrayList<org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint> points = new java.util.ArrayList<org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint>(2);
+ java.util.List<org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint> points = new java.util.ArrayList<org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint>(2);
points.add(new org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint());
points.add(new org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint());
bendpoints.setPoints(points);
edge.setBendpoints(bendpoints);
org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.insertChildView(containerView, edge, index, persisted);
edge.setType(«xptVisualIDRegistry.typeMethodCall(it)»);
- edge.setElement(«IF it.isTypeLink()»domainElement«ELSE»null«ENDIF»);
+ edge.setElement(«IF isTypeLink(it)»domainElement«ELSE»null«ENDIF»);
// initializePreferences
final org.eclipse.jface.preference.IPreferenceStore prefStore = (org.eclipse.jface.preference.IPreferenceStore) preferencesHint.getPreferenceStore();
- «initializeStyles(it, 'edge', 'prefStore', !viewmap.isFixedForeground(), false, !viewmap.isFixedFont())»
- org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
- if (routing != null) {
- org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
- }
+ «initializeStyles(it, 'edge', 'prefStore', !isFixedForeground(viewmap), false, !isFixedFont(viewmap))»
+ //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ //if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ //}
+ «initRountingFromPrefs(it,'edge', 'prefStore')»
«FOR label : it.labels»
«initLabel(label, 'edge', 'prefStore')»
«ENDFOR»
+ «initLabelVisibility(it,'edge', 'prefStore')»
return edge;
}
'''
def getSemanticElementMethod(GenDiagram it) '''
«generatedMemberComment»
- private org.eclipse.emf.ecore.EObject getSemanticElement(org.eclipse.core.runtime.IAdaptable semanticAdapter) {
+ protected org.eclipse.emf.ecore.EObject getSemanticElement(org.eclipse.core.runtime.IAdaptable semanticAdapter) {
if (semanticAdapter == null) {
return null;
}
@@ -490,7 +542,7 @@ import org.eclipse.gmf.runtime.notation.Style
def getSemanticElementTypeMethod(GenDiagram it) '''
«generatedMemberComment»
- private org.eclipse.gmf.runtime.emf.type.core.IElementType getSemanticElementType(org.eclipse.core.runtime.IAdaptable semanticAdapter) {
+ protected org.eclipse.gmf.runtime.emf.type.core.IElementType getSemanticElementType(org.eclipse.core.runtime.IAdaptable semanticAdapter) {
if (semanticAdapter == null) {
return null;
}
@@ -504,7 +556,65 @@ import org.eclipse.gmf.runtime.notation.Style
«ENDIF»
'''
- def additions(GenDiagram it) ''''''
+ def additions(GenDiagram it) '''
+
+ «generatedMemberComment»
+ private void initFontStyleFromPrefs(org.eclipse.gmf.runtime.notation.View view, final org.eclipse.jface.preference.IPreferenceStore store, String elementName)
+ {
+ String fontConstant = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.FONT);
+ String fontColorConstant = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_FONT);
+
+ org.eclipse.gmf.runtime.notation.FontStyle viewFontStyle = (org.eclipse.gmf.runtime.notation.FontStyle) view.getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.Literals.FONT_STYLE);
+ if (viewFontStyle != null)
+ {
+ org.eclipse.swt.graphics.FontData fontData = org.eclipse.jface.preference.PreferenceConverter.getFontData(store, fontConstant);
+ viewFontStyle.setFontName(fontData.getName());
+ viewFontStyle.setFontHeight(fontData.getHeight());
+ viewFontStyle.setBold((fontData.getStyle() & org.eclipse.swt.SWT.BOLD) != 0);
+ viewFontStyle.setItalic((fontData.getStyle() & org.eclipse.swt.SWT.ITALIC) != 0);
+
+ org.eclipse.swt.graphics.RGB fontRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(store, fontColorConstant);
+ viewFontStyle.setFontColor(org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fontRGB).intValue());
+ }
+ }
+
+ «generatedMemberComment»
+ private void initForegroundFromPrefs(org.eclipse.gmf.runtime.notation.View view, final org.eclipse.jface.preference.IPreferenceStore store, String elementName)
+ {
+ String lineColorConstant = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_LINE);
+ org.eclipse.swt.graphics.RGB lineRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(store, lineColorConstant);
+ org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(view, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(), org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(lineRGB));
+ }
+
+ «generatedMemberComment»
+ private void initBackgroundFromPrefs(org.eclipse.gmf.runtime.notation.View view, final org.eclipse.jface.preference.IPreferenceStore store, String elementName)
+ {
+ String fillColorConstant = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_FILL);
+ String gradientColorConstant = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant(elementName,org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_GRADIENT);
+ String gradientPolicyConstant = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant(elementName,org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.GRADIENT_POLICY);
+
+
+ org.eclipse.swt.graphics.RGB fillRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(store, fillColorConstant);
+ 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));
+
+
+ org.eclipse.gmf.runtime.notation.FillStyle fillStyle = (org.eclipse.gmf.runtime.notation.FillStyle) view
+ .getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.Literals.FILL_STYLE);
+ fillStyle
+ .setFillColor(org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fillRGB).intValue());
+
+ ;
+ if (store.getBoolean(gradientPolicyConstant)) {
+ org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter gradientPreferenceConverter = new org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter(
+ store.getString(gradientColorConstant));
+ fillStyle.setGradient(gradientPreferenceConverter.getGradientData());
+ fillStyle
+ .setTransparency(gradientPreferenceConverter.getTransparency());
+ }
+ }
+
+
+'''
def boolean hasFontStyleInCustom(GenCommonBase it) {
return hasNotationStyleInCustomStyles(it, typeof(FontStyle));
@@ -524,6 +634,112 @@ import org.eclipse.gmf.runtime.notation.Style
def boolean hasNotationStyleInCustomStyles(GenCommonBase it, Class<? extends Style> styleType) {
return it.styles.exists[s|s.ecoreClass.oclIsKindOf(styleType)];
}
-
+
+def specificInitFontFromPrefs(GenNode it,String viewVar, String prefStoreVar)'''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initFontStyleFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitFontFromPrefs(GenChildNode it,String viewVar, String prefStoreVar) '''
+«IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initFontStyleFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitFontFromPrefs(GenLink it,String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initFontStyleFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitFontFromPrefs(GenCommonBase it,String viewVar, String prefStoreVar) '''
+«IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initFontStyleFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitForegroundFromPrefs(GenNode it,String viewVar, String prefStoreVar)'''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initForegroundFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitForegroundFromPrefs(GenChildNode it,String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initForegroundFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitForegroundFromPrefs(GenLink it,String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initForegroundFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitForegroundFromPrefs(GenCommonBase it,String viewVar, String prefStoreVar) '''
+'''
+
+def specificInitBackgroundFromPrefs(GenNode it,String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initBackgroundFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitBackgroundFromPrefs(GenChildNode it,String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initBackgroundFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitBackgroundFromPrefs(GenLink it, String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initBackgroundFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitBackgroundFromPrefs(GenCommonBase it,String viewVar, String prefStoreVar) '''
+'''
+
+
+def initRountingFromPrefs(GenCommonBase it,String viewVar, String prefStoreVar) '''
+ « specificInitRountingFromPrefs(it,viewVar, prefStoreVar)»
+'''
+
+def specificInitRountingFromPrefs(GenNode it,String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initRountingFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitRountingFromPrefs(GenChildNode it,String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initRountingFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitRountingFromPrefs(GenLink it, String viewVar, String prefStoreVar) '''
+ «IF !"UNDEFINED".equals(elementType.displayName.toUpperCase())»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initRountingFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+def specificInitRountingFromPrefs(GenCommonBase it,String viewVar, String prefStoreVar) '''
+'''
+
+//write the line to initialize the property isVisible for the label of the link
+def initLabelVisibility(GenLink it,String viewVar, String prefStoreVar) '''
+
+ «IF it.labels.filter(typeof (GenLinkLabel)).exists[lbl | lbl.labelVisibilityPreference !== null]»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
+
+//write the line to initialize the property isVisible for the label of the link
+def initLabelVisibility(GenNode it,String viewVar, String prefStoreVar) '''
+ «IF it.labels.filter(typeof (GenExternalNodeLabel)).exists[lbl | lbl.labelVisibilityPreference !== null]»
+ org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(«viewVar», «prefStoreVar», "«elementType.displayName»");
+ «ENDIF»
+'''
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/VisualTypeProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/VisualTypeProvider.xtend
new file mode 100644
index 00000000000..e275137e029
--- /dev/null
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/VisualTypeProvider.xtend
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2015, 2021 Christian W. Damus, CEA LIST, Artal and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
+package xpt.providers
+
+import javax.inject.Inject
+import javax.inject.Singleton
+import org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram
+import xpt.CodeStyle
+import xpt.Common
+import xpt.editor.VisualIDRegistry
+import xpt.providers.ElementTypes
+
+/**
+ * Template for the class that plugs in knowledge of the Visual IDs of this diagram
+ * into the {@code VisualTypeService}.
+ */
+@Singleton class VisualTypeProvider {
+
+ @Inject extension Common
+ @Inject extension CodeStyle
+ @Inject VisualIDRegistry visualIDs
+ @Inject ElementTypes elementTypes
+
+ def packageName(GenDiagram it) '''«it.providersPackageName»'''
+
+
+ def qualifiedClassName(GenDiagram it) '''«packageName(it)».«visualTypeProvider»'''
+
+ protected def constructor(GenDiagram it) '''
+ «generatedMemberComment»
+ public «visualTypeProvider»() {
+ super();
+ }
+ '''
+
+ protected def getElementType_(GenDiagram it) '''
+ «generatedMemberComment»
+ «overrideI»
+ public org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(org.eclipse.gmf.runtime.notation.Diagram diagram, String viewType) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType result = null;
+
+ try {
+ result = «elementTypes.qualifiedClassName(it)».getElementType(viewType);
+ } catch (NumberFormatException e) {
+ // Not supported by this diagram
+ }
+
+ return result;
+ }
+ '''
+
+ protected def getNodeType(GenDiagram it) '''
+ «generatedMemberComment»
+ «overrideI»
+ public String getNodeType(org.eclipse.gmf.runtime.notation.View parentView, org.eclipse.emf.ecore.EObject element) {
+ return «visualIDs.getNodeVisualIDMethodCall(it)»(parentView, element);
+ }
+ '''
+
+ protected def getLinkType(GenDiagram it) '''
+ «generatedMemberComment»
+ «overrideI»
+ public String getLinkType(org.eclipse.gmf.runtime.notation.Diagram diagram, org.eclipse.emf.ecore.EObject element) {
+ return «visualIDs.getLinkWithClassVisualIDMethodCall(it)»(element);
+ }
+ '''
+
+ public def VisualTypeProvider(GenDiagram it) '''
+ «editorGen.copyright»
+ package «packageName»;
+
+ «generatedClassComment»
+ public class «visualTypeProvider» extends org.eclipse.papyrus.infra.gmfdiag.common.service.visualtype.AbstractVisualTypeProvider {
+
+ «constructor»
+
+ «getElementType_»
+
+ «getNodeType»
+
+ «getLinkType»
+
+ }
+ '''
+} \ No newline at end of file
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/extensions.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/extensions.xtend
index 934eacfbb15..68012f0bb9b 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/extensions.xtend
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/providers/extensions.xtend
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2007, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,9 +9,10 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Dmitry Stadnik (Borland) - initial API and implementation
- * Michael Golubev (Montages) - #386838 - migrate to Xtend2
- */
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend
+ *****************************************************************************/
package xpt.providers
import com.google.inject.Inject
@@ -43,6 +44,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
@Inject EditPartModelingAssistantProvider xptEditPartModelingAssistant;
@Inject ParserProvider labelParsers;
@Inject ShortcutsDecoratorProvider shorcutProvider;
+ @Inject VisualTypeProvider visualTypeProvider;
@Inject EditHelper editHelper;
@Inject EditHelperAdvice editHelperAdvice;
@@ -52,7 +54,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
«tripleSpace(2)»«xmlGeneratedTag»
«tripleSpace(2)»<viewProvider class="«viewProvider.qualifiedClassName(it)»">
«tripleSpace(3)»<Priority name="«notationViewProviderPriority»"/>
- «IF shortcutsProvidedFor.notEmpty/*allow provider activation when another diagram tries to create a node, perhaps ours*/»
+ «IF ! shortcutsProvidedFor.empty/*allow provider activation when another diagram tries to create a node, perhaps ours*/»
«tripleSpace(3)»<object id="referencing-diagrams" class="org.eclipse.gmf.runtime.notation.Diagram">
«tripleSpace(4)»<method name="getType()" value="«FOR s : shortcutsProvidedFor SEPARATOR ','»«s»«ENDFOR»"/>
«tripleSpace(3)»</object>
@@ -60,7 +62,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
«ENDIF»
«tripleSpace(3)»<context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="«editorGen.modelID»"/>
«tripleSpace(3)»<context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="«commaSeparatedVisualIDs(allNodes)»"/>
- «IF links.notEmpty/*it is unlikely there would be a diagram without a node, but a diagram without links deemed possible */»
+ «IF ! links.empty/*it is unlikely there would be a diagram without a node, but a diagram without links deemed possible */»
«tripleSpace(3)»<context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="«commaSeparatedVisualIDs(links)»"/>
«ENDIF»
«tripleSpace(2)»</viewProvider>
@@ -87,9 +89,9 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
«tripleSpace(3)»</object>
«tripleSpace(3)»<context views="generated-diagram,generated-nodes,generated-links,generated-labels,generated-compartments"/>
«tripleSpace(2)»</editpartProvider>
- «tripleSpace(1)»</extension>
+ «tripleSpace(1)»</extension>
- «modelingAssistantProvider(it)»
+««« «modelingAssistantProvider(it)»
«tripleSpace(1)»<extension point="org.eclipse.gmf.runtime.common.ui.services.iconProviders" id="icon-provider">
«tripleSpace(2)»«xmlGeneratedTag»
@@ -113,35 +115,53 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
«tripleSpace(2)»<decoratorProvider class="«shorcutProvider.qualifiedClassName(it)»">
«tripleSpace(3)»<Priority name="«shortcutsDecoratorProviderPriority»"/>
«tripleSpace(3)»<object class="org.eclipse.gmf.runtime.notation.Node(org.eclipse.gmf.runtime.notation)" id="generated-top-nodes">
- «tripleSpace(4)»<method name="getType()" value="«commaSeparatedVisualIDs(topLevelNodes)/*generated code supports shortcuts only to top-level nodes*/»"/>
+ «tripleSpace(4)»<method name="getType()" value="«commaSeparatedVisualIDs(it.topLevelNodes)/*generated code supports shortcuts only to top-level nodes*/»"/>
«tripleSpace(3)»</object>
«tripleSpace(3)»<context decoratorTargets="generated-top-nodes"/>
«tripleSpace(2)»</decoratorProvider>
«tripleSpace(1)»</extension>
«ENDIF»
-
- «tripleSpace(1)»<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes" id="element-types">
- «tripleSpace(2)»«xmlGeneratedTag»
- «FOR e : getAllTypedElements()»
- «elementTypeSafe(e.elementType)»
- «ENDFOR»
- «tripleSpace(1)»</extension>
-
- «tripleSpace(1)»<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings" id="element-types-bindings">
+
+««« commented for bug 520882
+««« «IF !getLocalDefineTypedElements(it).empty»
+««« «tripleSpace(1)»<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes" id="element-types">
+««« «tripleSpace(2)»«xmlGeneratedTag»
+««« «FOR e : getLocalDefineTypedElements(it)»
+««« «elementTypeSafe(e.elementType)»
+««« «ENDFOR»
+««« «tripleSpace(1)»</extension>
+««« «ENDIF»
+«««
+««« «tripleSpace(1)»<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings" id="element-types-bindings">
+««« «tripleSpace(2)»«xmlGeneratedTag»
+««« «IF it.eResource.allContents.filter(typeof (GenerateUsingElementTypeCreationCommand)).size<1»
+««« «tripleSpace(2)»<clientContext id="«editorGen.plugin.ID».TypeContext">
+««« «tripleSpace(3)»<enablement>
+««« «tripleSpace(4)»<test
+««« «tripleSpace(5)»property="org.eclipse.gmf.runtime.emf.core.editingDomain"
+««« «tripleSpace(5)»value="«editingDomainID»"/>
+««« «tripleSpace(3)»</enablement>
+««« «tripleSpace(2)»</clientContext>
+««« «tripleSpace(2)»<binding context="«editorGen.plugin.ID».TypeContext">
+««« «ENDIF»
+««« «IF it.eResource.allContents.filter(typeof (GenerateUsingElementTypeCreationCommand)).size>0»
+«««
+««« <binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
+««« «ENDIF»
+««« «FOR e : getLocalDefineTypedElements(it)»
+««« «tripleSpace(3)»<elementType ref="«e.elementType.uniqueIdentifier»"/>
+««« «ENDFOR»
+««« «tripleSpace(3)»<advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+««« «tripleSpace(2)»</binding>
+««« «tripleSpace(1)»</extension>
+
+ «extraLineBreak»
+ «tripleSpace(1)»<extension point="org.eclipse.papyrus.infra.gmfdiag.common.visualTypeProviders">
«tripleSpace(2)»«xmlGeneratedTag»
- «tripleSpace(2)»<clientContext id="«editorGen.plugin.ID».TypeContext">
- «tripleSpace(3)»<enablement>
- «tripleSpace(4)»<test
- «tripleSpace(5)»property="org.eclipse.gmf.runtime.emf.core.editingDomain"
- «tripleSpace(5)»value="«editingDomainID»"/>
- «tripleSpace(3)»</enablement>
- «tripleSpace(2)»</clientContext>
- «tripleSpace(2)»<binding context="«editorGen.plugin.ID».TypeContext">
- «FOR e : getAllTypedElements()»
- «tripleSpace(3)»<elementType ref="«e.elementType.uniqueIdentifier»"/>
- «ENDFOR»
- «tripleSpace(3)»<advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
- «tripleSpace(2)»</binding>
+ «tripleSpace(2)»<visualTypeProvider
+ «tripleSpace(4)»class="«visualTypeProvider.qualifiedClassName(it)»"
+ «tripleSpace(4)»diagramType="«editorGen.modelID»">
+ «tripleSpace(3)»</visualTypeProvider>
«tripleSpace(1)»</extension>
'''
@@ -153,17 +173,17 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
def dispatch elementType(ElementType it) '''«ERROR('Unknown element type: ' + it)»'''
- def dispatch elementType(MetamodelType it) '''
+ def dispatch elementType(MetamodelType it)'''
«tripleSpace(2)»<metamodel nsURI="«getMetaClass().genPackage.getEcorePackage.nsURI»">
«tripleSpace(3)»<metamodelType
«tripleSpace(5)»id="«uniqueIdentifier»"
«IF null != displayName»
- «tripleSpace(5)»name="%metatype.name.«diagramElement.uniqueIdentifier»"
+ «tripleSpace(5)»name="%metatype.name.«diagramElement.stringUniqueIdentifier»"
«ENDIF»
«tripleSpace(5)»kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
«tripleSpace(5)»eclass="«getMetaClass().ecoreClass.name»"
«tripleSpace(5)»edithelper="«editHelper.qualifiedClassName(it)»">
- «tripleSpace(4)»<param name="semanticHint" value="«diagramElement.visualID»"/>
+ «tripleSpace(4)»<param name="semanticHint" value="«diagramElement.stringVisualID»"/>
«tripleSpace(3)»</metamodelType>
«tripleSpace(2)»</metamodel>
'''
@@ -182,13 +202,13 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
«tripleSpace(3)»<specializationType
«tripleSpace(5)»id="«uniqueIdentifier»"
«IF null != displayName»
- «tripleSpace(5)»name="%metatype.name.«diagramElement.uniqueIdentifier»"
+ «tripleSpace(5)»name="%metatype.name.«diagramElement.stringUniqueIdentifier»"
«ENDIF»
«tripleSpace(5)»kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"«IF editHelperAdviceClassName != null»
«tripleSpace(5)»edithelperadvice="«editHelperAdvice.qualifiedClassName(it)»"«ENDIF»>
«tripleSpace(4)»<specializes id="«IF (null == metamodelType)»org.eclipse.gmf.runtime.emf.type.core.null«ELSE»«metamodelType.
uniqueIdentifier»«ENDIF»"/>
- «tripleSpace(4)»<param name="semanticHint" value="«diagramElement.visualID»"/>
+ «tripleSpace(4)»<param name="semanticHint" value="«diagramElement.stringVisualID»"/>
«tripleSpace(3)»</specializationType>
'''
@@ -196,11 +216,11 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
«tripleSpace(2)»<specializationType
«tripleSpace(4)»id="«uniqueIdentifier»"
«IF null != displayName»
- «tripleSpace(4)»name="%metatype.name.«diagramElement.uniqueIdentifier»"
+ «tripleSpace(4)»name="%metatype.name.«diagramElement.stringUniqueIdentifier»"
«ENDIF»
«tripleSpace(4)»kind="org.eclipse.gmf.runtime.diagram.ui.util.INotationType">
«tripleSpace(3)»<specializes id="org.eclipse.gmf.runtime.emf.type.core.null"/>
- «tripleSpace(3)»<param name="semanticHint" value="«diagramElement.visualID»"/>
+ «tripleSpace(3)»<param name="semanticHint" value="«diagramElement.stringVisualID»"/>
«tripleSpace(2)»</specializationType>
'''
@@ -228,7 +248,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
@MetaDef def dispatch modelingAssistantProviderQualifiedClassName(GenNode it)'''«xptEditPartModelingAssistant.qualifiedClassName(it)»'''
- def commaSeparatedVisualIDs(Iterable<? extends GenCommonBase> list) '''«FOR gcb : list SEPARATOR ','»«gcb.visualID»«ENDFOR»'''
+ def commaSeparatedVisualIDs(Iterable<? extends GenCommonBase> list) '''«FOR gcb : list SEPARATOR ','»«gcb.stringUniqueIdentifier»«ENDFOR»'''
@Localization def i18n(GenDiagram it) '''
@@ -241,4 +261,10 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNode
«IF null != displayName && !definedExternally»metatype.name.«diagramElement.uniqueIdentifier»=«displayName»«ENDIF»
'''
+
+
+ def getLocalDefineTypedElements(GenDiagram it) {
+ getAllTypedElements(it).filter[et| false == et.elementType.definedExternally]
+ }
+
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.ecore b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.ecore
index 68af8f78ee8..2b35f8fba43 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.ecore
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.ecore
@@ -102,6 +102,8 @@
<details key="documentation" value="Custom extensions for this generator"/>
</eAnnotations>
</eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="jdkComplianceLevel" eType="ecore:EEnum platform:/plugin/org.eclipse.emf.codegen.ecore/model/GenModel.ecore#//GenJDKLevel"
+ defaultValueLiteral="11.0"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="GenDiagram" eSuperTypes="#//GenContainerBase #//PackageNames #//ProviderClassNames #//LinkConstraints #//EditPartCandies #//EditorCandies #//Shortcuts #//BatchValidation #//MeasurementUnit">
<eAnnotations source="http://www.eclipse.org/gmf/2005/constraints">
@@ -1092,8 +1094,7 @@
<details key="documentation" value="Bug 569174 : from ExtendedGenView"/>
</eAnnotations>
</eStructuralFeatures>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="locatorClassName"
- eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="locatorClassName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Bug 569174 : from SpecificLocatorExternalLabel"/>
</eAnnotations>
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.genmodel b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.genmodel
index f6406786b8b..2ea1c24bf0f 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.genmodel
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/models/gmfgen.genmodel
@@ -173,6 +173,7 @@
<genFeatures createChild="false" propertyDescription="The target directory for generated editor code"
ecoreFeature="ecore:EAttribute gmfgen.ecore#//GenEditorGenerator/pluginDirectory"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference gmfgen.ecore#//GenEditorGenerator/extensions"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute gmfgen.ecore#//GenEditorGenerator/jdkComplianceLevel"/>
<genOperations ecoreOperation="gmfgen.ecore#//GenEditorGenerator/getAllDomainGenPackages">
<genParameters ecoreParameter="gmfgen.ecore#//GenEditorGenerator/getAllDomainGenPackages/withUsed"/>
</genOperations>
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GMFGenPackage.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GMFGenPackage.java
index f19dc77b106..08756435f96 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GMFGenPackage.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GMFGenPackage.java
@@ -303,13 +303,22 @@ public interface GMFGenPackage extends EPackage {
int GEN_EDITOR_GENERATOR__EXTENSIONS = 23;
/**
+ * The feature id for the '<em><b>Jdk Compliance Level</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int GEN_EDITOR_GENERATOR__JDK_COMPLIANCE_LEVEL = 24;
+
+ /**
* The number of structural features of the '<em>Gen Editor Generator</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int GEN_EDITOR_GENERATOR_FEATURE_COUNT = 24;
+ int GEN_EDITOR_GENERATOR_FEATURE_COUNT = 25;
/**
* The meta object id for the '{@link org.eclipse.papyrus.gmf.codegen.gmfgen.impl.GenCommonBaseImpl <em>Gen Common Base</em>}' class.
@@ -12768,6 +12777,17 @@ public interface GMFGenPackage extends EPackage {
EReference getGenEditorGenerator_Extensions();
/**
+ * Returns the meta object for the attribute '{@link org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator#getJdkComplianceLevel <em>Jdk Compliance Level</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Jdk Compliance Level</em>'.
+ * @see org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator#getJdkComplianceLevel()
+ * @see #getGenEditorGenerator()
+ * @generated
+ */
+ EAttribute getGenEditorGenerator_JdkComplianceLevel();
+
+ /**
* Returns the meta object for class '{@link org.eclipse.papyrus.gmf.codegen.gmfgen.GenDiagram <em>Gen Diagram</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GenEditorGenerator.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GenEditorGenerator.java
index a7e12b1c7fd..acc6bd76c45 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GenEditorGenerator.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/GenEditorGenerator.java
@@ -20,6 +20,7 @@
*/
package org.eclipse.papyrus.gmf.codegen.gmfgen;
+import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.common.util.EList;
@@ -73,6 +74,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenPropertySheet;
* <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator#getContextMenus <em>Context Menus</em>}</li>
* <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator#getPluginDirectory <em>Plugin Directory</em>}</li>
* <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator#getExtensions <em>Extensions</em>}</li>
+ * <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator#getJdkComplianceLevel <em>Jdk Compliance Level</em>}</li>
* </ul>
*
* @see org.eclipse.papyrus.gmf.codegen.gmfgen.GMFGenPackage#getGenEditorGenerator()
@@ -707,6 +709,32 @@ public interface GenEditorGenerator extends EObject {
EList<GenCustomGeneratorExtension> getExtensions();
/**
+ * Returns the value of the '<em><b>Jdk Compliance Level</b></em>' attribute.
+ * The default value is <code>"11.0"</code>.
+ * The literals are from the enumeration {@link org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Jdk Compliance Level</em>' attribute.
+ * @see org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel
+ * @see #setJdkComplianceLevel(GenJDKLevel)
+ * @see org.eclipse.papyrus.gmf.codegen.gmfgen.GMFGenPackage#getGenEditorGenerator_JdkComplianceLevel()
+ * @model default="11.0"
+ * @generated
+ */
+ GenJDKLevel getJdkComplianceLevel();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.papyrus.gmf.codegen.gmfgen.GenEditorGenerator#getJdkComplianceLevel <em>Jdk Compliance Level</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Jdk Compliance Level</em>' attribute.
+ * @see org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel
+ * @see #getJdkComplianceLevel()
+ * @generated
+ */
+ void setJdkComplianceLevel(GenJDKLevel value);
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* <!-- begin-model-doc -->
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
index b9c7639dc90..85d3224f07d 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
@@ -1594,6 +1594,16 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
* @generated
*/
@Override
+ public EAttribute getGenEditorGenerator_JdkComplianceLevel() {
+ return (EAttribute)getGenEditorGenerator().getEStructuralFeatures().get(24);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
public EClass getGenDiagram() {
if (genDiagramEClass == null) {
genDiagramEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(1);
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GenEditorGeneratorImpl.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GenEditorGeneratorImpl.java
index ddf0d7eccc9..9b35134bab1 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GenEditorGeneratorImpl.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/gmfgen/impl/GenEditorGeneratorImpl.java
@@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.codegen.util.CodeGenUtil;
@@ -88,6 +89,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenPropertySheet;
* <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.impl.GenEditorGeneratorImpl#getContextMenus <em>Context Menus</em>}</li>
* <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.impl.GenEditorGeneratorImpl#getPluginDirectory <em>Plugin Directory</em>}</li>
* <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.impl.GenEditorGeneratorImpl#getExtensions <em>Extensions</em>}</li>
+ * <li>{@link org.eclipse.papyrus.gmf.codegen.gmfgen.impl.GenEditorGeneratorImpl#getJdkComplianceLevel <em>Jdk Compliance Level</em>}</li>
* </ul>
*
* @generated
@@ -424,6 +426,26 @@ public class GenEditorGeneratorImpl extends EObjectImpl implements GenEditorGene
protected EList<GenCustomGeneratorExtension> extensions;
/**
+ * The default value of the '{@link #getJdkComplianceLevel() <em>Jdk Compliance Level</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getJdkComplianceLevel()
+ * @generated
+ * @ordered
+ */
+ protected static final GenJDKLevel JDK_COMPLIANCE_LEVEL_EDEFAULT = GenJDKLevel.JDK110_LITERAL;
+
+ /**
+ * The cached value of the '{@link #getJdkComplianceLevel() <em>Jdk Compliance Level</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getJdkComplianceLevel()
+ * @generated
+ * @ordered
+ */
+ protected GenJDKLevel jdkComplianceLevel = JDK_COMPLIANCE_LEVEL_EDEFAULT;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -1306,6 +1328,29 @@ public class GenEditorGeneratorImpl extends EObjectImpl implements GenEditorGene
return extensions;
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public GenJDKLevel getJdkComplianceLevel() {
+ return jdkComplianceLevel;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setJdkComplianceLevel(GenJDKLevel newJdkComplianceLevel) {
+ GenJDKLevel oldJdkComplianceLevel = jdkComplianceLevel;
+ jdkComplianceLevel = newJdkComplianceLevel == null ? JDK_COMPLIANCE_LEVEL_EDEFAULT : newJdkComplianceLevel;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, GMFGenPackage.GEN_EDITOR_GENERATOR__JDK_COMPLIANCE_LEVEL, oldJdkComplianceLevel, jdkComplianceLevel));
+ }
+
public String getPluginDirectory() {
String value = getPluginDirectoryGen();
if (GenCommonBaseImpl.isEmpty(value)) {
@@ -1515,6 +1560,8 @@ public class GenEditorGeneratorImpl extends EObjectImpl implements GenEditorGene
return getPluginDirectory();
case GMFGenPackage.GEN_EDITOR_GENERATOR__EXTENSIONS:
return getExtensions();
+ case GMFGenPackage.GEN_EDITOR_GENERATOR__JDK_COMPLIANCE_LEVEL:
+ return getJdkComplianceLevel();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -1602,6 +1649,9 @@ public class GenEditorGeneratorImpl extends EObjectImpl implements GenEditorGene
getExtensions().clear();
getExtensions().addAll((Collection<? extends GenCustomGeneratorExtension>)newValue);
return;
+ case GMFGenPackage.GEN_EDITOR_GENERATOR__JDK_COMPLIANCE_LEVEL:
+ setJdkComplianceLevel((GenJDKLevel)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -1686,6 +1736,9 @@ public class GenEditorGeneratorImpl extends EObjectImpl implements GenEditorGene
case GMFGenPackage.GEN_EDITOR_GENERATOR__EXTENSIONS:
getExtensions().clear();
return;
+ case GMFGenPackage.GEN_EDITOR_GENERATOR__JDK_COMPLIANCE_LEVEL:
+ setJdkComplianceLevel(JDK_COMPLIANCE_LEVEL_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -1746,6 +1799,8 @@ public class GenEditorGeneratorImpl extends EObjectImpl implements GenEditorGene
return PLUGIN_DIRECTORY_EDEFAULT == null ? pluginDirectory != null : !PLUGIN_DIRECTORY_EDEFAULT.equals(pluginDirectory);
case GMFGenPackage.GEN_EDITOR_GENERATOR__EXTENSIONS:
return extensions != null && !extensions.isEmpty();
+ case GMFGenPackage.GEN_EDITOR_GENERATOR__JDK_COMPLIANCE_LEVEL:
+ return jdkComplianceLevel != JDK_COMPLIANCE_LEVEL_EDEFAULT;
}
return super.eIsSet(featureID);
}
@@ -1778,6 +1833,8 @@ public class GenEditorGeneratorImpl extends EObjectImpl implements GenEditorGene
result.append(copyrightText);
result.append(", pluginDirectory: ");
result.append(pluginDirectory);
+ result.append(", jdkComplianceLevel: ");
+ result.append(jdkComplianceLevel);
result.append(')');
return result.toString();
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java
index 30091330e30..6a52d008742 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java
@@ -233,19 +233,6 @@ public class CodegenEmitters {
}
// parsers
-
- public JavaClassEmitter getAbstractParserEmitter() throws UnexpectedBehaviourException {
- return createJavaClassEmitter("impl::parsers::AbstractParser", "Main"); //$NON-NLS-1$
- }
-
- /**
- * @deprecated we don't want to generate this class anymore, but the changes in i18n may create compilation errors if we don't explicitly clear the contents of generated file.
- * @see comments in template impl::parsers::AbstractParser for details
- */
- public String getAbstractParserName(Object... input) throws UnexpectedBehaviourException {
- return createPrimaryJavaClassEmitter("impl::parsers::AbstractParser").getQualifiedClassName("deprecatedQualifiedClassName", input); //$NON-NLS-1$
- }
-
public JavaClassEmitter getPredefinedParserEmitter() throws UnexpectedBehaviourException {
return createJavaClassEmitter("parsers::PredefinedParser", "Main"); //$NON-NLS-1$
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java
index d5f658272bb..0a07fbac3d3 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java
@@ -90,7 +90,6 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.GenVisualEffect;
import org.eclipse.papyrus.gmf.codegen.gmfgen.InitDiagramAction;
import org.eclipse.papyrus.gmf.codegen.gmfgen.MetamodelType;
import org.eclipse.papyrus.gmf.codegen.gmfgen.OpenDiagramBehaviour;
-import org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedEnumParser;
import org.eclipse.papyrus.gmf.codegen.gmfgen.PredefinedParser;
import org.eclipse.papyrus.gmf.codegen.gmfgen.SpecializationType;
import org.eclipse.papyrus.gmf.codegen.gmfgen.StandardPreferencePages;
@@ -117,7 +116,7 @@ public class Generator extends GeneratorBase implements Runnable {
private final CodegenEmitters myEmitters;
private final BinaryEmitters myBinaryEmmiters;
-
+
public Generator(GenEditorGenerator genModel, CodegenEmitters emitters) {
this(genModel, emitters, new BinaryEmitters());
}
@@ -126,7 +125,7 @@ public class Generator extends GeneratorBase implements Runnable {
this(genModel, emitters, new BinaryEmitters(), codeFormatterFactory);
}
- public Generator(GenEditorGenerator genModel, CodegenEmitters emitters, BinaryEmitters binaryEmitters) {
+ public Generator(GenEditorGenerator genModel, CodegenEmitters emitters, BinaryEmitters binaryEmitters) {
this(genModel, emitters, binaryEmitters, CodeFormatterFactory.DEFAULT);
}
@@ -141,7 +140,7 @@ public class Generator extends GeneratorBase implements Runnable {
@Override
protected TextMerger createMergeService() {
- // Bug 569174 - Use project or worksapce preference as new line characters
+ // Bug 569174 - Use project or worksapce preference as new line characters
// don't delegate to emitter the merger configuration
URL controlFile = myEmitters.getJMergeControlFile();
if (controlFile != null) {
@@ -270,17 +269,17 @@ public class Generator extends GeneratorBase implements Runnable {
generateActionBarContributor();
generateMatchingStrategy();
generateDocumentProvider();
- if (myDiagram.generateInitDiagramAction() || myDiagram.generateCreateShortcutAction() /*FIXME use another condition here*/) {
+ if (myDiagram.generateInitDiagramAction() || myDiagram.generateCreateShortcutAction() /* FIXME use another condition here */) {
generateModelElementSelectionPage();
}
- if (myDiagram.generateInitDiagramAction() /*FIXME use another condition here*/) {
+ if (myDiagram.generateInitDiagramAction() /* FIXME use another condition here */) {
// FIXME HACK!!! until I decide how to contribute action against IFile
InitDiagramAction fakeAction = GMFGenFactory.eINSTANCE.createInitDiagramAction();
fakeAction.setQualifiedClassName(myDiagram.getInitDiagramFileActionQualifiedClassName());
doGenerateJavaClass(myEmitters.getPredefinedActionEmitter(), fakeAction.getQualifiedClassName(), fakeAction, myEditorGen);
generateNewDiagramFileWizard();
}
- if (myDiagram.generateCreateShortcutAction() /*FIXME use another condition here*/) {
+ if (myDiagram.generateCreateShortcutAction() /* FIXME use another condition here */) {
generateCreateShortcutDecorationsCommand();
if (myEditorGen.getApplication() == null) {
generateElementChooser();
@@ -530,7 +529,7 @@ public class Generator extends GeneratorBase implements Runnable {
}
/**
- * Generate classes for behaviours specified for the diagram element.
+ * Generate classes for behaviours specified for the diagram element.
* As part of its job, this method tries not to generate shared policies more than once.
*/
private void generateBehaviours(GenCommonBase commonBase) throws UnexpectedBehaviourException, InterruptedException {
@@ -621,23 +620,31 @@ public class Generator extends GeneratorBase implements Runnable {
if (myEditorGen.getLabelParsers() == null) {
return;
}
- boolean needsAbstractParser = false;
+ // BEGIN : don't generate AbstractParser
+ // boolean needsAbstractParser = false;
for (GenParserImplementation pi : myEditorGen.getLabelParsers().getImplementations()) {
if (pi instanceof PredefinedParser) {
- needsAbstractParser = true;
+ // needsAbstractParser = true;
doGenerateJavaClass(myEmitters.getPredefinedParserEmitter(), ((PredefinedParser) pi).getQualifiedClassName(), pi);
- } else if (pi instanceof PredefinedEnumParser) {
- needsAbstractParser = true;
- } else if (pi instanceof CustomParser && ((CustomParser) pi).isGenerateBoilerplate()) {
+ }
+ // else if (pi instanceof PredefinedEnumParser) {
+ // needsAbstractParser = true;
+ // }
+ else if (pi instanceof CustomParser && ((CustomParser) pi).isGenerateBoilerplate()) {
doGenerateJavaClass(myEmitters.getCustomParserEmitter(), ((CustomParser) pi).getQualifiedName(), pi);
} else if (pi instanceof ExpressionLabelParser) {
doGenerateJavaClass(myEmitters.getExpressionLabelParserEmitter(), ((ExpressionLabelParser) pi).getQualifiedClassName(), pi);
}
}
- if (needsAbstractParser) {
- JavaClassEmitter emitter = myEmitters.getAbstractParserEmitter();
- doGenerateJavaClass(emitter, myEmitters.getAbstractParserName(myEditorGen.getLabelParsers()), myEditorGen.getLabelParsers());
- }
+ // The generated AbstractParser.java class is empty (Only contains comment "Since GMFT 3.1 we don't generate class ...".
+ // - So template 'xtend/impl/parsers/AbstractParser.xtend' is deleted
+ // - so the call is deactivated too
+ //
+ // if (needsAbstractParser) {
+ // JavaClassEmitter emitter = myEmitters.getAbstractParserEmitter();
+ // doGenerateJavaClass(emitter, myEmitters.getAbstractParserName(myEditorGen.getLabelParsers()), myEditorGen.getLabelParsers());
+ // }
+ // END : don't generate AbstractParser
}
// providers
@@ -648,7 +655,7 @@ public class Generator extends GeneratorBase implements Runnable {
}
}
- // if there's no other parser than external, and provider is not contributed as a Service -
+ // if there's no other parser than external, and provider is not contributed as a Service -
// no need to generate class (only get() method would be there)
// XXX although adopters might want to change the logic - what if they generate smth reasonable?
// or if I add sort of getDescriptionParser common access method there?
@@ -777,7 +784,7 @@ public class Generator extends GeneratorBase implements Runnable {
}
private void generateShortcutCreationWizard() throws UnexpectedBehaviourException, InterruptedException {
- JavaClassEmitter emitter = myEmitters.getShortcutCreationWizardEmitter();
+ JavaClassEmitter emitter = myEmitters.getShortcutCreationWizardEmitter();
doGenerate(emitter, myDiagram);
}
@@ -870,7 +877,7 @@ public class Generator extends GeneratorBase implements Runnable {
}
}
- // property sheet
+ // property sheet
protected void generatePropertySheetSections() throws UnexpectedBehaviourException, InterruptedException {
if (myEditorGen.getPropertySheet().isNeedsCaption()) {
@@ -924,7 +931,7 @@ public class Generator extends GeneratorBase implements Runnable {
private void generateDiagramIcon(String path) throws UnexpectedBehaviourException, InterruptedException {
// use genModel.prefix if available to match colors of model icons and diagram icons
- // @see GenPackageImpl#generateEditor - it passes prefix to ModelGIFEmitter
+ // @see GenPackageImpl#generateEditor - it passes prefix to ModelGIFEmitter
Object[] args = new Object[] { myDiagram.getDomainDiagramElement() == null ? myEditorGen.getDiagramFileExtension() : myDiagram.getDomainDiagramElement().getGenPackage().getPrefix() };
doGenerateBinaryFile(myBinaryEmmiters.getDiagramIconEmitter(), new Path(path), args);
}
@@ -1084,7 +1091,8 @@ public class Generator extends GeneratorBase implements Runnable {
} catch (Exception e) {
handleException(new UnexpectedBehaviourException(//
"Error computing FQN for invocation " + invocation + //
- " on " + nextTemplateInput, e));
+ " on " + nextTemplateInput,
+ e));
continue;
}
if (nextFqn != null) {

Back to the top