blob: b7493c5ea16e77699be1a9df15befab988a6202c (
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
|
/*******************************************************************************
* Copyright (c) 2012 Red Hat Inc..
* 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.List;
import org.eclipse.swtbot.generator.framework.GenerationComplexRule;
import org.eclipse.swtbot.generator.framework.GenerationSimpleRule;
import org.eclipse.swtbot.generator.framework.rules.simple.ComboTextModifyRule;
public class ModifyComboComplexRule extends GenerationComplexRule{
private int textIndex;
@Override
public boolean appliesToPartially(GenerationSimpleRule rule, int i) {
if(i==0 && rule instanceof ComboTextModifyRule){ //first event, so we will store some identifier of text
this.textIndex = ((ComboTextModifyRule)rule).getTextIndex();
}
//check whether ComboTextModifyRule happened on the same text as the first one
//if not then it should be processed by another ModifyTextComplexRule
return rule instanceof ComboTextModifyRule && ((ComboTextModifyRule)rule).getTextIndex() == textIndex;
}
@Override
public boolean appliesTo(List<GenerationSimpleRule> rules) {
for(GenerationSimpleRule r: rules){
if (!(r instanceof ComboTextModifyRule)) {
return false;
} else if (((ComboTextModifyRule)r).getTextIndex() != this.textIndex){
return false;
}
}
return true;
}
@Override
public List<String> getActions() {
return ((ComboTextModifyRule)getInitializationRules().get(getInitializationRules().size()-1)).getActions();
}
@Override
public List<String> getImports() {
// TODO Auto-generated method stub
return null;
}
}
|