public class ScriptManagerImpl extends JPanel implements ScriptManager, CommandListener, com.tplan.robot.remoteclient.rfb.RfbConstants, RemoteDesktopServerListener, PluginListener, ConfigurationChangeListener, GenericListener<ScriptListener>, PropertyChangeListener
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
JComponent.AccessibleJComponent
Component.BaselineResizeBehavior
Modifier and Type | Field and Description |
---|---|
boolean |
debugEvents |
DynamicVariable[] |
DEFAULT_DYNAMIC_VARS
The following array lists regexp patterns and values of dynamically
created variables which should override variables existing in the
execution context.
|
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
OUTPUT_DISABLED_FLAG
BYTEMASK, CINIT_EXCLUSIVE_DESKTOP, CINIT_SHARE_DESKTOP, ENCODING_COMPRESSION_LEVEL_PSEUDO, ENCODING_COPY_RECT, ENCODING_CORRE, ENCODING_CURSOR_PSEUDO, ENCODING_DESKTOP_SIZE, ENCODING_GII_PSEUDO, ENCODING_HEXTILE, ENCODING_HEXTILE_ANY_SUBRECTS, ENCODING_HEXTILE_BG_SPECIFIED, ENCODING_HEXTILE_FG_SPECIFIED, ENCODING_HEXTILE_RAW, ENCODING_HEXTILE_SUBRECTS_COLORED, ENCODING_JPEG_FINE_GRAINED_PSEUDO, ENCODING_JPEG_SUBSAMPLING_PSEUDO, ENCODING_JPEGQLVL, ENCODING_LASTRECT_PSEUDO, ENCODING_POINTER_POSITION, ENCODING_RAW, ENCODING_RRE, ENCODING_TIGHT, ENCODING_X_CURSOR_PSEUDO, ENCODING_ZLIB, ENCODING_ZLIBHEX, MSG_C2S_CLIENT_CUT_TEXT, MSG_C2S_FIX_COLOR_MAP_ENTRIES, MSG_C2S_FRAMEBUFFER_UPDATE_REQUEST, MSG_C2S_KEY_EVENT, MSG_C2S_POINTER_EVENT, MSG_C2S_SET_ENCODINGS, MSG_C2S_SET_PIXEL_FORMAT, MSG_S2C_BELL, MSG_S2C_COMMUNICATION_ERROR, MSG_S2C_CONNECTED, MSG_S2C_CONNECTING, MSG_S2C_DISCONNECTED, MSG_S2C_DISCONNECTING, MSG_S2C_FRAMEBUFFER_UPDATE, MSG_S2C_SERVER_CUT_TEXT, MSG_S2C_SERVER_INIT, MSG_S2C_SET_COLOR_MAP_ENTRIES, PROTOCOL_VERSION_3_3, PROTOCOL_VERSION_3_7, PROTOCOL_VERSION_3_8, RFB_LISTEN_PORT_OFFSET, RFB_PORT_OFFSET, SECURITY_CDEAN, SECURITY_INVALID, SECURITY_MD5, SECURITY_NONE, SECURITY_RA2, SECURITY_RA2NE, SECURITY_RESPONSE_FAILED, SECURITY_RESPONSE_OK, SECURITY_RESPONSE_TOO_MANY_ATTEMPTS, SECURITY_SASL, SECURITY_TIGHT, SECURITY_TLS, SECURITY_TYPE_NAMES, SECURITY_TYPES, SECURITY_ULTRA, SECURITY_VENCRYPT, SECURITY_VNC_AUTH, SPECIAL_KEY_CODES, VAR_LISTEN, VK_CONTEXT_MENU, VK_WINDOWS
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
ScriptManagerImpl() |
ScriptManagerImpl(Map<String,Object> scriptingParams,
Map<String,String> cliVariables,
RemoteDesktopClient client,
AutomatedRunnable runnable) |
Modifier and Type | Method and Description |
---|---|
void |
addCommandListener(CommandListener listener)
Add a command listener to all available command handlers.
|
void |
addCommandListener(Reference<CommandListener> listener)
Add a command listener through a reference to all available command
handlers.
|
static boolean |
addExecutionListener(ExecutionListener l)
Add an execution listener.
|
void |
addSchedule(Schedule s) |
void |
addScriptListener(Reference<ScriptListener> listener)
Add a script listener through a reference.
|
void |
addScriptListener(ScriptListener listener)
Add a script listener.
|
String |
assembleFileName(String fileName,
ScriptingContext repository,
String variableName)
Resolve a file path with regard to a variable which is expected to
contain a directory.
|
void |
commandEvent(CommandEvent evt)
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.
|
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.
|
void |
genericEvent(ScriptListener listener,
EventObject event,
Object customObject)
Call the listener method on a particular listener.
|
List<Schedule> |
getActiveSchedules()
Get the list of active (opened) schedules.
|
static List<ScriptManager> |
getActiveScriptManagers() |
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.
|
Map |
getCliVariables()
Get the map of script variables overriden through the -v/--variable CLI
option.
|
Map<String,CommandHandler> |
getCommandHandlers()
Get the map of available command handlers.
|
static ScriptManager |
getDefaultScriptManager()
Get the default (first created) script manager.
|
TestScriptInterpret |
getDocumentOwner(Document doc)
Get owner of a document.
|
Object |
getDynamicVariableValue(String name,
Map cliVars,
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).
|
List<Schedule> |
getExecutingSchedules()
Get the list of executing schedules.
|
List<TestScriptInterpret> |
getExecutingTestScripts()
Get list of test script interprets which are being executed.
|
List<TestScriptInterpret> |
getRunningTestScripts()
Get list of test script interprets which are running.
|
Map<String,Object> |
getScriptingParams()
Get the map of scripting parameters passed from the CLI, such as
-r/--run, --fromlabel, --tolabel and --nooutput.
|
Object |
getScriptToRun()
Get a script to be executed which was passed from CLI.
|
Integer |
getScriptToRunRepeatCount()
Find out how many times the script returned by the
ScriptManager.getScriptToRun() is to be executed. |
String |
getVariableValue(String name,
ScriptingContext ctx)
Get a raw variable value.
|
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.
|
boolean |
isOutputEnabled() |
boolean |
isRfbServerEventRecording() |
void |
pluginEvent(PluginEvent e)
Gets called when the plugin map got changed and a plugin event was fired
by the
PluginManager . |
void |
propertyChange(PropertyChangeEvent evt) |
void |
pushScriptListener(ScriptListener listener)
Push a script listener to the first place of the listener list to ensure
that it gets notified prior to other registered ones.
|
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.
|
void |
removeSchedule(Schedule s) |
Object |
removeScriptListener(ScriptListener listener)
Remove a script listener.
|
String |
replace(ScriptingContext ctx,
String text,
String variableName,
int startOffset,
int endOffset,
String value) |
void |
serverMessageReceived(RemoteDesktopServerEvent evt)
This method gets called when an event is received from the server.
|
void |
setClient(RemoteDesktopClient client)
Set the currently used desktop client.
|
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.
|
void |
setCliVariables(Map<String,String> variables)
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 |
setOutputEnabled(boolean outputEnabled) |
void |
setOwningSchedule(Schedule s)
Set the workitem (former "schedule") that is using this script manager.
|
void |
setRfbServerEventRecording(boolean rfbServerEventRecording) |
void |
setScriptToRun(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
ScriptManager.getScriptToRun() . |
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public boolean debugEvents
public final DynamicVariable[] DEFAULT_DYNAMIC_VARS
public ScriptManagerImpl()
public ScriptManagerImpl(Map<String,Object> scriptingParams, Map<String,String> cliVariables, RemoteDesktopClient client, AutomatedRunnable runnable)
public static List<ScriptManager> getActiveScriptManagers()
public static ScriptManager getDefaultScriptManager()
public static boolean addExecutionListener(ExecutionListener l)
l
- an execution listener.public void setDesktopViewer(com.tplan.robot.gui.DesktopViewer fbPanel)
ScriptManager
setDesktopViewer
in interface ScriptManager
fbPanel
- a desktop viewer component.public ScriptingContext createDefaultContext()
ScriptManager
createDefaultContext
in interface ScriptManager
public ScriptingContext createDefaultContext(TestScriptInterpret ti)
ScriptManager
ScriptManager.createDefaultContext()
one to ensure that the
default output and template paths get correctly initialized to the
project ones.createDefaultContext
in interface ScriptManager
ti
- test script interpret owning the context.public Map<String,CommandHandler> getCommandHandlers()
ScriptManager
getCommandHandlers
in interface ScriptManager
public void commandEvent(CommandEvent evt)
CommandListener
commandEvent
in interface CommandListener
evt
- a command event.public void addCommandListener(CommandListener listener)
ScriptManager
addCommandListener
in interface ScriptManager
listener
- a command listener.public Object removeCommandListener(CommandListener listener)
ScriptManager
removeCommandListener
in interface ScriptManager
listener
- a command listener.public void addCommandListener(Reference<CommandListener> listener)
ScriptManager
addCommandListener
in interface ScriptManager
listener
- a command listener.public PauseRequestException fireScriptEvent(ScriptEvent evt)
ScriptManager
fireScriptEvent
in interface ScriptManager
evt
- a script event.public void addScriptListener(ScriptListener listener)
ScriptManager
addScriptListener
in interface ScriptManager
listener
- a script listener.public void pushScriptListener(ScriptListener listener)
listener
- a listenerpublic void addScriptListener(Reference<ScriptListener> listener)
ScriptManager
addScriptListener
in interface ScriptManager
listener
- a script listener.public Object removeScriptListener(ScriptListener listener)
ScriptManager
removeScriptListener
in interface ScriptManager
listener
- a script listener.public void genericEvent(ScriptListener listener, EventObject event, Object customObject)
GenericListener
ChangeListener
the method should call
listener.stateChanged((ChangeEvent)event)
. This method will
be called by the GenericListenerSupport.fireEvent(com.tplan.robot.util.GenericListener, java.util.EventObject, java.lang.Object)
method for each registered listener.genericEvent
in interface GenericListener<ScriptListener>
listener
- the registered listener.event
- an event to fire to the listener. The implementing class should
check whether it is an appropriate event matching the listener type and
throw an IllegalArgumentException
if not. For example, if the listener
is a ChangeListener
the event must be a ChangeEvent
.customObject
- an optional object allowing the implementing class to transfer
data between individual call of this method. For example, the argument may be a
List where the method will store all exceptions thrown by the listener to.public Map getCliVariables()
ScriptManager
getCliVariables
in interface ScriptManager
public void setCliVariables(Map<String,String> variables)
ScriptManager
setCliVariables
in interface ScriptManager
variables
- map of variables to override.public void serverMessageReceived(RemoteDesktopServerEvent evt)
RemoteDesktopServerListener
serverMessageReceived
in interface RemoteDesktopServerListener
evt
- a RemoteDesktopServerEvent event describing the event.public TestScriptInterpret getClientOwner(RemoteDesktopClient client)
ScriptManager
getClientOwner
in interface ScriptManager
client
- a clientpublic TestScriptInterpret getDocumentOwner(Document doc)
ScriptManager
getDocumentOwner
in interface ScriptManager
doc
- a document.public boolean isRfbServerEventRecording()
public void setRfbServerEventRecording(boolean rfbServerEventRecording)
public Object getScriptToRun()
ScriptManager
getScriptToRun
in interface ScriptManager
public void setScriptToRun(Object scriptToRun)
ScriptManager
setScriptToRun
in interface ScriptManager
scriptToRun
- a script to be executed automatically.public Integer getScriptToRunRepeatCount()
ScriptManager
ScriptManager.getScriptToRun()
is to be executed.getScriptToRunRepeatCount
in interface ScriptManager
public void setScriptToRunRepeatCount(int count)
ScriptManager
ScriptManager.getScriptToRun()
.setScriptToRunRepeatCount
in interface ScriptManager
count
- number of required executions.public boolean isOutputEnabled()
public void setOutputEnabled(boolean outputEnabled)
public boolean isConsoleMode()
ScriptManager
isConsoleMode
in interface ScriptManager
public Object getDynamicVariableValue(String name, Map cliVars, Map variables, TestWrapper wr, ScriptingContext ctx)
ScriptManager
getDynamicVariableValue
in interface ScriptManager
name
- variable name.cliVars
- command line variable table.variables
- standard variable table.wr
- test wrapper requesting the value.ctx
- scripting context.public String getVariableValue(String name, ScriptingContext ctx)
ScriptingContext.getVariableAsString(java.lang.String)
this
method observes local variables created within TPR code blocks.name
- variable name.ctx
- an execution context.public String assembleFileName(String fileName, ScriptingContext repository, String variableName)
ScriptManager
assembleFileName
in interface ScriptManager
fileName
- file name.repository
- a scripting context (needed for variables).variableName
- variable to get the target directory from.public void setClient(RemoteDesktopClient client)
ScriptManager
setClient
in interface ScriptManager
client
- a desktop client.public void setClient(RemoteDesktopClient client, ScriptingContext context)
ScriptManager
setClient
in interface ScriptManager
client
- a desktop client.context
- a script context.public RemoteDesktopClient getClient()
ScriptManager
getClient
in interface ScriptManager
public void pluginEvent(PluginEvent e)
PluginListener
PluginManager
.pluginEvent
in interface PluginListener
e
- a plugin event.public String replace(ScriptingContext ctx, String text, String variableName, int startOffset, int endOffset, String value)
public List<TestScriptInterpret> getActiveTestScripts()
getActiveTestScripts
in interface ScriptManager
public List<TestScriptInterpret> getExecutingTestScripts()
getExecutingTestScripts
in interface ScriptManager
public List<TestScriptInterpret> getRunningTestScripts()
getRunningTestScripts
in interface ScriptManager
TestScriptInterpret.isRunning()
.public List<Schedule> getActiveSchedules()
ScriptManager
getActiveSchedules
in interface ScriptManager
public boolean hasActiveSchedule()
ScriptManager
ScriptManager.getActiveSchedules()
and testing
whether it is empty.hasActiveSchedule
in interface ScriptManager
public void addSchedule(Schedule s)
public void removeSchedule(Schedule s)
public List<Schedule> getExecutingSchedules()
ScriptManager
getExecutingSchedules
in interface ScriptManager
public ScriptedExecutable getExecutingObject()
ScriptManager
getExecutingObject
in interface ScriptManager
public Map<String,Object> getScriptingParams()
ScriptManager
getScriptingParams
in interface ScriptManager
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 removeInterpret(TestScriptInterpret interpret)
ScriptManager
TestScriptInterpret.destroy()
method.removeInterpret
in interface ScriptManager
interpret
- a test script interpret.public void destroy()
ScriptManager
destroy
in interface ScriptManager
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
public void setOwningSchedule(Schedule s)
ScriptManager
setOwningSchedule
in interface ScriptManager
s
- a workitem.