Lines 19-57
Link Here
|
19 |
package org.apache.jmeter.threads.gui; |
19 |
package org.apache.jmeter.threads.gui; |
20 |
|
20 |
|
21 |
import java.awt.BorderLayout; |
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
|
|
23 |
import java.awt.event.ItemEvent; |
22 |
import java.awt.event.ItemEvent; |
24 |
import java.awt.event.ItemListener; |
23 |
import java.awt.event.ItemListener; |
25 |
import java.util.Collection; |
|
|
26 |
import java.util.Date; |
24 |
import java.util.Date; |
27 |
|
25 |
|
28 |
import javax.swing.BorderFactory; |
26 |
import javax.swing.BorderFactory; |
29 |
import javax.swing.Box; |
|
|
30 |
import javax.swing.ButtonGroup; |
31 |
import javax.swing.JCheckBox; |
27 |
import javax.swing.JCheckBox; |
32 |
import javax.swing.JLabel; |
28 |
import javax.swing.JLabel; |
33 |
import javax.swing.JPanel; |
29 |
import javax.swing.JPanel; |
34 |
import javax.swing.JPopupMenu; |
|
|
35 |
import javax.swing.JRadioButton; |
36 |
import javax.swing.JTextField; |
30 |
import javax.swing.JTextField; |
37 |
|
31 |
|
38 |
import org.apache.jmeter.control.LoopController; |
32 |
import org.apache.jmeter.control.LoopController; |
39 |
import org.apache.jmeter.control.gui.LoopControlPanel; |
33 |
import org.apache.jmeter.control.gui.LoopControlPanel; |
40 |
import org.apache.jmeter.gui.AbstractJMeterGuiComponent; |
|
|
41 |
import org.apache.jmeter.gui.action.ActionNames; |
42 |
import org.apache.jmeter.gui.tree.JMeterTreeNode; |
43 |
import org.apache.jmeter.gui.util.FocusRequester; |
34 |
import org.apache.jmeter.gui.util.FocusRequester; |
44 |
import org.apache.jmeter.gui.util.JDateField; |
35 |
import org.apache.jmeter.gui.util.JDateField; |
45 |
import org.apache.jmeter.gui.util.MenuFactory; |
|
|
46 |
import org.apache.jmeter.gui.util.VerticalPanel; |
36 |
import org.apache.jmeter.gui.util.VerticalPanel; |
47 |
import org.apache.jmeter.testelement.TestElement; |
37 |
import org.apache.jmeter.testelement.TestElement; |
48 |
import org.apache.jmeter.testelement.property.BooleanProperty; |
38 |
import org.apache.jmeter.testelement.property.BooleanProperty; |
49 |
import org.apache.jmeter.testelement.property.LongProperty; |
39 |
import org.apache.jmeter.testelement.property.LongProperty; |
50 |
import org.apache.jmeter.testelement.property.StringProperty; |
|
|
51 |
import org.apache.jmeter.threads.ThreadGroup; |
40 |
import org.apache.jmeter.threads.ThreadGroup; |
52 |
import org.apache.jmeter.util.JMeterUtils; |
41 |
import org.apache.jmeter.util.JMeterUtils; |
53 |
|
42 |
|
54 |
public class ThreadGroupGui extends AbstractJMeterGuiComponent implements ItemListener { |
43 |
public class ThreadGroupGui extends AbstractThreadGroupGui implements ItemListener { |
55 |
private static final long serialVersionUID = 240L; |
44 |
private static final long serialVersionUID = 240L; |
56 |
|
45 |
|
57 |
private LoopControlPanel loopPanel; |
46 |
private LoopControlPanel loopPanel; |
Lines 76-100
Link Here
|
76 |
|
65 |
|
77 |
private JTextField delay; // Relative start-up time |
66 |
private JTextField delay; // Relative start-up time |
78 |
|
67 |
|
79 |
// Sampler error action buttons |
|
|
80 |
private JRadioButton continueBox; |
81 |
|
82 |
private JRadioButton stopThrdBox; |
83 |
|
84 |
private JRadioButton stopTestBox; |
85 |
|
86 |
private JRadioButton stopTestNowBox; |
87 |
|
88 |
public ThreadGroupGui() { |
68 |
public ThreadGroupGui() { |
89 |
super(); |
69 |
super(); |
90 |
init(); |
70 |
init(); |
91 |
initGui(); |
71 |
initGui(); |
92 |
} |
72 |
} |
93 |
|
73 |
|
94 |
public Collection<String> getMenuCategories() { |
|
|
95 |
return null; |
96 |
} |
97 |
|
98 |
public TestElement createTestElement() { |
74 |
public TestElement createTestElement() { |
99 |
ThreadGroup tg = new ThreadGroup(); |
75 |
ThreadGroup tg = new ThreadGroup(); |
100 |
modifyTestElement(tg); |
76 |
modifyTestElement(tg); |
Lines 117-154
Link Here
|
117 |
tg.setProperty(new LongProperty(ThreadGroup.START_TIME, start.getDate().getTime())); |
93 |
tg.setProperty(new LongProperty(ThreadGroup.START_TIME, start.getDate().getTime())); |
118 |
tg.setProperty(new LongProperty(ThreadGroup.END_TIME, end.getDate().getTime())); |
94 |
tg.setProperty(new LongProperty(ThreadGroup.END_TIME, end.getDate().getTime())); |
119 |
tg.setProperty(new BooleanProperty(ThreadGroup.SCHEDULER, scheduler.isSelected())); |
95 |
tg.setProperty(new BooleanProperty(ThreadGroup.SCHEDULER, scheduler.isSelected())); |
120 |
tg.setProperty(new StringProperty(ThreadGroup.ON_SAMPLE_ERROR, onSampleError())); |
|
|
121 |
tg.setProperty(ThreadGroup.DURATION, duration.getText()); |
96 |
tg.setProperty(ThreadGroup.DURATION, duration.getText()); |
122 |
tg.setProperty(ThreadGroup.DELAY, delay.getText()); |
97 |
tg.setProperty(ThreadGroup.DELAY, delay.getText()); |
123 |
} |
98 |
} |
124 |
|
99 |
|
125 |
private void setSampleErrorBoxes(ThreadGroup te) { |
|
|
126 |
if (te.getOnErrorStopTest()) { |
127 |
stopTestBox.setSelected(true); |
128 |
} else if (te.getOnErrorStopTestNow()) { |
129 |
stopTestNowBox.setSelected(true); |
130 |
} else if (te.getOnErrorStopThread()) { |
131 |
stopThrdBox.setSelected(true); |
132 |
} else { |
133 |
continueBox.setSelected(true); |
134 |
} |
135 |
} |
136 |
|
137 |
private String onSampleError() { |
138 |
if (stopTestBox.isSelected()) { |
139 |
return ThreadGroup.ON_SAMPLE_ERROR_STOPTEST; |
140 |
} |
141 |
if (stopTestNowBox.isSelected()) { |
142 |
return ThreadGroup.ON_SAMPLE_ERROR_STOPTEST_NOW; |
143 |
} |
144 |
if (stopThrdBox.isSelected()) { |
145 |
return ThreadGroup.ON_SAMPLE_ERROR_STOPTHREAD; |
146 |
} |
147 |
|
148 |
// Defaults to continue |
149 |
return ThreadGroup.ON_SAMPLE_ERROR_CONTINUE; |
150 |
} |
151 |
|
152 |
@Override |
100 |
@Override |
153 |
public void configure(TestElement tg) { |
101 |
public void configure(TestElement tg) { |
154 |
super.configure(tg); |
102 |
super.configure(tg); |
Lines 174-181
Link Here
|
174 |
} |
122 |
} |
175 |
duration.setText(tg.getPropertyAsString(ThreadGroup.DURATION)); |
123 |
duration.setText(tg.getPropertyAsString(ThreadGroup.DURATION)); |
176 |
delay.setText(tg.getPropertyAsString(ThreadGroup.DELAY)); |
124 |
delay.setText(tg.getPropertyAsString(ThreadGroup.DELAY)); |
177 |
|
|
|
178 |
setSampleErrorBoxes((ThreadGroup) tg); |
179 |
} |
125 |
} |
180 |
|
126 |
|
181 |
public void itemStateChanged(ItemEvent ie) { |
127 |
public void itemStateChanged(ItemEvent ie) { |
Lines 188-212
Link Here
|
188 |
} |
134 |
} |
189 |
} |
135 |
} |
190 |
|
136 |
|
191 |
public JPopupMenu createPopupMenu() { |
|
|
192 |
JPopupMenu pop = new JPopupMenu(); |
193 |
pop.add(MenuFactory.makeMenus(new String[] { |
194 |
MenuFactory.CONTROLLERS, |
195 |
MenuFactory.CONFIG_ELEMENTS, |
196 |
MenuFactory.TIMERS, |
197 |
MenuFactory.PRE_PROCESSORS, |
198 |
MenuFactory.SAMPLERS, |
199 |
MenuFactory.POST_PROCESSORS, |
200 |
MenuFactory.ASSERTIONS, |
201 |
MenuFactory.LISTENERS, |
202 |
}, |
203 |
JMeterUtils.getResString("add"), // $NON-NLS-1$ |
204 |
ActionNames.ADD)); |
205 |
MenuFactory.addEditMenu(pop, true); |
206 |
MenuFactory.addFileMenu(pop); |
207 |
return pop; |
208 |
} |
209 |
|
210 |
private JPanel createControllerPanel() { |
137 |
private JPanel createControllerPanel() { |
211 |
loopPanel = new LoopControlPanel(false); |
138 |
loopPanel = new LoopControlPanel(false); |
212 |
LoopController looper = (LoopController) loopPanel.createTestElement(); |
139 |
LoopController looper = (LoopController) loopPanel.createTestElement(); |
Lines 276-306
Link Here
|
276 |
return "threadgroup"; // $NON-NLS-1$ |
203 |
return "threadgroup"; // $NON-NLS-1$ |
277 |
} |
204 |
} |
278 |
|
205 |
|
279 |
private JPanel createOnErrorPanel() { |
|
|
280 |
JPanel panel = new JPanel(); |
281 |
panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("sampler_on_error_action"))); // $NON-NLS-1$ |
282 |
|
283 |
ButtonGroup group = new ButtonGroup(); |
284 |
|
285 |
continueBox = new JRadioButton(JMeterUtils.getResString("sampler_on_error_continue")); // $NON-NLS-1$ |
286 |
group.add(continueBox); |
287 |
panel.add(continueBox); |
288 |
|
289 |
stopThrdBox = new JRadioButton(JMeterUtils.getResString("sampler_on_error_stop_thread")); // $NON-NLS-1$ |
290 |
group.add(stopThrdBox); |
291 |
panel.add(stopThrdBox); |
292 |
|
293 |
stopTestBox = new JRadioButton(JMeterUtils.getResString("sampler_on_error_stop_test")); // $NON-NLS-1$ |
294 |
group.add(stopTestBox); |
295 |
panel.add(stopTestBox); |
296 |
|
297 |
stopTestNowBox = new JRadioButton(JMeterUtils.getResString("sampler_on_error_stop_test_now")); // $NON-NLS-1$ |
298 |
group.add(stopTestNowBox); |
299 |
panel.add(stopTestNowBox); |
300 |
|
301 |
return panel; |
302 |
} |
303 |
|
304 |
@Override |
206 |
@Override |
305 |
public void clearGui(){ |
207 |
public void clearGui(){ |
306 |
super.clearGui(); |
208 |
super.clearGui(); |
Lines 311-317
Link Here
|
311 |
private void initGui(){ |
213 |
private void initGui(){ |
312 |
threadInput.setText("1"); // $NON-NLS-1$ |
214 |
threadInput.setText("1"); // $NON-NLS-1$ |
313 |
rampInput.setText("1"); // $NON-NLS-1$ |
215 |
rampInput.setText("1"); // $NON-NLS-1$ |
314 |
continueBox.setSelected(true); |
|
|
315 |
loopPanel.clearGui(); |
216 |
loopPanel.clearGui(); |
316 |
scheduler.setSelected(false); |
217 |
scheduler.setSelected(false); |
317 |
Date today = new Date(); |
218 |
Date today = new Date(); |
Lines 321-337
Link Here
|
321 |
duration.setText(""); // $NON-NLS-1$ |
222 |
duration.setText(""); // $NON-NLS-1$ |
322 |
} |
223 |
} |
323 |
|
224 |
|
324 |
private void init() { |
225 |
@Override |
325 |
setLayout(new BorderLayout(0, 5)); |
226 |
protected void init() { |
326 |
setBorder(makeBorder()); |
227 |
super.init(); |
327 |
|
228 |
|
328 |
Box box = Box.createVerticalBox(); |
|
|
329 |
box.add(makeTitlePanel()); |
330 |
box.add(createOnErrorPanel()); |
331 |
add(box, BorderLayout.NORTH); |
332 |
|
333 |
// JPanel mainPanel = new JPanel(new BorderLayout()); |
334 |
|
335 |
// THREAD PROPERTIES |
229 |
// THREAD PROPERTIES |
336 |
VerticalPanel threadPropsPanel = new VerticalPanel(); |
230 |
VerticalPanel threadPropsPanel = new VerticalPanel(); |
337 |
threadPropsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), |
231 |
threadPropsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), |
Lines 385-397
Link Here
|
385 |
intgrationPanel.add(mainPanel); |
279 |
intgrationPanel.add(mainPanel); |
386 |
add(intgrationPanel, BorderLayout.CENTER); |
280 |
add(intgrationPanel, BorderLayout.CENTER); |
387 |
} |
281 |
} |
388 |
|
|
|
389 |
public void setNode(JMeterTreeNode node) { |
390 |
getNamePanel().setNode(node); |
391 |
} |
392 |
|
393 |
@Override |
394 |
public Dimension getPreferredSize() { |
395 |
return getMinimumSize(); |
396 |
} |
397 |
} |
282 |
} |