Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariot Chauvin2009-12-15 15:37:14 +0000
committerMariot Chauvin2009-12-15 15:37:14 +0000
commit1f52517ae73a5e012c46fe5701b856e8ee723457 (patch)
tree439362ac163db8caf31207bc7bf363a0acf7417f
parentbaeab18e02f088238cfefd61c4ddd7c908a6dd86 (diff)
downloadorg.eclipse.swtbot-1f52517ae73a5e012c46fe5701b856e8ee723457.tar.gz
org.eclipse.swtbot-1f52517ae73a5e012c46fe5701b856e8ee723457.tar.xz
org.eclipse.swtbot-1f52517ae73a5e012c46fe5701b856e8ee723457.zip
Bug 287237 - Provide an API to click on an edit part at an arbitrary point
-rw-r--r--org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditPart.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditPart.java b/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditPart.java
index f3094d6e..1402672c 100644
--- a/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditPart.java
+++ b/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditPart.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Stack;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
@@ -132,37 +133,47 @@ public class SWTBotGefEditPart {
graphicalEditor.select(this);
return this;
}
-
+
/**
* click on the edit part.
*/
public SWTBotGefEditPart click() {
+ final Rectangle bounds = getBounds();
+ return click(bounds.getTopLeft());
+ }
+
+ /**
+ * click on the edit part at the specified location
+ */
+ public SWTBotGefEditPart click(final Point location) {
UIThreadRunnable.asyncExec(new VoidResult() {
public void run() {
- IFigure figure = ((GraphicalEditPart) part).getFigure();
- Rectangle bounds = figure.getBounds().getCopy();
- figure.translateToAbsolute(bounds);
- graphicalEditor.getCanvas().mouseEnterLeftClickAndExit(bounds.x, bounds.y);
+ graphicalEditor.getCanvas().mouseEnterLeftClickAndExit(location.x, location.y);
}
});
return this;
}
-
+
/**
* double click on the edit part.
*/
public SWTBotGefEditPart doubleClick() {
+ final Rectangle bounds = getBounds();
UIThreadRunnable.asyncExec(new VoidResult() {
public void run() {
- IFigure figure = ((GraphicalEditPart) part).getFigure();
- Rectangle bounds = figure.getBounds().getCopy();
- figure.translateToAbsolute(bounds);
graphicalEditor.getCanvas().mouseMoveDoubleClick(bounds.x, bounds.y);
}
});
return this;
}
+ private Rectangle getBounds() {
+ final IFigure figure = ((GraphicalEditPart) part).getFigure();
+ final Rectangle bounds = figure.getBounds().getCopy();
+ figure.translateToAbsolute(bounds);
+ return bounds;
+ }
+
public SWTBotGefEditPart activateDirectEdit() {
return activateDirectEdit(null);
}

Back to the top