Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/ActivityPartition2ItemSemanticEditPolicy.java')
-rw-r--r--uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/ActivityPartition2ItemSemanticEditPolicy.java202
1 files changed, 202 insertions, 0 deletions
diff --git a/uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/ActivityPartition2ItemSemanticEditPolicy.java b/uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/ActivityPartition2ItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..7273fa94985
--- /dev/null
+++ b/uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/ActivityPartition2ItemSemanticEditPolicy.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2008
+ * Conselleria de Infraestructuras y Transporte, Generalitat de la Comunitat Valenciana .
+ * 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:
+ * Francisco Javier Cano Muñoz (Prodevelop) - initial API implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.diagram.activity.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.diagram.activity.edit.commands.CommentAnnotatedElementCreateCommand;
+import org.eclipse.papyrus.diagram.activity.edit.commands.CommentAnnotatedElementReorientCommand;
+import org.eclipse.papyrus.diagram.activity.edit.commands.ElementOwnedCommentCreateCommand;
+import org.eclipse.papyrus.diagram.activity.edit.commands.ElementOwnedCommentReorientCommand;
+import org.eclipse.papyrus.diagram.activity.edit.parts.AcceptEventAction2EditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ActivityFinalNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ActivityPartition2EditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ActivityPartitionActivityPartitionCompartment2EditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.CallBehaviorActionEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.CallOperationActionEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.CreateObjectActionEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.DataStoreNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.DecisionNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ElementOwnedCommentEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.FlowFinalNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ForkNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.InitialNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.JoinNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.MergeNodeEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.OpaqueAction2EditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.PinEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.SendObjectActionEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.SendSignalActionEditPart;
+import org.eclipse.papyrus.diagram.activity.part.UMLVisualIDRegistry;
+import org.eclipse.papyrus.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.papyrus.diagram.common.util.DiagramEditPartsUtil;
+import org.eclipse.papyrus.diagram.common.util.MultiDiagramUtil;
+
+
+/**
+ * @generated
+ */
+public class ActivityPartition2ItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompoundCommand cc = getDestroyEdgesCommand();
+ addDestroyChildNodesCommand(cc);
+ addDestroyShortcutsCommand(cc);
+ cc.add(getGEFWrapper(new DestroyElementCommand(req)));
+ return cc.unwrap();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addDestroyChildNodesCommand(CompoundCommand cmd) {
+ View view = (View) getHost().getModel();
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation != null) {
+ return;
+ }
+ for (Iterator it = view.getChildren().iterator(); it.hasNext();) {
+ Node node = (Node) it.next();
+ switch (UMLVisualIDRegistry.getVisualID(node)) {
+ case ActivityPartitionActivityPartitionCompartment2EditPart.VISUAL_ID:
+ for (Iterator cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (UMLVisualIDRegistry.getVisualID(cnode)) {
+ case ActivityPartition2EditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case OpaqueAction2EditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case SendObjectActionEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case SendSignalActionEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case AcceptEventAction2EditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case ActivityFinalNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case DecisionNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case MergeNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case InitialNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case DataStoreNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case FlowFinalNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case ForkNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case JoinNodeEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case PinEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case CreateObjectActionEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case CallBehaviorActionEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ case CallOperationActionEditPart.VISUAL_ID:
+ cmd.add(getDestroyElementCommand(cnode));
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (UMLElementTypes.ElementOwnedComment_3005 == req.getElementType()) {
+ return getGEFWrapper(new ElementOwnedCommentCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_3006 == req.getElementType()) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ Diagram diagram = DiagramEditPartsUtil.findDiagramFromEditPart(getHost());
+ if (diagram != null) {
+ req.getParameters().put(MultiDiagramUtil.BelongToDiagramSource, diagram);
+ }
+ if (UMLElementTypes.ElementOwnedComment_3005 == req.getElementType()) {
+ return null;
+ }
+ if (UMLElementTypes.CommentAnnotatedElement_3006 == req.getElementType()) {
+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * Returns command to reorient EReference based link. New link target or source should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ @Override
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ElementOwnedCommentEditPart.VISUAL_ID:
+ return getGEFWrapper(new ElementOwnedCommentReorientCommand(req));
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+
+}

Back to the top