| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| WaitForEditor |
|
| 1.0;1 | ||||
| WaitForEditor$1 |
|
| 1.0;1 |
| 1 | 26 | /******************************************************************************* |
| 2 | * Copyright (c) 2008-2009 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 | * Ralf Ebert www.ralfebert.de - (bug 271630) SWTBot Improved RCP / Workbench support | |
| 11 | *******************************************************************************/ | |
| 12 | package org.eclipse.swtbot.eclipse.finder.waits; | |
| 13 | ||
| 14 | import java.util.List; | |
| 15 | ||
| 16 | import org.eclipse.swtbot.eclipse.finder.finders.WorkbenchContentsFinder; | |
| 17 | import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; | |
| 18 | import org.eclipse.swtbot.swt.finder.results.ListResult; | |
| 19 | import org.eclipse.swtbot.swt.finder.utils.SWTUtils; | |
| 20 | import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition; | |
| 21 | import org.eclipse.ui.IEditorReference; | |
| 22 | import org.hamcrest.Matcher; | |
| 23 | ||
| 24 | /** | |
| 25 | * Waits until an editor that matches the specified matcher appears. | |
| 26 | * | |
| 27 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
| 28 | * @author Ralf Ebert www.ralfebert.de (bug 271630) | |
| 29 | * @version $Id$ | |
| 30 | */ | |
| 31 | 13 | public class WaitForEditor extends WaitForObjectCondition<IEditorReference> { |
| 32 | ||
| 33 | /** | |
| 34 | * Creates a condition that waits until the matcher is true. | |
| 35 | * | |
| 36 | * @param matcher the matcher | |
| 37 | */ | |
| 38 | WaitForEditor(Matcher<IEditorReference> matcher) { | |
| 39 | 13 | super(matcher); |
| 40 | 13 | } |
| 41 | ||
| 42 | public String getFailureMessage() { | |
| 43 | 0 | return "Could not find editor matching: " + matcher; |
| 44 | } | |
| 45 | ||
| 46 | @Override | |
| 47 | protected List<IEditorReference> findMatches() { | |
| 48 | 13 | return UIThreadRunnable.syncExec(SWTUtils.display(), new ListResult<IEditorReference>() { |
| 49 | public List<IEditorReference> run() { | |
| 50 | 13 | return new WorkbenchContentsFinder().findEditors(matcher); |
| 51 | } | |
| 52 | }); | |
| 53 | } | |
| 54 | ||
| 55 | } |