setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
setBorder(makeBorder());
add(makeTitlePanel());
// Target
HorizontalPanel targetPanel = new HorizontalPanel();
targetPanel.add(new JLabel(targetLabel));
DefaultComboBoxModel targetModel = new DefaultComboBoxModel();
targetModel.addElement(threadTarget);
targetModel.addElement(testTarget);
targetBox = new JComboBox(targetModel);
targetBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((String) targetBox.getSelectedItem()).equals(threadTarget)) {
target = TestAction.THREAD;
} else {
target = TestAction.TEST;
}
}
});
targetPanel.add(targetBox);
add(targetPanel);
// Action
HorizontalPanel actionPanel = new HorizontalPanel();
ButtonGroup actionButtons = new ButtonGroup();
pauseButton = new JRadioButton(pauseAction, true);
pauseButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (pauseButton.isSelected()) {
action = TestAction.PAUSE;
durationField.setEnabled(true);
targetBox.setEnabled(true);
}
}
});
stopButton = new JRadioButton(stopAction, false);
stopButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (stopButton.isSelected()) {
action = TestAction.STOP;
durationField.setEnabled(false);
targetBox.setEnabled(true);
}
}
});
stopNowButton = new JRadioButton(stopNowAction, false);
stopNowButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (stopNowButton.isSelected()) {
action = TestAction.STOP_NOW;
durationField.setEnabled(false);
targetBox.setEnabled(true);
}
}
});
restartNextLoopButton = new JRadioButton(restartNextLoopAction, false);
restartNextLoopButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (restartNextLoopButton.isSelected()) {
action = TestAction.RESTART_NEXT_LOOP;
durationField.setEnabled(false);
targetBox.setSelectedIndex(TestAction.THREAD);
targetBox.setEnabled(false);
}
}
});
actionButtons.add(pauseButton);
actionButtons.add(stopButton);
actionButtons.add(stopNowButton);
actionButtons.add(restartNextLoopButton);
actionPanel.add(new JLabel(actionLabel));
actionPanel.add(pauseButton);
actionPanel.add(stopButton);
actionPanel.add(stopNowButton);
actionPanel.add(restartNextLoopButton);
add(actionPanel);
// Duration
HorizontalPanel durationPanel = new HorizontalPanel();
durationField = new JTextField(15);
durationField.setText(""); // $NON-NLS-1$
durationPanel.add(new JLabel(durationLabel));
durationPanel.add(durationField);
add(durationPanel);
}