From 7b82a35e7c2bc41fdd2b8575e3100a5fe6e176ee Mon Sep 17 00:00:00 2001 From: Céline Janssens Date: Wed, 27 May 2015 18:25:55 +0200 Subject: Bug 467979: Unexpected additionnal link present on stereotyped links https://bugs.eclipse.org/bugs/show_bug.cgi?id=467979 - Fix the creation of multiple comment Views - override refresh method in AppliedStereootypeCommentLinkEditPart because a Link with a null target is not refreshed by default. Change-Id: Id13e96e371fdfc8759ad9d523f29f5940c6759f6 Signed-off-by: Céline Janssens Reviewed-on: https://git.eclipse.org/r/48846 Tested-by: Hudson CI Reviewed-by: Benoit Maggi Tested-by: Benoit Maggi Reviewed-by: Camille Letavernier --- .../clazz/edit/parts/AssociationEditPart.java | 2 ++ ...AbstractAppliedStereotypeDisplayEditPolicy.java | 2 +- ...CommentShapeForAppliedStereotypeEditPolicy.java | 4 +++ .../AppliedStereotypesCommentLinkEditPart.java | 40 ++++++++++++++++++++++ .../AppliedStereotypeCommentEditPolicy.java | 8 +++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/parts/AssociationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/parts/AssociationEditPart.java index affc5b26088..f1bb55fdce4 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/parts/AssociationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/edit/parts/AssociationEditPart.java @@ -50,6 +50,8 @@ public class AssociationEditPart extends AbstractAssociationEditPart implements installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); + + } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java index 321b4bd7297..c66b20129cd 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java @@ -331,7 +331,7 @@ public abstract class AbstractAppliedStereotypeDisplayEditPolicy extends Graphic if (helper.isStereotypeView(child)) { if (((View) child).getElement() instanceof Stereotype) { Stereotype childStereotype = (Stereotype) ((View) child).getElement(); - if (!hostSemanticElement.isStereotypeApplied(childStereotype)) { + if (hostSemanticElement != null && !hostSemanticElement.isStereotypeApplied(childStereotype)) { executeStereotypeViewRemove(hostEditPart, (View) child); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java index a831e3e7dda..66c068e9987 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java @@ -213,6 +213,10 @@ public class CommentShapeForAppliedStereotypeEditPolicy extends AbstractAppliedS if (getUMLElement() == null) { executeAppliedStereotypeCommentDeletion(domain, commentNode); } + + if (commentNode.getSourceEdges().size() == 0 && commentNode.getTargetEdges().size() == 0) { + executeAppliedStereotypeCommentDeletion(domain, commentNode); + } } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypesCommentLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypesCommentLinkEditPart.java index e0f9ead2547..aca9b0b2fed 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypesCommentLinkEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypesCommentLinkEditPart.java @@ -18,6 +18,7 @@ import org.eclipse.draw2d.Graphics; import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart; +import org.eclipse.papyrus.uml.diagram.stereotype.edition.Activator; /** @@ -66,4 +67,43 @@ public class AppliedStereotypesCommentLinkEditPart extends ConnectionEditPart { this.setLineStyle(Graphics.LINE_DASH); } } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart#refresh() + * + */ + @Override + public void refresh() { + + try { + getEditingDomain().runExclusive(new Runnable() { + + public void run() { + refreshVisuals(); + refreshChildren(); + refreshSourceAnchor(); + refreshTargetAnchor(); + refreshSourceConnections(); + refreshTargetConnections(); + } + }); + } catch (InterruptedException e) { + Activator.log.error(e); + + } + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart#refreshVisuals() + * + */ + @Override + protected void refreshVisuals() { + + super.refreshVisuals(); + if (this.getTarget() == null || this.getSource() == null) { + setVisibility(false); + } + } + } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentEditPolicy.java index b5e09c80e9c..f437485fbf2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentEditPolicy.java @@ -116,6 +116,14 @@ public class AppliedStereotypeCommentEditPolicy extends AppliedStereotypeNodeLab if (eventType == Notification.REMOVE && notification.getOldValue().equals(hostView) && object == null) { executeAppliedStereotypeCommentDeletion(hostEditPart.getEditingDomain(), comment); } + + if (comment.getTargetEdges() != null) { + + // If the Target View is null then remove the Comment View + if (eventType == Notification.REMOVE && notification.getOldValue().equals(hostView) && comment.getTargetEdges().size() == 0) { + executeAppliedStereotypeCommentDeletion(hostEditPart.getEditingDomain(), comment); + } + } } -- cgit v1.2.3