drag & drop on treeviewer

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

drag & drop on treeviewer

Postby jemodurn » Fri Jun 09, 2006 10:12 am

Can you provide a sample of D&D on a jface treeviewer? Thanks.
Posts: 1
Joined: Fri Jun 09, 2006 10:10 am

re: drag & drop on treeviewer

Postby Phil Quitslund » Mon Jun 12, 2006 6:42 am


The trick with DnD is that the drag source is implicitly set by the last mouseMove/click. To start a drag from a tree item in the tree "tree", you can do something like this:

Code: Select all
ui.click("tree", "path/to/source"); //implicitly set drag source

where "path/to/source" is the tree path to the node.

To drag it, we can then do something like this:

Code: Select all
ui.dragTo("tree", "path/to/target");

Alternatively, we could establish the drag source using a moveTo command if we have a handle on the source tree item. For example:

Code: Select all
Widget treeItem = ui.find(new WidgetLocator(TreeItem.class, "SourceItem"); //find source by label
ui.moveTo(treeItem); //hover the mouse and set the drag source

Having done this we can drag and drop as above:

Code: Select all
ui.dragTo("tree", "path/to/target");

Hope this helps!
Phil Quitslund
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest