|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectabbot.script.ComponentReference
Encapsulate as much information as is available to identify a GUI
component. Usage:
<component id="..." class="..." [...]>
The component reference ID may be used in scripts in place of the actual
component to which this reference refers. The conversion will be made when
the actual component is needed. The ID is arbitrary, and may be changed in
scripts to any unique string (just remember to change all references to the
ID in other places in the script as well).
A number of optional tags are supported to provide an increasingly precise
specification of the desired component:
weighted
refers to the name of an available
attribute which should be weighted more heavily in comparisons, e.g. the
label on a JButton.parent
the reference id of this component's
parent.
Field Summary | |
(package private) static String |
ANON_INNER_CLASS
|
(package private) static boolean |
cacheOnCreation
Disable immediate cacheing of components when a reference is created based on a Component. |
static int |
MW_FAILURE
Match weight corresponding to no possible match. |
static String |
SHARED_FRAME_ID
|
Fields inherited from interface abbot.script.XMLConstants |
TAG_ACTION, TAG_APPLETVIEWER, TAG_ARCHIVE, TAG_ARGS, TAG_ASSERT, TAG_AWTTESTSCRIPT, TAG_BORDER_TITLE, TAG_CALL, TAG_CLASS, TAG_CLASSPATH, TAG_CODE, TAG_CODEBASE, TAG_COMMENT, TAG_COMPONENT, TAG_COUNT, TAG_DELEGATE, TAG_DESC, TAG_DOCBASE, TAG_EVENT, TAG_FILENAME, TAG_FORKED, TAG_HEIGHT, TAG_HORDER, TAG_ICON, TAG_ID, TAG_INDEX, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LABEL, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARAMS, TAG_PARENT, TAG_POLL_INTERVAL, TAG_PROPERTY, TAG_ROOT, TAG_SAMPLE, TAG_SCRIPT, TAG_SEQUENCE, TAG_SLOW, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_TEXT, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_VMARGS, TAG_VORDER, TAG_WAIT, TAG_WEIGHTED, TAG_WIDTH, TAG_WINDOW, TAG_X, TAG_Y |
Constructor Summary | |
ComponentReference(Resolver resolver,
Class cls,
Map attributes)
Create a reference to an instance of the given class, given a Map of attributes. |
|
ComponentReference(Resolver r,
Class cls,
String[][] attributes)
Create a reference to an instance of the given class, given an array of name/value pairs of attributes. |
|
ComponentReference(Resolver resolver,
Component comp)
Create a reference based on the given component. |
|
ComponentReference(Resolver resolver,
Component comp,
boolean includeHierarchyAttributes)
Create a reference based on the given component. |
|
ComponentReference(Resolver resolver,
org.jdom.Element el)
For creation from XML. |
|
ComponentReference(String id,
Class compClass)
Deprecated. Use #ComponentReference(Resolver, Class, Map) |
|
ComponentReference(String id,
Class compClass,
String name,
String tag)
Deprecated. The Tag attribute is deprecated. |
|
ComponentReference(String id,
Class compClass,
String name,
String tag,
String title)
Deprecated. The Tag attribute is deprecated, and the Title attribute has changed meaning. |
|
ComponentReference(String id,
Class compClass,
String name,
String tag,
String title,
ComponentReference parent,
int index)
Deprecated. The Tag attribute is deprecated, and the Title attribute has changed meaning. |
|
ComponentReference(String id,
Class compClass,
String name,
String tag,
String title,
ComponentReference parent,
int index,
ComponentReference invokerOrWindow)
Deprecated. The Tag attribute is deprecated, and the Title attribute has changed meaning. |
Method Summary | |
int |
compareTo(Object o)
|
boolean |
equals(Object obj)
Two ComponentReferences with identical XML representations should be equal. |
(package private) boolean |
expressionMatch(String pattern,
String actual)
Return whether the given pattern matches the given string. |
Component |
findInHierarchy(ComponentFinder finder)
Deprecated. Use #getComponent() instead. |
Component |
findInHierarchy(ComponentFinder finder,
Container root)
Deprecated. Use #getComponent() instead. |
void |
fromXML(String input)
Set all options based on the given XML. |
String |
getAttribute(String key)
|
Map |
getAttributes()
|
(package private) Component |
getCachedLookup(Hierarchy hierarchy)
Return the cached component match, if any. |
Component |
getComponent()
Return the component in the current Hierarchy that best matches this reference. |
Component |
getComponent(Hierarchy hierarchy)
Return the component in the given Hierarchy that best matches this reference. |
String |
getDescriptiveName()
Return a suitably descriptive name for this reference, for use as an ID (returns the ID itself if already set). |
static String |
getDescriptiveName(Component c)
Return a descriptive name for the given component for use in UI text (may be localized if appropriate and need not be re-usable across locales. |
String |
getID()
|
int |
getIndex()
Deprecated. use getAttribute(TAG_INDEX) instead. |
static int |
getIndex(Container parent,
Component comp)
|
String |
getInvokerID()
Deprecated. use getAttribute(TAG_INVOKER) instead. |
ComponentReference |
getInvokerReference()
|
(package private) int |
getMatchWeight(Component comp)
Return a measure of how well the given component matches the given component reference. |
String |
getName()
Deprecated. use getAttribute(TAG_NAME) instead. |
(package private) static String |
getOrder(Component original,
Component[] matchList,
boolean horizontal)
Return the order of the given component among the array given, sorted by horizontal or vertical screen position. |
ComponentReference |
getParentReference()
|
String |
getRefClassName()
|
String |
getTag()
Deprecated. use getAttribute(TAG_TAG) instead. |
String |
getTitle()
Deprecated. use getAttribute(TAG_TITLE) instead. |
String |
getWindowID()
Deprecated. use getAttribute(TAG_WINDOW) instead. |
ComponentReference |
getWindowReference()
Reference ID of this component's parent window (optional). |
boolean |
isAssignableFrom(Class cls)
Return whether this reference has the same class or is a superclass of the given component's class. |
static ComponentReference |
matchExisting(Component comp,
Collection existing)
Match the given component against an existing set of references. |
void |
setAttribute(String key,
String value)
|
String |
toEditableString()
Provide an editable string representation of the object. |
String |
toString()
Return a human-readable representation. |
org.jdom.Element |
toXML()
Provide an XML representation of the object. |
String |
toXMLString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int MW_FAILURE
static final String ANON_INNER_CLASS
static boolean cacheOnCreation
public static final String SHARED_FRAME_ID
Constructor Detail |
public ComponentReference(String id, Class compClass)
id
- Desired ID for the reference. Only used if this reference is
to be passed as the parent, window, or invoker of another.compClass
- Class of the component (required)public ComponentReference(String id, Class compClass, String name, String tag)
id
- Desired ID for the reference. Only used if this reference is
to be passed as the parent, window, or invoker of another.compClass
- Class of the component (required)name
- Name of the component, or nulltag
- Tag as returned by ComponentTester.getTag(Component)public ComponentReference(String id, Class compClass, String name, String tag, String title)
id
- Desired ID for the reference. Only used if this reference is
to be passed as the parent, window, or invoker of another.compClass
- Class of the component (required)name
- Name of the component, or nulltag
- Tag as returned by ComponentTester.getTag(Component)title
- Owning Frame/Dialog title, or nullpublic ComponentReference(String id, Class compClass, String name, String tag, String title, ComponentReference parent, int index)
id
- Desired ID for the reference. Only used if this reference is
to be passed as the parent, window, or invoker of another.compClass
- Class of the component (required)name
- Name of the component, or nulltag
- Tag as returned by ComponentTester.getTag(Component)title
- Owning Frame/Dialog title, or nullparent
- Reference to parent, or nullindex
- Index within parent, or -1public ComponentReference(String id, Class compClass, String name, String tag, String title, ComponentReference parent, int index, ComponentReference invokerOrWindow)
id
- Desired ID for the reference. Only used if this reference is
to be passed as the parent, window, or invoker of another.compClass
- Class of the component (required)name
- Name of the component, or nulltag
- Tag as returned by ComponentTester.getTag(Component)title
- Owning Frame/Dialog title, or nullparent
- Reference to parent, or nullindex
- Index within parent, or -1invokerOrWindow
- Window reference, invoker, or nullpublic ComponentReference(Resolver resolver, org.jdom.Element el) throws InvalidScriptException
public ComponentReference(Resolver r, Class cls, String[][] attributes)
public ComponentReference(Resolver resolver, Class cls, Map attributes)
public ComponentReference(Resolver resolver, Component comp)
public ComponentReference(Resolver resolver, Component comp, boolean includeHierarchyAttributes)
includeHierarchy
is true.
Method Detail |
public static int getIndex(Container parent, Component comp)
public Component getComponent() throws ComponentNotFoundException, MultipleComponentsFoundException
ComponentNotFoundException
MultipleComponentsFoundException
public Component getComponent(Hierarchy hierarchy) throws ComponentNotFoundException, MultipleComponentsFoundException
ComponentNotFoundException
MultipleComponentsFoundException
public static String getDescriptiveName(Component c)
public String getDescriptiveName()
public String getID()
public String getRefClassName()
public String getAttribute(String key)
public Map getAttributes()
public void setAttribute(String key, String value)
public boolean isAssignableFrom(Class cls)
public ComponentReference getParentReference()
public ComponentReference getWindowReference()
public ComponentReference getInvokerReference()
public void fromXML(String input) throws InvalidScriptException
InvalidScriptException
public org.jdom.Element toXML()
XMLifiable
toXML
in interface XMLifiable
public String toEditableString()
XMLifiable
toEditableString
in interface XMLifiable
public boolean equals(Object obj)
public String toString()
public String toXMLString()
static String getOrder(Component original, Component[] matchList, boolean horizontal)
int getMatchWeight(Component comp)
In general, we want to match if we get any weight at all, and there's only one component that matches.
public static ComponentReference matchExisting(Component comp, Collection existing)
boolean expressionMatch(String pattern, String actual)
public Component findInHierarchy(ComponentFinder finder) throws ComponentNotFoundException, MultipleComponentsFoundException
ComponentNotFoundException
MultipleComponentsFoundException
public Component findInHierarchy(ComponentFinder finder, Container root) throws ComponentNotFoundException, MultipleComponentsFoundException
ComponentNotFoundException
MultipleComponentsFoundException
Component getCachedLookup(Hierarchy hierarchy)
public String getName()
public String getTag()
public String getInvokerID()
public String getWindowID()
public String getTitle()
public int getIndex()
public int compareTo(Object o)
compareTo
in interface Comparable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |