org.fest.swing.core.matcher
Class DialogMatcher

java.lang.Object
  extended by org.fest.swing.core.AbstractComponentMatcher
      extended by org.fest.swing.core.GenericTypeMatcher<T>
          extended by org.fest.swing.core.matcher.NamedComponentMatcherTemplate<Dialog>
              extended by org.fest.swing.core.matcher.DialogMatcher
All Implemented Interfaces:
ComponentMatcher, ResettableComponentMatcher

public final class DialogMatcher
extends NamedComponentMatcherTemplate<Dialog>

Understands matching a Dialog by name, title and visibility on the screen.

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
ANY, name
 
Method Summary
 DialogMatcher andShowing()
          Indicates that the Dialog to match should be showing on the screen.
 DialogMatcher andTitle(Pattern titlePattern)
          Specifies the title to match.
 DialogMatcher andTitle(String newTitle)
          Specifies the title to match.
static DialogMatcher any()
          Creates a new DialogMatcher that matches any Dialog.
protected  boolean isMatching(Dialog dialog)
          Indicates whether: the name of the given Dialog is equal to the name in this matcher, and the title of the given Dialog matches the text (or pattern) in this matcher
 String toString()
           
static DialogMatcher withName(String name)
          Creates a new DialogMatcher that matches a Dialog that: has a matching name (optionally) has matching title (optionally) is showing on the screen
static DialogMatcher withTitle(Pattern titlePattern)
          Creates a new DialogMatcher that matches a Dialog by its title.
static DialogMatcher withTitle(String title)
          Creates a new DialogMatcher that matches a Dialog by its title.
 
Methods inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
arePropertyValuesMatching, isNameMatching, quoted, quotedName
 
Methods inherited from class org.fest.swing.core.GenericTypeMatcher
matches, supportedType
 
Methods inherited from class org.fest.swing.core.AbstractComponentMatcher
requireShowing, requireShowing, requireShowingMatches, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

withName

public static DialogMatcher withName(String name)
Creates a new DialogMatcher that matches a Dialog that:
  1. has a matching name
  2. (optionally) has matching title
  3. (optionally) is showing on the screen
  4. The following code listing shows how to match a Dialog by name and title:

     DialogMatcher m = withName("saveFile").andTitle("Save File");
     

    The following code listing shows how to match a Dialog, that should be showing on the screen, by name and title:

     DialogMatcher m = withName("saveFile").andTitle("Save File").andShowing();
     

    Parameters:
    name - the id to match.
    Returns:
    the created matcher.

withTitle

public static DialogMatcher withTitle(String title)
Creates a new DialogMatcher that matches a Dialog by its title.

The following code listing shows how to match a Dialog title:

 DialogMatcher m = withTitle("Save File");
 

The following code listing shows how to match a Dialog, that should be showing on the screen, by title:

 DialogMatcher m = withTitle("Save File").andShowing();
 

Parameters:
title - the title to match. It can be a regular expression.
Returns:
the created matcher.

withTitle

public static DialogMatcher withTitle(Pattern titlePattern)
Creates a new DialogMatcher that matches a Dialog by its title.

The following code listing shows how to match a Dialog title, using a regular expression pattern:

 DialogMatcher m = withTitle(Pattern.compile("Sav.*"));
 

The following code listing shows how to match a Dialog, that should be showing on the screen, by title, using a regular expression pattern:

 DialogMatcher m = withTitle(Pattern.compile("Sav.*")).andShowing();
 

Parameters:
titlePattern - the regular expression pattern to match.
Returns:
the created matcher.
Since:
1.2

any

public static DialogMatcher any()
Creates a new DialogMatcher that matches any Dialog.

Returns:
the created matcher.

andTitle

public DialogMatcher andTitle(String newTitle)
Specifies the title to match. If this matcher was created using withTitle(String) or withTitle(Pattern), this method will simply update the title to match.

Parameters:
newTitle - the new title to match. It can be a regular expression.
Returns:
this matcher.

andTitle

public DialogMatcher andTitle(Pattern titlePattern)
Specifies the title to match. If this matcher was created using withTitle(String), or withTitle(Pattern) this method will simply update the title to match.

Parameters:
titlePattern - the regular expression pattern to match.
Returns:
this matcher.
Since:
1.2

andShowing

public DialogMatcher andShowing()
Indicates that the Dialog to match should be showing on the screen.

Returns:
this matcher.

isMatching

@RunsInCurrentThread
protected boolean isMatching(Dialog dialog)
Indicates whether:

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Specified by:
isMatching in class GenericTypeMatcher<Dialog>
Parameters:
dialog - the Dialog to match.
Returns:
true if the Dialog matches the search criteria in this matcher.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.