public interface EditorFriendlyInterpret
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String |
LINE_ACTION_FLAG
Name of an optional flag identifying whether an action returned by the
getPopUpMenuActions(java.awt.Point, int) method is specific for
the specified offset (flag=true) or whether it is a global action applying
to the whole script (flag=false; default). |
Modifier and Type | Method and Description |
---|---|
boolean |
areNestedInterpretsSupported()
Declare whether the interpret supports nested interprets (code of a
different type embedded into the interpret's native code, such as for
example Java code block).
|
boolean |
canCollapseCode()
Find out whether the interpret is capable of identifying of areas which
may be collapsed (hidden) in order to make a custom or simpler script code
view.
|
boolean |
canInsertCommandTo(int offset)
Find out if it is legal to insert a command or a method call to the given
offset.
|
boolean |
canReport()
Indicate if the interpret is capable of producing a report.
|
boolean |
canSetBreakPoint(int offset)
Define if a break point can be set on the given element (line of code).
|
CharSequence |
create(int offset,
String command,
LinkedHashMap<String,Object> parameters)
Create a new method or a command call using the specified parameter map
and return it.
|
int |
createNewScript(PreferenceContainer preferences)
Create a new script instance based on the specified preferences.
|
String |
createVariableCall(String variableName,
Class returnType)
Create a piece of code that returns value of the specified variable.
|
LinkedHashMap<String,int[]> |
getCollapsibleAreas()
Get coordinates of the collapsible areas.
|
CommandHandler |
getCommandHandlerForElement(int offset,
LinkedHashMap<String,Object> parameters)
Get the command handler associated with the code contained in the
particular document element.
|
String[] |
getHelpKeyForOffset(int offset)
Return a help key for the specified offset.
|
TestScriptInterpret |
getInterpret()
Get the interpret.
|
int |
getLastCodeLineOffset()
Get offset (document position) of the last script code line.
|
Configurable |
getNewScriptPreferences(PreferenceContainer preferences)
Get the specification of preferences applicable to a new
script.Interprets which do not populate a new test script with a
configurable template may simply return null.
|
CharSequence |
getOutputPath(int offset,
boolean reportDefaultPathAsNull,
boolean resolveVariables)
Get the output (report) path valid for the code at the given offset.The
method is supposed to return the file path (as String) or the expression
the path is set to (as a StringBuilder or StringBuffer).
|
List<Action> |
getPopUpMenuActions(Point p,
int offset)
Get the list of interpret specific actions for the given point and offset.
|
LinkedHashMap<String,Object> |
getReport(int offset)
Get report properties (parameters) from the report producing command at
the specified offset.
|
CharSequence |
getTemplatePath(int offset,
boolean reportDefaultPathAsNull,
boolean resolveVariables)
Get the template path valid for the code at the given offset.The method
is supposed to return the file path (as String) or the expression the
path is set to (as a StringBuilder or StringBuffer).
|
Map<File,List<ScriptReferenceLocation>> |
getUsedImages()
Get the list of images used by the script for image comparison.
|
Map<String,Object> |
getUsedVariables(int offset)
Get the map of variables existing at the given script position.
|
int[] |
isBlockStartOrEnd(int offset)
Find out if the argument offset is near to the block start or end,
typically close to the opening or closing curly brace ('{' or '}'), and
get the start/end coordinates.
|
boolean |
isCodeInsertionSupported()
Test if the interpret is capable of generating the script code.
|
boolean |
isComment(int offset)
Define whether the specified offset in the code is inside a comment or not.
|
boolean |
isGradualCommandBuildingSupported()
This method defines whether the interpret allows gradual building of
a command in the test script editor.
|
int |
modifyOrInsert(int offset,
boolean replace,
String command,
LinkedHashMap<String,Object> parameters,
int[] outCoords)
Create a new method or a command call using the specified parameter map
and insert it to the specified offset (position).If the offset
corresponds to an already existing call of the same command, handle the
insertion as replacement.
|
void |
refreshStyle()
Refresh document styles.
|
int |
replace(int offset,
int length,
String command,
LinkedHashMap<String,Object> parameters,
int[] outCoords)
Replace the text at the specified coordinates with a new method or a command call
created from the specified command name and parameter map.
|
int |
setOutputPath(CharSequence path,
int offset)
Update the script output path at the selected offset of the editor.
|
int |
setReport(int offset,
LinkedHashMap<String,Object> parameters)
Create or update the report producing command at
the specified offset.
|
int |
setTemplatePath(CharSequence path,
int offset)
Update the template path at the selected offset of the editor.
|
void |
toggleComment(int offset,
boolean commentOut)
Comment out or uncomment the command at the specified index.
|
static final String LINE_ACTION_FLAG
getPopUpMenuActions(java.awt.Point, int)
method is specific for
the specified offset (flag=true) or whether it is a global action applying
to the whole script (flag=false; default). This makes the calling editor
put the action into the appropriate menu group
(line actions | script actions | editor actions). The flag can be only put
to a class extending AbstractAction
through its
AbstractAction.putValue(java.lang.String, java.lang.Object)
method.TestScriptInterpret getInterpret()
TestScriptInterpret
one. Those interprets which implement both
interfaces may simply return themselves.CommandHandler getCommandHandlerForElement(int offset, LinkedHashMap<String,Object> parameters)
CommandHandler.getStablePopupMenuItems()
method.offset
- position in the document to parse for the data..parameters
- optional output map for parameters parsed by the interpret at
the specified position. If the map is null, parameters will not be read.int modifyOrInsert(int offset, boolean replace, String command, LinkedHashMap<String,Object> parameters, int[] outCoords)
offset
- offset (position) in the test script source code document.replace
- true to replace, false to insert anew.command
- name as is specified by the
CommandHandler.getCommandNames()
method of the command handler
(usually in lower case).parameters
- command parameters.outCoords
- optional output array of the minimum length of 2 to
store the start offset and the length of the created/modified command to.
It may be null where the calling class is not interested in it.CharSequence create(int offset, String command, LinkedHashMap<String,Object> parameters)
offset
- offset (position) in the test script source code document.
It is here just for a reference because the command is not being inserted
into the editor. The interpret however may decide to return different
commands depending on the current editor offset. For example, a TPR
script may contain Java code in form of Java code blocks
and a Java command may be required instead of a TPR one if the offset
is inside such a block.command
- name as is specified by the
CommandHandler.getCommandNames()
method of the command handler
(usually in lower case).parameters
- command parameters.int replace(int offset, int length, String command, LinkedHashMap<String,Object> parameters, int[] outCoords)
modifyOrInsert(int, boolean, java.lang.String, java.util.LinkedHashMap, int[])
method
with the replace
parameter set to true save that no analysis of the
replaced command is required. This allows to optimize performance where the calling class
(typically the script recorder) needs to replace a call that is previously created and thus
its coordinates are well known.offset
- offset (position) in the test script source code document.length
- length of the text to be replaced.command
- name as is specified by the CommandHandler.getCommandNames()
method
of the command handler (usually in lower case).parameters
- command parameters.outCoords
- optional output array of the minimum length of 2 to store the start
offset and the length of the created/modified command to. It may be null where the calling class
is not interested in it.boolean areNestedInterpretsSupported()
boolean canSetBreakPoint(int offset)
offset
- a document element offset.CharSequence getTemplatePath(int offset, boolean reportDefaultPathAsNull, boolean resolveVariables)
reportDefaultPathAsNull=false
) or null
(reportDefaultPathAsNull=true
).resolveVariables
- true to make the method resolve variables in the
returned value.offset
- the script offset to start from. To search for the very
first path setting use the offset of -1.reportDefaultPathAsNull
- true makes the method return null instead
of the default path if the given script doesn't explicitly set the path.CharSequence getOutputPath(int offset, boolean reportDefaultPathAsNull, boolean resolveVariables)
reportDefaultPathAsNull=false
) or null
(reportDefaultPathAsNull=true
).resolveVariables
- true to make the method resolve variables in the
returned value.offset
- the script offset to start from. To search for the very
first path setting use the offset of -1.reportDefaultPathAsNull
- true makes the method return null instead
of the default path if the given script doesn't explicitly set the path.int setOutputPath(CharSequence path, int offset)
Update the script output path at the selected offset of the editor.
The output path is a directory where all output data such as screenshots and reports are being saved to when the script gets executed. Setting of the path is script specific. For example, the TPR interpret sets the path through the variable call like "Var _REPORT_DIR=[path]". When this method is called it simply creates the call at the specified offset or updates the existing one with the new path.
path
- a new output path.offset
- an offset (location) in the editor.int setTemplatePath(CharSequence path, int offset)
Update the template path at the selected offset of the editor.
The template path is a directory where comparison commands such as
Compareto or Click look for template (component)
images.
Setting of the path is script specific. For example, the TPR
interpret sets the path through the variable call like "Var _TEMPLATE_DIR=[path]"
.
When this method is called it simply creates the call at the specified
offset or updates the existing one with the new path.
path
- a new template path.offset
- an offset (location) in the editor.String createVariableCall(String variableName, Class returnType)
variableName
- the variable name.returnType
- may be used to indicate the desired return value type.
The method should presume a string value by default."{variableName}"
while the
Java one produces "getVariableAsString(\"variableName\")"
.boolean canReport()
LinkedHashMap<String,Object> getReport(int offset)
offset
- an offset (location) in the editor.int setReport(int offset, LinkedHashMap<String,Object> parameters)
offset
- an offset (location) in the editor.parameters
- an ordered map with the report parameters.Configurable getNewScriptPreferences(PreferenceContainer preferences)
Get the specification of preferences applicable to a new script.Interprets which do not populate a new test script with a configurable template may simply return null.
If a valid Configurable
instance is returned and its
Configurable.getPreferences()
methods returns a list of one or
more preferences is returned, they will be displayed to by the GUI
whenever the user selects to create a new script of the type associated
with this interpret. After the user populates the preferences, the values
are passed to the interpret through
createNewScript(com.tplan.robot.preferences.PreferenceContainer)
to create the initial content and after that the script is opened in the
editor.
preferences
- a preference container.Configurable
interface.int createNewScript(PreferenceContainer preferences)
getNewScriptPreferences(com.tplan.robot.preferences.PreferenceContainer)
method for more.preferences
- script preferences. Interprets which
do not populate a new test script with a configurable template may simply
return 0 to specify that the caret should be placed to the beginning
of the document.boolean canCollapseCode()
LinkedHashMap<String,int[]> getCollapsibleAreas()
canCollapseCode()
method returns true.void refreshStyle()
List<Action> getPopUpMenuActions(Point p, int offset)
offset
- document offset associated with the given click point.p
- the click point.boolean isComment(int offset)
offset
- an offset.void toggleComment(int offset, boolean commentOut)
offset
- an offset.commentOut
- true will comment out (turn the command into a comment), false uncomments.boolean isGradualCommandBuildingSupported()
This method defines whether the interpret allows gradual building of a command in the test script editor. If the method returns true the Command Wizard GUI component will insert selected items directly to the editor after every completed step. This is typical for example for scripting language interprets where the user first selects the command name and then the argument and/or parameters.
If the method returns false the GUI does not insert anything into the editor and passes the selected command elements to the interpret which is responsible for creating the call once all parameters have been specified. This is typical for programming languages such as Java where selection of a Java method should not insert anything into the editor until all parameters of the method call are specified and the underlying mapper is able to identify the particular method to be used.
.Map<File,List<ScriptReferenceLocation>> getUsedImages()
Map<String,Object> getUsedVariables(int offset)
offset
- a position in the script.int getLastCodeLineOffset()
String[] getHelpKeyForOffset(int offset)
offset
- an offset.int[] isBlockStartOrEnd(int offset)
offset
- an offsetboolean canInsertCommandTo(int offset)
offset
- a document offset.boolean isCodeInsertionSupported()
canInsertCommandTo(int)
. The method is
typically used for enabling or disabling of menu items working with
the script editor.modifyOrInsert(int, boolean, java.lang.String, java.util.LinkedHashMap, int[])
method or false otherwise.