|
|||||||||
| Home >> All >> abbot >> [ script overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
abbot.script
Class Script

java.lang.Objectabbot.script.Step
abbot.script.Sequence
abbot.script.Script
- All Implemented Interfaces:
- abbot.Resolver, abbot.i18n.Resources, abbot.editor.i18n.Resources, Tags, XMLifiable
- public class Script
- extends Sequence
- implements abbot.Resolver
- extends Sequence
Provide a structure to encapsulate actions invoked on GUI components and tests performed on those components. Scripts need to be short and concise (and therefore easy to read/write). Extensions don't have to be.
This takes a single filename as a constructor argument.
Use ScriptTestCase and ScriptTestSuite to generate a suite (auto-generate the collection).
| Nested Class Summary |
| Nested classes inherited from class abbot.editor.i18n.Resources |
abbot.editor.i18n.Resources.ResourceLoader |
| Field Summary | |
private java.util.WeakHashMap |
components
Maps actual components into ComponentReferences. |
private boolean |
exportAllData
|
private java.lang.String |
filename
|
private boolean |
fork
|
private int |
lastSaved
|
private boolean |
loaded
|
private java.util.HashMap |
refs
Maps a short mnemonic into a ComponentReference. |
private java.io.File |
relativeDirectory
|
private boolean |
slow
|
private static int |
SLOW_DELAY
Robot delay for slow playback. |
private static java.lang.String |
USAGE
|
private java.lang.String |
vmargs
|
private static java.lang.String |
XML_INFO
Typical xml header, so we can know about how much file prefix to skip. |
| Fields inherited from class abbot.script.Sequence |
|
| Fields inherited from class abbot.script.Step |
|
| Fields inherited from interface abbot.script.Tags |
TAG_ACTION, TAG_ARGS, TAG_ASSERT, TAG_AWTTESTSCRIPT, TAG_CALL, TAG_CLASS, TAG_CLASSPATH, TAG_COMMENT, TAG_COMPONENT, TAG_COUNT, TAG_DELEGATE, TAG_DESC, TAG_EVENT, TAG_FILENAME, TAG_FORKED, TAG_ID, TAG_INDEX, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARENT, TAG_POLL_INTERVAL, TAG_SCRIPT, TAG_SEQUENCE, TAG_SLOW, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_VMARGS, TAG_WAIT, TAG_WINDOW, TAG_X, TAG_Y |
| Fields inherited from interface abbot.editor.i18n.Resources |
bundle, STRINGS_BUNDLE |
| Constructor Summary | |
Script()
Create a new, empty script. |
|
Script(abbot.Resolver parent,
java.util.HashMap attributes)
|
|
Script(java.lang.String filename)
Create a script. |
|
| Method Summary | |
ComponentReference |
addComponent(java.awt.Component comp)
Add a new component reference for the given component. |
(package private) ComponentReference |
addComponentReference(org.jdom.Element el)
Add a new component reference to the script. |
org.jdom.Element |
addContent(org.jdom.Element el)
Save component references in addition to everything else. |
void |
addStep(int index,
Step step)
Inserts a step at the given index in the sequence. |
void |
addStep(Step step)
Adds a step to the end of the sequence. |
private void |
checkRelative(Step child)
Make the path to the given child script relative to this one. |
void |
clear()
Set up a blank script, discarding any current state. |
private static java.util.HashMap |
createDefaultHashMap(java.lang.String filename)
|
java.util.HashMap |
getAttributes()
Provide XML attributes for this Step. |
ComponentReference |
getComponentReference(java.awt.Component comp)
Return the reference for the given component, or null if none yet exists. |
private ComponentReference |
getComponentReference(java.awt.Component comp,
int requiredMatch)
Return the reference for the given component, or null if none yet exists. |
ComponentReference |
getComponentReference(java.lang.String name)
Convert the given reference ID into a component reference. |
java.util.Collection |
getComponentReferences()
Returns a collection of all the existing references. |
protected java.lang.String |
getDefaultDescription()
Return a reasonable default description for this script step. |
java.lang.String |
getDescription()
|
java.io.File |
getDirectory()
All relative files should be accessed relative to this directory, which is the directory where the script resides. |
java.io.File |
getFile()
|
java.lang.String |
getFilename()
Return the (possibly relative) path to this script. |
private int |
getHash()
|
Launch |
getLaunchStep()
|
java.lang.String |
getName()
|
java.io.File |
getRelativeTo()
By default, all pathnames are relative to the current working directory. |
Step |
getStep(int index)
Return the step at the given index in the sequence. |
private java.io.File |
getTempFile(java.io.File dir)
|
java.lang.String |
getUniqueID(ComponentReference ref)
Return a unique reference ID. |
java.lang.String |
getUsage()
Returns a string describing the proper XML usage for this class. |
java.lang.String |
getVMArgs()
|
java.lang.String |
getXMLTag()
Define the XML tag to use for this script step. |
boolean |
hasLaunch()
|
boolean |
hasTerminate()
|
int |
indexOf(Step step)
Returns the index of the given step in the sequence, or -1 if the step is not in the sequence. |
boolean |
isDirty()
Has this script changed since the last save. |
boolean |
isForked()
|
static boolean |
isScript(java.io.File file)
Return whether the given file looks like a valid AWT script. |
boolean |
isSlowPlayback()
|
void |
load()
Parse the script file and build internal structures. |
void |
load(java.io.Reader reader)
|
private void |
loadNoThrow()
|
protected void |
parseChild(org.jdom.Element el)
|
void |
removeStep(int index)
Removes the step at the given index in the sequence. |
void |
removeStep(Step step)
Removes the step if it exists in the sequence. |
protected void |
runStep(StepRunner runner)
Ensure we're not running on the event dispatch thread. |
void |
save()
Write the script to file. |
void |
save(java.io.Writer writer)
|
private void |
saveIncludedScripts(Sequence seq)
Recursively save any included scripts which may have been modified. |
void |
setFile(java.io.File outputFile)
Warning: if the directory is changed, need to change associated files as well. |
void |
setForked(boolean fork)
|
void |
setRelativeTo(java.io.File dir)
Indicate that when invoking toXML, a path relative to the given one should be shown. |
void |
setSlowPlayback(boolean slow)
|
void |
setStep(int index,
Step step)
Replaces the step at the given index. |
void |
setVMArgs(java.lang.String args)
|
int |
size()
Returns the number of steps contained in this one. |
java.util.List |
steps()
Returns a list of the steps contained in this one. |
java.lang.String |
toEditableString()
Only thing directly editable on a script is its file path. |
java.lang.String |
toString()
Return a description of this script step. |
private void |
verify()
Ensure that all referenced components are actually in the components list. |
| Methods inherited from class abbot.script.Sequence |
parseChildren, runStep |
| Methods inherited from class abbot.script.Step |
addAttributes, createAttributeMap, createStep, createStep, getFinder, getResolver, parseStepAttributes, resolve, resolveClass, resolveTester, run, setDescription, setScriptError, simpleClassName, toXML, toXMLString, usage, usage |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
SLOW_DELAY
private static final int SLOW_DELAY
- Robot delay for slow playback.
- See Also:
- Constant Field Values
USAGE
private static final java.lang.String USAGE
- See Also:
- Constant Field Values
filename
private java.lang.String filename
relativeDirectory
private java.io.File relativeDirectory
loaded
private boolean loaded
fork
private boolean fork
slow
private boolean slow
lastSaved
private int lastSaved
vmargs
private java.lang.String vmargs
XML_INFO
private static final java.lang.String XML_INFO
- Typical xml header, so we can know about how much file prefix to
skip.
- See Also:
- Constant Field Values
exportAllData
private boolean exportAllData
refs
private java.util.HashMap refs
- Maps a short mnemonic into a ComponentReference.
components
private java.util.WeakHashMap components
- Maps actual components into ComponentReferences. This speeds up
lookup when attempting to match a component to an existing reference.
| Constructor Detail |
Script
public Script()
- Create a new, empty script. Used as a temporary resolver.
Script
public Script(java.lang.String filename)
- Create a script. Actual reading of the script is deferred.
Script
public Script(abbot.Resolver parent, java.util.HashMap attributes)
| Method Detail |
createDefaultHashMap
private static java.util.HashMap createDefaultHashMap(java.lang.String filename)
getTempFile
private java.io.File getTempFile(java.io.File dir)
getName
public java.lang.String getName()
setForked
public void setForked(boolean fork)
isForked
public boolean isForked()
setVMArgs
public void setVMArgs(java.lang.String args)
getVMArgs
public java.lang.String getVMArgs()
isSlowPlayback
public boolean isSlowPlayback()
setSlowPlayback
public void setSlowPlayback(boolean slow)
getFile
public java.io.File getFile()
setFile
public void setFile(java.io.File outputFile)
- Warning: if the directory is changed, need to change associated files
as well.
saveIncludedScripts
private void saveIncludedScripts(Sequence seq) throws java.io.IOException
- Recursively save any included scripts which may have been modified.
save
public void save(java.io.Writer writer) throws java.io.IOException
toEditableString
public java.lang.String toEditableString()
- Only thing directly editable on a script is its file path.
- Specified by:
toEditableStringin interfaceXMLifiable- Overrides:
toEditableStringin classSequence
isDirty
public boolean isDirty()
- Has this script changed since the last save.
save
public void save()
throws java.io.IOException
- Write the script to file. Note that this differs from the toXML for
the script, which simply indicates the file on which it is based.
verify
private void verify()
throws InvalidScriptException
- Ensure that all referenced components are actually in the components
list.
checkRelative
private void checkRelative(Step child)
- Make the path to the given child script relative to this one.
parseChild
protected void parseChild(org.jdom.Element el)
- Overrides:
parseChildin classSequence
load
public void load(java.io.Reader reader) throws InvalidScriptException, java.io.IOException
loadNoThrow
private void loadNoThrow()
size
public int size()
- Description copied from class:
Sequence - Returns the number of steps contained in this one.
steps
public java.util.List steps()
- Description copied from class:
Sequence - Returns a list of the steps contained in this one.
indexOf
public int indexOf(Step step)
- Description copied from class:
Sequence - Returns the index of the given step in the sequence, or -1 if the step
is not in the sequence.
getStep
public Step getStep(int index)
- Description copied from class:
Sequence - Return the step at the given index in the sequence.
addStep
public void addStep(int index,
Step step)
- Description copied from class:
Sequence - Inserts a step at the given index in the sequence.
addStep
public void addStep(Step step)
- Description copied from class:
Sequence - Adds a step to the end of the sequence.
setStep
public void setStep(int index,
Step step)
removeStep
public void removeStep(Step step)
- Description copied from class:
Sequence - Removes the step if it exists in the sequence.
- Overrides:
removeStepin classSequence
removeStep
public void removeStep(int index)
- Description copied from class:
Sequence - Removes the step at the given index in the sequence.
- Overrides:
removeStepin classSequence
load
public void load()
throws InvalidScriptException,
java.io.IOException
- Parse the script file and build internal structures.
getHash
private int getHash()
getXMLTag
public java.lang.String getXMLTag()
- Description copied from class:
Step - Define the XML tag to use for this script step.
addContent
public org.jdom.Element addContent(org.jdom.Element el)
- Save component references in addition to everything else.
- Overrides:
addContentin classSequence
getFilename
public java.lang.String getFilename()
- Return the (possibly relative) path to this script.
getAttributes
public java.util.HashMap getAttributes()
- Provide XML attributes for this Step. This class adds its filename.
- Overrides:
getAttributesin classStep
runStep
protected void runStep(StepRunner runner) throws java.lang.Throwable
getUniqueID
public java.lang.String getUniqueID(ComponentReference ref)
- Return a unique reference ID.
- Specified by:
getUniqueIDin interfaceabbot.Resolver
clear
public void clear()
getUsage
public java.lang.String getUsage()
- Description copied from class:
Sequence - Returns a string describing the proper XML usage for this class.
getDescription
public java.lang.String getDescription()
- Overrides:
getDescriptionin classStep
getDefaultDescription
protected java.lang.String getDefaultDescription()
- Description copied from class:
Step - Return a reasonable default description for this script step.
This value is used in the absence of an explicit description.
- Overrides:
getDefaultDescriptionin classSequence
toString
public java.lang.String toString()
- Description copied from class:
Step - Return a description of this script step.
hasLaunch
public boolean hasLaunch()
hasTerminate
public boolean hasTerminate()
getRelativeTo
public java.io.File getRelativeTo()
- By default, all pathnames are relative to the current working
directory.
setRelativeTo
public void setRelativeTo(java.io.File dir)
- Indicate that when invoking toXML, a path relative to the given one
should be shown. Note that this is a runtime setting only and never
shows up in saved XML.
isScript
public static boolean isScript(java.io.File file)
- Return whether the given file looks like a valid AWT script.
getLaunchStep
public Launch getLaunchStep()
getDirectory
public java.io.File getDirectory()
- All relative files should be accessed relative to this directory,
which is the directory where the script resides.
- Specified by:
getDirectoryin interfaceabbot.Resolver
getComponentReferences
public java.util.Collection getComponentReferences()
- Description copied from interface:
abbot.Resolver - Returns a collection of all the existing references.
- Specified by:
getComponentReferencesin interfaceabbot.Resolver
addComponent
public ComponentReference addComponent(java.awt.Component comp)
- Add a new component reference for the given component.
- Specified by:
addComponentin interfaceabbot.Resolver
addComponentReference
ComponentReference addComponentReference(org.jdom.Element el)
- Add a new component reference to the script.
getComponentReference
public ComponentReference getComponentReference(java.awt.Component comp)
- Return the reference for the given component, or null if none yet
exists.
- Specified by:
getComponentReferencein interfaceabbot.Resolver
getComponentReference
private ComponentReference getComponentReference(java.awt.Component comp, int requiredMatch)
- Return the reference for the given component, or null if none yet
exists.
getComponentReference
public ComponentReference getComponentReference(java.lang.String name)
- Convert the given reference ID into a component reference. If it's
not in the Script's list, throw an appropriate exception.
- Specified by:
getComponentReferencein interfaceabbot.Resolver
|
|||||||||
| Home >> All >> abbot >> [ script overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC