Package org.fest.swing.finder
Class ComponentFinderTemplate<T extends Component>
java.lang.Object
org.fest.swing.finder.ComponentFinderTemplate<T>
- Type Parameters:
T
- the type of component this finder can search.
- Direct Known Subclasses:
JFileChooserFinder
,JOptionPaneFinder
,WindowFinderTemplate
Understands a template for
Component
finders.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ComponentMatcher
private final String
private long
(package private) static final long
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ComponentFinderTemplate
(Class<? extends T> componentType) Creates a newComponentFinderTemplate
.protected
ComponentFinderTemplate
(String componentName, Class<? extends T> componentType) Creates a newComponentFinderTemplate
.private
ComponentFinderTemplate
(ComponentMatcher matcher) protected
ComponentFinderTemplate
(GenericTypeMatcher<? extends T> matcher) Creates a newComponentFinderTemplate
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
Casts the givenComponent
to the type supported by this finder.protected final T
findComponentWith
(Robot robot) Finds the component using either by name or type.abstract ComponentFixture<T>
Finds a component by name or type using the given robot.protected ComponentFinderTemplate<T>
withTimeout
(long newTimeout) Sets the timeout for this finder.protected ComponentFinderTemplate<T>
withTimeout
(long newTimeout, TimeUnit unit) Sets the timeout for this finder.
-
Field Details
-
TIMEOUT
static final long TIMEOUT- See Also:
-
timeout
private long timeout -
matcher
-
searchDescription
-
-
Constructor Details
-
ComponentFinderTemplate
Creates a newComponentFinderTemplate
.- Parameters:
componentName
- the name of theComponent
to find.componentType
- the type of theComponent
to find.
-
ComponentFinderTemplate
Creates a newComponentFinderTemplate
.- Parameters:
matcher
- specifies the search criteria to use when looking up aComponent
.
-
ComponentFinderTemplate
Creates a newComponentFinderTemplate
.- Parameters:
componentType
- the type of theComponent
to find.
-
ComponentFinderTemplate
-
-
Method Details
-
withTimeout
Sets the timeout for this finder. TheComponent
to find should be found within the given time period.- Parameters:
newTimeout
- the period of time the search should be performed.unit
- the time unit fortimeout
.- Returns:
- this finder.
- Throws:
NullPointerException
- if the time unit isnull
.IllegalArgumentException
- if the timeout is a negative number.
-
withTimeout
Sets the timeout for this finder. TheComponent
to find should be found within the given time period.- Parameters:
newTimeout
- the number of milliseconds before stopping the search.- Returns:
- this finder.
- Throws:
IllegalArgumentException
- if the timeout is a negative number.
-
using
Finds a component by name or type using the given robot.- Parameters:
robot
- contains the underlying finding to delegate the search to.- Returns:
- a fixture capable of managing the found component.
- Throws:
WaitTimedOutError
- if a component with the given name or of the given type could not be found.
-
findComponentWith
Finds the component using either by name or type.- Parameters:
robot
- contains the underlying finding to delegate the search to.- Returns:
- the found component.
- Throws:
WaitTimedOutError
- if a component with the given name or of the given type could not be found.
-
cast
Casts the givenComponent
to the type supported by this finder.- Parameters:
c
- the givenComponent
.- Returns:
- the given
Component
casted to the type supported by this finder.
-