T-Plan Robot Enterprise 5.0.1
Build No. 5.0.1-20190308.1

com.tplan.robot.scripting
Interface ScriptManager

All Known Implementing Classes:
ScriptManagerImpl

public interface ScriptManager

Script manager public interface.


T-Plan Robot Enterprise, (C) 2009-2019 T-Plan Limited. All rights reserved.


Field Summary
static java.lang.String OUTPUT_DISABLED_FLAG
           
 
Method Summary
 void addCommandListener(CommandListener listener)
          Add a command listener to all available command handlers.
 void addCommandListener(java.lang.ref.Reference<CommandListener> listener)
          Add a command listener through a reference to all available command handlers.
 void addScriptListener(java.lang.ref.Reference<ScriptListener> listener)
          Add a script listener through a reference.
 void addScriptListener(ScriptListener listener)
          Add a script listener.
 java.lang.String assembleFileName(java.lang.String fileName, ScriptingContext repository, java.lang.String variableName)
          Resolve a file path with regard to a variable which is expected to contain a directory.
 ScriptingContext createDefaultContext()
          Create a scripting context instance and populate it with default data.
 ScriptingContext createDefaultContext(TestScriptInterpret ti)
          Create a scripting context instance and populate it with default data.
 void destroy()
          Destroy the script manager.
 PauseRequestException fireScriptEvent(ScriptEvent evt)
          Fire a script event to all registered script listeners.
 java.util.List<Schedule> getActiveSchedules()
          Get the list of active (opened) schedules.
 java.util.List<TestScriptInterpret> getActiveTestScripts()
          Get active test script interprets, i.e.
 RemoteDesktopClient getClient()
          Get the currently used desktop client.
 TestScriptInterpret getClientOwner(RemoteDesktopClient client)
          Get owner of a desktop client instance.
 java.util.Map<java.lang.String,java.lang.String> getCliVariables()
          Get the map of script variables overriden through the -v/--variable CLI option.
 java.util.Map<java.lang.String,CommandHandler> getCommandHandlers()
          Get the map of available command handlers.
 TestScriptInterpret getDocumentOwner(javax.swing.text.Document doc)
          Get owner of a document.
 java.lang.Object getDynamicVariableValue(java.lang.String name, java.util.Map cliVars, java.util.Map variables, TestWrapper wr, ScriptingContext ctx)
          Get dynamic value for a variable (if defined), such as the current time or randiom number.
 ScriptedExecutable getExecutingObject()
          Get the topmost currently executing object (schedule or test script).
 java.util.List<Schedule> getExecutingSchedules()
          Get the list of executing schedules.
 java.util.List<TestScriptInterpret> getExecutingTestScripts()
          Get list of test script interprets which are being executed.
 java.util.List<TestScriptInterpret> getRunningTestScripts()
          Get list of test script interprets which are running.
 java.util.Map<java.lang.String,java.lang.Object> getScriptingParams()
          Get the map of scripting parameters passed from the CLI, such as -r/--run, --fromlabel, --tolabel and --nooutput.
 java.lang.Object getScriptToRun()
          Get a script to be executed which was passed from CLI.
 java.lang.Integer getScriptToRunRepeatCount()
          Find out how many times the script returned by the getScriptToRun() is to be executed.
 boolean hasActiveSchedule()
          Find out if there's at least one active (opened) schedule.
 boolean isConsoleMode()
          Find out whether we run in the GUI or console mode.
 java.lang.Object removeCommandListener(CommandListener listener)
          Remove a command listener from all available command handlers.
 void removeInterpret(TestScriptInterpret interpret)
          Remove an interpret from the internal list of active interprets.
 java.lang.Object removeScriptListener(ScriptListener listener)
          Remove a script listener.
 void setClient(RemoteDesktopClient client)
          Set the currently used desktop client.
 void setClient(RemoteDesktopClient client, ScriptingContext context)
          Set the currently used desktop client.
 void setCliVariables(java.util.Map<java.lang.String,java.lang.String> cliVars)
          Set the map of CLI variables.
 void setDesktopViewer(com.tplan.robot.gui.DesktopViewer fbPanel)
          Associate the script manager with a desktop viewer GUI component.
 void setOwningSchedule(Schedule s)
           
 void setScriptToRun(java.lang.Object scriptToRun)
          Set the script to be executed after the tool startup.
 void setScriptToRunRepeatCount(int count)
          Set how many times to execute the script returned by the getScriptToRun().
 

Field Detail

OUTPUT_DISABLED_FLAG

static final java.lang.String OUTPUT_DISABLED_FLAG
Method Detail

getCommandHandlers

java.util.Map<java.lang.String,CommandHandler> getCommandHandlers()
Get the map of available command handlers. The key is the command name in upper case, the value is the command handler instance.

Returns:
map of available command handlers.

getScriptToRun

java.lang.Object getScriptToRun()
Get a script to be executed which was passed from CLI. This method returns the script interpret instance for a script passed through the -r/--run CLI option. If the option was not specified during the tool start or the script has been already started, the method returns null.

Returns:
script to execute.

setScriptToRun

void setScriptToRun(java.lang.Object scriptToRun)
Set the script to be executed after the tool startup.

Parameters:
scriptToRun - a script to be executed automatically.

getScriptToRunRepeatCount

java.lang.Integer getScriptToRunRepeatCount()
Find out how many times the script returned by the getScriptToRun() is to be executed.

Returns:
number of required executions.
Since:
4.2.1

setScriptToRunRepeatCount

void setScriptToRunRepeatCount(int count)
Set how many times to execute the script returned by the getScriptToRun().

Parameters:
count - number of required executions.
Since:
4.2.1

createDefaultContext

ScriptingContext createDefaultContext()
Create a scripting context instance and populate it with default data.

Returns:
a new scripting context instance populated with necessary object references and applicable default variables.

createDefaultContext

ScriptingContext createDefaultContext(TestScriptInterpret ti)
Create a scripting context instance and populate it with default data. It is highly recommended to use this method instead of the older parameterless createDefaultContext() one to ensure that the default output and template paths get correctly initialized to the project ones.

Parameters:
ti - test script interpret owning the context.
Returns:
a new scripting context instance populated with necessary object references and applicable default variables.
Since:
4.0

getCliVariables

java.util.Map<java.lang.String,java.lang.String> getCliVariables()
Get the map of script variables overriden through the -v/--variable CLI option.

Returns:
map of CLI variables.

setCliVariables

void setCliVariables(java.util.Map<java.lang.String,java.lang.String> cliVars)
Set the map of CLI variables.

Parameters:
cliVars - map of variables to override.

setDesktopViewer

void setDesktopViewer(com.tplan.robot.gui.DesktopViewer fbPanel)
Associate the script manager with a desktop viewer GUI component.

Parameters:
fbPanel - a desktop viewer component.

setClient

void setClient(RemoteDesktopClient client)
Set the currently used desktop client.

Parameters:
client - a desktop client.

setClient

void setClient(RemoteDesktopClient client,
               ScriptingContext context)
Set the currently used desktop client. The context argument is usually null and it is only populated by the Connect command to indicate that the client was created through a running script. The context reference is then passed to the script event which is fired to all registered ScriptListener objects.

Parameters:
client - a desktop client.

getClient

RemoteDesktopClient getClient()
Get the currently used desktop client.

Returns:
desktop client.

getScriptingParams

java.util.Map<java.lang.String,java.lang.Object> getScriptingParams()
Get the map of scripting parameters passed from the CLI, such as -r/--run, --fromlabel, --tolabel and --nooutput. The key is the CLI option without the minus (or --) prefix.

Returns:
map of scripting parameters passed through the CLI.

addScriptListener

void addScriptListener(ScriptListener listener)
Add a script listener. Script events are sent to notify of events associated with script control and handling, for example when a script gets compiled, when execution starts, pauses or finishes and so on.

Parameters:
listener - a script listener.

addScriptListener

void addScriptListener(java.lang.ref.Reference<ScriptListener> listener)
Add a script listener through a reference. Script events are sent to notify of events associated with script control and handling, for example when a script gets compiled, when execution starts, pauses or finishes and so on.

Parameters:
listener - a script listener.
Since:
3.1.1

removeScriptListener

java.lang.Object removeScriptListener(ScriptListener listener)
Remove a script listener. The method does nothing if the listener is not registered with this script manager.

Parameters:
listener - a script listener.

addCommandListener

void addCommandListener(CommandListener listener)
Add a command listener to all available command handlers.

Parameters:
listener - a command listener.

addCommandListener

void addCommandListener(java.lang.ref.Reference<CommandListener> listener)
Add a command listener through a reference to all available command handlers.

Parameters:
listener - a command listener.
Since:
3.1.1

removeCommandListener

java.lang.Object removeCommandListener(CommandListener listener)
Remove a command listener from all available command handlers.

Parameters:
listener - a command listener.

isConsoleMode

boolean isConsoleMode()
Find out whether we run in the GUI or console mode.

Returns:
true if the mode is the console one, false indicates the GUI mode.

fireScriptEvent

PauseRequestException fireScriptEvent(ScriptEvent evt)
Fire a script event to all registered script listeners.

Parameters:
evt - a script event.
Returns:
if any of the registered listeners requests pausing of a script execution, it throws a PauseRequestException and this method returns it.

assembleFileName

java.lang.String assembleFileName(java.lang.String fileName,
                                  ScriptingContext repository,
                                  java.lang.String variableName)
Resolve a file path with regard to a variable which is expected to contain a directory.

Parameters:
fileName - file name.
repository - a scripting context (needed for variables).
variableName - variable to get the target directory from.
Returns:
absolute path to the file specified by the fileName argument.

getActiveTestScripts

java.util.List<TestScriptInterpret> getActiveTestScripts()
Get active test script interprets, i.e. test scripts which have been opened and compiled and/or executed.

Returns:
list of active test script interprets known to this script manager instance.

getExecutingTestScripts

java.util.List<TestScriptInterpret> getExecutingTestScripts()
Get list of test script interprets which are being executed.

Returns:
list of active test script interprets known to this script manager instance which are being executed.

getRunningTestScripts

java.util.List<TestScriptInterpret> getRunningTestScripts()
Get list of test script interprets which are running.

Returns:
list of active test script interprets known to this script manager instance which are running (see TestScriptInterpret.isRunning().
Since:
4.4.3

getActiveSchedules

java.util.List<Schedule> getActiveSchedules()
Get the list of active (opened) schedules.

Returns:
list of active schedules or an empty list if there's no schedule..

hasActiveSchedule

boolean hasActiveSchedule()
Find out if there's at least one active (opened) schedule. This method is more efficient than calling getActiveSchedules() and testing whether it is empty.

Returns:
true if there's at least one open schedule.
Since:
4.0

getExecutingSchedules

java.util.List<Schedule> getExecutingSchedules()
Get the list of executing schedules.

Returns:
list of executing schedules or an empty list if there's no executing schedule.
Since:
4.0

getExecutingObject

ScriptedExecutable getExecutingObject()
Get the topmost currently executing object (schedule or test script).

Returns:
the topmost executing object or null if no schedule or test script is being executed.
Since:
4.0

getClientOwner

TestScriptInterpret getClientOwner(RemoteDesktopClient client)
Get owner of a desktop client instance.

Parameters:
client - a client
Returns:
test script interpret owning the client or null if no one owns it.

getDocumentOwner

TestScriptInterpret getDocumentOwner(javax.swing.text.Document doc)
Get owner of a document.

Parameters:
doc - a document.
Returns:
test script interpret owning the document or null if no one owns it.

removeInterpret

void removeInterpret(TestScriptInterpret interpret)
Remove an interpret from the internal list of active interprets. While the list gets populated automatically with any compilation and/or execution performed through the script manager, there's no way to remove the interpret from the internal structures except this method which should be called by interprets in their TestScriptInterpret.destroy() method.

Parameters:
interpret -

getDynamicVariableValue

java.lang.Object getDynamicVariableValue(java.lang.String name,
                                         java.util.Map cliVars,
                                         java.util.Map variables,
                                         TestWrapper wr,
                                         ScriptingContext ctx)
Get dynamic value for a variable (if defined), such as the current time or randiom number. If the name doesn't correspond to any known dynamic variable the method returns null.

Parameters:
name - variable name.
cliVars - command line variable table.
variables - standard variable table.
wr - test wrapper requesting the value.
ctx - scripting context.
Returns:
dynamic variable value or null if the name doesn't correspond to any known dynamic variable.

destroy

void destroy()
Destroy the script manager. This method is intended to break references to make the instance ready for garbage collection.


setOwningSchedule

void setOwningSchedule(Schedule s)

T-Plan Robot Enterprise 5.0.1
Build No. 5.0.1-20190308.1