public class DefaultReportProvider extends Object implements ActionListener, ConfigurationChangeListener, Configurable, ScriptListener, CommandListener, Plugin, LocalizedPlugin, ReportProvider
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Constructor and Description |
---|
DefaultReportProvider() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Implementation of the ActionListener interface.
|
void |
checkDependencies(PluginManager manager)
Check whether all dependencies are installed.
|
void |
commandEvent(CommandEvent e)
This method is called when a command handler fires an event.
|
void |
configurationChanged(ConfigurationChangeEvent evt)
This method gets called when a configuration parameter is changed.
|
int |
create(ScriptingContext repository,
Map params)
Create a report using the scripting context.
|
String |
getCode()
Get plugin code.
|
Date |
getDate()
Get plugin release date.
|
String |
getDescription()
Get plugin description to be displayed in the GUI.
|
String |
getDisplayName()
Get short plugin name to be displayed in the GUI.
|
String |
getDisplayNameKey()
Get the key to the plugin name in the resource bundle.
|
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.
|
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.
|
String |
getSupportContact()
Get support contact.
|
String[] |
getSupportedFormats()
Get formats supported by this particular provider.
|
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 |
requiresRestart()
Indicate whether installation of this plugin requires application restart.
|
void |
scriptEvent(ScriptEvent event)
Gets called when a script event is available.
|
void |
setConfiguration(UserConfiguration cfg)
If an object implementing this interface is a plugin (i.e.
|
public int create(ScriptingContext repository, Map params)
ReportProvider
Create a report using the scripting context. This method is called just once right after an instance of this provider is created through the Report command or it's associated Java test script method. It is up to the implementing class whether it prefers to generate one-time report and finish or register as ScriptListener and/or CommandListener and stay alive refreshing the report with updates until the script execution finishes.
The context provides access to all necessary objects associated with the
script and execution. Objects created by commands such as screen shots,
step results etc. may be obtained from ScriptingContext.getOutputObjects()
.
create
in interface ReportProvider
repository
- scripting context of the currently executed script.params
- Report command parameters parsed from the command. They typically
contain at least the output file name together with an optional description and scope.
See the Report command specification for more information.public void commandEvent(CommandEvent e)
CommandListener
commandEvent
in interface CommandListener
e
- a command event.public void scriptEvent(ScriptEvent event)
ScriptListener
scriptEvent
in interface ScriptListener
event
- a script event.public void actionPerformed(ActionEvent e)
Implementation of the ActionListener interface.
This method is at present used just by the state update timer which invokes this method at regular intervals. The method then creates a screenshot of the RFB buffer and saves it into a so called state image. A link to this image is then elaborated into the report as a view of the current state.
This class uses its own instance of the ScreenshotCommand class because we don't want the default ScreenshotCommand class to fire all the listeners which would make the report command to re-create the HTML report and even include the state image into the report body.
actionPerformed
in interface ActionListener
e
- an action event.public void configurationChanged(ConfigurationChangeEvent evt)
ConfigurationChangeListener
configurationChanged
in interface ConfigurationChangeListener
evt
- A ConfigurationChangeEvent object describing the event source
and the parameter that has changed.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<Preference> getPreferences()
Configurable
getPreferences
in interface Configurable
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.
getCode
in interface Plugin
getCode
in interface ReportProvider
public String getDisplayName()
Plugin
getDisplayName
in interface Plugin
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 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 void checkDependencies(PluginManager manager) throws DependencyMissingException
checkDependencies
in interface Plugin
manager
- plugin manager instance.DependencyMissingException
- when one or more required dependencies is not installed.public String[] getSupportedFormats()
ReportProvider
Get formats supported by this particular provider. The formats are not
case sensitive and they must correspond to the supported file extensions.
For example, a provider able to generate XML, HTML and Excel formats should
return new String[] {"xml", "html", "htm", "xls"}
.
The method is used by the calling Report instance to validate file name provided by the script command. If the file doesn't have one of the extensions supported by the selected provider, a syntax error is reported.
getSupportedFormats
in interface ReportProvider