Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt547
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt28
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt38
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt240
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt63
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt72
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt68
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt112
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt165
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt203
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto90
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt33
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt146
14 files changed, 1845 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..1066db193
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
@@ -0,0 +1,547 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::diagram::editpolicies::Utils»
+«EXTENSION xpt::diagram::Utils»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::expressions::ValueExpression»
+«EXTENSION xpt::StringOperations»
+
+«DEFINE BaseItemSemanticEditPolicy FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «baseItemSemanticEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND xpt::Common::generatedMemberComment(
+ 'Extended request data key to hold editpart visual id.
+Add visual id of edited editpart to extended data of the request
+so command switch can decide what kind of diagram element is being edited.
+It is done in those cases when it''s not possible to deduce diagram
+element kind from domain element.
+'
+ )»
+ public org.eclipse.gef.commands.Command getCommand(org.eclipse.gef.Request request) {
+ if (request instanceof org.eclipse.gef.requests.ReconnectRequest) {
+ Object view = ((org.eclipse.gef.requests.ReconnectRequest) request).getConnectionEditPart().getModel();
+ if (view instanceof org.eclipse.gmf.runtime.notation.View) {
+ Integer id = new Integer(«EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»((org.eclipse.gmf.runtime.notation.View) view));
+ request.getExtendedData().put(VISUAL_ID_KEY, id);
+ }
+ }
+ return super.getCommand(request);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Returns visual id from request parameters.
+')»
+ protected int getVisualID(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ Object id = request.getParameter(VISUAL_ID_KEY);
+ return id instanceof Integer ? ((Integer) id).intValue() : -1;
+ }
+
+ «EXPAND semanticPart-»
+
+ «EXPAND xpt::Common::generatedMemberComment('Returns editing domain from the host edit part.
+')»
+ protected org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain() {
+ return ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Creates command to destroy the link.
+')»
+ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.notation.View view) {
+ org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) getHost().getViewer().getEditPartRegistry().get(view);
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest request =
+ new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(getEditingDomain(), false);
+ return editPart.getCommand(
+ new org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper(request, java.util.Collections.EMPTY_MAP));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Creates commands to destroy all host incoming and outgoing links.
+')»
+ protected org.eclipse.gef.commands.CompoundCommand getDestroyEdgesCommand() {
+ org.eclipse.gef.commands.CompoundCommand cmd = new org.eclipse.gef.commands.CompoundCommand();
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ for (java.util.Iterator it = view.getSourceEdges().iterator(); it.hasNext();) {
+ cmd.add(getDestroyElementCommand((org.eclipse.gmf.runtime.notation.Edge) it.next()));
+ }
+ for (java.util.Iterator it = view.getTargetEdges().iterator(); it.hasNext();) {
+ cmd.add(getDestroyElementCommand((org.eclipse.gmf.runtime.notation.Edge) it.next()));
+ }
+ return cmd;
+ }
+
+ «EXPAND addDestroyShortcutsCommand-»
+
+ «EXPAND linkConstraints-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment('Extended request data key to hold editpart visual id.
+')»
+ public static final String VISUAL_ID_KEY = "visual_id"; «EXPAND xpt::Common::nonNLS»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.gmf.runtime.emf.type.core.IElementType myElementType;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected «baseItemSemanticEditPolicyClassName»(org.eclipse.gmf.runtime.emf.type.core.IElementType elementType) {
+ myElementType = elementType;
+ }
+«ENDDEFINE»
+
+«DEFINE addDestroyShortcutsCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void addDestroyShortcutsCommand(org.eclipse.gef.commands.CompoundCommand command) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ if (view.getEAnnotation("Shortcut") != null) { «EXPAND xpt::Common::nonNLS»
+ return;
+ }
+ for (java.util.Iterator it = view.getDiagram().getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { «EXPAND xpt::Common::nonNLS»
+ continue;
+ }
+ command.add(getDestroyElementCommand(nextView));
+ }
+}
+«ENDDEFINE»
+
+«DEFINE semanticPart FOR gmfgen::GenDiagram-»
+ «EXPAND getSemanticCommand-»
+
+ «EXPAND addDeleteViewCommand-»
+
+ «EXPAND getEditHelperCommand-»
+
+ «EXPAND getContextElementType-»
+
+ «EXPAND getSemanticCommandSwitch-»
+
+ «EXPAND getConfigureCommand-»
+
+ «EXPAND getCreateRelationshipCommand-»
+
+ «EXPAND getCreateCommand-»
+
+ «EXPAND getSetCommand-»
+
+ «EXPAND getEditContextCommand-»
+
+ «EXPAND getDestroyElementCommand-»
+
+ «EXPAND getDestroyReferenceCommand-»
+
+ «EXPAND getDuplicateCommand-»
+
+ «EXPAND getMoveCommand-»
+
+ «EXPAND getReorientReferenceRelationshipCommand-»
+
+ «EXPAND getReorientRelationshipCommand-»
+
+ «EXPAND getGEFWrapper-»
+ «EXPAND getMSLWrapper-»
+
+ «EXPAND getSemanticElement-»
+«ENDDEFINE»
+
+«DEFINE getEditHelperCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gef.commands.Command getEditHelperCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request, org.eclipse.gef.commands.Command editPolicyCommand) {
+ if (editPolicyCommand != null) {
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = editPolicyCommand instanceof org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy ? ((org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) editPolicyCommand).getICommand() : new org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy(editPolicyCommand);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::editPolicyCommandConstant», command);
+ }
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestContextElementType = getContextElementType(request);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::contextElementTypeConstant», requestContextElementType);
+ org.eclipse.gmf.runtime.common.core.command.ICommand command = requestContextElementType.getEditCommand(request);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::editPolicyCommandConstant», null);
+ request.setParameter(«EXPAND xpt::diagram::edithelpers::BaseEditHelper::contextElementTypeConstant», null);
+ if (command != null) {
+ if (!(command instanceof org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ command = new org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command);
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(command);
+ }
+ return editPolicyCommand;
+ }
+«ENDDEFINE»
+
+«DEFINE getContextElementType FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.runtime.emf.type.core.IElementType getContextElementType(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType requestContextElementType = «getElementTypesQualifiedClassName()».getElementType(getVisualID(request));
+ return requestContextElementType != null ? requestContextElementType : myElementType;
+ }
+«ENDDEFINE»
+
+«DEFINE getSemanticCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getSemanticCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest completedRequest = completeRequest(request);
+ org.eclipse.gef.commands.Command semanticCommand = getSemanticCommandSwitch(completedRequest);
+ semanticCommand = getEditHelperCommand(completedRequest, semanticCommand);
+ if (completedRequest instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) {
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest destroyRequest = (org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) completedRequest;
+ return shouldProceed(destroyRequest) ? addDeleteViewCommand(semanticCommand, destroyRequest) : null;
+ }
+ return semanticCommand;
+ }
+«ENDDEFINE»
+
+«DEFINE addDeleteViewCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command addDeleteViewCommand(org.eclipse.gef.commands.Command mainCommand, org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest completedRequest){
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ org.eclipse.gef.commands.Command deleteViewCommand = getGEFWrapper(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(editingDomain, (org.eclipse.gmf.runtime.notation.View) getHost().getModel()));
+ return mainCommand == null ? deleteViewCommand : mainCommand.chain(deleteViewCommand);
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticCommandSwitch FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getSemanticCommandSwitch(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest req) {
+ if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest) {
+ return getCreateRelationshipCommand((org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) {
+ return getCreateCommand((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) {
+ return getConfigureCommand((org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) {
+ return getDestroyElementCommand((org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest) {
+ return getDestroyReferenceCommand((org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest) {
+ return getDuplicateCommand((org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest) {
+ return getEditContextCommand((org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest) {
+ return getMoveCommand((org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest) {
+ return getReorientReferenceRelationshipCommand((org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest) {
+ return getReorientRelationshipCommand((org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest) req);
+ } else if (req instanceof org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest) {
+ return getSetCommand((org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest) req);
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getConfigureCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getCreateRelationshipCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getCreateCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getSetCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getEditContextCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getEditContextCommand(org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDestroyElementCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDestroyReferenceCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDuplicateCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDuplicateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getMoveCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getMoveCommand(org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest req) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getReorientReferenceRelationshipCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getReorientReferenceRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest req) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+}
+«ENDDEFINE»
+
+«DEFINE getReorientRelationshipCommand FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
+ return org.eclipse.gef.commands.UnexecutableCommand.INSTANCE;
+}
+«ENDDEFINE»
+
+«DEFINE getGEFWrapper FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected final org.eclipse.gef.commands.Command getGEFWrapper(org.eclipse.gmf.runtime.common.core.command.ICommand cmd) {
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(cmd);
+ }
+«ENDDEFINE»
+
+«DEFINE getMSLWrapper FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment('@deprecated use getGEFWrapper() instead')»
+ protected final org.eclipse.gef.commands.Command getMSLWrapper(org.eclipse.gmf.runtime.common.core.command.ICommand cmd) {
+ // XXX deprecated: use getGEFWrapper() instead
+ return getGEFWrapper(cmd);
+ }
+«ENDDEFINE»
+
+«DEFINE getSemanticElement FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.emf.ecore.EObject getSemanticElement() {
+ return org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.resolveSemanticElement((org.eclipse.gmf.runtime.notation.View) getHost().getModel());
+}
+«ENDDEFINE»
+
+
+«REM»
+ FIXME need to check constraint's provider to ensure we don't generate a field
+ for e.g. Java (or Literal, which is unlikely, though) expressions
+«ENDREM»
+«DEFINE linkConstraints FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::generatedClassComment»
+public static class «getLinkCreationConstraintsClassName()» {
+
+«IF null <> editorGen.expressionProviders-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static final String OPPOSITE_END_VAR = "oppositeEnd"; «EXPAND xpt::Common::nonNLS»
+
+«FOREACH getValidLinkConstraints(self) AS lc-»
+«IF lc.sourceEnd <> null-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static «editorGen.expressionProviders.getAbstractExpressionQualifiedClassName()» «sourceConstraintFieldName(lc.link)»;
+«ENDIF-»
+«IF lc.targetEnd <> null-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static «editorGen.expressionProviders.getAbstractExpressionQualifiedClassName()» «targetConstraintFieldName(lc.link)»;
+«ENDIF-»
+«ENDFOREACH»
+«ENDIF-»
+
+ «EXPAND canCreate FOREACH links-»
+ «EXPAND canExist FOREACH links-»
+}
+«ENDDEFINE»
+
+«DEFINE canCreate FOR gmfgen::GenLink»
+
+«EXPAND xpt::Common::generatedMemberComment»
+public static boolean canCreate«getUniqueIdentifier()»(«EXPAND canCreateParameters FOR modelFacet») {
+ «EXPAND checkEMFConstraints FOR modelFacet-»
+ return canExist«getUniqueIdentifier()»(«EXPAND canCreateValues FOR modelFacet»);
+}
+«ENDDEFINE»
+
+«REM»
+ XXX for now, both constraints are injected into single method
+ which may nob be suitable for modification especially when mixing
+ java and ocl constraints (former requires manual code).
+ Better approach would be:
+ if either is non-null and providers are not the same - introduce two methods,
+ to check source and target separately. Otherwize, do it inplace.
+«ENDREM»
+«DEFINE canExist FOR gmfgen::GenLink»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static boolean canExist«getUniqueIdentifier()»(«EXPAND canCreateParameters FOR modelFacet») {
+«IF creationConstraints <> null and (creationConstraints.isValid() and null <> getDiagram().editorGen.expressionProviders)-»
+ try {
+«IF null <> creationConstraints.sourceEnd-»
+ «EXPAND checkAdditionalConstraint(creationConstraints.sourceEnd, sourceConstraintFieldName(self), 'source', 'target', creationConstraints.getSourceEndContextClass(), creationConstraints.getTargetEndContextClass()) FOR creationConstraints.sourceEnd.provider-»
+«ENDIF-»
+«IF null <> creationConstraints.targetEnd-»
+ «EXPAND checkAdditionalConstraint(creationConstraints.targetEnd, targetConstraintFieldName(self), 'target', 'source', creationConstraints.getTargetEndContextClass(), creationConstraints.getSourceEndContextClass()) FOR creationConstraints.targetEnd.provider-»
+«ENDIF-»
+ return true;
+ } catch(Exception e) {
+ «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Link constraint evaluation error", e); «EXPAND xpt::Common::nonNLS»
+ return false;
+ }
+«ELSE-»
+ return true;
+«ENDIF-»
+ }
+«ENDDEFINE»
+
+«DEFINE canCreateParameters FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE»
+«DEFINE canCreateParameters FOR gmfgen::TypeLinkModelFacet»«IF hasContainerOtherThanSource(self)»«EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container, «ENDIF»«EXPAND sourceTargetParameters»«ENDDEFINE»
+«DEFINE canCreateParameters FOR gmfgen::FeatureLinkModelFacet»«EXPAND sourceTargetParameters»«ENDDEFINE»
+
+«DEFINE sourceTargetParameters FOR gmfgen::LinkModelFacet»«EXPAND MetaModel::QualifiedClassName FOR getSourceType()» source, «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» target«ENDDEFINE»
+
+«DEFINE canCreateValues FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE»
+«DEFINE canCreateValues FOR gmfgen::TypeLinkModelFacet»«IF hasContainerOtherThanSource(self)»container, «ENDIF»source, target«ENDDEFINE»
+«DEFINE canCreateValues FOR gmfgen::FeatureLinkModelFacet»source, target«ENDDEFINE»
+
+
+
+«DEFINE checkEMFConstraints FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE»
+
+«DEFINE checkEMFConstraints FOR gmfgen::TypeLinkModelFacet-»
+ «LET childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 AS checkChildFeatureUpperBound-»
+ «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 or checkChildFeatureUpperBound-»
+if («getContainerVariable(self)» != null) {
+ «EXPAND checkEMFConstraints(self) FOR containmentMetaFeature-»
+ «IF checkChildFeatureUpperBound-»
+ «EXPAND checkEMFConstraints(self) FOR childMetaFeature-»
+ «ENDIF-»
+}
+ «ENDIF-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE checkEMFConstraints(modelFacet : gmfgen::TypeLinkModelFacet) FOR genmodel::GenFeature-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) > 0-»
+if («EXPAND featureBoundComparator(getContainerVariable(modelFacet), modelFacet.getSourceType())») {
+ return false;
+}
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkEMFConstraints FOR gmfgen::FeatureLinkModelFacet-»
+if (source != null) {
+ if («EXPAND featureBoundsConditionClause('source', getSourceType()) FOR metaFeature») {
+ return false;
+ }
+ «IF isContains(metaFeature)-»
+ if (source == target) {
+ return false;
+ }
+ «ENDIF-»
+}
+«IF getReverse(metaFeature) <> null-»
+if (target != null && («EXPAND featureBoundsConditionClause('target', getTargetType()) FOR getReverse(metaFeature)»)) {
+ return false;
+}
+«ENDIF»
+«ENDDEFINE»
+
+«DEFINE featureBoundsConditionClause(targetVar : String, targetType : genmodel::GenClass) FOR genmodel::GenFeature-»
+«REM»Checking upper bounds if was specified in MM«ENDREM»«-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) > 0»«EXPAND featureBoundComparator(targetVar, targetType)»«ENDIF-»
+«REM»Checking uniqueness in addition if upper bounds > 1«ENDREM»«-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) > 1» || «ENDIF-»
+«REM»Checking uniqueness in if upper bounds > 1 or < 0«ENDREM»«-»
+«IF ecoreFeature.upperBound.oclAsType(Integer) <> 1»«EXPAND featureUniquenessComparator(targetVar, targetType)»«ENDIF»
+«ENDDEFINE»
+
+«DEFINE featureBoundComparator(featureVar : String, featureVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature»«EXPAND MetaModel::getFeatureValue(featureVar, featureVarGenClass)»«IF ecoreFeature.upperBound.oclAsType(Integer) = 1» != null«ELSE».size() >= «ecoreFeature.upperBound.oclAsType(Integer)»«ENDIF»«ENDDEFINE»
+«DEFINE featureUniquenessComparator(featureVar : String, featureVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature»«EXPAND MetaModel::getFeatureValue(featureVar, featureVarGenClass) FOR self».contains(target)«ENDDEFINE»
+
+
+«DEFINE checkAdditionalConstraint(valueExpr : gmfgen::ValueExpression, constraintFieldName : String, sourceEndVar : String, targetEndVar : String, context : genmodel::GenClass, oppositeEndContext : genmodel::GenClass) FOR gmfgen::GenExpressionProviderBase»
+«ERROR 'Have no idea what extra constraints to check for ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE checkAdditionalConstraint(valueExpr : gmfgen::ValueExpression, constraintFieldName : String, sourceEndVar : String, targetEndVar : String, context : genmodel::GenClass, oppositeEndContext : genmodel::GenClass) FOR gmfgen::GenExpressionInterpreter-»
+ if («sourceEndVar» == null) {
+ return true;
+ }
+ if («constraintFieldName» == null) {
+ java.util.Map env = java.util.Collections.singletonMap(OPPOSITE_END_VAR, «EXPAND MetaModel::MetaClass FOR oppositeEndContext»);
+ «constraintFieldName» = «getQualifiedClassName()».«getExpressionAccessor(valueExpr)»(«valueExpr.getBodyString()», «EXPAND MetaModel::MetaClass FOR context», env); «EXPAND xpt::Common::nonNLS»
+ }
+ Object «sourceEndVar»Val = «constraintFieldName».evaluate(«sourceEndVar», java.util.Collections.singletonMap(OPPOSITE_END_VAR, «targetEndVar»));
+ if (false == «sourceEndVar»Val instanceof Boolean || !((Boolean) «sourceEndVar»Val).booleanValue()) {
+ return false;
+ } // else fall-through
+«ENDDEFINE»
+
+«DEFINE checkAdditionalConstraint(valueExpr : gmfgen::ValueExpression, constraintFieldName : String, sourceEndVar : String, targetEndVar : String, context : genmodel::GenClass, oppositeEndContext : genmodel::GenClass) FOR gmfgen::GenJavaExpressionProvider-»
+«IF injectExpressionBody and (valueExpr.body <> null and valueExpr.body.xpandLength() <> 0)-»
+ «valueExpr.body»
+«ELSEIF throwException or (injectExpressionBody and (valueExpr.body = null or valueExpr.body.xpandLength() = 0))-»
+ // TODO: implement this method, using «sourceEndVar» and «targetEndVar»
+ // to access link source and target, respectively
+ // Ensure that you remove @generated or mark it @generated NOT
+ if (Boolean.TRUE.booleanValue()) {
+ throw new java.lang.UnsupportedOperationException("No java implementation provided");«EXPAND xpt::Common::nonNLS»
+ }
+«ELSE-»
+ if (Boolean.TRUE.booleanValue()) {«REM»just in case there are two consecutive java expression with neither throw nor inject - avoid unreachable code.«ENDREM»
+ return false;
+ }
+«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE incorrectLinkModelFacet FOR gmfgen::LinkModelFacet»«ERROR 'Unrecognized link model facet: ' + self.repr()»«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
+
+«DEFINE defaultConstructor FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «itemSemanticEditPolicyClassName»() {
+ «EXPAND defaultConstructorBody-»
+ }
+«ENDDEFINE»
+
+«REM»
+ This method should be called only with diagram, node or link used as a parameter
+ (then elementType != null)
+«ENDREM»
+«DEFINE defaultConstructorBody FOR gmfgen::GenCommonBase-»
+ «IF elementType = null-»
+ «ERROR 'No element type in the passed node. Only diagram, node or link are supported in this template: ' + self.repr()-»
+ «ENDIF-»
+ super(«EXPAND xpt::providers::ElementTypes::accessElementType»);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt
new file mode 100644
index 000000000..a13e0fed6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/ChildContainerCanonicalEditPolicy.xpt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE ChildContainerCanonicalEditPolicy FOR gmfgen::GenChildContainer-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «canonicalEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy {
+
+ «EXPAND xpt::diagram::updater::containerBaseCanonicalMethods::containerBaseCanonicalMethods-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenChildContainer»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..72cbc5316
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/CompartmentItemSemanticEditPolicy.xpt
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2006,2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE CompartmentItemSemanticEditPolicy FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «getDiagram().getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND _constructor-»
+
+ «EXPAND xpt::diagram::editpolicies::childContainerCreateCommand::childContainerCreateCommand FOR childNodes->asSequence()-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenCompartment-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public «itemSemanticEditPolicyClassName»() {
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructorBody FOR node-»
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenCompartment-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt
new file mode 100644
index 000000000..143126a59
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramCanonicalEditPolicy.xpt
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::diagram::editpolicies::Utils»
+«EXTENSION xpt::diagram::updater::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE DiagramCanonicalEditPolicy FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «canonicalEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalConnectionEditPolicy {
+
+ «EXPAND xpt::diagram::updater::containerBaseCanonicalMethods::containerBaseCanonicalMethods-»
+
+ «EXPAND getSemanticConnectionsList-»
+
+ «EXPAND getSourceElement-»
+
+ «EXPAND getTargetElement-»
+
+ «EXPAND shouldIncludeConnection-»
+
+ «EXPAND refreshSemantic-»
+
+ «EXPAND getDiagram-»
+
+ «EXPAND refreshLinks-»
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticConnectionsList FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected java.util.List getSemanticConnectionsList() {
+ return java.util.Collections.EMPTY_LIST;
+}
+«ENDDEFINE»
+
+«DEFINE getSourceElement FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.emf.ecore.EObject getSourceElement(org.eclipse.emf.ecore.EObject relationship) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getTargetElement FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.emf.ecore.EObject getTargetElement(org.eclipse.emf.ecore.EObject relationship) {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE shouldIncludeConnection FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected boolean shouldIncludeConnection(org.eclipse.gmf.runtime.notation.Edge connector, java.util.Collection children) {
+ return false;
+}
+«ENDDEFINE»
+
+«DEFINE refreshSemantic FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected void refreshSemantic() {
+ java.util.List createdViews = new java.util.LinkedList();
+ createdViews.addAll(refreshSemanticChildren());
+ java.util.List createdConnectionViews = new java.util.LinkedList();
+ createdConnectionViews.addAll(refreshSemanticConnections());
+ «IF not links->isEmpty()-»
+ createdConnectionViews.addAll(refreshConnections());
+ «ENDIF-»
+
+ if (createdViews.size() > 1) {
+ // perform a layout of the container
+ org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand layoutCmd = new org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
+ executeCommand(new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(layoutCmd));
+ }
+
+ createdViews.addAll(createdConnectionViews);
+ makeViewsImmutable(createdViews);
+}
+«ENDDEFINE»
+
+«DEFINE refreshLinks FOR gmfgen::GenDiagram-»
+ «IF not links->isEmpty()-»
+ «EXPAND refreshConnections-»
+
+ «EXPAND collectAllLinks-»
+
+ «EXPAND createConnections-»
+
+ «EXPAND getEditPart-»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE refreshConnections FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection refreshConnections() {
+ java.util.Map domain2NotationMap = new java.util.HashMap();
+ java.util.Collection linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap);
+ java.util.Collection existingLinks = new java.util.LinkedList(getDiagram().getEdges());
+ for (java.util.Iterator linksIterator = existingLinks.iterator(); linksIterator.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge nextDiagramLink = (org.eclipse.gmf.runtime.notation.Edge) linksIterator.next();
+ int diagramLinkVisualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(nextDiagramLink);
+ if (diagramLinkVisualID == -1) {
+ if (nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) {
+ linksIterator.remove();
+ }
+ continue;
+ }
+ org.eclipse.emf.ecore.EObject diagramLinkObject = nextDiagramLink.getElement();
+ org.eclipse.emf.ecore.EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
+ org.eclipse.emf.ecore.EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
+ for (java.util.Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
+ «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») linkDescriptorsIterator.next();
+ if (diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) {
+ linksIterator.remove();
+ linkDescriptorsIterator.remove();
+ break;
+ }
+ }
+ }
+ deleteViews(existingLinks.iterator());
+ return createConnections(linkDescriptors, domain2NotationMap);
+}
+«ENDDEFINE»
+
+«DEFINE collectAllLinks FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection collectAllLinks(org.eclipse.gmf.runtime.notation.View view, java.util.Map domain2NotationMap) {
+ if (!«EXPAND xpt::editor::VisualIDRegistry::modelID».equals(«EXPAND xpt::editor::VisualIDRegistry::getModelIDMethodCall»(view))) {
+ return java.util.Collections.EMPTY_LIST;
+ }
+ java.util.Collection result = new java.util.LinkedList();
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall»(view)) {
+ «EXPAND caseSemanticElement FOREACH getAllSemanticElements(self)-»
+ }
+ for (java.util.Iterator children = view.getChildren().iterator(); children.hasNext();) {
+ result.addAll(collectAllLinks((org.eclipse.gmf.runtime.notation.View) children.next(), domain2NotationMap));
+ }
+ for (java.util.Iterator edges = view.getSourceEdges().iterator(); edges.hasNext();) {
+ result.addAll(collectAllLinks((org.eclipse.gmf.runtime.notation.View) edges.next(), domain2NotationMap));
+ }
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE caseSemanticElement FOR gmfgen::GenCommonBase-»
+«EXPAND xpt::Common::caseVisualID» {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+«REM»
+ Processing each domain element only once. Prevents us from
+ having duplicated links if a shortcut to one of the "main"
+ diagram elements present on diagram.
+«ENDREM»«-»
+ result.addAll(«EXPAND xpt::diagram::updater::DiagramUpdater::getContainedLinksMethodCall»(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { «EXPAND xpt::Common::nonNLS»
+«REM»
+ Storing element view or replacing shortcut by the "original" element view.
+«ENDREM»«-»
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+}
+«ENDDEFINE»
+
+«REM»
+ GMF has no links to "leaf" child nodes.
+«ENDREM»
+«DEFINE caseSemanticElement FOR gmfgen::GenChildLabelNode»«ENDDEFINE»
+
+«DEFINE colectContainedLink FOR gmfgen::GenLink-»
+«EXPAND xpt::diagram::updater::DiagramUpdater::getContainedLinksMethodCall»(modelElement));
+«ENDDEFINE»
+
+«DEFINE createConnections FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private java.util.Collection createConnections(java.util.Collection linkDescriptors, java.util.Map domain2NotationMap) {
+ java.util.List adapters = new java.util.LinkedList();
+ for (java.util.Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
+ final «editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()» nextLinkDescriptor = («editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()») linkDescriptorsIterator.next();
+ org.eclipse.gef.EditPart sourceEditPart = getEditPart(nextLinkDescriptor.getSource(), domain2NotationMap);
+ org.eclipse.gef.EditPart targetEditPart = getEditPart(nextLinkDescriptor.getDestination(), domain2NotationMap);
+ if (sourceEditPart == null || targetEditPart == null) {
+ continue;
+ }
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor(nextLinkDescriptor.getSemanticAdapter(), null, org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, false, ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getDiagramPreferencesHint());
+ org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest ccr = new org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest(descriptor);
+ ccr.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_CONNECTION_START);
+ ccr.setSourceEditPart(sourceEditPart);
+ sourceEditPart.getCommand(ccr);
+ ccr.setTargetEditPart(targetEditPart);
+ ccr.setType(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_CONNECTION_END);
+ org.eclipse.gef.commands.Command cmd = targetEditPart.getCommand(ccr);
+ if (cmd != null && cmd.canExecute()) {
+ executeCommand(cmd);
+ org.eclipse.core.runtime.IAdaptable viewAdapter = (org.eclipse.core.runtime.IAdaptable) ccr.getNewObject();
+ if (viewAdapter != null) {
+ adapters.add(viewAdapter);
+ }
+ }
+ }
+ return adapters;
+}
+«ENDDEFINE»
+
+«DEFINE getEditPart FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gef.EditPart getEditPart(org.eclipse.emf.ecore.EObject domainModelElement, java.util.Map domain2NotationMap) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) domain2NotationMap.get(domainModelElement);
+ if (view != null) {
+ return (org.eclipse.gef.EditPart) getHost().getViewer().getEditPartRegistry().get(view);
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE getDiagram FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.gmf.runtime.notation.Diagram getDiagram() {
+ return ((org.eclipse.gmf.runtime.notation.View) getHost().getModel()).getDiagram();
+}
+«ENDDEFINE»
+
+«DEFINE incorrectLinkModelFacet FOR gmfgen::LinkModelFacet-»
+ «ERROR 'Incorrect LinkModelFacet: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..687c1ff54
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/DiagramItemSemanticEditPolicy.xpt
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2006,2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE DiagramItemSemanticEditPolicy FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «editPoliciesPackageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructor-»
+
+ «EXPAND xpt::diagram::editpolicies::childContainerCreateCommand::childContainerCreateCommand FOR topLevelNodes->asSequence()-»
+
+ «EXPAND getDuplicateCommand-»
+
+ «EXPAND DuplicateAnythingCommand-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE getDuplicateCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDuplicateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest req) {
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
+}
+«ENDDEFINE»
+
+«DEFINE DuplicateAnythingCommand FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedClassComment»
+private static class DuplicateAnythingCommand extends org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand {
+
+ «EXPAND DAC_constructor-»
+
+ «EXPAND DAC_additions-»
+}
+«ENDDEFINE»
+
+«DEFINE DAC_constructor FOR gmfgen::GenDiagram-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public DuplicateAnythingCommand(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest req) {
+ super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(), req.getAllDuplicatedElementsMap());
+}
+«ENDDEFINE»
+
+«DEFINE DAC_additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagram-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt
new file mode 100644
index 000000000..c0590c364
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/GraphicalNodeEditPolicy.xpt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2006, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE GraphicalNodeEditPolicy FOR gmfgen::GenNode-»
+«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «graphicalNodeEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy {
+
+ «EXPAND xpt::Common::generatedClassComment»
+ protected org.eclipse.gef.commands.Command getConnectionCompleteCommand(
+ org.eclipse.gef.requests.CreateConnectionRequest request) {
+ org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getElementType(request);
+ «FOREACH reorientedIncomingLinks->asSequence() AS link-»
+ if («EXPAND xpt::providers::ElementTypes::accessElementType FOR link» == elementType) {
+ «IF link.outgoingCreationAllowed-»
+ if (request.getSourceEditPart() != getHost()) {
+ «ENDIF-»
+ return getConnectionWithReorientedViewCompleteCommand(request);
+ «IF link.outgoingCreationAllowed-»
+ }
+ «ENDIF-»
+ }
+ «ENDFOREACH-»
+ return super.getConnectionCompleteCommand(request);
+ }
+
+ «EXPAND xpt::Common::generatedClassComment»
+ protected org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(
+ org.eclipse.gef.requests.CreateConnectionRequest request) {
+ if (request instanceof org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest) {
+ org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter requestAdapter =
+ ((org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest) request)
+ .getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
+ return (org.eclipse.gmf.runtime.emf.type.core.IElementType) requestAdapter.getAdapter(
+ org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
+ }
+ return null;
+ }
+
+ «EXPAND xpt::Common::generatedClassComment»
+ protected org.eclipse.gef.commands.Command getConnectionWithReorientedViewCompleteCommand(
+ org.eclipse.gef.requests.CreateConnectionRequest request) {
+ org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy c =
+ (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) super.getConnectionCompleteCommand(request);
+ org.eclipse.gmf.runtime.common.core.command.CompositeCommand cc =
+ (org.eclipse.gmf.runtime.common.core.command.CompositeCommand) c.getICommand();
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain =
+ ((org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) getHost()).getEditingDomain();
+ «getDiagram().getReorientConnectionViewCommandQualifiedClassName()» rcvCommand =
+ new «getDiagram().getReorientConnectionViewCommandQualifiedClassName()»(editingDomain, null);
+ rcvCommand.setEdgeAdaptor(getViewAdapter());
+ cc.compose(rcvCommand);
+ return c;
+ }
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..764aace1f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::diagram::editpolicies::LinkUtils»
+
+«DEFINE LinkItemSemanticEditPolicy FOR gmfgen::GenLink-»
+ «EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «diagram.getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructor-»
+
+ «EXPAND classBody-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE classBody FOR gmfgen::GenLink-»
+ «EXPAND getDestroySemanticCommand FOR modelFacet -»
+ «IF isTypeLink(self)-»
+ «EXPAND xpt::diagram::editpolicies::linkCommands::linkCommands -»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getDestroySemanticCommand FOR gmfgen::LinkModelFacet-»
+ «ERROR 'Unsupported model facet: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE getDestroySemanticCommand FOR gmfgen::FeatureLinkModelFacet-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
+ return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(req)«IF isContains(metaFeature)» {
+
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.emf.ecore.EObject referencedObject = getReferencedObject();
+ org.eclipse.emf.ecore.resource.Resource resource = referencedObject.eResource();
+ org.eclipse.gmf.runtime.common.core.command.CommandResult result = super.doExecuteWithResult(progressMonitor, info);
+ resource.getContents().add(referencedObject);
+ return result;
+ }
+
+ }«ENDIF»);
+}
+«ENDDEFINE»
+
+«DEFINE getDestroySemanticCommand FOR gmfgen::TypeLinkModelFacet-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenLink»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto
new file mode 100644
index 000000000..1726ee0d5
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkUtils.qvto
@@ -0,0 +1,40 @@
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
+
+library LinkUtils;
+
+helper isTypeLink(link : genModel::GenLink) : Boolean {
+ return (Sequence { link.modelFacet })[genModel::TypeLinkModelFacet]->size() > 0
+}
+
+helper isRefLink(link : genModel::GenLink) : Boolean {
+ return (Sequence { link.modelFacet })[genModel::FeatureLinkModelFacet]->size() > 0
+}
+
+helper canBeSource(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return link.sources->includes(linkEnd)
+}
+
+helper canBeTarget(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return link.targets->includes(linkEnd)
+}
+
+helper canBeContainer(link : genModel::GenLink, metaClass : genModel_1::GenClass) : Boolean {
+ return null <> link.modelFacet and isCompatible(link.modelFacet.getContainerClass(), metaClass)
+}
+
+helper genModel::LinkModelFacet::getContainerClass() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::TypeLinkModelFacet::getContainerClass() : genModel_1::GenClass {
+ return self.childMetaFeature.genClass
+}
+
+helper genModel::FeatureLinkModelFacet::getContainerClass() : genModel_1::GenClass {
+ return self.getSourceType()
+}
+
+helper isCompatible(desiredType : genModel_1::GenClass, actualClass : genModel_1::GenClass) : Boolean {
+ return null <> desiredType and desiredType.ecoreClass.isSuperTypeOf(actualClass.ecoreClass)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt
new file mode 100644
index 000000000..50c775256
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«REM»
+ This template should be called only for non-design nodes (modelFacet != null)
+ because *ItemSemanticEditPolicy responsible for dealing with semantic model
+ elements and meaningless (should not be generated) for pure design nodes.
+«ENDREM»
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::diagram::editpolicies::Utils»
+
+«DEFINE NodeItemSemanticEditPolicy FOR gmfgen::GenNode-»
+ «EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
+package «getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «itemSemanticEditPolicyClassName» extends «getDiagram().getBaseItemSemanticEditPolicyQualifiedClassName()» {
+
+ «EXPAND xpt::diagram::editpolicies::BaseItemSemanticEditPolicy::defaultConstructor-»
+
+ «EXPAND xpt::diagram::editpolicies::childContainerCreateCommand::childContainerCreateCommand FOR childNodes->asSequence()-»
+
+ «EXPAND getDestroyElementCommand-»
+ «IF hasChildrenOrCompartments(self)-»
+ «EXPAND addDestroyChildNodesCommand-»
+ «ENDIF-»
+ «EXPAND xpt::diagram::editpolicies::linkCommands::linkCommands-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE getDestroyElementCommand FOR gmfgen::GenNode-»
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ org.eclipse.gef.commands.CompoundCommand cc = getDestroyEdgesCommand();
+ «IF hasChildrenOrCompartments(self)-»
+ addDestroyChildNodesCommand(cc);
+ «ENDIF-»
+ addDestroyShortcutsCommand(cc);
+ «EXPAND destroySemanticElement-»
+ return cc.unwrap();
+}
+«ENDDEFINE»
+
+«DEFINE destroySemanticElement FOR gmfgen::GenNode-»
+ «EXPAND fixElementToDeleteIfShortcut-»
+cc.add(getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)));
+«ENDDEFINE»
+
+«DEFINE addDestroyChildNodesCommand FOR gmfgen::GenNode-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void addDestroyChildNodesCommand(org.eclipse.gef.commands.CompoundCommand cmd) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «EXPAND xpt::Common::nonNLS»
+ if (annotation != null) {
+ return;
+ }
+ for (java.util.Iterator it = view.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) it.next();
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(node)) {
+ «EXPAND destroyChildNodes('node')-»
+ «IF not compartments->isEmpty()-»
+ «FOREACH compartments->asSequence() AS compartment-»
+ «EXPAND xpt::Common::caseVisualID FOR compartment»
+ for (java.util.Iterator cit = node.getChildren().iterator(); cit.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Node cnode = (org.eclipse.gmf.runtime.notation.Node) cit.next();
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(cnode)) {
+ «EXPAND destroyChildNodes('cnode') FOR compartment-»
+ }
+ }
+ break;
+ «ENDFOREACH-»
+ «ENDIF-»
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE destroyChildNodes(nodeVar : String) FOR gmfgen::GenChildContainer-»
+ «FOREACH childNodes->asSequence() AS childNode-»
+ «EXPAND xpt::Common::caseVisualID FOR childNode»
+ cmd.add(getDestroyElementCommand(«nodeVar»));
+ break;
+ «ENDFOREACH-»
+«ENDDEFINE»
+
+
+«DEFINE fixElementToDeleteIfShortcut FOR gmfgen::GenTopLevelNode-»
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ if (view.getEAnnotation("Shortcut") != null) { «EXPAND xpt::Common::nonNLS»
+ req.setElementToDestroy(view);
+ }
+«ENDDEFINE»
+
+«REM»Shortcuts supported only for top-level elements«ENDREM»
+«DEFINE fixElementToDeleteIfShortcut FOR gmfgen::GenNode»«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt
new file mode 100644
index 000000000..306ca246d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/OpenDiagram.xpt
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::editpolicies::Utils»
+
+«DEFINE OpenDiagram FOR gmfgen::OpenDiagramBehaviour»
+«EXPAND xpt::Common::copyright FOR subject.getDiagram().editorGen-»
+package «subject.getDiagram().editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «editPolicyClassName» extends «EXPAND extendsList» {
+
+«EXPAND getOpenCommand-»
+
+«EXPAND openCommandClass-»
+
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::OpenDiagramBehaviour»org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy«ENDDEFINE»
+
+«DEFINE getOpenCommand FOR gmfgen::OpenDiagramBehaviour»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.commands.Command getOpenCommand(org.eclipse.gef.Request request) {
+ org.eclipse.gef.EditPart targetEditPart = getTargetEditPart(request);
+ if (false == targetEditPart.getModel() instanceof org.eclipse.gmf.runtime.notation.View) {
+ return null;
+ }
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) targetEditPart.getModel();
+ org.eclipse.gmf.runtime.notation.Style link = view.getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getHintedDiagramLinkStyle());
+ if (false == link instanceof org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle) {
+ return null;
+ }
+ return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(new OpenDiagramCommand((org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle) link));
+ }
+«ENDDEFINE»
+
+«DEFINE openCommandClass FOR gmfgen::OpenDiagramBehaviour»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static class OpenDiagramCommand extends org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle diagramFacet;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ OpenDiagramCommand(org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle linkStyle) {
+ // editing domain is taken for original diagram,
+ // if we open diagram from another file, we should use another editing domain
+ super(org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(linkStyle), «EXPAND xpt::Externalizer::accessorCall(i18nKeyForOpenCommandName()) FOR subject.getDiagram().editorGen», null);
+ diagramFacet = linkStyle;
+ }
+
+ // FIXME canExecute if !(readOnly && getDiagramToOpen == null), i.e. open works on ro diagrams only when there's associated diagram already
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ try {
+ org.eclipse.gmf.runtime.notation.Diagram diagram = getDiagramToOpen();
+ if (diagram == null) {
+ diagram = intializeNewDiagram();
+ }
+ «EXPAND xpt::navigator::getEditorInput::defineURIEditorInput('diagram') FOR subject.getDiagram()-»
+ org.eclipse.ui.IWorkbenchPage page = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.openEditor(editorInput, getEditorID());
+ return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
+ } catch (Exception ex) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't open diagram", ex);
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.Diagram getDiagramToOpen() {
+ return diagramFacet.getDiagramLink();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.notation.Diagram intializeNewDiagram() throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.gmf.runtime.notation.Diagram d = org.eclipse.gmf.runtime.diagram.core.services.ViewService.createDiagram(getDiagramDomainElement(), getDiagramKind(), getPreferencesHint());
+ if (d == null) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind");
+ }
+ diagramFacet.setDiagramLink(d);
+ «EXPAND xpt::Common::_assert('diagramFacet.eResource() != null')-»
+ diagramFacet.eResource().getContents().add(d);
+ org.eclipse.emf.ecore.EObject container = diagramFacet.eContainer();
+ while (container instanceof org.eclipse.gmf.runtime.notation.View) {
+ ((org.eclipse.gmf.runtime.notation.View) container).persist();
+ container = container.eContainer();
+ }
+ try {
+ «IF null = subject.getDiagram().editorGen.application-»
+ new org.eclipse.ui.actions.WorkspaceModifyOperation() {
+ protected void execute(org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, java.lang.reflect.InvocationTargetException, InterruptedException {
+ try {
+ «ENDIF-»
+ for (java.util.Iterator it = diagramFacet.eResource().getResourceSet().getResources().iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
+ if (nextResource.isLoaded() && !getEditingDomain().isReadOnly(nextResource)) {
+ nextResource.save(«EXPAND xpt::Common::getSaveOptions FOR subject.getDiagram()»);
+ }
+ }
+ «IF null = subject.getDiagram().editorGen.application-»
+ } catch (java.io.IOException ex) {
+ throw new java.lang.reflect.InvocationTargetException(ex, "Save operation failed");
+ }
+ }
+ }.run(null);
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e);
+ } catch (InterruptedException e) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e);
+ }
+ «ELSE-»
+ } catch (java.io.IOException ex) {
+ throw new org.eclipse.core.commands.ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", ex);
+ }
+ «ENDIF-»
+ return d;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.emf.ecore.EObject getDiagramDomainElement() {
+ // use same element as associated with EP
+ return ((org.eclipse.gmf.runtime.notation.View) diagramFacet.eContainer()).getElement();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint getPreferencesHint() {
+ // XXX prefhint from target diagram's editor?
+ return «EXPAND xpt::plugin::Activator::preferenceHintAccess FOR subject.getDiagram().editorGen»;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getDiagramKind() {
+ return «IF diagramKind = null»«EXPAND xpt::editor::VisualIDRegistry::modelID FOR subject.getDiagram()»«ELSE»"«diagramKind»"«ENDIF»;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected String getEditorID() {
+ return «IF editorID = null»«subject.getDiagram().editorGen.editor.getQualifiedClassName()».ID«ELSE»"«editorID»"«ENDIF»;
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::OpenDiagramBehaviour»«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::accessorField(i18nKeyForOpenCommandName())-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Externalizer::messageEntry(i18nKeyForOpenCommandName(), 'Open Diagram')-»
+«ENDDEFINE»
+
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt
new file mode 100644
index 000000000..5f1bca683
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/TextFeedback.xpt
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2006, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«DEFINE TextSelectionEditPolicy FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «textSelectionEditPolicyClassName» extends org.eclipse.gef.editpolicies.SelectionEditPolicy {
+
+ «EXPAND textFeedback FOR self-»
+}
+«ENDDEFINE»
+
+«DEFINE TextNonResizableEditPolicy FOR gmfgen::GenDiagram-»
+«EXPAND xpt::Common::copyright FOR editorGen-»
+package «editPoliciesPackageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «textNonResizableEditPolicyClassName» extends org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx {
+
+ «EXPAND textFeedback FOR self-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected java.util.List createSelectionHandles() {
+ org.eclipse.gef.handles.MoveHandle moveHandle =
+ new org.eclipse.gef.handles.MoveHandle((org.eclipse.gef.GraphicalEditPart) getHost());
+ moveHandle.setBorder(null);
+ moveHandle.setDragTracker(new org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx(getHost()));
+ return java.util.Collections.singletonList(moveHandle);
+ }
+}
+«ENDDEFINE»
+
+«DEFINE textFeedback FOR gmfgen::GenDiagram»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.IFigure selectionFeedbackFigure;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.IFigure focusFeedbackFigure;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.FigureListener hostPositionListener;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void showPrimarySelection() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setSelected(true);
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ showSelection();
+ showFocus();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void showSelection() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setSelected(true);
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ hideSelection();
+ addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure());
+ getHostFigure().addFigureListener(getHostPositionListener());
+ refreshSelectionFeedback();
+ hideFocus();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void hideSelection() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setSelected(false);
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (selectionFeedbackFigure != null) {
+ removeFeedback(selectionFeedbackFigure);
+ getHostFigure().removeFigureListener(getHostPositionListener());
+ selectionFeedbackFigure = null;
+ }
+ hideFocus();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void showFocus() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(true);
+ } else {
+ hideFocus();
+ addFeedback(focusFeedbackFigure = createFocusFeedbackFigure());
+ refreshFocusFeedback();
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void hideFocus() {
+ if (getHostFigure() instanceof org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) {
+ ((org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel) getHostFigure()).setFocus(false);
+ } else {
+ if (focusFeedbackFigure != null) {
+ removeFeedback(focusFeedbackFigure);
+ focusFeedbackFigure = null;
+ }
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.geometry.Rectangle getFeedbackBounds() {
+ org.eclipse.draw2d.geometry.Rectangle bounds;
+ if (getHostFigure() instanceof org.eclipse.draw2d.Label) {
+ bounds = ((org.eclipse.draw2d.Label) getHostFigure()).getTextBounds();
+ bounds.intersect(getHostFigure().getBounds());
+ } else {
+ bounds = getHostFigure().getBounds().getCopy();
+ }
+ getHostFigure().getParent().translateToAbsolute(bounds);
+ getFeedbackLayer().translateToRelative(bounds);
+ return bounds;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createSelectionFeedbackFigure() {
+ if (getHostFigure() instanceof org.eclipse.draw2d.Label) {
+ org.eclipse.draw2d.Label feedbackFigure = new org.eclipse.draw2d.Label();
+ feedbackFigure.setOpaque(true);
+ feedbackFigure.setBackgroundColor(org.eclipse.draw2d.ColorConstants.menuBackgroundSelected);
+ feedbackFigure.setForegroundColor(org.eclipse.draw2d.ColorConstants.menuForegroundSelected);
+ return feedbackFigure;
+ } else {
+ org.eclipse.draw2d.RectangleFigure feedbackFigure = new org.eclipse.draw2d.RectangleFigure();
+ feedbackFigure.setFill(false);
+ return feedbackFigure;
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.draw2d.IFigure createFocusFeedbackFigure() {
+ return new org.eclipse.draw2d.Figure() {
+
+ protected void paintFigure(org.eclipse.draw2d.Graphics graphics) {
+ graphics.drawFocus(getBounds().getResized(-1, -1));
+ }
+ };
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void updateLabel(org.eclipse.draw2d.Label target) {
+ org.eclipse.draw2d.Label source = (org.eclipse.draw2d.Label) getHostFigure();
+ target.setText(source.getText());
+ target.setTextAlignment(source.getTextAlignment());
+ target.setFont(source.getFont());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshSelectionFeedback() {
+ if (selectionFeedbackFigure != null) {
+ if (selectionFeedbackFigure instanceof org.eclipse.draw2d.Label) {
+ updateLabel((org.eclipse.draw2d.Label) selectionFeedbackFigure);
+ selectionFeedbackFigure.setBounds(getFeedbackBounds());
+ } else {
+ selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5));
+ }
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected void refreshFocusFeedback() {
+ if (focusFeedbackFigure != null) {
+ focusFeedbackFigure.setBounds(getFeedbackBounds());
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void refreshFeedback() {
+ refreshSelectionFeedback();
+ refreshFocusFeedback();
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.draw2d.FigureListener getHostPositionListener() {
+ if (hostPositionListener == null) {
+ hostPositionListener = new org.eclipse.draw2d.FigureListener() {
+ public void figureMoved(org.eclipse.draw2d.IFigure source) {
+ refreshFeedback();
+ }
+ };
+ }
+ return hostPositionListener;
+ }
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
new file mode 100644
index 000000000..cdb4a132c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
@@ -0,0 +1,90 @@
+import xpt.diagram.editpolicies.LinkUtils;
+import xpt.GenModelUtils;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Utils;
+
+helper hasChildrenOrCompartments(node : genModel::GenNode) : Boolean {
+ return not node.childNodes->isEmpty() or not node.compartments->isEmpty()
+}
+
+helper getContainerVariable(modelFacet : genModel::TypeLinkModelFacet) : String {
+ return (if null <> modelFacet.sourceMetaFeature then 'container' else 'source' endif)
+}
+
+helper getValidLinkConstraints(diagram : genModel::GenDiagram) : Sequence(genModel::GenLinkConstraints) {
+ return diagram.links->select(l | null <> l.creationConstraints and l.creationConstraints.isValid())->collect(l | l.creationConstraints)
+}
+
+helper getAllPotentialLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedLinks(linkEnd)->select(link | isCreationAllowed(link))
+}
+
+helper getReroutableTypeLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedReroutableLinks(linkEnd)->select(link | isTypeLink(link))
+}
+
+helper getReroutableRefLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return getAllRelatedReroutableLinks(linkEnd)->select(link | isRefLink(link))
+}
+
+helper getAllRelatedLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) or canBeTarget(link, linkEnd))->asSequence()
+}
+
+helper getAllRelatedReroutableLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) and link.sourceReorientingAllowed or (canBeTarget(link, linkEnd) and link.targetReorientingAllowed))->asSequence()
+}
+
+helper isCreationAllowed(link : genModel::GenLink) : Boolean {
+ return null <> link.modelFacet and (link.outgoingCreationAllowed or link.incomingCreationAllowed)
+}
+
+helper createStartLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return createStartOutgoingLinkCommand(link, linkEnd) or createStartIncomingLinkCommand(link, linkEnd)
+}
+
+helper createStartOutgoingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isSelf(link, linkEnd) or (isOutgoing(link, linkEnd) and link.outgoingCreationAllowed)
+}
+
+helper createStartIncomingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isIncoming(link, linkEnd) and link.incomingCreationAllowed
+}
+
+helper createCompleteLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return createCompleteIncomingLinkCommand(link, linkEnd) or createCompleteOutgoingLinkCommand(link, linkEnd)
+}
+
+helper createCompleteIncomingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isSelf(link, linkEnd) or (isIncoming(link, linkEnd) and link.outgoingCreationAllowed)
+}
+
+helper createCompleteOutgoingLinkCommand(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return isOutgoing(link, linkEnd) and link.incomingCreationAllowed
+}
+
+helper checkSource(reversedRequest : Boolean, isCompleteCommand : Boolean) : Boolean {
+ return not reversedRequest or isCompleteCommand
+}
+
+helper checkTarget(reversedRequest : Boolean, isCompleteCommand : Boolean) : Boolean {
+ return reversedRequest or isCompleteCommand
+}
+
+helper isSelf(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeSource(link, linkEnd) and canBeTarget(link, linkEnd)
+}
+
+helper isOutgoing(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeSource(link, linkEnd) and not canBeTarget(link, linkEnd)
+}
+
+helper isIncoming(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
+ return canBeTarget(link, linkEnd) and not canBeSource(link, linkEnd)
+}
+
+helper i18nKeyForOpenCommandName() : String {
+ return 'CommandName.OpenDiagram'
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt
new file mode 100644
index 000000000..675eda752
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/childContainerCreateCommand.xpt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE childContainerCreateCommand FOR Sequence(gmfgen::GenNode)-»
+«IF not self->isEmpty()-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
+«FOREACH self AS n-»
+ «EXPAND childNodeCreateCommand(n) FOR n.modelFacet-»
+«ENDFOREACH-»
+ return super.getCreateCommand(req);
+ }
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE childNodeCreateCommand(node : gmfgen::GenNode) FOR gmfgen::TypeModelFacet-»
+if («EXPAND xpt::providers::ElementTypes::accessElementType FOR node» == req.getElementType()) {
+ return getGEFWrapper(new «node.getCreateCommandQualifiedClassName()»(req));
+}
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt
new file mode 100644
index 000000000..297223b6f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/linkCommands.xpt
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2007, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Dmitry Stadnik (Borland) - creation logic was moved in commands
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::diagram::editpolicies::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«REM»
+ * Start start of link creation.
+ * User click to this editpart and start dragging with link tool.
+ * Complete end of the command
+ * User points to this editpart as a link target and release mouse button.
+ *
+ * Outgoing the node is link source
+ * This element could be a source for this type of link.
+ * Incoming the node is link destination
+ * This element could be a target for this type of link.
+ *
+ * Parameters:
+ *
+ * diagram GenDiagram used to collect all defined links
+ *
+ * this Instance of GenLinkEnd for the element link could be creates to/from.
+ * This could be GenNode or GenLink in case of links to links,
+ * in the latter case it is assumed that its a TypeLink (so its model facet is LinkTypeModelFacet),
+ * because RefLinks don't have underlying semantic identity
+ *
+«ENDREM»
+
+«DEFINE linkCommands FOR gmfgen::GenLinkEnd-»
+ «IF getAllPotentialLinks(self)->size() > 0-»
+ «EXPAND createLinkCommands -»
+ «ENDIF-»
+ «IF getReroutableTypeLinks(self)->size() > 0-»
+ «EXPAND reorientTypeLinkCommands -»
+ «ENDIF-»
+ «IF getReroutableRefLinks(self)->size() > 0-»
+ «EXPAND reorientRefLinkCommands -»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE createLinkCommands FOR gmfgen::GenLinkEnd-»
+
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ org.eclipse.gef.commands.Command command = req.getTarget() == null ?
+ getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+}
+
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getStartCreateRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ «EXPAND startLinkCommands(self) FOREACH getAllPotentialLinks(self)-»
+ return null;
+}
+
+«EXPAND xpt::Common::generatedMemberComment»
+protected org.eclipse.gef.commands.Command getCompleteCreateRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
+ «EXPAND completeLinkCommands(self) FOREACH getAllPotentialLinks(self)-»
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE startLinkCommands(linkEnd : gmfgen::GenLinkEnd) FOR gmfgen::GenLink-»
+if («EXPAND xpt::providers::ElementTypes::accessElementType» == req.getElementType()) {
+ «IF createStartLinkCommand(self, linkEnd)-»
+ return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
+ «IF createStartIncomingLinkCommand(self, linkEnd)-»
+ req.getTarget(), req.getSource()
+ «ELSE-»
+ req.getSource(), req.getTarget()
+ «ENDIF-»
+ ));
+ «ELSE-»
+ return null;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE completeLinkCommands(linkEnd : gmfgen::GenLinkEnd) FOR gmfgen::GenLink-»
+if («EXPAND xpt::providers::ElementTypes::accessElementType» == req.getElementType()) {
+ «IF createCompleteLinkCommand(self, linkEnd)-»
+ return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
+ «IF createCompleteOutgoingLinkCommand(self, linkEnd)-»
+ req.getTarget(), req.getSource()
+ «ELSE-»
+ req.getSource(), req.getTarget()
+ «ENDIF-»
+ ));
+ «ELSE-»
+ return null;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE reorientTypeLinkCommands FOR gmfgen::GenLinkEnd-»
+
+«EXPAND xpt::Common::generatedMemberComment(
+ 'Returns command to reorient EClass based link. New link target or source
+should be the domain model element associated with this node.
+'
+)»
+protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ «EXPAND reorientLinkCommand FOREACH getReroutableTypeLinks(self)-»
+ }
+ return super.getReorientRelationshipCommand(req);
+}
+«ENDDEFINE»
+
+«DEFINE reorientRefLinkCommands FOR gmfgen::GenLinkEnd-»
+
+«EXPAND xpt::Common::generatedMemberComment(
+ 'Returns command to reorient EReference based link. New link target or source
+should be the domain model element associated with this node.
+'
+)»
+protected org.eclipse.gef.commands.Command getReorientReferenceRelationshipCommand(
+ org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ «EXPAND reorientLinkCommand FOREACH getReroutableRefLinks(self)-»
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+}
+«ENDDEFINE»
+
+«DEFINE reorientLinkCommand FOR gmfgen::GenLink-»
+«EXPAND xpt::Common::caseVisualID»
+ return getGEFWrapper(new «getReorientCommandQualifiedClassName()»(req));
+«ENDDEFINE»

Back to the top