package org.jboss.reddeer.swt.condition;

import org.eclipse.swt.widgets.Shell;
import org.hamcrest.Matcher;
import org.hamcrest.core.IsEqual;
import org.jboss.reddeer.common.logging.Logger;
import org.jboss.reddeer.swt.lookup.ShellLookup;
import org.jboss.reddeer.swt.matcher.WithTextMatcher;
import org.jboss.reddeer.swt.util.internal.InstanceValidator;

/**
 * Condition is met when shell with specific text (title) is available.
 * 
 * @author Andrej Podhradsky (andrej.podhradsky@gmail.com)
 * @author jniederm
 */
public class ShellWithTextIsAvailable implements WaitCondition { 
	private Matcher<String> matcher;
	private final Logger log = Logger.getLogger(this.getClass());

	/**
	 * Constructs ShellWithTextIsAvailable wait condition.
	 * Condition is met when shell with the specified title is available.
	 * 
	 * @param text text/name of the shell
	 */
	public ShellWithTextIsAvailable(String title) {
		InstanceValidator.checkNotNull(title, "title");
		this.matcher = new IsEqual<String>(title);
	}

	@Override
	public boolean test() {
		log.debug("Looking for shell with title matching '" + matcher + "'");
		Shell shell = ShellLookup.getInstance().getShell(matcher);
		return shell != null;
	}

	@Override
	public String description() {
		return "shell with title matching " + matcher + " is available";
	}
}

@@ -106,42 +106,8 @@
 er;%0A
-import org.hamcrest.core.IsEqual;%0A
 impo
@@ -948,23 +948,23 @@
 new 
-IsEqual%3CString%3E
+WithTextMatcher
 (tit

Use right matcher for matching shell title. Fixes #713