Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
WaitForShell |
|
| 1.5;1.5 |
1 | /******************************************************************************* | |
2 | * Copyright (c) 2008 Ketan Padegaonkar and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Ketan Padegaonkar - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.swtbot.swt.finder.waits; | |
12 | ||
13 | import java.util.ArrayList; | |
14 | import java.util.List; | |
15 | ||
16 | import org.eclipse.swt.widgets.Shell; | |
17 | import org.hamcrest.Matcher; | |
18 | ||
19 | /** | |
20 | * Condiion that waits for a shell with the specified text to appear. | |
21 | * | |
22 | * @see Conditions | |
23 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
24 | * @version $Id$ | |
25 | * @since 2.0 | |
26 | */ | |
27 | class WaitForShell extends WaitForObjectCondition<Shell> { | |
28 | ||
29 | WaitForShell(Matcher<Shell> matcher) { | |
30 | 37 | super(matcher); |
31 | 37 | } |
32 | ||
33 | public String getFailureMessage() { | |
34 | 2 | return "Could not find shell matching: " + matcher; //$NON-NLS-1$ |
35 | } | |
36 | ||
37 | protected List<Shell> findMatches() { | |
38 | 56 | Shell[] shells = findShells(); |
39 | 56 | ArrayList<Shell> matchingShells = new ArrayList<Shell>(); |
40 | 216 | for (Shell shell : shells) { |
41 | 160 | if (matcher.matches(shell)) { |
42 | 35 | matchingShells.add(shell); |
43 | } | |
44 | } | |
45 | 56 | return matchingShells; |
46 | } | |
47 | ||
48 | /** | |
49 | * Subclasses may override to find other shells. | |
50 | */ | |
51 | Shell[] findShells() { | |
52 | 56 | return bot.getFinder().getShells(); |
53 | } | |
54 | ||
55 | } |