| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| InUIThread |
|
| 1.0;1 | ||||
| InUIThread$1 |
|
| 1.0;1 |
| 1 | 0 | /******************************************************************************* |
| 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 | * Ketan Padegaonkar - http://swtbot.org/bugzilla/show_bug.cgi?id=126 | |
| 11 | *******************************************************************************/ | |
| 12 | package org.eclipse.swtbot.swt.finder.matchers; | |
| 13 | ||
| 14 | import org.eclipse.swt.widgets.Widget; | |
| 15 | import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; | |
| 16 | import org.eclipse.swtbot.swt.finder.results.BoolResult; | |
| 17 | import org.hamcrest.Description; | |
| 18 | import org.hamcrest.Factory; | |
| 19 | import org.hamcrest.Matcher; | |
| 20 | ||
| 21 | /** | |
| 22 | * Matches another matcher in the context of the UI thread. Useful if you want to make a matcher UI thread safe. | |
| 23 | * | |
| 24 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
| 25 | * @version $Id$ | |
| 26 | * @since 2.0 | |
| 27 | * @deprecated this has been deprecated and will be removed in future releases of swtbot | |
| 28 | */ | |
| 29 | public class InUIThread<T extends Widget> extends AbstractMatcher<T> { | |
| 30 | ||
| 31 | 0 | private Matcher<?> matcher; |
| 32 | ||
| 33 | /** | |
| 34 | * @param matcher another matcher | |
| 35 | */ | |
| 36 | 0 | InUIThread(Matcher<?> matcher) { |
| 37 | 0 | this.matcher = matcher; |
| 38 | 0 | } |
| 39 | ||
| 40 | protected boolean doMatch(final Object obj) { | |
| 41 | 0 | return UIThreadRunnable.syncExec(new BoolResult() { |
| 42 | public Boolean run() { | |
| 43 | 0 | return matcher.matches(obj); |
| 44 | } | |
| 45 | }); | |
| 46 | } | |
| 47 | ||
| 48 | public void describeTo(Description description) { | |
| 49 | 0 | description.appendText("evaluates matcher [").appendDescriptionOf(matcher).appendText("] in the ui thread"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 50 | 0 | } |
| 51 | ||
| 52 | /** | |
| 53 | * Matches another matcher in the context of the UI thread. Useful if you want to make a matcher UI thread safe. | |
| 54 | * | |
| 55 | * @param matcher the matcher | |
| 56 | * @return a matcher. | |
| 57 | * @since 2.0 | |
| 58 | * @deprecated this has been deprecated and will be removed in future releases of swtbot. | |
| 59 | */ | |
| 60 | @Factory | |
| 61 | public static <T extends Widget> Matcher<T> inUIThread(Matcher<?> matcher) { | |
| 62 | 0 | return new InUIThread<T>(matcher); |
| 63 | } | |
| 64 | ||
| 65 | } |