public abstract class AbstractCommandHandler extends Object implements CommandHandler, com.tplan.robot.gui.GUIConstants, Plugin, Configurable, LocalizedPlugin, ContextualDescriptionCapable
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT_COMMAND_CALL_COMPILED_PARAMETER_MAP |
static String |
CONTEXT_COMMAND_CALL_SOURCE_PARAMETER_MAP |
static String |
PARAM_COUNT |
static String |
PARAM_ONFAIL |
static String |
PARAM_ONPASS |
static String |
PARAM_WAIT |
CFG_DEADLOCK_ENABLE, CFG_DEADLOCK_SHOW_MSG, CFG_DEADLOCK_TIMEOUT, CFG_OPEN_SCHEDULE, DEADLOCK_DEFAULT_TIMEOUT, DEFAULT_TPLAN_ROBOT_FILE_EXTENSION, EVENT_ADD_CUSTOM_ACTION_MSG, EVENT_ADD_STABLE_ACTION_MSG, EVENT_DISPLAY_HASHTABLE, EVENT_DISPLAY_PREFERENCES, EVENT_DOCUMENT_CHANGED, EVENT_MOUSE_MOVED, EVENT_REMOVE_CUSTOM_ACTION_MSG, EVENT_REMOVE_STABLE_ACTION_MSG, EVENT_SELECTION_CHANGED, EVENT_STATUSBAR_MSG, HELP_URL_JAPI, HELP_URL_SPEC, HELP_URLS, PROPERTY_EXIT_REQUESTED
Constructor and Description |
---|
AbstractCommandHandler() |
Modifier and Type | Method and Description |
---|---|
void |
addCommandListener(CommandListener listener)
Add a
CommandListener to the listener list. |
boolean |
canRunWithoutConnection()
This method should return true if it can be executed even when the tool
is not connected to a desktop.
|
void |
checkDependencies(PluginManager manager)
Check whether the current product installation contains all dependencies
(other plugins) required to install this plugin.
|
Map |
compileParameters(Map paramsAndValues,
TestScriptInterpret interpret) |
void |
executeFallBackCodeOrProcedure(String code,
String procedure,
String[] procedureArgs,
ScriptingContext ctx) |
void |
fireCommandEvent(Object source,
ScriptingContext context,
String actionCode,
Object customObject) |
String |
getCode()
Get plugin code.
|
String |
getContextArgument()
Get the dummy command argument.
|
Map |
getContextAttributes()
Get a map with context attributes.
|
KeyStroke |
getContextShortcut()
Get preferred hot key for the GUI command wizard.
|
Date |
getDate()
Get plugin release date.
|
String |
getDescription()
Get plugin description to be displayed in the GUI.
|
String |
getDescription(ScriptingContext ctx,
List<String> parameters,
Map<String,String> values)
Get description of what the command performs when executed.
|
String |
getDisplayName()
Get a generic display name.
|
String |
getDisplayNameKey()
Get the key to the plugin name in the resource bundle.
|
Icon |
getIcon(String argument)
Get the command icon.
|
Class |
getImplementedInterface()
Get Class of the exposed functional interface that this plugin implements.
|
int[] |
getLowestSupportedVersion()
Get the lowest required version of T-Plan Robot Enterprise.
|
CommandHandler |
getMaster() |
String |
getMessageAfterInstall()
Get text of a message to be displayed after installation of this plugin.
|
String |
getMessageBeforeInstall()
Get text of a message to be displayed before installation of this plugin.
|
List<Preference> |
getPreferences()
Get metadata of displayable/editable configurable parameters.
|
List |
getStablePopupMenuItems()
Get a list of stable actions.
|
String |
getSupportContact()
Get support contact.
|
String |
getUniqueId()
Get unique ID associated with the plugin.
|
String |
getVendorHomePage()
Get the vendor home page.
|
String |
getVendorName()
Get vendor (provider) name to be displayed in the GUI.
|
int[] |
getVersion()
Get plugin version in form of an integer array.
|
boolean |
isGlobalPrerequisity(String command)
This method should return true if the command needs to be executed prior to running part of a test script.
|
void |
removeCommandListener(CommandListener listener)
Removes a
CommandListener from the listener list. |
boolean |
requiresOriginalValues()
Indicate whether the handler is interested in key-value pairs exactly as
they are specified on the command line.
|
boolean |
requiresRestart()
Indicate whether installation of this plugin requires application restart.
|
void |
setConfiguration(UserConfiguration cfg)
If an object implementing this interface is a plugin (i.e.
|
void |
setMaster(CommandHandler master) |
static LinkedHashMap<String,Object> |
toLinkedMap(String command,
List args,
Map params)
Convert the old fashioned set of command parameters in a List and a Map
to a single LinkedHashMap instance.
|
void |
validateOnPassAndOnFail(ScriptingContext repository,
Map params) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, getCommandNames, validate
public static final String PARAM_WAIT
public static final String PARAM_COUNT
public static final String PARAM_ONFAIL
public static final String PARAM_ONPASS
public static final String CONTEXT_COMMAND_CALL_COMPILED_PARAMETER_MAP
public static final String CONTEXT_COMMAND_CALL_SOURCE_PARAMETER_MAP
public void validateOnPassAndOnFail(ScriptingContext repository, Map params) throws SyntaxErrorException
SyntaxErrorException
public void executeFallBackCodeOrProcedure(String code, String procedure, String[] procedureArgs, ScriptingContext ctx)
public boolean isGlobalPrerequisity(String command)
CommandHandler
This method should return true if the command needs to be executed prior to running part of a test script.
Imagine a following situation. User creates a script:
Var PATH=/usr/java
Type {PATH}/bin/java
Press Enter
User then selects just the last two commands to be executed. It would of course fail because the PATH variable is not defined. If this method returns true, the command will be executed before running selected commands are executed.
isGlobalPrerequisity
in interface CommandHandler
command
- a command with parameters to be processed.public void addCommandListener(CommandListener listener)
CommandHandler
CommandListener
to the listener list.addCommandListener
in interface CommandHandler
listener
- a CommandListener
to be added.public void removeCommandListener(CommandListener listener)
CommandHandler
CommandListener
from the listener list.removeCommandListener
in interface CommandHandler
listener
- the CommandListener
to be removedpublic void fireCommandEvent(Object source, ScriptingContext context, String actionCode, Object customObject)
public List<Preference> getPreferences()
Configurable
getPreferences
in interface Configurable
public void setConfiguration(UserConfiguration cfg)
Configurable
If an object implementing this interface is a plugin (i.e. implements also the Plugin interface) and is instantiated through a supported plugin factory, the Plugin Manager calls this method right after an instance of this object is created.
Custom objects which do not already have their configuration parameters in
the default configuration file should take advantage of this method
to store their configuration into the shared User Configuration instance.
It is recommended to call the UserConfiguration.saveConfiguration()
method in the end to save the configuration to the hard drive.
Objects wishing to be notified of changes of configuration parameters
should implement the ConfigurationChangeListener interface and register
with the UserConfiguration instance through the
addConfigurationChangeListener()
method.
setConfiguration
in interface Configurable
cfg
- global shared instance of user configuration preloaded with
parameters from the default and user configuration files.public List getStablePopupMenuItems()
CommandHandler
getStablePopupMenuItems
in interface CommandHandler
public String getContextArgument()
CommandHandler
getContextArgument
in interface CommandHandler
public Map getContextAttributes()
getContextAttributes
in interface CommandHandler
public KeyStroke getContextShortcut()
CommandHandler
getContextShortcut
in interface CommandHandler
public boolean canRunWithoutConnection()
canRunWithoutConnection
in interface CommandHandler
public String getCode()
Plugin
Get plugin code. This string serves as an identifier of the functionality delivered by the plugin. For example, desktop client plugins return protocol name like "RFB" or "RDP" as their code.
Plugin code is used by pluggable instance factories to identify
a particular plugin. It may be used to replace internal plugins with
third party code. For
example if you develop a class which implements this and the
com.tplan.robot.remoteclient.RemoteDesktop
interfaces and the
getCode()
method returns "RFB", it will replace the internal
implementation of the RFB (VNC) client.
public String getVendorName()
Plugin
getVendorName
in interface Plugin
public String getSupportContact()
Plugin
getSupportContact
in interface Plugin
public int[] getVersion()
Plugin
new int[] { 1, 2, 3 }
.getVersion
in interface Plugin
public Class getImplementedInterface()
Plugin
com.tplan.robot.remoteclient.RemoteDesktopClient.class
.getImplementedInterface
in interface Plugin
public boolean requiresRestart()
Plugin
requiresRestart
in interface Plugin
public String getVendorHomePage()
Plugin
getVendorHomePage
in interface Plugin
public int[] getLowestSupportedVersion()
Plugin
getLowestSupportedVersion
in interface Plugin
public String getMessageBeforeInstall()
Plugin
getMessageBeforeInstall
in interface Plugin
public String getMessageAfterInstall()
Plugin
getMessageAfterInstall
in interface Plugin
public String getDisplayName()
getDisplayName
in interface Plugin
getCmdDisplayName()
method.public String getDisplayNameKey()
LocalizedPlugin
getDisplayNameKey
in interface LocalizedPlugin
public String getDescription()
Plugin
getDescription
in interface Plugin
public String getUniqueId()
Plugin
Get unique ID associated with the plugin. The plugin manager uses the ID together with the version string to identify whether a plugin is already installed and whether a newer version of the same plugin is available.
The unique ID in fact identifies a particular plugin delivered by a particular vendor. Plugin developers are recommended to choose an ID and keep it constant for all versions of one particular plugin. The ID is never displayed in the GUI so it doesn't have to be a readable text. To avoid conflicts with other vendors it is recommended to elaborate vendor or author name and feature description into the ID, for example "custom RFB client implemented by John Doe".
getUniqueId
in interface Plugin
public void checkDependencies(PluginManager manager) throws DependencyMissingException
Plugin
DependencyMissingException
if one or more dependencies are missing.checkDependencies
in interface Plugin
manager
- shared instance of the plugin manager.DependencyMissingException
- when one or more dependencies requested by this plugin is missing.public static LinkedHashMap<String,Object> toLinkedMap(String command, List args, Map params)
command
- the command name.args
- the list of arguments.params
- the map of parameters and their values.public Map compileParameters(Map paramsAndValues, TestScriptInterpret interpret)
public boolean requiresOriginalValues()
public void setMaster(CommandHandler master)
public CommandHandler getMaster()
public String getDescription(ScriptingContext ctx, List<String> parameters, Map<String,String> values)
ContextualDescriptionCapable
interface so that command handlers may declare the interface and use the
setDescription(com.tplan.robot.scripting.ScriptingContext, java.lang.String)
method to deliver the interface functionality.getDescription
in interface ContextualDescriptionCapable
ctx
- context.parameters
- the command parameters.values
- the map of parameter values.public Icon getIcon(String argument)
ContextualDescriptionCapable
getIcon
in interface ContextualDescriptionCapable
argument
- optional argument for those commands that accept stable
arguments. For example, for the "Mouse click" command the argument will
be "click".