Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2015-06-24 08:05:52 +0000
committerLaurent Redor2015-07-06 06:49:24 +0000
commita37057c793aaa16273ca830340c7d5c655dfc399 (patch)
tree4fae51f9bad756c2fddb7a76fbc2db46c6ff12c2
parent13df0838fc2ee2e7de848b71af07775f4594d783 (diff)
downloadorg.eclipse.sirius-a37057c793aaa16273ca830340c7d5c655dfc399.tar.gz
org.eclipse.sirius-a37057c793aaa16273ca830340c7d5c655dfc399.tar.xz
org.eclipse.sirius-a37057c793aaa16273ca830340c7d5c655dfc399.zip
[463485] Update SWTBot framework for edge feedback and shortcut
For tests of bug 463485, we need 2 additional points: * to allow a key pressed during a drag'n'drop, * to move bendpoint of edge. For the first, allow a key pressed during a drag'n'drop, the method mouseDragWithKey is added in SWTBotSiriusFigureCanvas. This method has an additional parameter to precise the key code to press during the drag'n'drop. It is possible to call this method with SWT.None to retrieve the standard behavior of mouseDrag method. For the second point, move bendpoint of edge, the behavior is currently not correctly handled. Indeed, the feedback of edge is not redrawn, so the policy/command uses wrong data when it creates/executes the SetConnectionBendpointsCommand. The method mouseDragWithKey has been completed to force an update of the Viewport (that draws the feedback) and then to dispatch a second time the mouse drag event. Bug: 463485 Change-Id: If2709b01057b1db88e85fddeca0ca8f725ad8f41 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-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.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java26
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java28
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java62
5 files changed, 121 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 2fbc1380ad..44a180c3e1 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -69,6 +69,13 @@
<li><span class="label label-success">Added</span> The
<code>org.eclipse.sirius.tests.swtbot.support.api.condition.PerspectiveActivatedCondition</code> new offers the capability to inverse the test. This condition becomes a DeactivatedCondition instead of an ActivatedCondition by using the new constructor with inverse parameter.
</li>
+ <li><span class="label label-success">Added</span> The method
+ <code>org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor.dragWithKey(int, int, int, int, int)</code>, and so
+ <code>SWTBotSiriusGefViewer.dragWithKey</code> and
+ <code>SWTBotSiriusFigureCanvas.mouseDragWithKey</code>), has an additional parameter, compared to
+ <code>drag(int, int, int, int)</code> method, to precise the key code to press during the drag&#8217;n&#8217;drop. It is possible to call this method with SWT.None to retrieve the standard behavior of
+ <code>drag</code> method. This method also has a correct behavior for the move of bendpoints of edges.
+ </li>
</ul>
<h2 id="sirius3.0.0">Changes in Sirius 3.0.0</h2>
<h3 id="UserVisibleChanges">User-Visible Changes</h3>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index c1bd9440a6..b51b58b4d1 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -12,6 +12,7 @@ h4. Changes in @org.eclipse.sirius.tests.swtbot.support@
* <span class="label label-success">Added</span> The methods @closePerspective(String)@, @closeSiriusPerspective()@ and @closeModelingPerspective()@ have been added in class @org.eclipse.sirius.tests.swtbot.support.api.perspective.DesignerPerspectives@ to allow the closing of perspectives.
* <span class="label label-success">Added</span> The @org.eclipse.sirius.tests.swtbot.support.api.condition.PerspectiveActivatedCondition@ new offers the capability to inverse the test. This condition becomes a DeactivatedCondition instead of an ActivatedCondition by using the new constructor with inverse parameter.
+* <span class="label label-success">Added</span> The method @org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor.dragWithKey(int, int, int, int, int)@, and so @SWTBotSiriusGefViewer.dragWithKey@ and @SWTBotSiriusFigureCanvas.mouseDragWithKey@), has an additional parameter, compared to @drag(int, int, int, int)@ method, to precise the key code to press during the drag'n'drop. It is possible to call this method with SWT.None to retrieve the standard behavior of @drag@ method. This method also has a correct behavior for the move of bendpoints of edges.
h2(#sirius3.0.0). Changes in Sirius 3.0.0
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
index 9f14edb2a9..abc4ce7a76 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
@@ -903,6 +903,29 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
}
/**
+ * Drag and drop from the specified to the specified location with a key
+ * pressed during the drag'n'drop. This method also correctly handles the
+ * move of a bendpoint of an edge.
+ *
+ * @param fromXPosition
+ * the relative x position to drag from
+ * @param fromYPosition
+ * the relative y position to drag from
+ * @param toXPosition
+ * the relative x position to drag to
+ * @param toYPosition
+ * the relative y position to drag to
+ * @param keyCode
+ * the key code of the key that was typed, as defined by the key
+ * code constants in class <code>SWT</code>, or
+ * {@link org.eclipse.swt.SWT#None} if no key. @see
+ * org.eclipse.swt.SWT
+ */
+ public void dragWithKey(int fromXPosition, int fromYPosition, int toXPosition, int toYPosition, int keyCode) {
+ ((SWTBotSiriusGefViewer) getSWTBotGefViewer()).dragWithKey(fromXPosition, fromYPosition, toXPosition, toYPosition, keyCode);
+ }
+
+ /**
* Drag and drop the specified edit part to the specified location.
*
* @param editPartBot
@@ -1100,7 +1123,8 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
* type.<BR>
* Examples :
* <UL>
- * <LI>If the zoom is set to 50% a dimension of (80, 80) return (40, 40)</LI>
+ * <LI>If the zoom is set to 50% a dimension of (80, 80) return (40, 40)
+ * </LI>
* </UL>
*
* @param editPartName
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
index 45fb9f041a..3290369f7e 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES
+ * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES
* 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
@@ -298,4 +298,30 @@ public class SWTBotSiriusGefViewer extends SWTBotGefViewer {
return getEditpart(label, allEditParts);
}
+ /**
+ * Drag and drop from the specified to the specified location with a key
+ * pressed during the drag'n'drop. This method also correctly handles the
+ * move of a bendpoint of an edge.
+ *
+ * @param fromXPosition
+ * the relative x position to drag from
+ * @param fromYPosition
+ * the relative y position to drag from
+ * @param toXPosition
+ * the relative x position to drag to
+ * @param toYPosition
+ * the relative y position to drag to
+ * @param keyCode
+ * the key code of the key that was typed, as defined by the key
+ * code constants in class <code>SWT</code>, or
+ * {@link org.eclipse.swt.SWT#None} if no key. @see
+ * org.eclipse.swt.SWT
+ */
+ public void dragWithKey(final int fromXPosition, final int fromYPosition, final int toXPosition, final int toYPosition, final int keyCode) {
+ if (canvas instanceof SWTBotSiriusFigureCanvas) {
+ ((SWTBotSiriusFigureCanvas) canvas).mouseDragWithKey(fromXPosition, fromYPosition, toXPosition, toYPosition, keyCode);
+ } else {
+ canvas.mouseDrag(fromXPosition, fromYPosition, toXPosition, toYPosition);
+ }
+ }
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
index 374e27d474..dc4d11a563 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2012, 2014 THALES GLOBAL SERVICES
+ * Copyright (c) 2012, 2015 THALES GLOBAL SERVICES
* 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
@@ -13,6 +13,7 @@ package org.eclipse.sirius.tests.swtbot.support.api.widget;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Text;
@@ -143,4 +144,63 @@ public class SWTBotSiriusFigureCanvas extends SWTBotGefFigureCanvas {
keyEvent.keyCode = keyCode;
return keyEvent;
}
+
+ /**
+ * This method emits mouse events that handle drags within the canvas.
+ * Compared to {@link #mouseDrag(int, int, int, int)}, this method also
+ * calls an update of the viewport and makes a second calls to drag event.
+ * These new events allow to have a feedback drawn for edges and a correct
+ * behavior when moving bendpoints of edge.
+ *
+ * @param fromXPosition
+ * the relative x position within the canvas to drag from
+ * @param fromYPosition
+ * the relative y position within the canvas to drag from
+ * @param toXPosition
+ * the relative x position within the canvas to drag to
+ * @param toYPosition
+ * the relative y position within the canvas to drag to
+ * @param keyCode
+ * the key code of the key that was typed, as defined by the key
+ * code constants in class <code>SWT</code>, or {@link SWT#None}
+ * if no key. @see org.eclipse.swt.SWT
+ */
+ public void mouseDragWithKey(final int fromXPosition, final int fromYPosition, final int toXPosition, final int toYPosition, final int keyCode) {
+ UIThreadRunnable.asyncExec(new VoidResult() {
+ @Override
+ public void run() {
+ org.eclipse.swt.events.MouseEvent meMove = wrapMouseEvent(fromXPosition, fromYPosition, 0, 0, 0);
+ eventDispatcher.dispatchMouseMoved(meMove);
+ org.eclipse.swt.events.MouseEvent meDown = wrapMouseEvent(fromXPosition, fromYPosition, 1, SWT.BUTTON1, 1);
+ eventDispatcher.dispatchMousePressed(meDown);
+
+ KeyEvent keyEvent = null;
+ if (keyCode != SWT.None) {
+ keyEvent = new KeyEvent(createEvent());
+ keyEvent.keyCode = keyCode;
+ keyEvent.doit = true;
+ eventDispatcher.dispatchKeyPressed(keyEvent);
+ }
+
+ org.eclipse.swt.events.MouseEvent meMoveTarget = wrapMouseEvent(toXPosition, toYPosition, 1, SWT.BUTTON1, 0);
+ eventDispatcher.dispatchMouseMoved(meMoveTarget);
+
+ // Force an update of viewport (necessary to have a correct
+ // feedback of edge in case of moving bendpoint of edge for
+ // example)
+ if (widget instanceof FigureCanvas) {
+ ((FigureCanvas) widget).getViewport().getUpdateManager().performUpdate();
+ // Sent the mouse drag event a second time to consider the
+ // correct feedback in the policy/command
+ eventDispatcher.dispatchMouseMoved(meMoveTarget);
+ }
+
+ org.eclipse.swt.events.MouseEvent meUp = wrapMouseEvent(toXPosition, toYPosition, 1, SWT.BUTTON1, 1);
+ eventDispatcher.dispatchMouseReleased(meUp);
+ if (keyCode != SWT.None) {
+ eventDispatcher.dispatchKeyReleased(keyEvent);
+ }
+ }
+ });
+ }
}

Back to the top