01: package abbot.finder.matchers;
02:
03: import java.awt.*;
04:
05: /** Provides matching of a Window by title or component name. */
06: public class WindowMatcher extends ClassMatcher {
07: private String id;
08: private boolean mustBeShowing;
09:
10: public WindowMatcher(String id) {
11: this (id, true);
12: }
13:
14: public WindowMatcher(String id, boolean mustBeShowing) {
15: super (Window.class);
16: this .id = id;
17: this .mustBeShowing = mustBeShowing;
18: }
19:
20: public boolean matches(Component c) {
21: return super .matches(c)
22: && (c.isShowing() || !mustBeShowing)
23: && (stringsMatch(id, c.getName())
24: || (c instanceof Frame && stringsMatch(id,
25: ((Frame) c).getTitle())) || (c instanceof Dialog && stringsMatch(
26: id, ((Dialog) c).getTitle())));
27: }
28:
29: public String toString() {
30: return "Window matcher (id=" + id + ")";
31: }
32: }
|