Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PartLabelDescription |
|
| 1.0;1 |
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.eclipse.finder.widgets.utils; | |
12 | ||
13 | import org.eclipse.swtbot.swt.finder.utils.ClassUtils; | |
14 | import org.eclipse.ui.IWorkbenchPartReference; | |
15 | import org.hamcrest.Description; | |
16 | import org.hamcrest.SelfDescribing; | |
17 | import org.hamcrest.StringDescription; | |
18 | ||
19 | /** | |
20 | * Describes the IWorkbenchPartReference, by invoking {@link IWorkbenchPartReference#getPartName()} on it. | |
21 | * | |
22 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
23 | * @version $Id$ | |
24 | */ | |
25 | public class PartLabelDescription<T extends IWorkbenchPartReference> implements SelfDescribing { | |
26 | ||
27 | private final T partReference; | |
28 | ||
29 | 60 | public PartLabelDescription(T partReference) { |
30 | 60 | this.partReference = partReference; |
31 | 60 | } |
32 | ||
33 | public void describeTo(Description description) { | |
34 | 0 | description.appendText(ClassUtils.simpleClassName(partReference) + " with label {" + partReference.getPartName() + "}"); //$NON-NLS-1$ //$NON-NLS-2$ |
35 | 0 | } |
36 | ||
37 | public String toString() { | |
38 | 0 | return StringDescription.asString(this); |
39 | } | |
40 | ||
41 | } |