| java.lang.Object abbot.script.ComponentReference
ComponentReference | public class ComponentReference implements XMLConstants,XMLifiable,Comparable(Code) | | 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.
- Resolver.addComponent(Component) - creates a reference if one doesn't
already exist and modifiers the Resolver to include it.
- getReference(Resolver, Component, Map) - create a reference only if a
matching one does not exist, but does not modify the Resolver.
- ComponentReference - create a new reference.
|
Constructor Summary | |
public | ComponentReference(Resolver resolver, Element el) For creation from XML. | public | 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. | public | ComponentReference(Resolver resolver, Class cls, Map attributes) Create a reference to an instance of the given class, given a Map of
attributes. | public | ComponentReference(Resolver resolver, Component comp) Create a reference based on the given component. | public | ComponentReference(Resolver resolver, Component comp, Map newReferences) Create a reference based on the given component. |
Method Summary | |
public int | compareTo(Object o) | public boolean | equals(Object obj) Two ComponentReferences with identical XML representations should
be equal. | boolean | expressionMatch(String pattern, String actual) Return whether the given pattern matches the given string. | public void | fromXML(String input) Set all options based on the given XML. | public String | getAttribute(String key) | public Map | getAttributes() | Component | getCachedLookup(Hierarchy hierarchy) Return the cached component match, if any. | public Component | getComponent() Return the component in the current Hierarchy that best matches this
reference. | public Component | getComponent(Hierarchy hierarchy) Return the component in the given Hierarchy that best matches this
reference. | public 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. | public String | getDescriptiveName() Return a suitably descriptive name for this reference, for use as an
ID (returns the ID itself if already set). | public String | getID() | public ComponentReference | getInvokerReference(Map newReferences) | int | getMatchWeight(Component comp) Return a measure of how well the given component matches the given
component reference. | 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. | public ComponentReference | getParentReference(Map newRefs) | public String | getRefClassName() | public 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. | public String | getUniqueID(Map refs) | public ComponentReference | getWindowReference(Map newReferences) Reference ID of this component's parent window (optional). | public boolean | isAssignableFrom(Class cls) Return whether this reference has the same class or is a superclass of
the given component's class. | public static ComponentReference | matchExisting(Component comp, Collection existing) Match the given component against an existing set of references. | public static ComponentReference | matchExisting(Component comp, Collection existing, Map newReferences) Match the given component against an existing set of references. | public void | setAttribute(String key, String value) | public String | toEditableString() | public String | toString() Return a human-readable representation. | public Element | toXML() Generate an XML representation of this object. | public String | toXMLString() |
MW_FAILURE | final public static int MW_FAILURE(Code) | | Match weight corresponding to no possible match.
|
SHARED_FRAME_ID | final public static String SHARED_FRAME_ID(Code) | | |
cacheOnCreation | static boolean cacheOnCreation(Code) | | Disable immediate cacheing of components when a reference is created
based on a Component. Cacheing will first be done when the reference
is resolved for the first time after creation. For testing purposes
only.
|
ComponentReference | public ComponentReference(Resolver r, Class cls, String[][] attributes)(Code) | | Create a reference to an instance of the given class, given an array
of name/value pairs of attributes.
|
ComponentReference | public ComponentReference(Resolver resolver, Class cls, Map attributes)(Code) | | Create a reference to an instance of the given class, given a Map of
attributes.
|
ComponentReference | public ComponentReference(Resolver resolver, Component comp)(Code) | | Create a reference based on the given component. Will not use or
create any ancestor components/references.
|
ComponentReference | public ComponentReference(Resolver resolver, Component comp, Map newReferences)(Code) | | Create a reference based on the given component. May recursively
create other components required to identify this one.
|
equals | public boolean equals(Object obj)(Code) | | Two ComponentReferences with identical XML representations should
be equal.
|
expressionMatch | boolean expressionMatch(String pattern, String actual)(Code) | | Return whether the given pattern matches the given string. Performs
variable substitution on the pattern.
|
getAttributes | public Map getAttributes()(Code) | | |
getDescriptiveName | public String getDescriptiveName()(Code) | | Return a suitably descriptive name for this reference, for use as an
ID (returns the ID itself if already set). Will never return an empty
String.
|
getMatchWeight | int getMatchWeight(Component comp)(Code) | | Return a measure of how well the given component matches the given
component reference. The weight performs two functions; one is to
loosely match so that we can find a component even if some of its
attributes have changed. The other is to distinguish between similar
components.
In general, we want to match if we get any weight at all, and there's
only one component that matches.
|
getOrder | static String getOrder(Component original, Component[] matchList, boolean horizontal)(Code) | | Return the order of the given component among the array given, sorted
by horizontal or vertical screen position. All components with the
same effective value will have the same order.
|
getReference | public static ComponentReference getReference(Resolver r, Component comp, Map newReferences)(Code) | | Returns a reference to the given component, preferring an existing
reference if a matching one is available or creating a new one if not.
The new references are not added to the resolver.
|
getWindowReference | public ComponentReference getWindowReference(Map newReferences)(Code) | | Reference ID of this component's parent window (optional).
|
isAssignableFrom | public boolean isAssignableFrom(Class cls)(Code) | | Return whether this reference has the same class or is a superclass of
the given component's class. Simply compare class names to avoid class
loader conflicts. Note that this does not take into account interfaces
(which is okay, since with GUI components we're only concerned with
class inheritance).
|
matchExisting | public static ComponentReference matchExisting(Component comp, Collection existing, Map newReferences)(Code) | | Match the given component against an existing set of references.
Extended method that also takes in a list of new references that
might have been created in this cycle
|
toString | public String toString()(Code) | | Return a human-readable representation.
|
toXML | public Element toXML()(Code) | | Generate an XML representation of this object.
|
|
|