public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Ops Board configuration the default"); final Wallboard wallboard = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(wallboard.isDefault()); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { for (Wallboard wallboard1 : m_beanItemContainer.getItemIds()) { wallboard1.setDefault(false); } } wallboard.setDefault(newValue); m_table.refreshRowCache(); WallboardProvider.getInstance().save(); } }); return checkBox; } });
@Override public void setChecked(boolean checked, MouseEventDetails mouseEventDetails) { if (isReadOnly()) { return; } /* * Client side updates the state before sending the event so we need * to make sure the cached state is updated to match the client. If * we do not do this, a reverting setValue() call in a listener will * not cause the new state to be sent to the client. * * See #11028, #10030. */ getUI().getConnectorTracker().getDiffState(CheckBox.this) .put("checked", checked); final Boolean oldValue = getValue(); final Boolean newValue = checked; if (!newValue.equals(oldValue)) { // The event is only sent if the switch state is changed setValue(newValue); } } };
/** * Creates a new checkbox with a set caption. * * @param caption * the Checkbox caption. */ public CheckBox(String caption) { this(); setCaption(caption); }
/** * Creates a new checkbox. */ public CheckBox() { registerRpc(rpc); registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent)); setValue(Boolean.FALSE); }
protected <T extends Field> T createBooleanField(Class<T> fieldType) { if (fieldType.isAssignableFrom(CheckBox.class)) { CheckBox cb = new CheckBox(null); cb.setImmediate(true); return (T) cb; } else if (AbstractTextField.class.isAssignableFrom(fieldType)) { return (T) createAbstractTextField( (Class<? extends AbstractTextField>) fieldType); } return null; }
m_maximizeWidth = new CheckBox(); m_maximizeWidth.setCaption("Maximize width"); m_maximizeWidth.setDescription("Maximize width"); m_maximizeHeight = new CheckBox(); m_maximizeHeight.setCaption("Maximize height"); m_maximizeHeight.setDescription("Maximize height"); boolean maximizeWidth = ("true".equals(maximizeWidthString) || "yes".equals(maximizeWidthString) || "1".equals(maximizeWidthString)); m_maximizeWidth.setValue(maximizeWidth); m_maximizeHeight.setValue(maximizeHeight);
final CheckBox button = new CheckBox(); button.setData(property.getValue()); button.setValue(isSelected((Integer) property.getValue())); button.addValueChangeListener(new ValueChangeListener() {
CheckBox authenticateField = new CheckBox(); authenticateField.setCaption("Authentication"); authenticateField.setId("authenticate"); authenticateField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { authenticateField.setDescription("Connection requires authentication");
/** * Creates a new checkbox with a caption and a set initial state. * * @param caption * the caption of the checkbox * @param initialState * the initial state of the checkbox */ public CheckBox(String caption, boolean initialState) { this(caption); setValue(initialState); }
selectedField = new CheckBox(); selectedField.setCaption("selected"); selectedField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) {
if (hasAlarmData.getValue() != enable) { hasAlarmData.setValue(enable); alarmDataAutoClean.setVisible(enable); alarmDataReductionKey.setVisible(enable); alarmDataClearKey.setVisible(enable);
setComponentAlignment(button.getComponent(), Alignment.MIDDLE_CENTER); textSelectionCheckBox = new CheckBox(); textSelectionCheckBox.setInvalidCommitted(true); textSelectionCheckBox.setCaption(messages.getMainMessage("PresentationsPopup.textSelection")); addComponent(textSelectionCheckBox); textSelectionCheckBox.setPropertyDataSource(new AbstractProperty() { @Override public Object getValue() {
return new CheckBox();
@Test public void setReadOnlyDefaultValue() throws Exception { // GIVEN baseItem = new JcrNewNodeAdapter(baseNode, baseNode.getPrimaryNodeType().getName()); checkBoxField = new CheckBoxFieldFactory(definition, baseItem, uiContext, i18NAuthoringSupport); checkBoxField.setComponentProvider(componentProvider); definition.setDefaultValue("true"); definition.setReadOnly(true); // WHEN Field<Boolean> field = checkBoxField.createField(); // THEN assertEquals(true, field.getValue()); assertTrue(field.isReadOnly()); CheckBox checkBox = (CheckBox) ((CheckBoxField) field).iterator().next(); assertEquals(true, checkBox.getValue()); assertTrue(checkBox.isReadOnly()); }
eventLayout.addComponent(logMsgContent); hasAlarmData.setWidth("100%"); hasAlarmData.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { eventLayout.addComponent(alarmDataAlarmType); alarmDataAutoClean.setWidth("100%"); alarmDataAutoClean.setVisible(false); eventLayout.addComponent(alarmDataAutoClean);
m_filterByNameCheckBox = new CheckBox(); m_filterByNameCheckBox.setCaption("Enable"); m_filterByNameCheckBox.setDescription("Filter by Business Service name"); m_filterByNameCheckBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { m_filterByNameCheckBox.setValue(filterByName); m_filterByAttributeCheckBox = new CheckBox(); m_filterByAttributeCheckBox.setCaption("Enable"); m_filterByAttributeCheckBox.setDescription("Filter by Business Service attribute"); m_filterByAttributeCheckBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { m_filterByAttributeCheckBox.setValue(filterByAttribute); m_filterBySeverityCheckBox = new CheckBox(); m_filterBySeverityCheckBox.setCaption("Enable"); m_filterBySeverityCheckBox.setDescription("Filter by Business Service severity"); m_filterBySeverityCheckBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { m_filterBySeverityCheckBox.setValue(filterBySeverity);
@Override public void clear() { setValue(Boolean.FALSE); }