Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2017-08-24 12:47:53 +0000
committerLaurent Redor2017-08-31 08:46:35 +0000
commitd39abea68da6cde80b6c5ef7f31d5e3205a5f178 (patch)
treedfa8f4a230d2d2d14e4014f4fcb722948ef00d87
parent70bfe4877f1e5391721b432aedf71a1f95bd9192 (diff)
downloadorg.eclipse.sirius-d39abea68da6cde80b6c5ef7f31d5e3205a5f178.tar.gz
org.eclipse.sirius-d39abea68da6cde80b6c5ef7f31d5e3205a5f178.tar.xz
org.eclipse.sirius-d39abea68da6cde80b6c5ef7f31d5e3205a5f178.zip
[518246] Complete execution resize in top direction
This commit also adapts ExecutionTest has the behavior has changed. Bug: 518246 Change-Id: Ib6311e031d8cc73f40d9f8fc2d6ffd1269f63774 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java40
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/OperandResizableEditPolicy.java2
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/AbstractNodeEventResizeSelectionValidator.java24
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html7
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile1
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/ExecutionTests.java13
6 files changed, 74 insertions, 13 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java
index 03c00b5bca..cbae041532 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/ExecutionSelectionEditPolicy.java
@@ -23,12 +23,14 @@ import org.eclipse.draw2d.FreeformViewport;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -140,6 +142,33 @@ public class ExecutionSelectionEditPolicy extends SpecificBorderItemSelectionEdi
ExecutionEditPart hostPart = (ExecutionEditPart) getHost();
AbstractNodeEvent host = (AbstractNodeEvent) hostPart.getISequenceEvent();
+ // The resize in top direction is not handled as the resize in bottom direction. A vertical space expansion can
+ // be needed for resize to bottom, and there is always free space in bottom. All this aspect is handled by the
+ // AbstractNodeEventResizeSelectionValidator. For resize to top, we only need to resize recursively the parent
+ // as long as it is possible.
+ Command resizeParentToTopCmd = null;
+ RequestQuery requestQuery = new RequestQuery(request);
+ if (requestQuery.isResizeFromTop()) {
+ ISequenceEvent parentEvent = host.getParentEvent();
+ EditPart parentEventEditPart = (EditPart) hostPart.getViewer().getEditPartRegistry().get(parentEvent.getNotationView());
+ if (hostPart != null && parentEventEditPart != null) {
+ // Get resize command in top direction from for its container
+ Rectangle executionFinalBounds = requestQuery.getFinalBounds(hostPart);
+ Range executionFinalRange = RangeHelper.verticalRange(executionFinalBounds);
+ if (parentEvent.getValidSubEventsRange().getLowerBound() >= executionFinalRange.getLowerBound()) {
+ ChangeBoundsRequest parentRequest = new ChangeBoundsRequest(request.getType());
+ int yDelta = parentEvent.getValidSubEventsRange().getLowerBound() - executionFinalRange.getLowerBound();
+ parentRequest.setMoveDelta(new PrecisionPoint(request.getMoveDelta().x(), -yDelta));
+ parentRequest.setSizeDelta(new Dimension(request.getSizeDelta().width(), yDelta));
+ parentRequest.setEditParts(parentEventEditPart);
+ parentRequest.setResizeDirection(request.getResizeDirection());
+ parentRequest.setLocation(request.getLocation());
+
+ resizeParentToTopCmd = parentEventEditPart.getCommand(parentRequest);
+ }
+ }
+ }
+
AbstractNodeEventResizeSelectionValidator validator = AbstractNodeEventResizeSelectionValidator.getOrCreateValidator(request, host);
if (validator.isValid()) {
@@ -147,7 +176,14 @@ public class ExecutionSelectionEditPolicy extends SpecificBorderItemSelectionEdi
if (solution == null) {
solution = IdentityCommand.INSTANCE;
}
- result = new ICommandProxy(solution);
+ if (resizeParentToTopCmd == null) {
+ result = new ICommandProxy(solution);
+ } else if (resizeParentToTopCmd.canExecute()) {
+ CompoundCommand cc = new CompoundCommand(solution.getLabel());
+ cc.add(resizeParentToTopCmd);
+ cc.add(new ICommandProxy(solution));
+ result = cc;
+ }
}
return result;
}
@@ -162,7 +198,7 @@ public class ExecutionSelectionEditPolicy extends SpecificBorderItemSelectionEdi
validator.setExpansionZone(null);
}
- CompositeTransactionalCommand ctc = new CompositeTransactionalCommand(hostPart.getEditingDomain(), Messages.ExecutionSelectionEditPolicy_resizeCompositeCommand);
+ CompositeTransactionalCommand ctc = new CompositeTransactionalCommand(editingDomain, Messages.ExecutionSelectionEditPolicy_resizeCompositeCommand);
if (needVerticalSpaceExpansion(validator, request)) {
SequenceDiagramEditPart diagram = EditPartsHelper.getSequenceDiagramPart(hostPart);
Collection<ISequenceEvent> eventToIgnore = Collections.singletonList((ISequenceEvent) self);
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/OperandResizableEditPolicy.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/OperandResizableEditPolicy.java
index 7f1c60f041..9959d80ba8 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/OperandResizableEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/policy/OperandResizableEditPolicy.java
@@ -154,7 +154,7 @@ public class OperandResizableEditPolicy extends AirResizableEditPolicy {
// Resizing the operand from north face must resize the
// previous operand
OperandEditPart previousOperandEditPart = getPreviousOperandEditPart(operandIndex);
- if (previousOperandEditPart == null && self.getSelected() != EditPart.SELECTED_NONE) {
+ if (previousOperandEditPart == null) {
// There is no previous operand, resize from north face is forwarded to the parent
// CombinedFragmentEditPart in order to resize it instead.
if (getHost() != null && getHost().getParent() != null && getHost().getParent().getParent() instanceof CombinedFragmentEditPart) {
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 6e2ddbcbbf..0592e58ca0 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
@@ -186,11 +186,8 @@ public class AbstractNodeEventResizeSelectionValidator {
* Expansion of the operand is valid and triggers a zone expansion.
*/
if (requestQuery.isResize()) {
- if (parent instanceof Operand && requestQuery.isResizeFromBottom()) {
- 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);
- }
+ if (parent instanceof Operand) {
+ okForParent = validateNewBounds(self, newBounds, (Operand) parent);
} else if (!parent.getValidSubEventsRange().includes(RangeHelper.verticalRange(newBounds))) {
okForParent = false;
}
@@ -204,6 +201,23 @@ public class AbstractNodeEventResizeSelectionValidator {
return result;
}
+ private boolean validateNewBounds(ExecutionEditPart self, Rectangle newBounds, Operand parent) {
+ boolean okForParent = false;
+ if (requestQuery.isResizeFromBottom()) {
+ if (parent.getValidSubEventsRange().getLowerBound() < RangeHelper.verticalRange(newBounds).getLowerBound()) {
+ okForParent = true;
+ if (parent.getValidSubEventsRange().getUpperBound() < RangeHelper.verticalRange(newBounds).getUpperBound()) {
+ expansionZone = new Range(parent.getValidSubEventsRange().getUpperBound(), RangeHelper.verticalRange(newBounds).getUpperBound());
+ }
+ }
+ } else if (requestQuery.isResizeFromTop()) {
+ // We consider that parent is resize before if needed.
+ okForParent = true;
+ } else if (parent.getValidSubEventsRange().includes(RangeHelper.verticalRange(newBounds))) {
+ okForParent = true;
+ }
+ return okForParent;
+ }
/**
* If this execution is delimited by a start and finish message, make sure they always point to the same remote
* execution/lifeline.
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index a3d5589f96..6d78c052f8 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -133,6 +133,13 @@
</p>
<ul>
<li><span class="label label-info">Modified</span> In a sequence diagram, it is now possible to resize the combined fragment when the first or the last operand is selected (increase the size of the first operand to the top, or increase the size of the last operand to the bottom). Before, it was necessary to select the combined fragment itself to resize it. </li>
+ <li><span class="label label-info">Modified</span> In a sequence diagram, it is now possible to resize an
+ <em>Execution</em> contained in an
+ <em>Operand</em> without previously resize its
+ <em>Operand</em> if more space is needed. The
+ <em>Operand</em>, and if necessary the
+ <em>Combined Fragment</em>, is resized too.
+ </li>
</ul>
<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
<ul>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index ef3974abdb..8411f604ca 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -17,6 +17,7 @@ h3. User-Visible Changes
* <span class="label label-info">Modified</span> In a diagram with _snapToGrid_ enabled, when you create an edge with a tool that also create the associated border nodes, the border nodes are now snapped near the click location. Before, it was created to respect a shortest path.
!./images/borderNodesWithSnapToGrid.png!
* <span class="label label-info">Modified</span> In a sequence diagram, it is now possible to resize the combined fragment when the first or the last operand is selected (increase the size of the first operand to the top, or increase the size of the last operand to the bottom). Before, it was necessary to select the combined fragment itself to resize it.
+* <span class="label label-info">Modified</span> In a sequence diagram, it is now possible to resize an _Execution_ contained in an _Operand_ without previously resize its _Operand_ if more space is needed. The _Operand_, and if necessary the _Combined Fragment_, is resized too.
h3. Specifier-Visible Changes
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/ExecutionTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/ExecutionTests.java
index 69cbe25d01..11df990db3 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/ExecutionTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/sequence/ExecutionTests.java
@@ -1223,9 +1223,11 @@ public class ExecutionTests extends AbstractDefaultModelSequenceTests {
Rectangle executionBoundsB = editor.getBounds(executionB);
assertEquals("the execution position is wrong", combinedFragmentBoundsA.getCenter().y, executionBoundsB.getTop().y);
- // Resize execution in combined fragment, near the upper bound of the
- // Operand (it's forbidden)
- int limitAuthorized = combinedFragmentBoundsA.getTop().y + LayoutConstants.COMBINED_FRAGMENT_TITLE_HEIGHT + LayoutConstants.EXECUTION_CHILDREN_MARGIN;
+ // Resize execution in combined fragment, just before the lower bound of
+ // the lifeline, just when grand parent Combined Fragment becomes
+ // unauthorized (it's forbidden)
+ int limitAuthorized = getBounds(LIFELINE_A, true).getBottom().y + LayoutConstants.TIME_START_MIN_OFFSET + LayoutConstants.COMBINED_FRAGMENT_TITLE_HEIGHT
+ + LayoutConstants.EXECUTION_CHILDREN_MARGIN;
int previousExecutionTop = executionBoundsB.getTop().y;
editor.drag(executionBoundsB.getTop(), combinedFragmentBoundsA.getCenter().x, limitAuthorized - 1);
bot.sleep(500);
@@ -1233,8 +1235,9 @@ public class ExecutionTests extends AbstractDefaultModelSequenceTests {
executionBoundsB = editor.getBounds(executionB);
assertEquals("the execution must not be moved", previousExecutionTop, executionBoundsB.getTop().y);
- // Resize execution in combined fragment, just after the upper bound of
- // the Operand
+ // Resize execution in combined fragment, just before the lower bound of
+ // the lifeline, just when grand parent Combined Fragment starts to be
+ // authorized
ICondition done = new OperationDoneCondition();
editor.drag(executionBoundsB.getTop(), combinedFragmentBoundsA.getCenter().x, limitAuthorized);
bot.waitUntil(done);

Back to the top