| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ToolbarResolver |
|
| 1.5;1.5 |
| 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.swt.finder.resolvers; | |
| 12 | ||
| 13 | import java.util.ArrayList; | |
| 14 | import java.util.Arrays; | |
| 15 | import java.util.List; | |
| 16 | ||
| 17 | import org.eclipse.swt.widgets.ToolBar; | |
| 18 | import org.eclipse.swt.widgets.Widget; | |
| 19 | ||
| 20 | /** | |
| 21 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
| 22 | * @version $Id$ | |
| 23 | */ | |
| 24 | 8105 | public class ToolbarResolver implements IChildrenResolver, IParentResolver { |
| 25 | ||
| 26 | public boolean canResolve(Widget w) { | |
| 27 | 2115 | return w instanceof ToolBar; |
| 28 | } | |
| 29 | ||
| 30 | public List getChildren(Widget w) { | |
| 31 | 423 | return hasChildren(w) ? Arrays.asList(((ToolBar) w).getItems()) : new ArrayList(); |
| 32 | } | |
| 33 | ||
| 34 | public Widget getParent(Widget w) { | |
| 35 | 0 | return (canResolve(w)) ? ((ToolBar) w).getParent() : null; |
| 36 | } | |
| 37 | ||
| 38 | public Class[] getResolvableClasses() { | |
| 39 | 8105 | return new Class[] { ToolBar.class }; |
| 40 | } | |
| 41 | ||
| 42 | public boolean hasChildren(Widget w) { | |
| 43 | 1269 | return (canResolve(w)) && ((ToolBar) w).getItems().length > 0; |
| 44 | } | |
| 45 | ||
| 46 | public boolean hasParent(Widget w) { | |
| 47 | 0 | return getParent(w) != null; |
| 48 | } | |
| 49 | ||
| 50 | } |