Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-02-21 11:23:24 -0500
committercletavernie2012-02-21 11:23:24 -0500
commitb41ca4b90a30f657c4057c05a30b1775709d4ce8 (patch)
treeb774f6dc794fbf5e26f884c001c33c743a0d2dc6 /plugins
parent7c4a985d76cedb06b5aeb0586d632416b5f7fb6f (diff)
downloadorg.eclipse.papyrus-b41ca4b90a30f657c4057c05a30b1775709d4ce8.tar.gz
org.eclipse.papyrus-b41ca4b90a30f657c4057c05a30b1775709d4ce8.tar.xz
org.eclipse.papyrus-b41ca4b90a30f657c4057c05a30b1775709d4ce8.zip
364795: [Sequence Diagram] - Nested combined fragments creation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364795
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java46
1 files changed, 36 insertions, 10 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java
index 6f738722cd5..dbff1679a13 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/InteractionFragmentEditPart.java
@@ -29,6 +29,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
import org.eclipse.uml2.uml.InteractionFragment;
import org.eclipse.uml2.uml.Lifeline;
@@ -142,20 +143,32 @@ public abstract class InteractionFragmentEditPart extends ShapeNodeEditPart {
List<Lifeline> coveredLifelinesToAdd = new ArrayList<Lifeline>();
List<Lifeline> coveredLifelinesToRemove = new ArrayList<Lifeline>();
- for(Object child : getParent().getChildren()) {
- if(child instanceof LifelineEditPart) {
- LifelineEditPart lifelineEditPart = (LifelineEditPart)child;
- Lifeline lifeline = (Lifeline)lifelineEditPart.resolveSemanticElement();
- if(newBound.intersects(lifelineEditPart.getFigure().getBounds())) {
- if(!coveredLifelines.contains(lifeline)) {
- coveredLifelinesToAdd.add(lifeline);
+ EditPart interactionCompartment = getInteractionCompartment();
+ if (interactionCompartment != null) {
+ this.getFigure().translateToAbsolute(newBound);
+ for (Object child : interactionCompartment.getChildren()) {
+ if (child instanceof LifelineEditPart) {
+ LifelineEditPart lifelineEditPart = (LifelineEditPart) child;
+ Lifeline lifeline = (Lifeline) lifelineEditPart
+ .resolveSemanticElement();
+ LifelineDotLineCustomFigure dotLineFigure = lifelineEditPart
+ .getPrimaryShape().getFigureLifelineDotLineFigure();
+ Rectangle dotLineBounds = dotLineFigure.getBounds()
+ .getCopy();
+ Rectangle centralLineBounds = new Rectangle(
+ dotLineBounds.x() + dotLineBounds.width() / 2,
+ dotLineBounds.y(), 1, dotLineBounds.height());
+ dotLineFigure.translateToAbsolute(centralLineBounds);
+ if (newBound.intersects(centralLineBounds)) {
+ if (!coveredLifelines.contains(lifeline)) {
+ coveredLifelinesToAdd.add(lifeline);
+ }
+ } else if (coveredLifelines.contains(lifeline)) {
+ coveredLifelinesToRemove.add(lifeline);
}
- } else if(coveredLifelines.contains(lifeline)) {
- coveredLifelinesToRemove.add(lifeline);
}
}
}
-
if(!coveredLifelinesToAdd.isEmpty()) {
CommandHelper.executeCommandWithoutHistory(getEditingDomain(), AddCommand.create(getEditingDomain(), combinedFragment, UMLPackage.eINSTANCE.getInteractionFragment_Covered(), coveredLifelinesToAdd));
}
@@ -164,5 +177,18 @@ public abstract class InteractionFragmentEditPart extends ShapeNodeEditPart {
}
}
+
+ /**
+ * Find parent editpart of lifeline
+ * @return EditPart
+ */
+ public EditPart getInteractionCompartment() {
+ EditPart editPart = getParent();
+ while (editPart != null
+ && !(editPart instanceof InteractionInteractionCompartmentEditPart)) {
+ editPart = editPart.getParent();
+ }
+ return editPart;
+ }
}

Back to the top