PageRenderTime 101ms CodeModel.GetById 97ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/Fest/src/org/gjt/sp/jedit/testframework/FirstDialogMatcher.java

#
Java | 63 lines | 22 code | 12 blank | 29 comment | 3 complexity | a169919e4783110d57053edd98458978 MD5 | raw file
 1/*
 2* $Revision: 12869 $
 3* $Date: 2008-06-21 10:02:28 -0600 (Sat, 21 Jun 2008) $
 4* $Author: kerik-sf $
 5*
 6* Copyright (C) 2008 Eric Le Lay
 7*
 8* This program is free software; you can redistribute it and/or
 9* modify it under the terms of the GNU General Public License
10* as published by the Free Software Foundation; either version 2
11* of the License, or any later version.
12*
13* This program is distributed in the hope that it will be useful,
14* but WITHOUT ANY WARRANTY; without even the implied warranty of
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16* GNU General Public License for more details.
17*
18* You should have received a copy of the GNU General Public License
19* along with this program; if not, write to the Free Software
20* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21*/
22
23package org.gjt.sp.jedit.testframework;
24
25
26//{{{ Imports
27
28import java.awt.Dialog;
29import java.awt.Component;
30
31
32//{{{	junit
33import org.junit.*;
34import static org.junit.Assert.*;
35//}}}
36
37//{{{	FEST...
38import org.fest.swing.fixture.*;
39import org.fest.swing.core.*;
40import org.fest.swing.finder.WindowFinder;
41//}}}
42
43///}}}
44
45
46public class FirstDialogMatcher implements ComponentMatcher{
47	private boolean found = false;
48	private String title;
49
50	public FirstDialogMatcher(String title){
51		this.title = title;
52	}
53
54	public boolean matches(Component comp){
55		if(found)return false;
56		if(comp instanceof Dialog && comp.isVisible()){
57			//System.err.println("got this window : "+((JDialog)comp).getTitle());
58			found = title.equals(((Dialog)comp).getTitle());
59		}
60		//System.out.println("discarded:"+comp);
61		return found;
62	}
63}