Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2017-08-23 13:00:25 +0000
committerLaurent Redor2017-08-31 08:46:31 +0000
commit70bfe4877f1e5391721b432aedf71a1f95bd9192 (patch)
tree0c91afa6d51f91d1162e41a0a0b61dc97d36fab1
parentedc3d5238c18005aa1aa2af9c1a2e97b12bfb761 (diff)
downloadorg.eclipse.sirius-70bfe4877f1e5391721b432aedf71a1f95bd9192.tar.gz
org.eclipse.sirius-70bfe4877f1e5391721b432aedf71a1f95bd9192.tar.xz
org.eclipse.sirius-70bfe4877f1e5391721b432aedf71a1f95bd9192.zip
[518246] Complete resize in bottom direction from all operand
Previously, only the resize from the last operand is available. This commit also computes future sizes of parent Operand and grand parent CombinedFragment to avoid potential conflict (red line) during resizing. Bug: 518246 Change-Id: Ia4bb4debe368c38802ec93fe64649d313f38f41e 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.java4
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/AbstractNodeEventResizeSelectionValidator.java15
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/operation/VerticalSpaceExpansion.java16
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/util/Range.java30
4 files changed, 46 insertions, 19 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 6a6ebb8be2..03c00b5bca 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -166,7 +166,7 @@ public class ExecutionSelectionEditPolicy extends SpecificBorderItemSelectionEdi
if (needVerticalSpaceExpansion(validator, request)) {
SequenceDiagramEditPart diagram = EditPartsHelper.getSequenceDiagramPart(hostPart);
Collection<ISequenceEvent> eventToIgnore = Collections.singletonList((ISequenceEvent) self);
- ctc.compose(CommandFactory.createICommand(editingDomain, new VerticalSpaceExpansion(diagram.getSequenceDiagram(), validator.getExpansionZone(), 0, eventToIgnore))); // FinalParentHelper.computeLinkedSiblings(requestQuery))));
+ ctc.compose(CommandFactory.createICommand(editingDomain, new VerticalSpaceExpansion(diagram.getSequenceDiagram(), validator.getExpansionZone(), 0, eventToIgnore)));
}
if (validator.getFinalHierarchicalParent().equals(self.getHierarchicalParentEvent())) {
Command cmd = DiagramBorderNodeEditPartOperation.getResizeBorderItemCommand((ExecutionEditPart) getHost(), request, false);
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 6c0493a43f..6e2ddbcbbf 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@ import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.sirius.diagram.sequence.business.internal.RangeHelper;
import org.eclipse.sirius.diagram.sequence.business.internal.elements.AbstractFrame;
import org.eclipse.sirius.diagram.sequence.business.internal.elements.AbstractNodeEvent;
+import org.eclipse.sirius.diagram.sequence.business.internal.elements.CombinedFragment;
import org.eclipse.sirius.diagram.sequence.business.internal.elements.Execution;
import org.eclipse.sirius.diagram.sequence.business.internal.elements.ISequenceEvent;
import org.eclipse.sirius.diagram.sequence.business.internal.elements.Lifeline;
@@ -182,10 +183,10 @@ public class AbstractNodeEventResizeSelectionValidator {
// GraphicalHelper.verticalRange(newBounds));
boolean okForParent = ((AbstractNodeEvent) self.getISequenceEvent()).getLifeline().get().getValidSubEventsRange().includes(RangeHelper.verticalRange(newBounds));
/*
- * Expansion of the last operand is valid and triggers a zone expansion.
+ * Expansion of the operand is valid and triggers a zone expansion.
*/
if (requestQuery.isResize()) {
- if (parent instanceof Operand && requestQuery.isResizeFromBottom() && ((Operand) parent).getCombinedFragment().getLastOperand().equals(parent)) {
+ 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);
@@ -440,7 +441,6 @@ public class AbstractNodeEventResizeSelectionValidator {
} else {
final Range finalRange = RangeHelper.verticalRange(newBounds);
Function<ISequenceEvent, Range> futureRangeFunction = new Function<ISequenceEvent, Range>() {
-
@Override
public Range apply(ISequenceEvent from) {
Range verticalRange = from.getVerticalRange();
@@ -467,8 +467,13 @@ public class AbstractNodeEventResizeSelectionValidator {
verticalRange = verticalRange.shifted(requestQuery.getLogicalDelta().height);
}
}
+ } else if (from instanceof Operand && from.equals(host.getParentEvent())) {
+ // The parent Operand will be resized.
+ verticalRange = finalRange.grown(LayoutConstants.EXECUTION_CHILDREN_MARGIN).union(verticalRange);
+ } else if (from instanceof CombinedFragment && host.getParentEvent() != null && from.equals(host.getParentEvent().getParentEvent())) {
+ // The grand parent CombinedFragment will be resized.
+ verticalRange = finalRange.shifted(-LayoutConstants.COMBINED_FRAGMENT_TITLE_HEIGHT - LayoutConstants.EXECUTION_CHILDREN_MARGIN).union(verticalRange);
}
-
return verticalRange;
}
};
diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/operation/VerticalSpaceExpansion.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/operation/VerticalSpaceExpansion.java
index 58a100a70f..6864eaf288 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/operation/VerticalSpaceExpansion.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/operation/VerticalSpaceExpansion.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,8 +41,8 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
- * An operation to shift all the atomic events on a sequence diagram below a
- * certain point to make room.
+ * An operation to shift all the atomic events on a sequence diagram below a certain point to make room. The space is
+ * added from a point to the bottom direction.
*
* @author pcdavid, smonnier
*/
@@ -76,11 +76,9 @@ public class VerticalSpaceExpansion extends AbstractModelChangeOperation<Void> {
* @param shift
* the zone to expand.
* @param move
- * how much the main execution which triggered this change is
- * vertically moved.
+ * how much the main execution which triggered this change is vertically moved.
* @param eventsToIgnore
- * the events which should be ignored, as they will be moved into
- * the new space.
+ * the events which should be ignored, as they will be moved into the new space.
*/
public VerticalSpaceExpansion(SequenceDiagram diagram, Range shift, Integer move, Collection<ISequenceEvent> eventsToIgnore) {
super(MessageFormat.format(Messages.VerticalSpaceExpansion_operationName, shift));
@@ -305,11 +303,11 @@ public class VerticalSpaceExpansion extends AbstractModelChangeOperation<Void> {
}
private boolean containsInsertionPoint(ISequenceEvent event) {
- return event != null && event.getVerticalRange().includes(insertionPoint);
+ return event != null && event.getVerticalRange().includes(insertionPoint, true, false);
}
private boolean isStrictlyBelowInsertionPoint(ISequenceEvent event) {
- return event != null && event.getVerticalRange().getLowerBound() > insertionPoint;
+ return event != null && event.getVerticalRange().getLowerBound() >= insertionPoint;
}
private void expandDown(Lifeline lifeline, int height) {
diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/util/Range.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/util/Range.java
index 5eacb8131a..24a50ffb4a 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/util/Range.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/util/Range.java
@@ -162,11 +162,35 @@ public class Range {
* @return <code>true</code> if the element is included in the range.
*/
public boolean includes(int value) {
+ return includes(value, false, false);
+ }
+
+ /**
+ * Tests whether on element is included or not in the range.
+ *
+ * @param value
+ * the element to test.
+ * @param excludeLowerBounds
+ * true to exclude the lower bounds of the {@link Range}, false otherwise
+ * @param excludeUpperBounds
+ * true to exclude the upper bounds of the {@link Range}, false otherwise
+ * @return <code>true</code> if the element is included in the range.
+ */
+ public boolean includes(int value, boolean excludeLowerBounds, boolean excludeUpperBounds) {
+ boolean result = false;
if (!isEmpty()) {
- return lower <= value && value <= upper;
- } else {
- return false;
+ if (excludeLowerBounds) {
+ result = lower < value;
+ } else {
+ result = lower <= value;
+ }
+ if (excludeUpperBounds) {
+ result = result && value < upper;
+ } else {
+ result = result && value <= upper;
+ }
}
+ return result;
}
/**

Back to the top