|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot<T>
public abstract class AbstractSWTBot<T extends Widget>
Helper to find SWT Widget
s and perform operations on them.
Field Summary | |
---|---|
protected SelfDescribing |
description
The description of the widget. |
Display |
display
With great power comes great responsibility, use carefully. |
protected org.apache.log4j.Logger |
log
The logger. |
T |
widget
With great power comes great responsibility, use carefully. |
Constructor Summary | |
---|---|
AbstractSWTBot(T w)
Constructs a new instance with the given widget. |
|
AbstractSWTBot(T w,
SelfDescribing description)
Constructs a new instance with the given widget. |
Method Summary | ||
---|---|---|
protected Rectangle |
absoluteLocation()
|
|
protected void |
assertEnabled()
Check if the widget is enabled, throws if the widget is disabled. |
|
protected void |
asyncExec(VoidResult toExecute)
Invokes Result.run() asynchronously on the UI thread. |
|
Color |
backgroundColor()
Gets the background color of the widget. |
|
protected AbstractSWTBot<T> |
click()
Clicks on this widget. |
|
protected AbstractSWTBot<T> |
click(int x,
int y,
boolean post)
Perform a click action at the given coordinates |
|
protected void |
clickXY(int x,
int y)
Click on the table at given coordinates |
|
protected SWTBotMenu |
contextMenu(Control control,
String text)
Gets the context menu on the given control, matching the text. |
|
SWTBotMenu |
contextMenu(String text)
Gets the context menu matching the text. |
|
protected Event |
createEvent()
Creates an event. |
|
protected Event |
createMouseEvent(int x,
int y,
int button,
int stateMask,
int count)
Create a mouse event |
|
protected Event |
createSelectionEvent(int stateMask)
Create a selection event with a particular state mask |
|
protected void |
doubleClickXY(int x,
int y)
Double-click on the table at given coordinates |
|
Color |
foregroundColor()
Gets the foreground color of the widget. |
|
String |
getId()
Gets the value of Widget#getData(String)) for the key SWTBotPreferences.DEFAULT_KEY of this
object's widget. |
|
String |
getText()
Gets the text of this object's widget. |
|
String |
getToolTipText()
Gets the tooltip of this object's widget. |
|
protected boolean |
hasStyle(Widget w,
int style)
Check if this widget has a style attribute. |
|
boolean |
isActive()
|
|
boolean |
isEnabled()
Gets if the object's widget is enabled. |
|
protected boolean |
isEnabledInternal()
Gets if the widget is enabled. |
|
boolean |
isVisible()
Checks if the widget is visible. |
|
protected Keyboard |
keyboard()
|
|
protected void |
notify(int eventType)
Sends a non-blocking notification of the specified type to the widget. |
|
protected void |
notify(int eventType,
Event createEvent)
Sends a non-blocking notification of the specified type to the widget . |
|
protected void |
notify(int eventType,
Event createEvent,
Widget widget)
Sends a non-blocking notification of the specified type to the widget. |
|
AbstractSWTBot<T> |
pressShortcut(int modificationKeys,
char c)
Presses the shortcut specified by the given keys. |
|
AbstractSWTBot<T> |
pressShortcut(int modificationKeys,
int keyCode,
char c)
Presses the shortcut specified by the given keys. |
|
AbstractSWTBot<T> |
pressShortcut(KeyStroke... keys)
Presses the shortcut specified by the given keys. |
|
protected AbstractSWTBot<T> |
rightClick()
Empty method stub, since it should be overridden by subclass#rightClick |
|
protected AbstractSWTBot<T> |
rightClick(int x,
int y,
boolean post)
Perform a right-click action at the given coordinates |
|
void |
setFocus()
Sets the focus on this control. |
|
protected static void |
sleep(long millis)
Sleeps for millis milliseconds. |
|
protected
|
syncExec(ArrayResult<T> toExecute)
Invokes ArrayResult.run() on the UI thread. |
|
protected boolean |
syncExec(BoolResult toExecute)
Invokes Result.run() synchronously on the UI thread. |
|
protected int |
syncExec(IntResult toExecute)
Invokes Result.run() synchronously on the UI thread. |
|
protected
|
syncExec(ListResult<E> toExecute)
Invokes Result.run() on the UI thread. |
|
protected
|
syncExec(Result<T> toExecute)
Invokes Result.run() synchronously on the UI thread. |
|
protected String |
syncExec(StringResult toExecute)
Invokes Result.run() synchronously on the UI thread. |
|
protected void |
syncExec(VoidResult toExecute)
Invokes VoidResult.run() on the UI thread. |
|
protected T |
syncExec(WidgetResult<T> toExecute)
Invokes Result.run() synchronously on the UI thread. |
|
String |
toString()
|
|
boolean |
traverse(Traverse traverse)
|
|
protected void |
waitForEnabled()
Wait until the widget is enabled. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final org.apache.log4j.Logger log
public final T extends Widget widget
public final Display display
protected final SelfDescribing description
Constructor Detail |
---|
public AbstractSWTBot(T w) throws WidgetNotFoundException
w
- the widget.
WidgetNotFoundException
- if the widget is null
or widget has been disposed.public AbstractSWTBot(T w, SelfDescribing description) throws WidgetNotFoundException
w
- the widget.description
- the description of the widget, this will be reported by toString()
WidgetNotFoundException
- if the widget is null
or widget has been disposed.Method Detail |
---|
protected void notify(int eventType)
eventType
- the event type.Widget.notifyListeners(int, Event)
protected void notify(int eventType, Event createEvent)
widget
.
eventType
- the type of event.createEvent
- the event to be sent to the widget
.protected void notify(int eventType, Event createEvent, Widget widget)
eventType
- the type of event.createEvent
- the event to be sent to the widget
.widget
- the widget to send the event to.protected static void sleep(long millis)
SWTUtils.sleep(long)
millis
- the time in milli secondsprotected Event createEvent()
widget
and display
. Subclasses may override to set other
event properties.protected Event createMouseEvent(int x, int y, int button, int stateMask, int count)
x
- the x co-ordinate of the mouse event.y
- the y co-ordinate of the mouse event.button
- the mouse button that was clicked.stateMask
- the state of the keyboard modifier keys.count
- the number of times the mouse was clicked.
widget
and display
protected Event createSelectionEvent(int stateMask)
stateMask
- the state of the keyboard modifier keys.protected void clickXY(int x, int y)
x
- the x co-ordinate of the clicky
- the y co-ordinate of the clickprotected void doubleClickXY(int x, int y)
x
- the x co-ordinate of the clicky
- the y co-ordinate of the clickpublic String toString()
toString
in class Object
public String getText()
public String getId()
Widget#getData(String))
for the key SWTBotPreferences.DEFAULT_KEY
of this
object's widget.
WithId
public String getToolTipText()
protected boolean hasStyle(Widget w, int style)
w
- the widget.style
- the style bits, one of the constants in SWT
.
true
if style is set on the widget.public SWTBotMenu contextMenu(String text) throws WidgetNotFoundException
text
- the text on the context menu.
WidgetNotFoundException
- if the widget is not found.protected SWTBotMenu contextMenu(Control control, String text)
control
- the controltext
- the text on the context menu.
WidgetNotFoundException
- if the widget is not found.public boolean isEnabled()
true
if the widget is enabled.Control.isEnabled()
protected boolean isEnabledInternal()
This method is not thread safe, and must be called from the UI thread.
true
if the widget is enabled.protected <T> T[] syncExec(ArrayResult<T> toExecute)
ArrayResult.run()
on the UI thread.
toExecute
- the object to be invoked in the UI thread.
protected void syncExec(VoidResult toExecute)
VoidResult.run()
on the UI thread.
toExecute
- the object to be invoked in the UI thread.protected <E> List<E> syncExec(ListResult<E> toExecute)
Result.run()
on the UI thread.
toExecute
- the object to be invoked in the UI thread.
protected boolean syncExec(BoolResult toExecute)
Result.run()
synchronously on the UI thread.
toExecute
- the object to be invoked in the UI thread.
protected String syncExec(StringResult toExecute)
Result.run()
synchronously on the UI thread.
toExecute
- the object to be invoked in the UI thread.
protected <T> T syncExec(Result<T> toExecute)
Result.run()
synchronously on the UI thread.
toExecute
- the object to be invoked in the UI thread.
protected T syncExec(WidgetResult<T> toExecute)
Result.run()
synchronously on the UI thread.
toExecute
- the object to be invoked in the UI thread.
protected int syncExec(IntResult toExecute)
Result.run()
synchronously on the UI thread.
toExecute
- the object to be invoked in the UI thread.
protected void asyncExec(VoidResult toExecute)
Result.run()
asynchronously on the UI thread.
toExecute
- the object to be invoked in the UI thread.public Color foregroundColor()
null
if the widget is not an instance of
Control
.public Color backgroundColor()
null
if the widget is not an instance of
Control
.protected void assertEnabled()
protected void waitForEnabled()
public boolean isVisible()
true
if the widget is visible, false
otherwise.public void setFocus()
public boolean traverse(Traverse traverse)
traverse
- the kind of traversal to perform.
true
if the traversal succeeded.Control.traverse(int)
public boolean isActive()
true
if this widget has focus.Display.getFocusControl()
protected AbstractSWTBot<T> click()
protected AbstractSWTBot<T> rightClick()
protected AbstractSWTBot<T> click(int x, int y, boolean post)
x
- the x coordinatey
- the y coordinatepost
- Whether or not Display.post(org.eclipse.swt.widgets.Event)
should be used
protected AbstractSWTBot<T> rightClick(int x, int y, boolean post)
x
- the x coordinatey
- the y coordinatepost
- Whether or not Display.post(org.eclipse.swt.widgets.Event)
should be used
protected Rectangle absoluteLocation()
protected Keyboard keyboard()
public AbstractSWTBot<T> pressShortcut(int modificationKeys, char c)
modificationKeys
- the combination of SWT.ALT
| SWT.CTRL
| SWT.SHIFT
|
SWT.COMMAND
.c
- the character
Keystrokes.toKeys(int, char)
public AbstractSWTBot<T> pressShortcut(int modificationKeys, int keyCode, char c)
modificationKeys
- the combination of SWT.ALT
| SWT.CTRL
| SWT.SHIFT
| SWT.COMMAND
.keyCode
- the keyCode, these may be special keys like F1-F12, or navigation keys like HOME, PAGE_UPc
- the character
Keystrokes.toKeys(int, char)
public AbstractSWTBot<T> pressShortcut(KeyStroke... keys)
keys
- the keys to press
Keyboard.pressShortcut(KeyStroke...)
,
Keystrokes
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |