|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object abbot.script.ComponentReference
public class 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.ComponentReferences may be created in one of three ways, each of which has slightly different implications.
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_AWT, 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_EXPR, TAG_FILENAME, TAG_FIXTURE, 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,
Map newReferences)
Create a reference based on the given component. |
|
ComponentReference(Resolver resolver,
Element el)
For creation from XML. |
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. |
void |
fromXML(String input)
Deprecated. |
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)
Deprecated. Use Robot.getDescriptiveName(Component) instead |
String |
getID()
|
ComponentReference |
getInvokerReference(Map newReferences)
|
(package private) int |
getMatchWeight(Component comp)
Return a measure of how well the given component matches the given component reference. |
(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(Map newRefs)
|
String |
getRefClassName()
|
static ComponentReference |
getReference(Resolver r,
Component comp,
Map newReferences)
Returns a reference to the given component, preferring an existing reference if a matching one is available or creating a new one if not. |
String |
getUniqueID(Map refs)
|
ComponentReference |
getWindowReference(Map newReferences)
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. |
static ComponentReference |
matchExisting(Component comp,
Collection existing,
Map newReferences)
Match the given component against an existing set of references. |
void |
setAttribute(String key,
String value)
|
String |
toEditableString()
Deprecated. Used to be used to edit XML in a text editor. |
String |
toString()
Return a human-readable representation. |
Element |
toXML()
Generate an XML representation of this object. |
String |
toXMLString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String SHARED_FRAME_ID
public static final int MW_FAILURE
static final String ANON_INNER_CLASS
static boolean cacheOnCreation
Constructor Detail |
---|
public ComponentReference(Resolver resolver, Element el) throws InvalidScriptException
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, Map newReferences)
Method Detail |
---|
public Component getComponent() throws ComponentNotFoundException, MultipleComponentsFoundException
ComponentNotFoundException
MultipleComponentsFoundException
public Component getComponent(Hierarchy hierarchy) throws ComponentNotFoundException, MultipleComponentsFoundException
ComponentNotFoundException
MultipleComponentsFoundException
public static String getDescriptiveName(Component c)
Robot.getDescriptiveName(Component)
instead
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(Map newRefs)
public ComponentReference getWindowReference(Map newReferences)
public ComponentReference getInvokerReference(Map newReferences)
public void fromXML(String input) throws InvalidScriptException, IOException
InvalidScriptException
IOException
public Element toXML()
toXML
in interface XMLifiable
public String toEditableString()
XMLifiable
toEditableString
in interface XMLifiable
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
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 getReference(Resolver r, Component comp, Map newReferences)
public static ComponentReference matchExisting(Component comp, Collection existing)
public static ComponentReference matchExisting(Component comp, Collection existing, Map newReferences)
boolean expressionMatch(String pattern, String actual)
Component getCachedLookup(Hierarchy hierarchy)
public int compareTo(Object o)
compareTo
in interface Comparable
public String getUniqueID(Map refs)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |