| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ExpandBarResolver |
|
| 1.5;1.5 |
| 1 | /******************************************************************************* | |
| 2 | * Copyright (c) 2011 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.ExpandBar; | |
| 18 | import org.eclipse.swt.widgets.Widget; | |
| 19 | ||
| 20 | /** | |
| 21 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
| 22 | */ | |
| 23 | 8105 | public class ExpandBarResolver implements IChildrenResolver, IParentResolver { |
| 24 | ||
| 25 | public boolean canResolve(Widget w) { | |
| 26 | 130 | return w instanceof ExpandBar; |
| 27 | } | |
| 28 | ||
| 29 | public List getChildren(Widget w) { | |
| 30 | 26 | return hasChildren(w) ? Arrays.asList(((ExpandBar) w).getItems()) : new ArrayList(); |
| 31 | } | |
| 32 | ||
| 33 | public Widget getParent(Widget w) { | |
| 34 | 0 | return canResolve(w) ? ((ExpandBar) w).getParent() : null; |
| 35 | } | |
| 36 | ||
| 37 | public Class[] getResolvableClasses() { | |
| 38 | 8105 | return new Class[] { ExpandBar.class }; |
| 39 | } | |
| 40 | ||
| 41 | public boolean hasChildren(Widget w) { | |
| 42 | 78 | return canResolve(w) && ((ExpandBar) w).getItems().length > 0; |
| 43 | } | |
| 44 | ||
| 45 | public boolean hasParent(Widget w) { | |
| 46 | 0 | return getParent(w) != null; |
| 47 | } | |
| 48 | ||
| 49 | } |