Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SWTBotToolbarPushButton |
|
| 1.0;1 |
1 | 1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Obeo 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 | * Obeo - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.swtbot.swt.finder.widgets; | |
12 | ||
13 | import org.eclipse.swt.SWT; | |
14 | import org.eclipse.swt.widgets.ToolItem; | |
15 | import org.eclipse.swtbot.swt.finder.ReferenceBy; | |
16 | import org.eclipse.swtbot.swt.finder.SWTBotWidget; | |
17 | import org.eclipse.swtbot.swt.finder.Style; | |
18 | import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; | |
19 | import org.eclipse.swtbot.swt.finder.utils.MessageFormat; | |
20 | import org.eclipse.swtbot.swt.finder.utils.SWTUtils; | |
21 | import org.eclipse.swtbot.swt.finder.utils.internal.Assert; | |
22 | import org.hamcrest.SelfDescribing; | |
23 | ||
24 | /** | |
25 | * @author Mariot Chauvin <mariot [dot] chauvin [at] obeo [dot] fr> | |
26 | */ | |
27 | @SWTBotWidget(clasz = ToolItem.class, style = @Style(name = "SWT.PUSH", value = SWT.PUSH), preferredName = "toolbarButton", referenceBy = { | |
28 | ReferenceBy.MNEMONIC, ReferenceBy.TOOLTIP }, returnType = SWTBotToolbarButton.class) | |
29 | public class SWTBotToolbarPushButton extends SWTBotToolbarButton { | |
30 | ||
31 | /** | |
32 | * Constructs an new instance of this item. | |
33 | * | |
34 | * @param w the tool item. | |
35 | * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed. | |
36 | */ | |
37 | public SWTBotToolbarPushButton(ToolItem w) throws WidgetNotFoundException { | |
38 | 0 | this(w, null); |
39 | 0 | } |
40 | ||
41 | /** | |
42 | * Constructs an new instance of this item. | |
43 | * | |
44 | * @param w the tool item. | |
45 | * @param description the description of the widget, this will be reported by {@link #toString()} | |
46 | * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed. | |
47 | */ | |
48 | public SWTBotToolbarPushButton(ToolItem w, SelfDescribing description) throws WidgetNotFoundException { | |
49 | 15 | super(w, description); |
50 | 15 | Assert.isTrue(SWTUtils.hasStyle(w, SWT.PUSH), "Expecting a push button."); //$NON-NLS-1$ |
51 | 15 | } |
52 | ||
53 | /** | |
54 | * Click on the tool item. | |
55 | * | |
56 | * @since 1.0 | |
57 | */ | |
58 | public SWTBotToolbarPushButton click() { | |
59 | 1 | log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$ |
60 | 1 | waitForEnabled(); |
61 | 1 | sendNotifications(); |
62 | 1 | log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$ |
63 | 1 | return this; |
64 | } | |
65 | } |