|
T-Plan Robot Enterprise 3.4 Build No. 3.4-20130322.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.tplan.robot.scripting.commands.AbstractCommandHandler
com.tplan.robot.scripting.commands.impl.WaitforCommand
public class WaitforCommand
Handler implementing functionality of the WaitFor command.
T-Plan Robot Enterprise, (C) 2009-2013 T-Plan Limited. All rights reserved.
| Field Summary | |
|---|---|
static String |
ACTION_EDIT_WAITFOR
|
static String |
EVENT_BELL
|
static String |
EVENT_CLIPBOARD
|
static String |
EVENT_MATCH
|
static String |
EVENT_MISMATCH
|
static String |
EVENT_UPDATE
|
static String |
PARAM_AREA
|
static String |
PARAM_CUMULATIVE
|
static String |
PARAM_EVENT
|
static String |
PARAM_EXTENT
|
static String |
PARAM_INTERVAL
|
static String |
PARAM_ONTIMEOUT
|
static String |
PARAM_TEMPLATE
|
static String |
PARAM_TIMEOUT
|
| Fields inherited from class com.tplan.robot.scripting.commands.AbstractCommandHandler |
|---|
ALT, CONTEXT_COMMAND_CALL_PARAMETER_MAP, CONTEXT_COMPILE_SINGLE_COMMAND_MODE, CONTEXT_LAST_WAIT_FACTOR, CONTEXT_WAIT_FACTOR_ERR_MSG_SHOWN, CTRL, PARAM_COUNT, PARAM_ONFAIL, PARAM_ONPASS, PARAM_WAIT, SHIFT, WINDOWS |
| Fields inherited from interface com.tplan.robot.scripting.commands.EditorFriendlyCommandHandler |
|---|
CATEGORY_ADMIN, CATEGORY_DESKTOP, CATEGORY_IMAGE_OPS, CATEGORY_IO, CATEGORY_REPORTING, CATEGORY_UNKNOWN |
| Constructor Summary | |
|---|---|
WaitforCommand()
|
|
| Method Summary | |
|---|---|
boolean |
canRunWithoutConnection()
This method should return true if it can be executed even when the tool is not connected to a desktop. |
void |
checkVisualParameters(Map<String,CharSequence> parameters,
TestScriptInterpret interpret)
Check (compile) the map of parameters retrieved through the command editor window before they are used to build and/or update the command or Java method call. |
void |
configurationChanged(ConfigurationChangeEvent evt)
This method gets called when a configuration parameter is changed. |
int |
execute(List args,
Map values,
ScriptingContext ctx)
Execute the command. |
List |
getArguments(String command,
ScriptingContext context)
Get the list of supported arguments. |
int |
getCategory(StringBuilder description)
Get the category the command falls to. |
String[] |
getCommandNames()
Get command names. |
String |
getContextArgument()
Implementation of the getContextArgument() method. |
Map |
getContextAttributes()
Get a map with context attributes. |
KeyStroke |
getContextShortcut()
Get preferred hot key for the GUI command wizard. |
List |
getParameters(String command,
ScriptingContext context)
Get the list of supported parameters. |
List |
getParameterValues(String paramName,
String command,
ScriptingContext context)
Get values of a particular parameter. |
List<Preference> |
getPreferences()
Get metadata of displayable/editable configurable parameters. |
String |
getShortDescription(Map<String,String> parameters,
TestScriptInterpret interpret)
Get short description (up to 50 chars) of what the command does. |
List<Preference> |
getVisualParameters(LinkedHashMap<String,Object> parameters,
TestScriptInterpret interpret)
Get the list of visual parameters for construction of a dynamic command editor window. |
protected int |
handleWaitUntilEvent(ScriptingContext repository,
Map params)
|
boolean |
hasCustomParameterComponent(LinkedHashMap<String,Object> parameters,
TestScriptInterpret interpret,
PreferencePanel[] panel)
Specify whether the command provides a custom preference panel. |
boolean |
hasCustomPropertyDialog(LinkedHashMap<String,Object> parameters,
TestScriptInterpret interpret,
int offset,
Action[] action)
Specify whether the command provides a custom editor. |
boolean |
hasFixedArgument(List<String> arguments)
Defines whether the command uses a fixed argument (one-of-a-list). |
protected void |
updateRectVariables(ScriptingContext ctx,
Map variables,
Rectangle r)
|
void |
validate(List args,
Map values,
Map variableContainer,
ScriptingContext ctx)
Validate that the command has correct syntax. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.tplan.robot.scripting.commands.CommandHandler |
|---|
addCommandListener, getStablePopupMenuItems, isGlobalPrerequisity, removeCommandListener |
| Field Detail |
|---|
public static final String PARAM_TIMEOUT
public static final String PARAM_ONTIMEOUT
public static final String PARAM_AREA
public static final String PARAM_EXTENT
public static final String PARAM_EVENT
public static final String PARAM_CUMULATIVE
public static final String PARAM_TEMPLATE
public static final String PARAM_INTERVAL
public static final String EVENT_BELL
public static final String EVENT_UPDATE
public static final String EVENT_MATCH
public static final String EVENT_MISMATCH
public static final String EVENT_CLIPBOARD
public static final String ACTION_EDIT_WAITFOR
| Constructor Detail |
|---|
public WaitforCommand()
| Method Detail |
|---|
public Map getContextAttributes()
getContextAttributes in interface CommandHandlergetContextAttributes in class AbstractCommandHandlerpublic KeyStroke getContextShortcut()
CommandHandler
getContextShortcut in interface CommandHandlergetContextShortcut in class AbstractCommandHandlerpublic String getContextArgument()
getContextArgument in interface CommandHandlergetContextArgument in class AbstractCommandHandler
public void validate(List args,
Map values,
Map variableContainer,
ScriptingContext ctx)
throws SyntaxErrorException
validate in interface CommandHandlerargs - a list of parameters.values - a map of [param, value] pairs resulted from parsing of the command.variableContainer - output map for values.ctx - execution context.
SyntaxErrorException - An exception is thrown when the command syntax is incorrect.public String[] getCommandNames()
CommandHandlerGet command names. A command name is the first word in a script line, e.g. "Type" or "Press". Though most commands have just one name, you may use this method to define any number of command aliases. You may even use one class to implement more commands if you want. In such a case you need to define more command names and implement a different behavior for each command.
Please note that command name parsing is NOT case sensitive. You don't have to define the names as e.g. { "MyCommand", "mycommand" }. Script parser will always parse the command name in a script and convert it to upper case using the String.toUpperCase(). Such a command name will be then used to look for a command implementation in the command table.
getCommandNames in interface CommandHandler
public int execute(List args,
Map values,
ScriptingContext ctx)
throws SyntaxErrorException
CommandHandlerExecute the command.
Argument context will contain all necessary objects that the command may possibly use,
for example the com.tplan.robot.gui.FrameBufferPanel and com.tplan.robot.api.rfb.RfbModule instances etc. If the command e.g. needs to send
some key events to the RFB server, you should save the reference to the RfbModuleImpl instance and use
its methods to fire the required key events.
execute in interface CommandHandlerargs - a list of parameters.values - a map of [param, value] pairs resulted from parsing of the command.ctx - execution context.
SyntaxErrorException - when the command doesn't meet the required syntax.
protected int handleWaitUntilEvent(ScriptingContext repository,
Map params)
throws InterruptedException
InterruptedException
protected void updateRectVariables(ScriptingContext ctx,
Map variables,
Rectangle r)
public List<Preference> getPreferences()
Configurable
getPreferences in interface ConfigurablegetPreferences in class AbstractCommandHandlerpublic boolean canRunWithoutConnection()
canRunWithoutConnection in interface CommandHandlercanRunWithoutConnection in class AbstractCommandHandler
public List getArguments(String command,
ScriptingContext context)
AdvancedCommandHandler
getArguments in interface AdvancedCommandHandlercommand - the current command.context - a context.
public List getParameters(String command,
ScriptingContext context)
AdvancedCommandHandler
getParameters in interface AdvancedCommandHandlercommand - the current conmmand text (complete).context - a context.
public List getParameterValues(String paramName,
String command,
ScriptingContext context)
AdvancedCommandHandler
getParameterValues in interface AdvancedCommandHandlerparamName - parameter name.command - the current conmmand text (complete).context - a context.
public void configurationChanged(ConfigurationChangeEvent evt)
ConfigurationChangeListener
configurationChanged in interface ConfigurationChangeListenerevt - A ConfigurationChangeEvent object describing the event source
and the parameter that has changed.
public String getShortDescription(Map<String,String> parameters,
TestScriptInterpret interpret)
EditorFriendlyCommandHandler
getShortDescription in interface EditorFriendlyCommandHandlerparameters - map of parameters and their values. All values are
in the format recognized by token parser (TokenParserImpl.getParser())
which may be used to convert them to native Java objects such as Number, Point,
Rectangle etc.interpret - test script interpret owning the edited script.
public List<Preference> getVisualParameters(LinkedHashMap<String,Object> parameters,
TestScriptInterpret interpret)
EditorFriendlyCommandHandlerGet the list of visual parameters for construction of a dynamic command editor window.
This method will be called only after the EditorFriendlyCommandHandler.hasCustomPropertyDialog(java.util.LinkedHashMap, com.tplan.robot.scripting.interpret.TestScriptInterpret, int, javax.swing.Action[])
and EditorFriendlyCommandHandler.hasCustomParameterComponent(java.util.LinkedHashMap, com.tplan.robot.scripting.interpret.TestScriptInterpret, com.tplan.robot.gui.preferences.PreferencePanel[]) methods
return false.
getVisualParameters in interface EditorFriendlyCommandHandlerparameters - input parameters parsed from the already existing command
or preselected through the Command Wizard menu.interpret - test script interpret owning the edited script.
EditorFriendlyCommandHandler.hasCustomPropertyDialog(java.util.LinkedHashMap, com.tplan.robot.scripting.interpret.TestScriptInterpret, int, javax.swing.Action[])
and EditorFriendlyCommandHandler.hasCustomParameterComponent(java.util.LinkedHashMap, com.tplan.robot.scripting.interpret.TestScriptInterpret, com.tplan.robot.gui.preferences.PreferencePanel[]) methods,
it will be considered as not editable through the GUI.public boolean hasFixedArgument(List<String> arguments)
EditorFriendlyCommandHandler
hasFixedArgument in interface EditorFriendlyCommandHandlerarguments - optional output list for the argument values.
public int getCategory(StringBuilder description)
EditorFriendlyCommandHandlerEditorFriendlyCommandHandler.CATEGORY_UNKNOWN or a code outside of the recognized constants
and pass the desired category name through the argument string builder instance.
getCategory in interface EditorFriendlyCommandHandlerdescription - string buffer for category name. It is only used
if the returned value is other than the standard ones.
public void checkVisualParameters(Map<String,CharSequence> parameters,
TestScriptInterpret interpret)
throws IllegalArgumentException
EditorFriendlyCommandHandlerCheck (compile) the map of parameters retrieved through the command editor window before they are used to build and/or update the command or Java method call. This method may be also used to remove or filter the parameters. This is especially useful if the command editor uses auxiliary settings which are not recognized by the command or method at runtime.
If the command handler extends the AbstractCommandHandler class,
it may take advantage of the AbstractCommandHandler.compileParameters(java.util.Map, com.tplan.robot.scripting.interpret.TestScriptInterpret)
method which converts a copy of the input map to the legacy parameter format and passes it to
the CommandHandler.validate(java.util.List, java.util.Map, java.util.Map, com.tplan.robot.scripting.ScriptingContext) method
to verify whether the parameters are recognized and their values are acceptable. This allows
to avoid duplication of parameter parsing and compilation code.
checkVisualParameters in interface EditorFriendlyCommandHandlerparameters - map of parameters and their values. All values are
in the format recognized by token parser (TokenParserImpl.getParser())
which may be used to convert them to native Java objects such as Number, Point,
Rectangle etc.interpret - test script interpret owning the edited script.
IllegalArgumentException - when one or more parameters is not
recognized or its value is invalid. The exception should contain a descriptive
message because it will be displayed by the GUI.
public boolean hasCustomParameterComponent(LinkedHashMap<String,Object> parameters,
TestScriptInterpret interpret,
PreferencePanel[] panel)
EditorFriendlyCommandHandlerpanel
array with an instance of the panel.
hasCustomParameterComponent in interface EditorFriendlyCommandHandlerparameters - map of parameters and their values. All values are
in the format recognized by token parser (TokenParserImpl.getParser())
which may be used to convert them to native Java objects such as Number, Point,
Rectangle etc.interpret - test script interpret owning the edited script.panel - output array of length=1 which should be populated inside the method
with the custom panel instance if the method returns true.
public boolean hasCustomPropertyDialog(LinkedHashMap<String,Object> parameters,
TestScriptInterpret interpret,
int offset,
Action[] action)
EditorFriendlyCommandHandlerSpecify whether the command provides a custom editor. If it does
it is expected to return true and populate the first field of the action
array with an instance of an Action which opens up the dialog.
Even though the method is implemented to return false, it may be also used to preprocess parameters parsed from an existing command call before they reach the command editor window. The method may for example change the parameters or their values in the input map. As the argument map the real one rather than a copy, any data change will hold in there and it will be reflected in the GUI.
hasCustomPropertyDialog in interface EditorFriendlyCommandHandlerparameters - map of parameters and their values. All values are
in the format recognized by token parser (TokenParserImpl.getParser())
which may be used to convert them to native Java objects such as Number, Point,
Rectangle etc.interpret - test script interpret owning the edited script.offset - position in the edited script.action - output array of length=1 which should be populated inside the method
with an Action instance if the method returns true.
|
T-Plan Robot Enterprise 3.4 Build No. 3.4-20130322.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||