@Override public void updateUI() { super.updateUI(); boolean newValue; if (getParameter().getValue() instanceof Boolean) { newValue = (Boolean) getParameter().getValue(); } else { newValue = Boolean.valueOf(getParameter().getValueAsText()); } if (getCheckBox().isSelected() != newValue) { getCheckBox().setSelected(newValue); } if (getCheckBox().isEnabled() != isEnabled()) { getCheckBox().setEnabled(isEnabled()); } }
private void updateParameter() { boolean newValue = getCheckBox().isSelected(); getParameter().setValue(newValue, null); } }
public void testBooleanEditor() { final ParamProperties properties = new ParamProperties(Boolean.class); properties.setLabel(LABEL_NAME); properties.setPhysicalUnit(UNIT_NAME); properties.setDefaultValue(Boolean.TRUE); final Parameter parameter = new Parameter(PARAM_NAME, properties); ParamEditor editor = parameter.getEditor(); assertTrue(editor instanceof BooleanEditor); final BooleanEditor booleanEditor = (BooleanEditor) editor; final JComponent editorComponent = booleanEditor.getEditorComponent(); assertEquals(JCheckBox.class.getName(), editorComponent.getClass().getName()); assertEquals("theParamName.Editor", editorComponent.getName()); assertNull(booleanEditor.getLabelComponent()); assertNull(booleanEditor.getPhysUnitLabelComponent()); }
@Override protected void initUI() { // do not call super.initUI() since we don't want any labels to be created _checkBox = new JCheckBox(); nameEditorComponent(_checkBox); if (getParameter().getProperties().getLabel() != null) { _checkBox.setText(getParameter().getProperties().getLabel()); } if (getParameter().getProperties().getDescription() != null) { _checkBox.setToolTipText(getParameter().getProperties().getDescription()); } _checkBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { updateParameter(); } }); }
/** * Gets the UI component used to edit the parameter's value. */ public JComponent getEditorComponent() { return getCheckBox(); }
editor = new BooleanEditor(parameter); } else if (parameter.isTypeOf(Color.class)) { editor = new ColorEditor(parameter);