Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-07-26 13:13:11 +0000
committerNicolas FAUVERGUE2018-07-27 06:34:20 +0000
commit72ecc9b3b9e1b682901b35d03f4bacc71a57097c (patch)
treee94daf23dca99a2bf86f7f7e0cfc9e2d00ae9485 /plugins
parentdc7bec32ef1cbba17c97a77e1b28f7866b6747f3 (diff)
downloadorg.eclipse.papyrus-72ecc9b3b9e1b682901b35d03f4bacc71a57097c.tar.gz
org.eclipse.papyrus-72ecc9b3b9e1b682901b35d03f4bacc71a57097c.tar.xz
org.eclipse.papyrus-72ecc9b3b9e1b682901b35d03f4bacc71a57097c.zip
Bug 507348 : Shift Key to reorder Messages
- Move listener from the DragTracker to the MessageEditPart to know the shift key position before starting the drag. - Listener must be removed durinf deactivation of the message. Change-Id: I8b589ef26cc6267b59926b6a84840a571945524a Signed-off-by: CĂ©line Janssens <Celine.Janssens@all4tec.net> Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/RequirementsSequenceDiagram.usecases5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java145
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectMessagesEditPartTracker.java111
3 files changed, 131 insertions, 130 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/RequirementsSequenceDiagram.usecases b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/RequirementsSequenceDiagram.usecases
index bf7cdbc0aeb..ed113c4b1a9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/RequirementsSequenceDiagram.usecases
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/RequirementsSequenceDiagram.usecases
@@ -35,6 +35,11 @@ Code instruction: - org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/ecli
- org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/SetResizeCommand.java
- org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/SetResizeAndLocationCommand.java
+Requirement: ReqFunctional_Messages_SequenceDiagram_002: Messages can be re-ordered with 'SHIFT' key. In this case, the move of other messages does not work.
+Code instruction: - org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
+- org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectMessagesEditPartTracker.java
+- org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
+
Requirement: ReqFunctional_Messages_SequenceDiagram_003: When a move of a message is done (with the preference to keep gaps between messages), all the messages and elements in the life lines must be moved down.
Code instruction: - org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
index a9d8b626e3a..0ba36e08746 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Celine Janssens (ALL4TEC) - Bug 507348
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
import java.util.List;
@@ -26,20 +39,41 @@ import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPar
import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceReferenceEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageDelete;
import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.keyboardlistener.IKeyPressState;
+import org.eclipse.papyrus.uml.diagram.sequence.keyboardlistener.KeyboardListener;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectMessageToGridEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectRectangleToGridEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.LifeLineGraphicalNodeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.util.SelectMessagesEditPartTracker;
import org.eclipse.papyrus.uml.diagram.sequence.util.SelfMessageHelper;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.ui.PlatformUI;
-public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart {
+public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart implements IKeyPressState {
private List messageEventParts;
+ private boolean reorderMessages = false;
+
+ /**
+ * The shift down key.
+ *
+ * @since 5.1
+ */
+ protected KeyboardListener SHIFTDown = new KeyboardListener(this, SWT.SHIFT, true);
+
+ /**
+ * The shift up key.
+ *
+ * @since 5.1
+ */
+ protected KeyboardListener SHIFTUp = new KeyboardListener(this, SWT.SHIFT, false);
+
/**
* Handle mouse move event to update cursors.
*/
@@ -53,9 +87,43 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
super(view);
}
+ /**
+ * {{@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.keyboardlistener.IKeyPressState#setKeyPressState(java.lang.Boolean)
+ *
+ * @param isPressed
+ * @since 5.1
+ */
+ @Override
+ public void setKeyPressState(Boolean isPressed) {
+ reorderMessages = isPressed;
+ }
+
+ /**
+ * Get the value of reorderMessages property. This is defined by the Shift pressed Key.
+ *
+ * @return true if the messages should be reordered in the Interaction and false if the move of a message move also the other message without reorder it.
+ * @since 5.1
+ */
+ public boolean mustReorderMessage() {
+ if (getFigure() instanceof MessageDelete) {
+ return false;
+ }
+ return reorderMessages;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart#activate()
+ */
@Override
public void activate() {
super.activate();
+ // activate listeners
+ PlatformUI.getWorkbench().getDisplay().addFilter(SWT.KeyDown, SHIFTDown);
+ PlatformUI.getWorkbench().getDisplay().addFilter(SWT.KeyUp, SHIFTUp);
if (getTarget() == null || getSource() == null) {
getViewer().getControl().getDisplay().asyncExec(new Runnable() {
@@ -152,6 +220,8 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
if (mouseMoveListener != null) {
getViewer().getControl().removeMouseMoveListener(mouseMoveListener);
}
+ PlatformUI.getWorkbench().getDisplay().removeFilter(SWT.KeyDown, SHIFTDown);
+ PlatformUI.getWorkbench().getDisplay().removeFilter(SWT.KeyUp, SHIFTUp);
super.deactivate();
}
@@ -194,7 +264,6 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
}
-
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
@@ -202,7 +271,6 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
// Ordering Message Occurrence Specification. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=403233
installEditPolicy(ConnectRectangleToGridEditPolicy.CONNECT_TO_GRILLING_MANAGEMENT, new ConnectMessageToGridEditPolicy());
installEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE, new SequenceReferenceEditPolicy());
-
}
@Override
@@ -292,78 +360,9 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
*/
@Override
protected void refreshRoutingStyles() {
+ // Do nothing
}
- // public static class MessageFigure extends UMLEdgeFigure {
- //
- // private boolean selection;
- //
- // /**
- // * Constructor.
- // *
- // */
- // public MessageFigure() {
- // }
- //
- // @Override
- // public void setLineWidth(int w) {
- // if(selection) {
- // w = AbstractMessageEditPart.this.getLineWidth() * 2;
- // }
- // super.setLineWidth(w);
- // if(getSourceDecoration() instanceof Shape) {
- // ((Shape)getSourceDecoration()).setLineWidth(w);
- // }
- // if(getTargetDecoration() instanceof Shape) {
- // ((Shape)getTargetDecoration()).setLineWidth(w);
- // }
- // }
- //
- // @Override
- // public void setForegroundColor(Color c) {
- // super.setForegroundColor(c);
- // if(getSourceDecoration() instanceof Shape) {
- // ((Shape)getSourceDecoration()).setForegroundColor(c);
- // ((Shape)getSourceDecoration()).setBackgroundColor(c);
- // }
- // if(getTargetDecoration() instanceof Shape) {
- // ((Shape)getTargetDecoration()).setForegroundColor(c);
- // ((Shape)getTargetDecoration()).setBackgroundColor(c);
- // }
- // }
- //
- // @Override
- // public Cursor getCursor() {
- // Cursor customCursor = getCustomCursor();
- // if(customCursor != null) {
- // return customCursor;
- // }
- // return super.getCursor();
- // }
- //
- // /**
- // * @return the selection
- // */
- // public boolean getSelection() {
- // return selection;
- // }
- //
- // /**
- // * @param selection
- // * the selection to set
- // */
- // public void setSelection(boolean selection) {
- // this.selection = selection;
- // if(!selection) {
- // setLineWidth(AbstractMessageEditPart.this.getLineWidth());
- // }
- // repaint();
- // }
- //
- // protected IMapMode getMapMode() {
- // return AbstractMessageEditPart.this.getMapMode();
- // }
- // }
static abstract class MessageLabelEditPart extends LabelEditPart {
public MessageLabelEditPart(View view) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectMessagesEditPartTracker.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectMessagesEditPartTracker.java
index cfccdbf25cf..6288b65d0c8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectMessagesEditPartTracker.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelectMessagesEditPartTracker.java
@@ -8,6 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Celine Janssens (ALL4TEC) - Bug 507348
*
*****************************************************************************/
@@ -26,11 +27,8 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.selection.SelectSeveralLinksEditPartTracker;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.PlatformUI;
/**
* @author Patrick Tessier
@@ -38,33 +36,31 @@ import org.eclipse.ui.PlatformUI;
*
*/
public class SelectMessagesEditPartTracker extends SelectSeveralLinksEditPartTracker {
- protected Listener KeyDownListener = new Listener() {
- @Override
- public void handleEvent(Event event) {
- // in case the SHIFT key is released, the creation mode goes back to normal
- if (event.keyCode == SWT.SHIFT) {
- allowReoder = true;
- }
- }
-
- };
- protected Listener KeyUPListener = new Listener() {
-
- @Override
- public void handleEvent(Event event) {
- // in case the SHIFT key is released, the creation mode goes back to normal
- if (event.keyCode == SWT.SHIFT) {
- allowReoder = false;
- }
- }
-
- };
protected int MinDistancetop = Integer.MAX_VALUE;
protected int MinDistancebottom = Integer.MAX_VALUE;
protected Dimension delta = null;
/**
+ * This allows to determinate if this is a reorder or not.
+ */
+ private boolean allowReorder;
+
+ private boolean isOneMessageDeleteSelected;
+
+ /**
+ * Constructor.
+ *
+ * @param owner
+ * @param shiftDown
+ */
+ public SelectMessagesEditPartTracker(ConnectionEditPart owner) {
+ super(owner);
+ this.allowReorder = ((AbstractMessageEditPart) owner).mustReorderMessage();
+ this.isOneMessageDeleteSelected = false;
+ }
+
+ /**
* @see org.eclipse.gef.tools.AbstractTool#activate()
*
*/
@@ -81,12 +77,13 @@ public class SelectMessagesEditPartTracker extends SelectSeveralLinksEditPartTra
*/
@Override
protected boolean handleButtonDown(int button) {
- Dimension delta = null;
MinDistancetop = Integer.MAX_VALUE;
MinDistancebottom = Integer.MAX_VALUE;
- // 1. look for all Nodes connected by connections
- // and find the MinDistancetop (maximum mouvment without reorder to the top) and the MinDistancebottom (maximum distance without reorder to the bottom)
+ this.isOneMessageDeleteSelected = false;
+
+ // 1. look for all Nodes connected by connections
+ // and find the MinDistancetop (maximum movement without reorder to the top) and the MinDistancebottom (maximum distance without reorder to the bottom)
ArrayList<GraphicalEditPart> nodeEditPart = new ArrayList<>();
@@ -97,7 +94,9 @@ public class SelectMessagesEditPartTracker extends SelectSeveralLinksEditPartTra
if (currentEditPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) {
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart currentConnectionEdiPart = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) currentEditPart;
nodeEditPart.add((GraphicalEditPart) currentConnectionEdiPart.getSource());
-
+ if (currentConnectionEdiPart instanceof MessageCreateEditPart) {
+ isOneMessageDeleteSelected = true;
+ }
}
}
@@ -134,6 +133,11 @@ public class SelectMessagesEditPartTracker extends SelectSeveralLinksEditPartTra
if (MinDistancetop > (currentSelectedConnectionPosition.y - currentConnectionPosition.y)) {
MinDistancetop = (currentSelectedConnectionPosition.y - currentConnectionPosition.y);
}
+ } else if (isOneMessageDeleteSelected) {
+ // selected Message is above the currentConnection
+ if (MinDistancebottom > (currentConnectionPosition.y - currentSelectedConnectionPosition.y)) {
+ MinDistancebottom = (currentConnectionPosition.y - currentSelectedConnectionPosition.y);
+ }
}
}
@@ -143,39 +147,33 @@ public class SelectMessagesEditPartTracker extends SelectSeveralLinksEditPartTra
return super.handleButtonDown(button);
}
- /**
- * Constructor.
- *
- * @param owner
- */
- public SelectMessagesEditPartTracker(ConnectionEditPart owner) {
- super(owner);
- PlatformUI.getWorkbench().getDisplay().addFilter(SWT.KeyDown, KeyDownListener);
- PlatformUI.getWorkbench().getDisplay().addFilter(SWT.KeyUp, KeyUPListener);
- }
-
- private boolean allowReoder = false;
-
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gef.Tool#deactivate()
- */
- @Override
- public void deactivate() {
- PlatformUI.getWorkbench().getDisplay().removeFilter(SWT.KeyUp, KeyDownListener);
- PlatformUI.getWorkbench().getDisplay().removeFilter(SWT.KeyUp, KeyUPListener);
- super.deactivate();
- }
/**
* @see org.eclipse.gef.tools.SimpleDragTracker#updateSourceRequest()
*/
@Override
protected void updateSourceRequest() {
- if (!allowReoder) {
+ // When the reorder is called and there is at least one MessageCreate selected, we need to hold the message create movement
+ if (isOneMessageDeleteSelected) {
+ if (allowReorder) {
+ Dimension computedDelta = getLocation().getDifference(getStartLocation());
+ delta = null;
+ if (computedDelta.height < 0) {
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_UTIL, "Move " + computedDelta.height + " MinDistancetop" + MinDistancetop);//$NON-NLS-1$
+ if (MinDistancetop + computedDelta.height < 0) {
+ computedDelta.height = -MinDistancetop;
+ delta = computedDelta.getCopy();
+ }
+ } else {
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG_UTIL, "Move " + computedDelta.height + " MinDistancebottom" + MinDistancebottom);//$NON-NLS-1$
+ if (MinDistancebottom - computedDelta.height - 10 < 0) {
+ computedDelta.height = MinDistancebottom - 10;
+ delta = computedDelta.getCopy();
+ }
+
+ }
+ }
+ } else if (!allowReorder) {
Dimension computedDelta = getLocation().getDifference(getStartLocation());
delta = null;
if (computedDelta.height < 0) {
@@ -192,7 +190,6 @@ public class SelectMessagesEditPartTracker extends SelectSeveralLinksEditPartTra
}
}
-
}
super.updateSourceRequest();
}

Back to the top