tabControls.add(label);
tabControls.add(button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Config params = new Config();
params.setProperty("value",
new Boolean(!bb.getValue()).toString());
bb.filterParams(params, true);
if (bb.getValue()) {
button.setText(I18n.msg( "set_PROPERTY_VALUE", new Object[]{bb.getName(), I18n.msg("false")}));
} else {
button.setText(I18n.msg( "set_PROPERTY_VALUE", new Object[]{bb.getName(), I18n.msg("true")}));
}
}
});
button.setEnabled(!b.isReadOnly());
}
if (b instanceof RangedIntBehaviorLogic) {
final RangedIntBehaviorLogic rb = (RangedIntBehaviorLogic) b;
final JLabel doubleValue = new JLabel(rb.getValueAsString());
final JPanel sliderPanel = new JPanel(new FlowLayout());
final JSlider slider = new JSlider();
slider.setValue(rb.getValue());
slider.setMaximum(rb.getMax());
slider.setMinimum(rb.getMin());
slider.setPaintTicks(true);
slider.setPaintTrack(true);
slider.setPaintLabels(false);
slider.setMajorTickSpacing(rb.getScale() * 10);
slider.setMinorTickSpacing(rb.getStep());
slider.setSnapToTicks(true);
JLabel label = new JLabel(b.getName() + ":");
tabControls.add(label);
sliderPanel.add(slider);
sliderPanel.add(doubleValue);
tabControls.add(sliderPanel);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (!slider.getValueIsAdjusting()) {
Config params = new Config();
params.setProperty("value",
String.valueOf(slider.getValue()));
System.out.println("Slider value: " + slider.getValue());
rb.filterParams(params, true);
}
if (rb.getScale() != 1) {
doubleValue.setText(new Double((double) slider.getValue() / rb.getScale()).toString());
} else {
doubleValue.setText(new Integer(slider.getValue()).toString());
}
}
});
slider.setEnabled(!b.isReadOnly());
}
if (b instanceof ListBehaviorLogic) {
final ListBehaviorLogic lb = (ListBehaviorLogic) b;
final JComboBox comboBox = new JComboBox();
for (String listValue : lb.getValuesList()) {
comboBox.addItem(listValue);
}
comboBox.setEditable(false);
comboBox.setSelectedItem(lb.getSelected());
JLabel label = new JLabel(b.getName() + ":");
// controlPanel.addRow();
// controlPanel.addElement(label, row, 0);
// controlPanel.addElement(comboBox, row, 1);
tabControls.add(label);
tabControls.add(comboBox);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Config params = new Config();
params.setProperty("value", (String) comboBox.getSelectedItem());
lb.filterParams(params, true);
}
});
comboBox.setEnabled(!b.isReadOnly());
}