Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-04-23 07:48:46 -0400
committerCamille Letavernier2018-04-23 08:15:02 -0400
commitbf84836f6b6020d40f7a738603e8d4238f421b41 (patch)
treeef6ca70700b55d714040640b19749b63ef2e046c
parent9a01911759c5878c05283bdf61fa2e3d977ae3c3 (diff)
downloadorg.eclipse.papyrus-bugs/533770-CFLayout.tar.gz
org.eclipse.papyrus-bugs/533770-CFLayout.tar.xz
org.eclipse.papyrus-bugs/533770-CFLayout.zip
Bug 533770: [Sequence Diagram] Layout operands in a CombinedFragmentbugs/533770-CFLayout
- Add feedback when moving the operands separator - Also fix the feedback when moving the CF (Using the GMF extension of the ResizableEditPolicy, which handles this feedback) Change-Id: I3588612938546a5b7968b7c93cc61b6dec93fe76 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentResizeEditPolicy.java72
1 files changed, 66 insertions, 6 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentResizeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentResizeEditPolicy.java
index 586d8478eb0..9e65bd3074b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentResizeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CombinedFragmentResizeEditPolicy.java
@@ -16,11 +16,16 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
+import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Cursors;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Locator;
+import org.eclipse.draw2d.Polyline;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PrecisionRectangle;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
@@ -30,12 +35,12 @@ import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gef.handles.RelativeHandleLocator;
import org.eclipse.gef.handles.SquareHandle;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
@@ -54,7 +59,9 @@ import org.eclipse.uml2.uml.CombinedFragment;
*
* @since 5.0
*/
-public class CombinedFragmentResizeEditPolicy extends ResizableEditPolicy {
+public class CombinedFragmentResizeEditPolicy extends ResizableEditPolicyEx {
+
+ private Polyline separatorFeedback;
/**
* @see org.eclipse.gef.editpolicies.ResizableEditPolicy#createSelectionHandles()
@@ -169,11 +176,10 @@ public class CombinedFragmentResizeEditPolicy extends ResizableEditPolicy {
}
double moveDistance = request.getMoveDelta().getDistance(new Point(0, 0));
- if (moveDistance < 5) {
+ if (moveDistance < 1) {
return UnexecutableCommand.INSTANCE;
}
-
ChangeBoundsRequest requestAbove = getResizeAboveRequest(request);
ChangeBoundsRequest requestBelow = getResizeBelowRequest(request);
@@ -234,7 +240,36 @@ public class CombinedFragmentResizeEditPolicy extends ResizableEditPolicy {
}
protected void showMoveSeparatorFeedback(MoveSeparatorRequest request) {
- // TODO Feedback
+ Polyline feedback = getMoveSeparatorFeedbackFigure();
+ GraphicalEditPart operandPart = getOperandBelow(request.getSeparatorIndex());
+ IFigure operandBelowFigure = operandPart.getFigure();
+ IFigure operandAboveFigure = getOperandAbove(request.getSeparatorIndex()).getFigure();
+
+ PrecisionRectangle location = new PrecisionRectangle(operandBelowFigure.getBounds());
+ location.translate(0., request.getMoveDelta().preciseY());
+
+ Point newPosition = location.getTopLeft();
+ if (operandBelowFigure.containsPoint(newPosition) || operandAboveFigure.containsPoint(newPosition)) {
+ feedback.setVisible(true);
+ } else {
+ // We're leaving the valid area; hide the feedback
+ feedback.setVisible(false);
+ }
+
+ operandBelowFigure.translateToAbsolute(location);
+ feedback.translateToRelative(location);
+
+ feedback.setPoint(location.getTopLeft(), 0);
+ feedback.setPoint(location.getTopRight(), 1);
+
+ feedback.validate();
+ }
+
+ protected Polyline getMoveSeparatorFeedbackFigure() {
+ if (separatorFeedback == null) {
+ separatorFeedback = createSeparatorFeedbackFigure();
+ }
+ return separatorFeedback;
}
/**
@@ -251,7 +286,32 @@ public class CombinedFragmentResizeEditPolicy extends ResizableEditPolicy {
}
protected void eraseMoveSeparatorFeedback(MoveSeparatorRequest request) {
- // TODO Feedback
+ if (separatorFeedback != null) {
+ removeFeedback(separatorFeedback);
+ }
+ separatorFeedback = null;
+ }
+
+ protected Polyline createSeparatorFeedbackFigure() {
+ Polyline l = new Polyline() {
+ /**
+ * @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics)
+ *
+ * @param graphics
+ */
+ @Override
+ public void paint(Graphics graphics) {
+ super.paint(graphics);
+ }
+ };
+ l.setLineStyle(Graphics.LINE_DASH);
+ l.setForegroundColor(ColorConstants.darkGray);
+ l.addPoint(new Point(0, 0));
+ l.addPoint(new Point(0, 50));
+ l.setBounds(getHostFigure().getBounds());
+ l.validate();
+ addFeedback(l);
+ return l;
}
/**

Back to the top