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/DecisionNodeItemSemanticEditPolicy.java')
-rw-r--r--uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/DecisionNodeItemSemanticEditPolicy.java150
1 files changed, 150 insertions, 0 deletions
diff --git a/uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/DecisionNodeItemSemanticEditPolicy.java b/uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/DecisionNodeItemSemanticEditPolicy.java
new file mode 100644
index 00000000000..b70ba549187
--- /dev/null
+++ b/uml/org.eclipse.papyrus.diagram.activity/src/org/eclipse/papyrus/diagram/activity/edit/policies/DecisionNodeItemSemanticEditPolicy.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * 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.List;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+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.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Diagram;
+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.ControlFlowCreateCommand;
+import org.eclipse.papyrus.diagram.activity.edit.commands.ControlFlowReorientCommand;
+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.commands.ObjectFlowCreateCommand;
+import org.eclipse.papyrus.diagram.activity.edit.commands.ObjectFlowReorientCommand;
+import org.eclipse.papyrus.diagram.activity.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ControlFlowEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ElementOwnedCommentEditPart;
+import org.eclipse.papyrus.diagram.activity.edit.parts.ObjectFlowEditPart;
+import org.eclipse.papyrus.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.papyrus.diagram.common.ids.ReorientLinkIDs;
+import org.eclipse.papyrus.diagram.common.util.DiagramEditPartsUtil;
+import org.eclipse.papyrus.diagram.common.util.MultiDiagramUtil;
+
+/**
+ * @generated
+ */
+public class DecisionNodeItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ CompoundCommand cc = getDestroyEdgesCommand();
+ addDestroyShortcutsCommand(cc);
+ cc.add(getGEFWrapper(new DestroyElementCommand(req)));
+ return cc.unwrap();
+ }
+
+ /**
+ * @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.ControlFlow_3001 == req.getElementType()) {
+ return getGEFWrapper(new ControlFlowCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ObjectFlow_3002 == req.getElementType()) {
+ return getGEFWrapper(new ObjectFlowCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ 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.ControlFlow_3001 == req.getElementType()) {
+ return getGEFWrapper(new ControlFlowCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ if (UMLElementTypes.ObjectFlow_3002 == req.getElementType()) {
+ return getGEFWrapper(new ObjectFlowCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ 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 EClass based link. New link target or source should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ @Override
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+
+ // add the view element
+ req.setParameter(ReorientLinkIDs.nodeEditPart, ((IGraphicalEditPart) this.getHost()).getNotationView());
+ // add the view link
+ List list = DiagramEditPartsUtil.getEObjectViews(req.getRelationship());
+ if (list.size() > 0) {
+ req.setParameter(ReorientLinkIDs.linkEditPart, list.get(0));
+ }
+
+ switch (getVisualID(req)) {
+ case ControlFlowEditPart.VISUAL_ID:
+ return getGEFWrapper(new ControlFlowReorientCommand(req));
+ case ObjectFlowEditPart.VISUAL_ID:
+ return getGEFWrapper(new ObjectFlowReorientCommand(req));
+ }
+ return super.getReorientRelationshipCommand(req);
+ }
+
+ /**
+ * 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