Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SWTBotCLabel |
|
| 1.0;1 | ||||
SWTBotCLabel$1 |
|
| 1.0;1 |
1 | 6 | /******************************************************************************* |
2 | * Copyright (c) 2008 Cedric Chabanois 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 | * Cedric Chabanois - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.swtbot.swt.finder.widgets; | |
12 | ||
13 | import org.eclipse.swt.custom.CLabel; | |
14 | import org.eclipse.swt.graphics.Image; | |
15 | import org.eclipse.swtbot.swt.finder.ReferenceBy; | |
16 | import org.eclipse.swtbot.swt.finder.SWTBotWidget; | |
17 | import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; | |
18 | import org.eclipse.swtbot.swt.finder.results.IntResult; | |
19 | import org.hamcrest.SelfDescribing; | |
20 | ||
21 | /** | |
22 | * This represents a {@link CLabel} widget. | |
23 | * | |
24 | * @author Cedric Chabanois <cchabanois [at] no-log [dot] org> | |
25 | * @version $Id$ | |
26 | * @since 1.0 | |
27 | */ | |
28 | @SWTBotWidget(clasz = CLabel.class, preferredName = "clabel", referenceBy = { ReferenceBy.MNEMONIC }) | |
29 | public class SWTBotCLabel extends AbstractSWTBotControl<CLabel> { | |
30 | ||
31 | /** | |
32 | * Constructs an instance of this using the given finder and text to search for. | |
33 | * | |
34 | * @param w the widget. | |
35 | * @throws WidgetNotFoundException if the widget is not found. | |
36 | * @since 2.0 | |
37 | */ | |
38 | public SWTBotCLabel(CLabel w) throws WidgetNotFoundException { | |
39 | 0 | this(w, null); |
40 | 0 | } |
41 | ||
42 | /** | |
43 | * Constructs an instance of this using the given finder and text to search for. | |
44 | * | |
45 | * @param w the widget. | |
46 | * @param description the description of the widget, this will be reported by {@link #toString()} | |
47 | * @throws WidgetNotFoundException if the widget is not found. | |
48 | * @since 2.0 | |
49 | */ | |
50 | public SWTBotCLabel(CLabel w, SelfDescribing description) throws WidgetNotFoundException { | |
51 | 6 | super(w, description); |
52 | 6 | } |
53 | ||
54 | /** | |
55 | * Return the CLabel's image or <code>null</code>. | |
56 | * | |
57 | * @return the image of the label or null | |
58 | */ | |
59 | public Image image() { | |
60 | 1 | return widget.getImage(); |
61 | } | |
62 | ||
63 | /** | |
64 | * Returns the alignment. The alignment style (LEFT, CENTER or RIGHT) is returned. | |
65 | * | |
66 | * @return SWT.LEFT, SWT.RIGHT or SWT.CENTER | |
67 | */ | |
68 | public int alignment() { | |
69 | 3 | return syncExec(new IntResult() { |
70 | public Integer run() { | |
71 | 3 | return widget.getAlignment(); |
72 | } | |
73 | }); | |
74 | } | |
75 | ||
76 | } |