Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ContextMenuFinder |
|
| 1.0;1 | ||||
ContextMenuFinder$1 |
|
| 1.0;1 |
1 | 64 | /******************************************************************************* |
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.swt.finder.finders; | |
12 | ||
13 | ||
14 | ||
15 | import org.eclipse.swt.widgets.Control; | |
16 | import org.eclipse.swt.widgets.Menu; | |
17 | import org.eclipse.swt.widgets.Shell; | |
18 | import org.eclipse.swtbot.swt.finder.results.WidgetResult; | |
19 | import org.eclipse.swtbot.swt.finder.utils.internal.Assert; | |
20 | ||
21 | /** | |
22 | * Finds context menus for a given control. | |
23 | * | |
24 | * @see UIThreadRunnable | |
25 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
26 | * @version $Id$ | |
27 | */ | |
28 | public class ContextMenuFinder extends MenuFinder { | |
29 | ||
30 | /** | |
31 | * The control to find context menus. | |
32 | */ | |
33 | 32 | private final Control control; |
34 | ||
35 | /** | |
36 | * Constructs the context menu finder for the given control to be searched. | |
37 | * | |
38 | * @param control the control that has a context menu. | |
39 | */ | |
40 | public ContextMenuFinder(Control control) { | |
41 | 9 | super(); |
42 | 9 | Assert.isNotNull(control, "The control cannot be null"); //$NON-NLS-1$ |
43 | 9 | this.control = control; |
44 | 9 | } |
45 | ||
46 | /** | |
47 | * Gets the menubar for the given shell. | |
48 | * | |
49 | * @see org.eclipse.swtbot.swt.finder.finders.MenuFinder#menuBar(org.eclipse.swt.widgets.Shell) | |
50 | * @param shell The shell to find the menu bar for. | |
51 | * @return The menu bar found. | |
52 | */ | |
53 | @Override | |
54 | protected Menu menuBar(final Shell shell) { | |
55 | 32 | return UIThreadRunnable.syncExec(display, new WidgetResult<Menu>() { |
56 | public Menu run() { | |
57 | 32 | return control.getMenu(); |
58 | } | |
59 | }); | |
60 | } | |
61 | } |