| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ChildrenControlFinder |
|
| 1.0;1 |
| 1 | /******************************************************************************* | |
| 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.finders; | |
| 12 | ||
| 13 | import java.util.List; | |
| 14 | ||
| 15 | import org.eclipse.swt.widgets.Widget; | |
| 16 | import org.eclipse.swtbot.swt.finder.resolvers.DefaultChildrenResolver; | |
| 17 | import org.eclipse.swtbot.swt.finder.resolvers.DefaultParentResolver; | |
| 18 | import org.eclipse.swtbot.swt.finder.resolvers.IChildrenResolver; | |
| 19 | import org.eclipse.swtbot.swt.finder.resolvers.IParentResolver; | |
| 20 | import org.hamcrest.Matcher; | |
| 21 | ||
| 22 | /** | |
| 23 | * Finds controls matching a particular matcher in the given parent widget. | |
| 24 | * | |
| 25 | * @author Cedric Chabanois <cchabanois [at] no-log [dot] org> | |
| 26 | * @version $Id$ | |
| 27 | * @since 1.0 | |
| 28 | */ | |
| 29 | public class ChildrenControlFinder extends ControlFinder { | |
| 30 | /** | |
| 31 | * The parent widget to begin searching for children. | |
| 32 | * | |
| 33 | * @since 1.1 | |
| 34 | */ | |
| 35 | protected final Widget parentWidget; | |
| 36 | ||
| 37 | /** | |
| 38 | * Constructs a child control finder widget using the given parent widget as its starting point. | |
| 39 | * | |
| 40 | * @param parentWidget the parent widget in which controls should be found. | |
| 41 | */ | |
| 42 | public ChildrenControlFinder(Widget parentWidget) { | |
| 43 | 2 | this(parentWidget, new DefaultChildrenResolver(), new DefaultParentResolver()); |
| 44 | 2 | } |
| 45 | ||
| 46 | /** | |
| 47 | * Constructs the child control finder with the given parent widget as it's starting point and the set resolvers. | |
| 48 | * | |
| 49 | * @param parentWidget the parent widget in which controls should be found. | |
| 50 | * @param childrenResolver the resolver used to resolve children of a control. | |
| 51 | * @param parentResolver the resolver used to resolve parent of a control. | |
| 52 | */ | |
| 53 | public ChildrenControlFinder(Widget parentWidget, IChildrenResolver childrenResolver, IParentResolver parentResolver) { | |
| 54 | 2 | super(childrenResolver, parentResolver); |
| 55 | 2 | this.parentWidget = parentWidget; |
| 56 | 2 | } |
| 57 | ||
| 58 | /** | |
| 59 | * Attempts to find the controls using the given matcher starting with the given parent widget. This will search | |
| 60 | * recursively. | |
| 61 | * | |
| 62 | * @param matcher the matcher used to find controls in the {@link #parentWidget}. | |
| 63 | * @return all controls in the parent widget that the matcher matches. | |
| 64 | */ | |
| 65 | @Override | |
| 66 | public <T extends Widget> List<T> findControls(Matcher<T> matcher) { | |
| 67 | 2 | return findControls(parentWidget, matcher, true); |
| 68 | } | |
| 69 | ||
| 70 | } |