org.eclipse.swtbot.swt.finder.widgets
Class SWTBotTree

java.lang.Object
  extended by org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot<Tree>
      extended by org.eclipse.swtbot.swt.finder.widgets.SWTBotTree

public class SWTBotTree
extends AbstractSWTBot<Tree>

Version:
$Id$
Author:
Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>, Joshua Gosse <jlgosse [at] ca [dot] ibm [dot] com>

Field Summary
 
Fields inherited from class org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot
description, display, log, widget
 
Constructor Summary
SWTBotTree(Tree tree)
          Constructs an instance of this object with the given tree.
SWTBotTree(Tree tree, SelfDescribing description)
          Constructs an instance of this object with the given tree.
 
Method Summary
 String cell(int row, int column)
          Gets the cell data for the given row/column index.
 String cell(int row, String columnName)
          Gets the cell data for the given row/column information.
 SWTBotTreeItem collapseNode(String nodeText)
          Collapses the node matching the node information.
 int columnCount()
          Gets the column count of this tree.
 List<String> columns()
          Gets the columns of this tree.
 SWTBotTreeItem expandNode(String... nodes)
          Attempts to expand all nodes along the path specified by the node array parameter.
 SWTBotTreeItem expandNode(String nodeText, boolean recursive)
          Expands the nodes as if the plus sign was clicked.
 SWTBotTreeItem[] getAllItems()
          Gets all the items in the tree.
 SWTBotTreeItem getTreeItem(String nodeText)
          Gets the tree item matching the given name.
 boolean hasItems()
          Gets if this tree has items within it.
protected  void notifySelect()
          Notifies the tree widget about selection changes
 int rowCount()
          Gets the number of rows in the tree.
 SWTBotTree select(int... indices)
          Select the indexes provided.
 SWTBotTree select(String... items)
          Selects the items matching the array list.
 SWTBotTree select(SWTBotTreeItem... items)
          Selects the items in the array.
 TableCollection selection()
          Gets the table collection representing the selection.
 int selectionCount()
          Gets the current selection count.
 SWTBotTree unselect()
          Unselects the selection in the tree.
 int visibleRowCount()
          Gets the visible row count.
 
Methods inherited from class org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot
absoluteLocation, assertEnabled, asyncExec, backgroundColor, click, click, clickXY, contextMenu, contextMenu, createEvent, createMouseEvent, createSelectionEvent, doubleClickXY, foregroundColor, getId, getText, getToolTipText, hasStyle, isActive, isEnabled, isEnabledInternal, isVisible, keyboard, notify, notify, notify, pressShortcut, pressShortcut, pressShortcut, rightClick, rightClick, setFocus, sleep, syncExec, syncExec, syncExec, syncExec, syncExec, syncExec, syncExec, syncExec, toString, traverse, waitForEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SWTBotTree

public SWTBotTree(Tree tree,
                  SelfDescribing description)
           throws WidgetNotFoundException
Constructs an instance of this object with the given tree.

Parameters:
tree - the widget.
description - the description of the widget, this will be reported by AbstractSWTBot.toString()
Throws:
WidgetNotFoundException - if the widget is null or widget has been disposed.

SWTBotTree

public SWTBotTree(Tree tree)
           throws WidgetNotFoundException
Constructs an instance of this object with the given tree.

Parameters:
tree - the widget.
Throws:
WidgetNotFoundException - if the widget is null or widget has been disposed.
Method Detail

rowCount

public int rowCount()
Gets the number of rows in the tree.

Returns:
the number of rows in the tree

columnCount

public int columnCount()
Gets the column count of this tree.

Returns:
the number of columns in the tree

columns

public List<String> columns()
Gets the columns of this tree.

Returns:
the list of columns in the tree.

cell

public String cell(int row,
                   int column)
Gets the cell data for the given row/column index.

Parameters:
row - the row index.
column - the column index.
Returns:
the cell at the location specified by the row and column

cell

public String cell(int row,
                   String columnName)
Gets the cell data for the given row/column information.

Parameters:
row - the row index.
columnName - the column name.
Returns:
the cell in the tree at the specified row and column header.

selectionCount

public int selectionCount()
Gets the current selection count.

Returns:
the number of selected items.

selection

public TableCollection selection()
Gets the table collection representing the selection.

Returns:
the selection in the tree

select

public SWTBotTree select(String... items)
Selects the items matching the array list.

Parameters:
items - the items to select.
Returns:
this same instance.

select

public SWTBotTree select(SWTBotTreeItem... items)
Selects the items in the array. Useful for cases where you're selecting items whose names are not unique, or items you've exposed one at a time while traversing the tree.

Parameters:
items - the items to select.
Returns:
this same instance.

unselect

public SWTBotTree unselect()
Unselects the selection in the tree.

Returns:
this same instance.

select

public SWTBotTree select(int... indices)
Select the indexes provided.

Parameters:
indices - the indices to select.
Returns:
this same instance.

notifySelect

protected void notifySelect()
Notifies the tree widget about selection changes


expandNode

public SWTBotTreeItem expandNode(String... nodes)
                          throws WidgetNotFoundException
Attempts to expand all nodes along the path specified by the node array parameter.

Parameters:
nodes - node path to expand
Returns:
the last Tree item that was expanded.
Throws:
WidgetNotFoundException - if any of the nodes on the path do not exist

collapseNode

public SWTBotTreeItem collapseNode(String nodeText)
                            throws WidgetNotFoundException
Collapses the node matching the node information.

Parameters:
nodeText - the text on the node.
Returns:
the Tree item that was expanded.
Throws:
WidgetNotFoundException - if the node is not found.

visibleRowCount

public int visibleRowCount()
Gets the visible row count.

Returns:
the number of visible rows

expandNode

public SWTBotTreeItem expandNode(String nodeText,
                                 boolean recursive)
                          throws WidgetNotFoundException
Expands the nodes as if the plus sign was clicked.

Parameters:
nodeText - the node to be expanded.
recursive - if the expansion should be recursive.
Returns:
the tree item that was expanded.
Throws:
WidgetNotFoundException - if the node is not found.

getTreeItem

public SWTBotTreeItem getTreeItem(String nodeText)
                           throws WidgetNotFoundException
Gets the tree item matching the given name.

Parameters:
nodeText - the text on the node.
Returns:
the tree item with the specified text.
Throws:
WidgetNotFoundException - if the node was not found.

getAllItems

public SWTBotTreeItem[] getAllItems()
Gets all the items in the tree.

Returns:
the list of all tree items in the tree, or an empty list if there are none.
Since:
1.0

hasItems

public boolean hasItems()
Gets if this tree has items within it.

Returns:
true if the tree has any items, false otherwise.
Since:
1.0