|
Added
Link Here
|
| 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.List; |
| 15 |
|
| 16 |
import org.eclipse.swt.widgets.ToolItem; |
| 17 |
import org.eclipse.swt.widgets.Widget; |
| 18 |
|
| 19 |
/** |
| 20 |
* @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> |
| 21 |
* @version $Id$ |
| 22 |
*/ |
| 23 |
public class ToolItemResolver implements IChildrenResolver, IParentResolver { |
| 24 |
|
| 25 |
public boolean canResolve(Widget w) { |
| 26 |
return w instanceof ToolItem; |
| 27 |
} |
| 28 |
|
| 29 |
public List getChildren(Widget w) { |
| 30 |
ArrayList children = new ArrayList(); |
| 31 |
children.add(((ToolItem) w).getControl()); |
| 32 |
return children; |
| 33 |
} |
| 34 |
|
| 35 |
public Widget getParent(Widget w) { |
| 36 |
return (canResolve(w)) ? ((ToolItem) w).getParent() : null; |
| 37 |
} |
| 38 |
|
| 39 |
public Class[] getResolvableClasses() { |
| 40 |
return new Class[] { ToolItem.class }; |
| 41 |
} |
| 42 |
|
| 43 |
public boolean hasChildren(Widget w) { |
| 44 |
return (canResolve(w)) && ((ToolItem) w).getControl() != null; |
| 45 |
} |
| 46 |
|
| 47 |
public boolean hasParent(Widget w) { |
| 48 |
return getParent(w) != null; |
| 49 |
} |
| 50 |
|
| 51 |
} |