Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Pascual2014-11-13 16:02:30 +0000
committerGabriel Pascual2015-01-29 13:42:09 +0000
commit3b21c2baf52df9dcdf58c34c248d5e213033dc48 (patch)
treeeb0896d4ef549c7d1a91603dfb4f5a76818a5ce0
parent8c6be54105c3480e839406fe8dd41043570bd8b9 (diff)
downloadorg.eclipse.papyrus-3b21c2baf52df9dcdf58c34c248d5e213033dc48.tar.gz
org.eclipse.papyrus-3b21c2baf52df9dcdf58c34c248d5e213033dc48.tar.xz
org.eclipse.papyrus-3b21c2baf52df9dcdf58c34c248d5e213033dc48.zip
430548: [Constraints] ConstraintLink not show on diagram after drag and
drop from Model Explorer https://bugs.eclipse.org/bugs/show_bug.cgi?id=430548 - Show the contraintlink while dropping a constraint in a class diagram Change-Id: Ibe3678e3604420fc831372ade4770d244a72242e Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr> Signed-off-by: Gabriel Pascual <gabriel.pascual@all4tec.net>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ClassDiagramDragDropEditPolicy.java104
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ShowConstraintContextLink.java15
2 files changed, 80 insertions, 39 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ClassDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ClassDiagramDragDropEditPolicy.java
index 239eb4586d0..cb4745ee29a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ClassDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/ClassDiagramDragDropEditPolicy.java
@@ -19,25 +19,26 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.GMFtoGEFCommandWrapper;
import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.AssociationClassHelper;
import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.ClassLinkMappingHelper;
import org.eclipse.papyrus.uml.diagram.clazz.custom.helper.ContainmentHelper;
@@ -49,6 +50,7 @@ import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.AssociationNodeEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPartCN;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ConstraintEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DependencyEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DependencyNodeEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.EnumerationLiteralEditPart;
@@ -67,8 +69,10 @@ import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.UsageEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.strategy.paste.ShowConstraintContextLink;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.AssociationClass;
+import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Dependency;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.InstanceSpecification;
@@ -107,6 +111,7 @@ public class ClassDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPol
droppableElementsVisualID.add(PackageEditPart.VISUAL_ID);
droppableElementsVisualID.add(InstanceSpecificationEditPart.VISUAL_ID);
droppableElementsVisualID.add(InstanceSpecificationLinkEditPart.VISUAL_ID);
+ droppableElementsVisualID.add(ConstraintEditPart.VISUAL_ID);
return droppableElementsVisualID;
}
@@ -143,6 +148,7 @@ public class ClassDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPol
return dropAssociation(dropRequest, semanticLink);
case NestedClassForClassEditPart.VISUAL_ID:
case ClassEditPartCN.VISUAL_ID:
+
case PackageEditPartCN.VISUAL_ID:
case ModelEditPartCN.VISUAL_ID:
return dropChildNodeWithContainmentLink(dropRequest, semanticLink, nodeVISUALID);
@@ -150,6 +156,8 @@ public class ClassDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPol
case ClassEditPart.VISUAL_ID:
case PackageEditPart.VISUAL_ID:
return dropTopLevelNodeWithContainmentLink(dropRequest, semanticLink, nodeVISUALID);
+ case ConstraintEditPart.VISUAL_ID:
+ return dropConstraintNode(dropRequest, (Constraint) semanticLink, nodeVISUALID);
default:
return UnexecutableCommand.INSTANCE;
}
@@ -350,6 +358,26 @@ public class ClassDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPol
return new ICommandProxy(cc);
}
+
+ /**
+ * Use to drop a constraint, will also display the contextlink
+ *
+ * @param dropRequest
+ * @param droppedConstraint
+ * @param nodeVISUALID
+ * @return
+ */
+ protected Command dropConstraintNode(DropObjectsRequest dropRequest, Constraint droppedConstraint, int nodeVISUALID) {
+ ICommand dropConstraintCommand = getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), droppedConstraint, dropRequest);
+ if (droppedConstraint.getContext() != null) {
+ ShowConstraintContextLink showConstraintContextLink = new ShowConstraintContextLink(getEditingDomain(), (GraphicalEditPart) getHost(), droppedConstraint);
+ dropConstraintCommand = dropConstraintCommand.compose(showConstraintContextLink);
+ }
+ return GMFtoGEFCommandWrapper.wrap(dropConstraintCommand);
+ }
+
+
+
/**
* call the mechanism to drop a binary link without specific type
*
@@ -417,39 +445,39 @@ public class ClassDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPol
return cmd;
}
}
-
- /**
- * @Overrided org.eclipse.papyrus.uml.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy to resolve cause of repeated definition
- * of attributes shown outside classes when dragged back
- *
- * @param hostEP
- * The host edit part which will be the parent of the new node
- * @param semanticHint
- * the semantic hint of the view to create
- * @param location
- * the drop location
- * @param droppedObject
- * the object to drop
- * @param request
- * the drop request (use to test ctrl key)
- * @return the creation node command
- */
- @Override
- protected ICommand getDefaultDropNodeCommand(EditPart hostEP, String semanticHint, Point absoluteLocation, EObject droppedObject, DropObjectsRequest request) {
- GraphicalEditPart parent = (GraphicalEditPart) getHost();
- if (parent instanceof ListCompartmentEditPart) {
- @SuppressWarnings("unchecked")
- List<EditPart> allChildren = parent.getChildren();
- for (EditPart nextChild : allChildren) {
- if (!(nextChild instanceof GraphicalEditPart)) {
- continue;
- }
- EObject nextChildSemantic = ((GraphicalEditPart) nextChild).resolveSemanticElement();
- if (nextChildSemantic == droppedObject) {
- return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
- }
- }
- }
- return super.getDefaultDropNodeCommand(hostEP, semanticHint, absoluteLocation, droppedObject, request);
- }
+
+ /**
+ * @Overrided org.eclipse.papyrus.uml.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy to resolve cause of repeated definition
+ * of attributes shown outside classes when dragged back
+ *
+ * @param hostEP
+ * The host edit part which will be the parent of the new node
+ * @param semanticHint
+ * the semantic hint of the view to create
+ * @param location
+ * the drop location
+ * @param droppedObject
+ * the object to drop
+ * @param request
+ * the drop request (use to test ctrl key)
+ * @return the creation node command
+ */
+ @Override
+ protected ICommand getDefaultDropNodeCommand(EditPart hostEP, String semanticHint, Point absoluteLocation, EObject droppedObject, DropObjectsRequest request) {
+ GraphicalEditPart parent = (GraphicalEditPart) getHost();
+ if (parent instanceof ListCompartmentEditPart) {
+ @SuppressWarnings("unchecked")
+ List<EditPart> allChildren = parent.getChildren();
+ for (EditPart nextChild : allChildren) {
+ if (!(nextChild instanceof GraphicalEditPart)) {
+ continue;
+ }
+ EObject nextChildSemantic = ((GraphicalEditPart) nextChild).resolveSemanticElement();
+ if (nextChildSemantic == droppedObject) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+ }
+ }
+ return super.getDefaultDropNodeCommand(hostEP, semanticHint, absoluteLocation, droppedObject, request);
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ShowConstraintContextLink.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ShowConstraintContextLink.java
index 5ddc5fb3a67..0e6be93585d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ShowConstraintContextLink.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/ShowConstraintContextLink.java
@@ -62,9 +62,22 @@ public class ShowConstraintContextLink extends AbstractTransactionalCommand {
this.constraint = (Constraint) constraintView.getElement();
}
+ /**
+ * Show the <<context>> link between a constraint and its context
+ *
+ * @param domain
+ * @param targetEditPart
+ * @param constraint
+ */
+ public ShowConstraintContextLink(TransactionalEditingDomain domain, GraphicalEditPart targetEditPart, Constraint constraint) {
+ super(domain, "Show Constraint Context Link", null);
+ this.diagramEP = DiagramEditPartsUtil.getDiagramEditPart(targetEditPart);
+ this.constraint = constraint;
+ }
+
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
* org.eclipse.core.runtime.IAdaptable)

Back to the top