Project

General

Profile

Download (2.18 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.test;
2

    
3
import java.util.List;
4

    
5
import org.eclipse.swt.widgets.Tree;
6
import org.eclipse.swt.widgets.Widget;
7
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
8
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
9
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
10
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
11
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
12
import org.eclipse.swtbot.swt.finder.finders.ChildrenControlFinder;
13
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
14
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
15

    
16
public class SwtBotUtils {
17

    
18
	private SWTWorkbenchBot bot;
19

    
20
	public SwtBotUtils(SWTWorkbenchBot bot) {
21
		this.bot = bot;
22
	}
23

    
24
	/**
25
	 * @return
26
	 * @throws WidgetNotFoundException
27
	 */
28
	public SWTBotTree tree(Widget widget) throws WidgetNotFoundException {
29
		List<Tree> controls = new ChildrenControlFinder(widget).findControls(WidgetMatcherFactory.widgetOfType(Tree.class));
30
		if (controls.isEmpty()) {
31
            throw new WidgetNotFoundException("Could not find any tree");
32
        }
33
		SWTBotTree tree = new SWTBotTree(controls.get(0));
34
		return tree;
35
	}
36

    
37
	/**
38
	 *
39
	 * @param index the index of the SelectionElement
40
	 * @param dialogName the title of the expected dialog
41
	 */
42
	public void openFilteredSelection(int index, String dialogName){
43
		SWTBotButton existing = bot.buttonWithTooltip("Browse existing", index);
44
		existing.click();
45
		bot.waitUntil(Conditions.shellIsActive(dialogName));
46
	}
47

    
48
	/**
49
	 * @return
50
	 * @throws WidgetNotFoundException
51
	 */
52
	public SWTBotView view(String title) throws WidgetNotFoundException {
53
		return getBot().viewByTitle(title);
54
	}
55

    
56
	public void cancel() {
57
		clickButton("Cancel");
58
	}
59

    
60
	public void ok() {
61
		clickButton("OK");
62
	}
63

    
64
	public void finish() {
65
		clickButton("Finish");
66
	}
67

    
68
	public void clickButton(String label) {
69
		getBot().button(label).click();
70
	}
71

    
72
	public String getActiveShellHeadline(){
73
		return getBot().activeShell().getText();
74
	}
75

    
76
	public SWTWorkbenchBot getBot() {
77
		return bot;
78
	}
79

    
80
	public void setBot(SWTWorkbenchBot bot) {
81
		this.bot = bot;
82
	}
83
}
(4-4/4)