org.eclipse.swtbot.eclipse.finder.widgets
Class SWTBotWorkbenchPart<T extends IWorkbenchPartReference>

java.lang.Object
  extended by org.eclipse.swtbot.eclipse.finder.widgets.SWTBotWorkbenchPart<T>
Direct Known Subclasses:
SWTBotEditor, SWTBotView

public abstract class SWTBotWorkbenchPart<T extends IWorkbenchPartReference>
extends Object

This represents the eclipse IWorkbenchPartReference item, subclasses must extend this to implement support for various IWorkbenchPartReferences.

Since:
2.0
Version:
$Id$
Author:
Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>, Ralf Ebert www.ralfebert.de (bug 271630)

Field Summary
protected  SWTWorkbenchBot bot
          A helper swtbot instance.
protected  org.apache.log4j.Logger log
          The logger.
protected  T partReference
          The IWorkbenchPartReference reference that this part encapsulates.
 
Constructor Summary
SWTBotWorkbenchPart(T partReference, SWTWorkbenchBot bot)
          Creates an instance of a workbench part.
SWTBotWorkbenchPart(T partReference, SWTWorkbenchBot bot, SelfDescribing description)
          Creates an instance of a workbench part.
 
Method Summary
protected  void assertActive()
          Asserts that the viewpart is active.
 SWTBot bot()
          Returns a SWTBot instance that matches the contents of this workbench part.
abstract  void close()
          Close the partReference.
protected
<S extends Widget>
S
findWidget(Matcher<S> matcher)
           
protected
<S extends Widget>
List<? extends S>
findWidgets(Matcher<S> matcher)
           
 T getReference()
           
 String getTitle()
          Gets the title of the partReference.
 List<SWTBotToolbarButton> getToolbarButtons()
          Gets the toolbar buttons currently visible.
 Widget getWidget()
          The parent widget inside the partReference.
abstract  boolean isActive()
           
abstract  void setFocus()
          Sets focus on the current part.
 void show()
          Shows the part if it is visible.
 SWTBotToolbarButton toolbarButton(String tooltip)
          Gets the toolbar button matching the given toolbar button.
 SWTBotToolbarDropDownButton toolbarDropDownButton(String tooltip)
          Gets the toolbar drop down button matching the given toolbar button.
 SWTBotToolbarPushButton toolbarPushButton(String tooltip)
          Gets the toolbar push button matching the given toolbar button.
 SWTBotToolbarRadioButton toolbarRadioButton(String tooltip)
          Gets the toolbar radio button matching the given toolbar button.
 SWTBotToolbarToggleButton toolbarToggleButton(String tooltip)
          Gets the toggle toolbar button matching the given toolbar button.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

partReference

protected final T extends IWorkbenchPartReference partReference
The IWorkbenchPartReference reference that this part encapsulates.


log

protected final org.apache.log4j.Logger log
The logger.


bot

protected final SWTWorkbenchBot bot
A helper swtbot instance.

Constructor Detail

SWTBotWorkbenchPart

public SWTBotWorkbenchPart(T partReference,
                           SWTWorkbenchBot bot)
Creates an instance of a workbench part.

Parameters:
partReference - the part reference.
bot - the helper bot.

SWTBotWorkbenchPart

public SWTBotWorkbenchPart(T partReference,
                           SWTWorkbenchBot bot,
                           SelfDescribing description)
Creates an instance of a workbench part.

Parameters:
partReference - the part reference.
bot - the helper bot.
description - the description of the workbench part.
Method Detail

getReference

public T getReference()
Returns:
the reference for this part.

close

public abstract void close()
Close the partReference.


show

public void show()
Shows the part if it is visible.


getTitle

public String getTitle()
Gets the title of the partReference.

Returns:
the title of the part as visible in the tab

getToolbarButtons

public List<SWTBotToolbarButton> getToolbarButtons()
Gets the toolbar buttons currently visible.

Returns:
The set of toolbar buttons.

toolbarDropDownButton

public SWTBotToolbarDropDownButton toolbarDropDownButton(String tooltip)
                                                  throws WidgetNotFoundException
Gets the toolbar drop down button matching the given toolbar button.

Parameters:
tooltip - The tooltip to use to find the button to return.
Returns:
The toolbar button.
Throws:
WidgetNotFoundException - Thrown if the widget was not found matching the given tooltip.

toolbarRadioButton

public SWTBotToolbarRadioButton toolbarRadioButton(String tooltip)
                                            throws WidgetNotFoundException
Gets the toolbar radio button matching the given toolbar button.

Parameters:
tooltip - The tooltip to use to find the button to return.
Returns:
The toolbar button.
Throws:
WidgetNotFoundException - Thrown if the widget was not found matching the given tooltip.

toolbarPushButton

public SWTBotToolbarPushButton toolbarPushButton(String tooltip)
                                          throws WidgetNotFoundException
Gets the toolbar push button matching the given toolbar button.

Parameters:
tooltip - The tooltip to use to find the button to return.
Returns:
The toolbar button.
Throws:
WidgetNotFoundException - Thrown if the widget was not found matching the given tooltip.

toolbarToggleButton

public SWTBotToolbarToggleButton toolbarToggleButton(String tooltip)
                                              throws WidgetNotFoundException
Gets the toggle toolbar button matching the given toolbar button.

Parameters:
tooltip - The tooltip to use to find the button to return.
Returns:
The toolbar button.
Throws:
WidgetNotFoundException - Thrown if the widget was not found matching the given tooltip.

toolbarButton

public SWTBotToolbarButton toolbarButton(String tooltip)
                                  throws WidgetNotFoundException
Gets the toolbar button matching the given toolbar button.

Parameters:
tooltip - The tooltip to use to find the button to return.
Returns:
The toolbar button.
Throws:
WidgetNotFoundException - Thrown if the widget was not found matching the given tooltip.

findWidget

protected <S extends Widget> S findWidget(Matcher<S> matcher)
Parameters:
matcher - a matcher.
Returns:
a widget within the parent widget that matches the specified matcher.

findWidgets

protected <S extends Widget> List<? extends S> findWidgets(Matcher<S> matcher)
Parameters:
matcher - a matcher.
Returns:
a widget within the parent widget that matches the specified matcher.

bot

public SWTBot bot()
Returns a SWTBot instance that matches the contents of this workbench part.

Returns:
SWTBot

assertActive

protected void assertActive()
Asserts that the viewpart is active.


isActive

public abstract boolean isActive()
Returns:
true if the part is currently active.

setFocus

public abstract void setFocus()
Sets focus on the current part.


getWidget

public Widget getWidget()
The parent widget inside the partReference. If you want to look for a particular widget within the part, this is a good place to start searching for the widget.

NOTE: Clients must ensure that the part is active at the time of making this call. If the part is not active, then this method will throw a WidgetNotFoundException.

Returns:
the parent widget in the part.
See Also:
findWidget(org.hamcrest.Matcher), assertActive(), show()