forked from srizzo/code2code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomizeGenerationDialog.java
More file actions
78 lines (66 loc) · 2.53 KB
/
CustomizeGenerationDialog.java
File metadata and controls
78 lines (66 loc) · 2.53 KB
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
package pageobjects;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.ControlFinder;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import utils.Driver;
public class CustomizeGenerationDialog {
public static void uncheckFile(String file) throws Exception {
Driver.bot().checkBox(file).deselect();
}
@SuppressWarnings("unchecked")
public static void setDestination(String template, String destination) throws Exception {
Widget templateButtonWidget = new ControlFinder().findControls(
WidgetMatcherFactory.allOf(
WidgetMatcherFactory.widgetOfType(Button.class),
WidgetMatcherFactory.withText(template)
))
.get(0);
SWTBotText destinationText = new SWTBotText((Text) SWTUtils.nextWidget(templateButtonWidget));
destinationText.setText(destination);
}
@SuppressWarnings("unchecked")
public static void openPreview(String template) throws Exception {
Widget templateButtonWidget = new ControlFinder().findControls(
WidgetMatcherFactory.allOf(
WidgetMatcherFactory.widgetOfType(Button.class),
WidgetMatcherFactory.withText(template)
))
.get(0);
Widget destinationWidget = SWTUtils.nextWidget(templateButtonWidget);
SWTBotButton previewButton = new SWTBotButton((Button) SWTUtils.nextWidget(destinationWidget));
previewButton.click();
}
public static boolean isVisible() {
try {
Driver.bot().label("Customize Generation");
} catch (WidgetNotFoundException e) {
return false;
}
return true;
}
@SuppressWarnings("unchecked")
public static boolean isListed(String template) {
return new ControlFinder().findControls(
WidgetMatcherFactory.allOf(
WidgetMatcherFactory.widgetOfType(Button.class),
WidgetMatcherFactory.withText(template)
)).size() == 1;
}
@SuppressWarnings("unchecked")
public static String getDestination(String template) {
Widget templateButtonWidget = new ControlFinder().findControls(
WidgetMatcherFactory.allOf(
WidgetMatcherFactory.widgetOfType(Button.class),
WidgetMatcherFactory.withText(template)
))
.get(0);
SWTBotText destinationText = new SWTBotText((Text) SWTUtils.nextWidget(templateButtonWidget));
return destinationText.getText();
}
}