Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2017-07-05 12:55:18 +0000
committerSteve Monnier2017-07-26 07:53:45 +0000
commitc6ad066eb1f59f2e802c968edcc36b83ef1a4e22 (patch)
tree962e2622540434c8d86da8702aff9a7d98a5c36c
parent2b92e230ae5d8be89d131737fe5ec12da354d763 (diff)
downloadorg.eclipse.sirius-c6ad066eb1f59f2e802c968edcc36b83ef1a4e22.tar.gz
org.eclipse.sirius-c6ad066eb1f59f2e802c968edcc36b83ef1a4e22.tar.xz
org.eclipse.sirius-c6ad066eb1f59f2e802c968edcc36b83ef1a4e22.zip
[518246] Resize an operand when resizing an inner execution
* Allows to resize an execution even if the new range is out of the parent operand. Bug: 518246 Change-Id: Idd0e02efd4cbb3985d908c6603f8d516af79ad8c Signed-off-by: Florian Barbin <florian.barbin@obeo.fr> Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/AbstractNodeEventResizeSelectionValidator.java59
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/util/FinalParentHelper.java42
2 files changed, 45 insertions, 56 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/AbstractNodeEventResizeSelectionValidator.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/AbstractNodeEventResizeSelectionValidator.java
index d9d593602e..6f11199e89 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/AbstractNodeEventResizeSelectionValidator.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/AbstractNodeEventResizeSelectionValidator.java
@@ -47,8 +47,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
/**
- * Abstract class to validate Execution move & resize request and get from it a
- * command.
+ * Abstract class to validate Execution move & resize request and get from it a command.
*
* @author edugueperoux
*
@@ -100,8 +99,7 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * Return the validation status. Validate the request result in the first
- * call only.
+ * Return the validation status. Validate the request result in the first call only.
*
* @return the validation status.
*/
@@ -111,10 +109,9 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * Performs all the computations required to validate the resizing, and
- * stores any important information which will be useful to actually execute
- * the move if it is valid, like for example avoid contact with siblings or
- * handle reconnection.
+ * Performs all the computations required to validate the resizing, and stores any important information which will
+ * be useful to actually execute the move if it is valid, like for example avoid contact with siblings or handle
+ * reconnection.
*/
public final void validate() {
if (!initialized) {
@@ -124,9 +121,8 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * Performs all the computations required to validate the resizing, and
- * stores any important information which will be useful to actually execute
- * the resize if it is valid, like for example avoid contact with siblings.
+ * Performs all the computations required to validate the resizing, and stores any important information which will
+ * be useful to actually execute the resize if it is valid, like for example avoid contact with siblings.
*/
private void doValidation() {
Preconditions.checkNotNull(host, Messages.AbstractNodeEventResizeSelectionValidator_nullExecution);
@@ -145,9 +141,8 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * Verifies whether the new position/size of the execution would still be
- * valid if we accept the request. In particular, ensures sibling events can
- * not overlap.
+ * Verifies whether the new position/size of the execution would still be valid if we accept the request. In
+ * particular, ensures sibling events can not overlap.
*
* @return true if the request is validated to true
*/
@@ -161,8 +156,8 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * Checks whether the new bounds implied by the requested change are valid
- * for this execution. Uses Draw2D information to get the current bounds.
+ * Checks whether the new bounds implied by the requested change are valid for this execution. Uses Draw2D
+ * information to get the current bounds.
*/
private boolean validateNewBounds(ExecutionEditPart self) {
final boolean result;
@@ -176,10 +171,8 @@ public class AbstractNodeEventResizeSelectionValidator {
} else {
boolean isMove = requestQuery.isMove();
/*
- * If this is a MOVE, children will move along with us, so it is OK
- * for them. Otherwise this is a RESIZE, where children do not move,
- * so the resize is constrained by the range currently occupied by
- * them.
+ * If this is a MOVE, children will move along with us, so it is OK for them. Otherwise this is a RESIZE,
+ * where children do not move, so the resize is constrained by the range currently occupied by them.
*/
boolean okForChildren = isMove || RangeHelper.verticalRange(newBounds).includes(self.getISequenceEvent().getOccupiedRange());
// linkedMessages are moved during execution resize too
@@ -189,16 +182,20 @@ public class AbstractNodeEventResizeSelectionValidator {
// GraphicalHelper.verticalRange(newBounds));
boolean okForParent = ((AbstractNodeEvent) self.getISequenceEvent()).getLifeline().get().getValidSubEventsRange().includes(RangeHelper.verticalRange(newBounds));
/*
- * Do not allow resize to expand beyond the range of the parent.
+ * Expansion of the last operand is valid and triggers a zone expansion.
*/
if (requestQuery.isResize()) {
- if (!parent.getVerticalRange().includes(RangeHelper.verticalRange(newBounds))) {
+ if (parent instanceof Operand && ((Operand) parent).getCombinedFragment().getLastOperand().equals(parent)) {
+ okForParent = parent.getVerticalRange().getLowerBound() < RangeHelper.verticalRange(newBounds).getLowerBound();
+ if (parent.getVerticalRange().getUpperBound() < RangeHelper.verticalRange(newBounds).getUpperBound()) {
+ expansionZone = new Range(parent.getVerticalRange().getUpperBound(), RangeHelper.verticalRange(newBounds).getUpperBound() + LayoutConstants.EXECUTION_CHILDREN_MARGIN);
+ }
+ } else if (!parent.getVerticalRange().includes(RangeHelper.verticalRange(newBounds))) {
okForParent = false;
}
}
/*
- * Also check that the messages which will move with us will not
- * become inconsistent.
+ * Also check that the messages which will move with us will not become inconsistent.
*/
boolean okForMessageEnds = (expansionZone != null) || validateMessageEndsConsistency(self, bounds, newBounds);
result = okForChildren && okForParent && okForMessageEnds;
@@ -207,8 +204,8 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * If this execution is delimited by a start and finish message, make sure
- * they always point to the same remote execution/lifeline.
+ * If this execution is delimited by a start and finish message, make sure they always point to the same remote
+ * execution/lifeline.
*
* @param move
* indicates the current action : move or resize.
@@ -294,9 +291,8 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * Check upper range margin between parentSequenceEventEditPart and
- * returnMessageEditPart respect LayoutConstants.EXECUTION_CHILDREN_MARGIN
- * margin
+ * Check upper range margin between parentSequenceEventEditPart and returnMessageEditPart respect
+ * LayoutConstants.EXECUTION_CHILDREN_MARGIN margin
*
* @param parentSequenceEventEditPart
* @param returnMessageEditPart
@@ -319,9 +315,8 @@ public class AbstractNodeEventResizeSelectionValidator {
}
/**
- * Check if lower range margin between parentSequenceEventEditPart and
- * callMessageEditPart respect LayoutConstants.EXECUTION_CHILDREN_MARGIN
- * margin
+ * Check if lower range margin between parentSequenceEventEditPart and callMessageEditPart respect
+ * LayoutConstants.EXECUTION_CHILDREN_MARGIN margin
*
* @param parentSequenceEventEditPart
* @param callMessageEditPart
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/util/FinalParentHelper.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/util/FinalParentHelper.java
index 023be506a5..e8b06229ef 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/util/FinalParentHelper.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/util/FinalParentHelper.java
@@ -60,22 +60,16 @@ public class FinalParentHelper {
}
/**
- * Determines what event will be the direct parent of this execution after
- * the execution of the specified request. Returns <code>null</code> if the
- * request is invalid. Calling this method also sets the
- * <code>expansionZone</code> field: it is set to <code>null</code> if the
- * returned parent can accept this execution directly, or to the vertical
- * range which needs to be expanded on the future parent if there is not yet
- * enough room to contain this execution.
+ * Determines what event will be the direct parent of this execution after the execution of the specified request.
+ * Returns <code>null</code> if the request is invalid. Calling this method also sets the <code>expansionZone</code>
+ * field: it is set to <code>null</code> if the returned parent can accept this execution directly, or to the
+ * vertical range which needs to be expanded on the future parent if there is not yet enough room to contain this
+ * execution.
*/
public void computeFinalParent() {
Range fullFinalRange = getFullFinalRange();
- if (fullFinalRange != null) {
- if (isInvalidInteractionInsideOperand(fullFinalRange)) {
- globalFinalParent = null;
- } else if (request.isResize()) {
- globalFinalParent = getFinalParentOnResize(fullFinalRange);
- }
+ if (fullFinalRange != null && request.isResize()) {
+ globalFinalParent = getFinalParentOnResize(fullFinalRange);
}
}
@@ -114,14 +108,12 @@ public class FinalParentHelper {
}
/**
- * Computes the full final range which would be occupied by this execution
- * and any of the elements resized along with it if we accept the specified
- * request.
+ * Computes the full final range which would be occupied by this execution and any of the elements resized along
+ * with it if we accept the specified request.
*
* @param request
* the request for changing the size/location of this execution
- * @return the final vertical range of the execution and its linked messages
- * (if any) if we accept the request.
+ * @return the final vertical range of the execution and its linked messages (if any) if we accept the request.
*/
private Range getFullFinalRange() {
Rectangle newBounds = request.getLogicalTransformedRectangle(self.getProperLogicalBounds());
@@ -157,14 +149,15 @@ public class FinalParentHelper {
*/
ISequenceEvent finalParent = self.getParentEvent();
/*
- * We must still check that the resizing is valid, in that it will not
- * cause an overlap/conflict with sibling events.
+ * We must still check that the resizing is valid, in that it will not cause an overlap/conflict with sibling
+ * events.
*/
final Collection<ISequenceEvent> linkedSiblings = FinalParentHelper.computeLinkedSiblings(request);
Iterable<ISequenceEvent> finalSiblings = EventEndHelper.getIndependantEvents(self, finalParent.getSubEvents());
final Option<Lifeline> selfLifeline = self.getLifeline();
Predicate<ISequenceEvent> sameLifeline = new Predicate<ISequenceEvent>() {
+ @Override
public boolean apply(ISequenceEvent input) {
Option<Lifeline> inputLifeline = input.getLifeline();
boolean same = !inputLifeline.some() || (selfLifeline.some() && inputLifeline.get() == selfLifeline.get());
@@ -181,6 +174,7 @@ public class FinalParentHelper {
};
Predicate<ISequenceEvent> intersectsFinalBounds = new Predicate<ISequenceEvent>() {
+ @Override
public boolean apply(ISequenceEvent input) {
Range inputRange = input.getVerticalRange();
boolean intersection = inputRange.intersects(fullFinalRange) && !linkedSiblings.contains(input);
@@ -211,10 +205,10 @@ public class FinalParentHelper {
};
/*
- * Removes parent combined fragment to be able to resize an execution in
- * a combined fragment
+ * Removes parent combined fragment to be able to resize an execution in a combined fragment
*/
Predicate<ISequenceEvent> notParentCombinedFragment = new Predicate<ISequenceEvent>() {
+ @Override
public boolean apply(ISequenceEvent input) {
if (input instanceof CombinedFragment && self.getLifeline().some()) {
CombinedFragment combinedFragment = (CombinedFragment) input;
@@ -287,8 +281,8 @@ public class FinalParentHelper {
ISequenceEvent sourceParent = (smep.getSourceElement() instanceof ISequenceEvent) ? (ISequenceEvent) smep.getSourceElement() : null;
/*
- * The target will not be an ISequenceEvent for creation and destruction
- * messages as instance roles and EOL are not ISequenceEvents.
+ * The target will not be an ISequenceEvent for creation and destruction messages as instance roles and EOL are
+ * not ISequenceEvents.
*/
ISequenceEvent targetParent = (smep.getTargetElement() instanceof ISequenceEvent) ? (ISequenceEvent) smep.getTargetElement() : null;
ISequenceEvent remoteParent = allMovedElements.contains(sourceParent) ? targetParent : sourceParent;

Back to the top