public class Action extends Object
It handles performing action through main menu (MENU_MODE), popup menu (POPUP_MODE), IDE SystemAction API call (API_MODE) or through keyboard shortcut (SHORTCUT_MODE).
Action can be performed in exact mode by calling performMenu(...), performPopup(...), performAPI(...) or performShortcut(...).
If exact mode is not supported by the action it throws UnsupportedOperationException.
Current implementation supports MENU_MODE when menuPath is defined, POPUP_MODE when popupPath is defined, API_MODE when systemActionClass is defined and SHORTCUT_MODE when shortcut is defined (see Action constructors).
Action also can be performed using runtime default mode by calling perform(...).
When default mode is not support by the action other modes are tried till
supported mode found and action is performed.
Timeouts used:
Action.WaitAfterShortcutTimeout - time to sleep between shortcuts in sequence
(default 0)
Modifier and Type | Class and Description |
---|---|
static class |
Action.Shortcut
Deprecated.
Use
KeyStroke instead. |
Modifier and Type | Field and Description |
---|---|
protected static long |
AFTER_ACTION_WAIT_TIME
sleep time after action execution
|
static int |
API_MODE
through API action performing mode
|
protected KeyStroke[] |
keystrokes
Array of key strokes or null when SHORTCUT_MODE is not supported.
|
protected String |
layerInstancePath
Path to action instance FileObject in layer or null when API_MODE is not
supported or systemActionClass is used.
|
static int |
MENU_MODE
through menu action performing mode
|
protected String |
menuPath
menu path of current action or null when MENU_MODE is not supported
|
static int |
POPUP_MODE
through popup menu action performing mode
|
protected String |
popupPath
popup menu path of current action or null when POPUP_MODE is not
supported
|
protected static long |
SELECTION_WAIT_TIME
sleep time between nodes selection and action execution
|
static int |
SHORTCUT_MODE
through shortcut action performing mode
|
protected Class |
systemActionClass
SystemAction class of current action or null when API_MODE is not
supported
|
protected static long |
WAIT_AFTER_SHORTCUT_TIMEOUT
sleep time between sequence of shortcuts
|
Constructor and Description |
---|
Action(String menuPath,
String popupPath)
creates new Action instance without API_MODE and SHORTCUT_MODE support
|
Action(String menuPath,
String popupPath,
Action.Shortcut shortcut)
Deprecated.
|
Action(String menuPath,
String popupPath,
Action.Shortcut[] shortcuts)
Deprecated.
|
Action(String menuPath,
String popupPath,
KeyStroke keystroke)
Creates new Action instance without API_MODE support.
|
Action(String menuPath,
String popupPath,
KeyStroke[] keystrokes)
Creates new Action instance without API_MODE support.
|
Action(String menuPath,
String popupPath,
String systemActionClass)
creates new Action instance without SHORTCUT_MODE support
|
Action(String menuPath,
String popupPath,
String systemActionClass,
Action.Shortcut shortcut)
Deprecated.
|
Action(String menuPath,
String popupPath,
String systemActionClass,
Action.Shortcut[] shortcuts)
Deprecated.
|
Action(String menuPath,
String popupPath,
String systemActionClass,
KeyStroke keystroke)
Creates new Action instance.
|
Action(String menuPath,
String popupPath,
String systemActionClass,
KeyStroke[] keystrokes)
Creates new Action instance.
|
Modifier and Type | Method and Description |
---|---|
org.netbeans.jemmy.operators.Operator.StringComparator |
getComparator()
Gets comparator set for this action instance.
|
int |
getDefaultMode()
Returns default mode in which actions are performed.
|
KeyStroke[] |
getKeyStrokes()
Returns an array of KeyStroke objects.
|
String |
getMenuPath()
getter for main menu path
|
String |
getPopupPath()
getter for popup menu path
|
Class |
getSystemActionClass()
getter for system action class
|
boolean |
isEnabled()
Checks whether this action is enabled.
|
boolean |
isEnabled(org.netbeans.jemmy.operators.ComponentOperator componentOperator)
Checks whether this action is enabled for given ComponentOperator.
|
boolean |
isEnabled(Node node)
Checks whether this action on given node is enabled.
|
boolean |
isEnabled(Node[] nodes)
Checks whether this action on given nodes is enabled.
|
void |
perform()
performs action depending on default mode,
calls performPopup(), performMenu() or performAPI(), when default mode is not supported, others are tried |
void |
perform(org.netbeans.jemmy.operators.ComponentOperator component)
performs action depending on default mode,
calls performPopup(), performMenu() or performAPI(), when default mode is not supported, others are tried |
void |
perform(Node node)
performs action depending on default mode,
calls performPopup(), performMenu() or performAPI(), when default mode is not supported, others are tried |
void |
perform(Node[] nodes)
performs action depending on default mode,
calls performPopup(), performMenu() or performAPI(), when default mode is not supported, others are tried |
void |
perform(OutlineNode node)
performs action depending on default mode,
calls performPopup(), performMenu(), performShortcut or performAPI(), when default mode is not supported, others are tried |
void |
performAPI()
performs action through API
|
void |
performAPI(org.netbeans.jemmy.operators.ComponentOperator component)
performs action through API
|
void |
performAPI(Node node)
performs action through API
|
void |
performAPI(Node[] nodes)
performs action through API
|
void |
performAPI(OutlineNode node)
performs action through API
|
void |
performMenu()
performs action through main menu
|
void |
performMenu(org.netbeans.jemmy.operators.ComponentOperator component)
performs action through main menu
|
void |
performMenu(Node node)
performs action through main menu
|
void |
performMenu(Node[] nodes)
performs action through main menu
|
void |
performMenu(OutlineNode node) |
void |
performPopup()
performs action through popup menu
|
void |
performPopup(org.netbeans.jemmy.operators.ComponentOperator component)
performs action through popup menu
|
void |
performPopup(Node node)
performs action through popup menu
|
void |
performPopup(Node[] nodes)
performs action through popup menu
|
void |
performPopup(OutlineNode node)
Performs action on an OutlineNode through popup menu.
|
void |
performShortcut()
performs action through shortcut
|
void |
performShortcut(org.netbeans.jemmy.operators.ComponentOperator component)
performs action through shortcut
|
void |
performShortcut(Node node)
performs action through shortcut
|
void |
performShortcut(Node[] nodes)
performs action through shortcut
|
void |
performShortcut(OutlineNode node)
performs action through shortcut
|
void |
setComparator(org.netbeans.jemmy.operators.Operator.StringComparator comparator)
Sets comparator fot this action.
|
int |
setDefaultMode(int mode)
Sets default mode in which actions are performed.
|
protected void |
testNodes(Node[] nodes)
tests if nodes are all from the same tree
|
public static final int MENU_MODE
public static final int POPUP_MODE
public static final int API_MODE
public static final int SHORTCUT_MODE
protected static final long SELECTION_WAIT_TIME
protected static final long AFTER_ACTION_WAIT_TIME
protected static final long WAIT_AFTER_SHORTCUT_TIMEOUT
protected String menuPath
protected String popupPath
protected Class systemActionClass
protected String layerInstancePath
protected KeyStroke[] keystrokes
public Action(String menuPath, String popupPath)
menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
shell is not supported)public Action(String menuPath, String popupPath, String systemActionClass)
menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
is not supported)systemActionClass
- String class name of SystemAction (use null
value if API mode is not supported)@Deprecated public Action(String menuPath, String popupPath, Action.Shortcut[] shortcuts)
Action.Action(String menuPath, String popupPath, KeyStroke[] keystrokes)
instead.shortcuts
- array of Shortcut instances (use null value if shorcut
mode is not supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
shell is not supported)@Deprecated public Action(String menuPath, String popupPath, Action.Shortcut shortcut)
Action.Action(String menuPath, String popupPath, KeyStroke keystroke)
instead.shortcut
- Shortcut (use null value if menu mode is not supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
shell is not supported)@Deprecated public Action(String menuPath, String popupPath, String systemActionClass, Action.Shortcut[] shortcuts)
Action.Action(String menuPath, String popupPath, String systemActionClass, KeyStroke[] keystrokes)
instead.shortcuts
- array of Shortcut instances (use null value if shortcut
mode is not supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
is not supported)systemActionClass
- String class name of SystemAction (use null
value if API mode is not supported)@Deprecated public Action(String menuPath, String popupPath, String systemActionClass, Action.Shortcut shortcut)
Action.Action(String menuPath, String popupPath, String systemActionClass, KeyStroke keystroke)
instead.shortcut
- Shortcut String (use null value if menu mode is not
supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
is not supported)systemActionClass
- String class name of SystemAction (use null
value if API mode is not supported)public Action(String menuPath, String popupPath, KeyStroke keystroke)
keystroke
- KeyStroke instance (use null value if shorcut mode is
not supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
shell is not supported)public Action(String menuPath, String popupPath, KeyStroke[] keystrokes)
keystrokes
- array of KeyStroke instances (use null value if shorcut
mode is not supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
shell is not supported)public Action(String menuPath, String popupPath, String systemActionClass, KeyStroke keystroke)
keystroke
- KeyStroke instance (use null value if shorcut mode is
not supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
is not supported)systemActionClass
- String class name of SystemAction (use null
value if API mode is not supported)public Action(String menuPath, String popupPath, String systemActionClass, KeyStroke[] keystrokes)
keystrokes
- array of KeyStroke instances (use null value if
shortcut mode is not supported)menuPath
- action path in main menu (use null value if menu mode is
not supported)popupPath
- action path in popup menu (use null value if popup mode
is not supported)systemActionClass
- String class name of SystemAction (use null
value if API mode is not supported)public void perform()
public void perform(Node node)
node
- node to be action performed onpublic void perform(Node[] nodes)
nodes
- nodes to be action performed onpublic void perform(OutlineNode node)
node
- node to be action performed onpublic void perform(org.netbeans.jemmy.operators.ComponentOperator component)
component
- component to be action performed onpublic void performMenu()
UnsupportedOperationException
- when action does not support menu
modepublic void performMenu(Node node)
node
- node to be action performed onUnsupportedOperationException
- when action does not support menu
modepublic void performMenu(Node[] nodes)
nodes
- nodes to be action performed onUnsupportedOperationException
- when action does not support menu
modepublic void performMenu(OutlineNode node)
public void performMenu(org.netbeans.jemmy.operators.ComponentOperator component)
component
- component to be action performed onUnsupportedOperationException
- when action does not support menu
modepublic void performPopup()
UnsupportedOperationException
public void performPopup(Node node)
node
- node to be action performed onUnsupportedOperationException
- when action does not support popup
modepublic void performPopup(Node[] nodes)
nodes
- nodes to be action performed onUnsupportedOperationException
- when action does not support popup
modepublic void performPopup(OutlineNode node)
node
- node to be performed onpublic void performPopup(org.netbeans.jemmy.operators.ComponentOperator component)
component
- component to be action performed onUnsupportedOperationException
- when action does not support popup
modepublic void performAPI()
UnsupportedOperationException
- when action does not support API
modepublic void performAPI(Node node)
node
- node to be action performed onUnsupportedOperationException
- when action does not support API
modepublic void performAPI(Node[] nodes)
nodes
- nodes to be action performed onUnsupportedOperationException
- when action does not support API
modepublic void performAPI(OutlineNode node)
node
- node to be action performed onUnsupportedOperationException
- when action does not support API
modepublic void performAPI(org.netbeans.jemmy.operators.ComponentOperator component)
component
- component to be action performed onUnsupportedOperationException
- when action does not support API
modepublic void performShortcut()
UnsupportedOperationException
- if no shortcut is definedpublic void performShortcut(Node node)
node
- node to be action performed onUnsupportedOperationException
- when action does not support
shortcut modepublic void performShortcut(Node[] nodes)
nodes
- nodes to be action performed onUnsupportedOperationException
- when action does not support
shortcut modepublic void performShortcut(OutlineNode node)
node
- node to be action performed onUnsupportedOperationException
- when action does not support
shortcut modepublic void performShortcut(org.netbeans.jemmy.operators.ComponentOperator component)
component
- component to be action performed onUnsupportedOperationException
- when action does not support
shortcut modeprotected void testNodes(Node[] nodes)
nodes
- nodesIllegalArgumentException
- when given nodes does not passpublic int getDefaultMode()
Action.POPUP_MODE
,
Action.MENU_MODE
,
Action.API_MODE
,
Action.SHORTCUT_MODE
public int setDefaultMode(int mode)
Action.POPUP_MODE
as default.mode
- mode to be setAction.POPUP_MODE
,
Action.MENU_MODE
,
Action.API_MODE
,
Action.SHORTCUT_MODE
public void setComparator(org.netbeans.jemmy.operators.Operator.StringComparator comparator)
comparator
- new comparator to be set (e.g. new
Operator.DefaultStringComparator(true, true); to search string item
exactly and case sensitive)public org.netbeans.jemmy.operators.Operator.StringComparator getComparator()
public String getPopupPath()
public String getMenuPath()
public Class getSystemActionClass()
public KeyStroke[] getKeyStrokes()
public boolean isEnabled()
public boolean isEnabled(Node[] nodes)
nodes
- array of nodes to be selected before a checkpublic boolean isEnabled(Node node)
node
- node to be selected before a checkpublic boolean isEnabled(org.netbeans.jemmy.operators.ComponentOperator componentOperator)
componentOperator
- instance of ComponentOperator