|
1
|
|
package abbot.editor.editors;
|
|
2
|
|
|
|
3
|
|
import java.awt.event.ActionEvent;
|
|
4
|
|
import java.io.File;
|
|
5
|
|
import javax.swing.*;
|
|
6
|
|
import java.util.Collection;
|
|
7
|
|
|
|
8
|
|
import abbot.Log;
|
|
9
|
|
import abbot.i18n.Strings;
|
|
10
|
|
import abbot.script.*;
|
|
11
|
|
import abbot.script.Script;
|
|
12
|
|
import abbot.editor.EditorConstants;
|
|
13
|
|
import abbot.editor.widgets.Mnemonic;
|
|
14
|
|
|
|
15
|
|
|
|
16
|
|
public class ScriptEditor extends SequenceEditor {
|
|
17
|
|
|
|
18
|
|
private Script script;
|
|
19
|
|
|
|
20
|
|
private JTextField path;
|
|
21
|
|
private JCheckBox fork;
|
|
22
|
|
private JTextField vmargs;
|
|
23
|
|
|
|
24
|
0
|
public ScriptEditor(Script script) {
|
|
25
|
0
|
super(script);
|
|
26
|
0
|
this.script = script;
|
|
27
|
|
|
|
28
|
0
|
path = addTextField(Strings.get("FilePath"),
|
|
29
|
|
script.getFilename());
|
|
30
|
|
|
|
31
|
0
|
if (!(script instanceof Fixture)) {
|
|
32
|
0
|
fork = addCheckBox("", script.isForked());
|
|
33
|
0
|
String key = EditorConstants.ACTION_PREFIX
|
|
34
|
|
+ EditorConstants.ACTION_TOGGLE_FORKED;
|
|
35
|
0
|
Mnemonic mnemonic = Mnemonic.getMnemonic(Strings.get(key));
|
|
36
|
0
|
mnemonic.setMnemonic(fork);
|
|
37
|
0
|
addVMArgs();
|
|
38
|
|
}
|
|
39
|
|
}
|
|
40
|
|
|
|
41
|
0
|
private void addVMArgs() {
|
|
42
|
0
|
if (script.isForked()) {
|
|
43
|
0
|
vmargs = addTextField(Strings.get("VMArgs"),
|
|
44
|
|
script.getVMArgs());
|
|
45
|
|
}
|
|
46
|
0
|
else if (vmargs != null) {
|
|
47
|
0
|
while (getComponent(getComponentCount()-1) != fork) {
|
|
48
|
0
|
remove(getComponentCount()-1);
|
|
49
|
|
}
|
|
50
|
0
|
vmargs = null;
|
|
51
|
|
}
|
|
52
|
0
|
revalidate();
|
|
53
|
0
|
repaint();
|
|
54
|
|
}
|
|
55
|
|
|
|
56
|
0
|
public void actionPerformed(ActionEvent ev) {
|
|
57
|
0
|
Object src = ev.getSource();
|
|
58
|
0
|
if (src == path) {
|
|
59
|
0
|
String filename = path.getText().trim();
|
|
60
|
0
|
File file = new File(script.getRelativeTo(), filename);
|
|
61
|
0
|
script.setFile(file);
|
|
62
|
0
|
try {
|
|
63
|
0
|
script.load();
|
|
64
|
|
}
|
|
65
|
|
catch(Exception exc) {
|
|
66
|
0
|
Log.warn(exc);
|
|
67
|
|
}
|
|
68
|
0
|
fireStepChanged();
|
|
69
|
|
}
|
|
70
|
0
|
else if (src == fork) {
|
|
71
|
0
|
script.setForked(!script.isForked());
|
|
72
|
0
|
addVMArgs();
|
|
73
|
0
|
fireStepChanged();
|
|
74
|
|
}
|
|
75
|
0
|
else if (src == vmargs) {
|
|
76
|
0
|
String text = vmargs.getText();
|
|
77
|
0
|
if ("".equals(text))
|
|
78
|
0
|
text = null;
|
|
79
|
0
|
script.setVMArgs(text);
|
|
80
|
0
|
fireStepChanged();
|
|
81
|
|
}
|
|
82
|
|
else {
|
|
83
|
0
|
super.actionPerformed(ev);
|
|
84
|
|
}
|
|
85
|
|
}
|
|
86
|
|
}
|
|
87
|
|
|