Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/edithelpers/BaseEditHelper.xpt35
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt42
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt7
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementTypes.xpt17
4 files changed, 81 insertions, 20 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/edithelpers/BaseEditHelper.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/edithelpers/BaseEditHelper.xpt
index f0317ad9a..fe5b0b3f7 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/edithelpers/BaseEditHelper.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/edithelpers/BaseEditHelper.xpt
@@ -19,15 +19,16 @@ package «editHelpersPackageName»;
«EXPAND xpt::Common::generatedClassComment»
public class «baseEditHelperClassName» extends org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper {
- «EXPAND xpt::Common::generatedMemberComment»
- public static final String EDIT_POLICY_COMMAND = "edit policy command"; //$NON-NLS-1$
+ «EXPAND attributes-»
+
+ «EXPAND getEditHelperAdvice-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.common.core.command.ICommand getInsteadCommand(
org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest req) {
org.eclipse.gmf.runtime.common.core.command.ICommand epCommand =
- (org.eclipse.gmf.runtime.common.core.command.ICommand) req.getParameter(EDIT_POLICY_COMMAND);
- req.setParameter(EDIT_POLICY_COMMAND, null);
+ (org.eclipse.gmf.runtime.common.core.command.ICommand) req.getParameter(«EXPAND editPolicyCommand»);
+ req.setParameter(«EXPAND editPolicyCommand», null);
org.eclipse.gmf.runtime.common.core.command.ICommand ehCommand = super.getInsteadCommand(req);
if (epCommand == null) {
return ehCommand;
@@ -69,4 +70,30 @@ public class «baseEditHelperClassName» extends org.eclipse.gmf.runtime.emf.type.
}
«ENDDEFINE»
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final String «EXPAND editPolicyCommand» = "edit policy command"; //$NON-NLS-1$
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static final String «EXPAND contextElementType» = "context element type"; //$NON-NLS-1$
+«ENDDEFINE»
+
+«DEFINE editPolicyCommand FOR gmfgen::GenDiagram»EDIT_POLICY_COMMAND«ENDDEFINE»
+
+«DEFINE contextElementType FOR gmfgen::GenDiagram»CONTEXT_ELEMENT_TYPE«ENDDEFINE»
+
+«DEFINE editPolicyCommandConstant FOR gmfgen::GenDiagram»«getBaseEditHelperQualifiedClassName()».«EXPAND editPolicyCommand»«ENDDEFINE»
+
+«DEFINE contextElementTypeConstant FOR gmfgen::GenDiagram»«getBaseEditHelperQualifiedClassName()».«EXPAND contextElementType»«ENDDEFINE»
+
+«DEFINE getEditHelperAdvice FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice[] getEditHelperAdvice(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest req) {
+ if (req.getParameter(«EXPAND contextElementType») instanceof org.eclipse.gmf.runtime.emf.type.core.IElementType) {
+ return org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry.getInstance().getEditHelperAdvice((org.eclipse.gmf.runtime.emf.type.core.IElementType) req.getParameter(«EXPAND contextElementType»));
+ }
+ return super.getEditHelperAdvice(req);
+ }
+«ENDDEFINE»
+
«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
index b10efc675..932da5948 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
@@ -126,6 +126,8 @@ protected void addDestroyShortcutsCommand(org.eclipse.gef.commands.CompoundComma
«DEFINE semanticPart FOR gmfgen::GenDiagram-»
«EXPAND getSemanticCommand-»
+ «EXPAND getEditHelperCommand-»
+
«EXPAND getSemanticCommandSwitch-»
«EXPAND getConfigureCommand-»
@@ -156,24 +158,38 @@ protected void addDestroyShortcutsCommand(org.eclipse.gef.commands.CompoundComma
«EXPAND getSemanticElement-»
«ENDDEFINE»
+«DEFINE getEditHelperCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gef.commands.Command getEditHelperCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request, org.eclipse.gef.commands.Command editPolicyCommand) {
+ if (editPolicyCommand != null) {
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = editPolicyCommand instanceof org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy ? ((org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) editPolicyCommand).getICommand() : new org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy(editPolicyCommand);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::editPolicyCommandConstant», command);
+ }
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestContextElementType = «getElementTypesQualifiedClassName()».getElementType(getVisualID(request));
+ if (requestContextElementType == null) {
+ requestContextElementType = myElementType;
+ }
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::contextElementTypeConstant», requestContextElementType);
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = requestContextElementType.getEditCommand(request);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::editPolicyCommandConstant», null);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::contextElementTypeConstant», null);
+ if (command != null) {
+ if (!(command instanceof org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ command = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command);
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ }
+ return editPolicyCommand;
+ }
+«ENDDEFINE»
+
«DEFINE getSemanticCommand FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gef.commands.Command getSemanticCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest completedRequest = completeRequest(request);
org.eclipse.gef.commands.Command semanticCommand = getSemanticCommandSwitch(completedRequest);
- if (semanticCommand != null) {
- org.eclipse.gmf.runtime.common.core.command.ICommand command = semanticCommand instanceof org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy ? ((org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) semanticCommand).getICommand() : new org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy(semanticCommand);
- completedRequest.setParameter(«getBaseEditHelperQualifiedClassName()».EDIT_POLICY_COMMAND, command);
- }
- org.eclipse.gmf.runtime.common.core.command.ICommand command = myElementType.getEditCommand(completedRequest);
- completedRequest.setParameter(«getBaseEditHelperQualifiedClassName()».EDIT_POLICY_COMMAND, null);
- if (command != null) {
- if (!(command instanceof org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)) {
- org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
- command = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command);
- }
- semanticCommand = new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
- }
+ semanticCommand = getEditHelperCommand(completedRequest, semanticCommand);
boolean shouldProceed = true;
if (completedRequest instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) {
shouldProceed = shouldProceed((org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) completedRequest);
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt
index eccbee912..b2b605b48 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt
@@ -121,11 +121,12 @@ private java.util.Collection refreshConnections() {
org.eclipse.emf.ecore.EObject diagramLinkObject = nextDiagramLink.getElement();
org.eclipse.emf.ecore.EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
org.eclipse.emf.ecore.EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
- for (java.util.Iterator LinkDescriptorsIterator = linkDescriptors.iterator(); LinkDescriptorsIterator.hasNext();) {
- «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») LinkDescriptorsIterator.next();
+ for (java.util.Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
+ «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») linkDescriptorsIterator.next();
if (diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) {
linksIterator.remove();
- LinkDescriptorsIterator.remove();
+ linkDescriptorsIterator.remove();
+ break;
}
}
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementTypes.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementTypes.xpt
index d4f9b95f3..125017224 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementTypes.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementTypes.xpt
@@ -48,6 +48,8 @@ public class «elementTypesClassName» extends ElementInitializers {
«EXPAND getElementType-»
«EXPAND isKnownElementType-»
+
+ «EXPAND getElementTypeByVisualID-»
«EXPAND additions-»
}
@@ -234,5 +236,20 @@ KNOWN_ELEMENT_TYPES.add(«getUniqueIdentifier()»);
«ENDIF-»
«ENDDEFINE»
+«DEFINE getElementTypeByVisualID FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(int visualID) {
+ switch (visualID) {
+ «EXPAND caseElementType FOREACH getElements().select(el | el.elementType != null)-»
+ }
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE caseElementType FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::caseVisualID-»
+ return «getUniqueIdentifier()»;
+«ENDDEFINE»
+
«DEFINE additions FOR gmfgen::GenDiagram-»
«ENDDEFINE» \ No newline at end of file

Back to the top