blob: 8b9e279754672b7847908638c4b44b1eaa6addd4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*******************************************************************************
* Copyright (c) 2012-2015 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Rastislav Wagner (Red Hat) - initial API and implementation
*******************************************************************************/
package org.eclipse.swtbot.generator.framework.rules.complex;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swtbot.generator.framework.GenerationComplexRule;
import org.eclipse.swtbot.generator.framework.GenerationSimpleRule;
import org.eclipse.swtbot.generator.framework.rules.simple.ContextMenuRule;
import org.eclipse.swtbot.generator.framework.rules.simple.ToolBarDropDownRule;
public class ToolBarMenuComplexRule extends GenerationComplexRule{
private List<GenerationSimpleRule> rules;
public ToolBarMenuComplexRule(){
rules = new ArrayList<GenerationSimpleRule>();
ToolBarDropDownRule toolBar = new ToolBarDropDownRule();
ContextMenuRule menu = new ContextMenuRule();
rules.add(toolBar);
rules.add(menu);
}
@Override
public boolean appliesToPartially(GenerationSimpleRule rule, int i) {
if(rules.size() > i){
return rules.get(i).getClass().equals(rule.getClass());
}
return false;
}
@Override
public boolean appliesTo(List<GenerationSimpleRule> rules) {
if(rules.size() != this.rules.size()){
return false;
}
for(int i=0;i<rules.size();i++){
if(!this.rules.get(i).getClass().equals(rules.get(i).getClass())){
return false;
}
}
return true;
}
@Override
public List<String> getActions() {
List<String> actions = new ArrayList<String>();
StringBuilder builder = new StringBuilder();
String toolTip = ((ToolBarDropDownRule)getInitializationRules().get(0)).getToolTipText();
builder.append("bot.toolbarDropDownButtonWithTooltip(\""+toolTip+"\")");
ContextMenuRule cmr = ((ContextMenuRule)getInitializationRules().get(1));
for(String s: cmr.getPath()){
builder.append(".menuItem(\""+s+"\")");
}
builder.append(".menuItem(\""+cmr.getMenu()+"\")");
builder.append(".click()");
actions.add(builder.toString());
return actions;
}
@Override
public List<String> getImports() {
// TODO Auto-generated method stub
return null;
}
}
|