diff options
Diffstat (limited to 'org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java')
-rw-r--r-- | org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java index 832f2451..642ebc89 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java @@ -360,6 +360,23 @@ public class SWTBotTreeItem extends AbstractSWTBot<TreeItem> { } /** + * Unselects the current tree item. The tree must have the SWT.MULTI style. + * + * @return the current node. + * @since 2.8 + */ + public SWTBotTreeItem unselect() { + assertMultiSelect(); + if (!isSelected()) { + return this; + } + waitForEnabled(); + setFocus(); + notifyUnselect(widget); + return this; + } + + /** * Click on the tree at given coordinates * * @param x the x co-ordinate of the click @@ -635,6 +652,31 @@ public class SWTBotTreeItem extends AbstractSWTBot<TreeItem> { } /** + * Unselects the given tree item. + * + * @param item + * tree item to unselect + */ + private Runnable unselectRunnable(final TreeItem item) { + return new Runnable() { + @Override + public void run() { + tree.deselect(item); + } + }; + } + + /** + * Unselects the specified item and sends notifications. + * + * @param unselected + * the tree item to unselect + */ + private void notifyUnselect(TreeItem unselected) { + notifySelect(unselected, SWT.MOD1, unselectRunnable(unselected)); + } + + /** * Selects the specified item and sends notifications. * * @param selected the tree item to select. |