|
Lines 29-34
Link Here
|
| 29 |
import org.eclipse.gmf.runtime.notation.Bounds; |
29 |
import org.eclipse.gmf.runtime.notation.Bounds; |
| 30 |
import org.eclipse.gmf.runtime.notation.Shape; |
30 |
import org.eclipse.gmf.runtime.notation.Shape; |
| 31 |
import org.eclipse.gmf.runtime.notation.View; |
31 |
import org.eclipse.gmf.runtime.notation.View; |
|
|
32 |
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure; |
| 32 |
import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper; |
33 |
import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper; |
| 33 |
import org.eclipse.uml2.uml.InteractionFragment; |
34 |
import org.eclipse.uml2.uml.InteractionFragment; |
| 34 |
import org.eclipse.uml2.uml.Lifeline; |
35 |
import org.eclipse.uml2.uml.Lifeline; |
|
Lines 142-161
Link Here
|
| 142 |
|
143 |
|
| 143 |
List<Lifeline> coveredLifelinesToAdd = new ArrayList<Lifeline>(); |
144 |
List<Lifeline> coveredLifelinesToAdd = new ArrayList<Lifeline>(); |
| 144 |
List<Lifeline> coveredLifelinesToRemove = new ArrayList<Lifeline>(); |
145 |
List<Lifeline> coveredLifelinesToRemove = new ArrayList<Lifeline>(); |
| 145 |
for(Object child : getParent().getChildren()) { |
146 |
EditPart interactionCompartment = getInteractionCompartment(); |
| 146 |
if(child instanceof LifelineEditPart) { |
147 |
if (interactionCompartment != null) { |
| 147 |
LifelineEditPart lifelineEditPart = (LifelineEditPart)child; |
148 |
this.getFigure().translateToAbsolute(newBound); |
| 148 |
Lifeline lifeline = (Lifeline)lifelineEditPart.resolveSemanticElement(); |
149 |
for (Object child : interactionCompartment.getChildren()) { |
| 149 |
if(newBound.intersects(lifelineEditPart.getFigure().getBounds())) { |
150 |
if (child instanceof LifelineEditPart) { |
| 150 |
if(!coveredLifelines.contains(lifeline)) { |
151 |
LifelineEditPart lifelineEditPart = (LifelineEditPart) child; |
| 151 |
coveredLifelinesToAdd.add(lifeline); |
152 |
Lifeline lifeline = (Lifeline) lifelineEditPart |
|
|
153 |
.resolveSemanticElement(); |
| 154 |
LifelineDotLineCustomFigure dotLineFigure = lifelineEditPart |
| 155 |
.getPrimaryShape().getFigureLifelineDotLineFigure(); |
| 156 |
Rectangle dotLineBounds = dotLineFigure.getBounds() |
| 157 |
.getCopy(); |
| 158 |
Rectangle centralLineBounds = new Rectangle( |
| 159 |
dotLineBounds.x() + dotLineBounds.width() / 2, |
| 160 |
dotLineBounds.y(), 1, dotLineBounds.height()); |
| 161 |
dotLineFigure.translateToAbsolute(centralLineBounds); |
| 162 |
if (newBound.intersects(centralLineBounds)) { |
| 163 |
if (!coveredLifelines.contains(lifeline)) { |
| 164 |
coveredLifelinesToAdd.add(lifeline); |
| 165 |
} |
| 166 |
} else if (coveredLifelines.contains(lifeline)) { |
| 167 |
coveredLifelinesToRemove.add(lifeline); |
| 152 |
} |
168 |
} |
| 153 |
} else if(coveredLifelines.contains(lifeline)) { |
|
|
| 154 |
coveredLifelinesToRemove.add(lifeline); |
| 155 |
} |
169 |
} |
| 156 |
} |
170 |
} |
| 157 |
} |
171 |
} |
| 158 |
|
|
|
| 159 |
if(!coveredLifelinesToAdd.isEmpty()) { |
172 |
if(!coveredLifelinesToAdd.isEmpty()) { |
| 160 |
CommandHelper.executeCommandWithoutHistory(getEditingDomain(), AddCommand.create(getEditingDomain(), combinedFragment, UMLPackage.eINSTANCE.getInteractionFragment_Covered(), coveredLifelinesToAdd)); |
173 |
CommandHelper.executeCommandWithoutHistory(getEditingDomain(), AddCommand.create(getEditingDomain(), combinedFragment, UMLPackage.eINSTANCE.getInteractionFragment_Covered(), coveredLifelinesToAdd)); |
| 161 |
} |
174 |
} |
|
Lines 164-168
Link Here
|
| 164 |
} |
177 |
} |
| 165 |
|
178 |
|
| 166 |
} |
179 |
} |
|
|
180 |
|
| 181 |
/** |
| 182 |
* Find parent editpart of lifeline |
| 183 |
* @return EditPart |
| 184 |
*/ |
| 185 |
public EditPart getInteractionCompartment() { |
| 186 |
EditPart editPart = getParent(); |
| 187 |
while (editPart != null |
| 188 |
&& !(editPart instanceof InteractionInteractionCompartmentEditPart)) { |
| 189 |
editPart = editPart.getParent(); |
| 190 |
} |
| 191 |
return editPart; |
| 192 |
} |
| 167 |
|
193 |
|
| 168 |
} |
194 |
} |