/** * 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); }
@Override public void clear() { setValue(Boolean.FALSE); }
public void clearSelectedIds(Table source) { m_selectAll = false; // Uncheck all of the checkboxes for (CheckBox button : m_checkboxes) { button.setValue(false); } m_selectedCheckboxes.clear(); m_notSelectedCheckboxes.clear(); }
public void selectAll(Table source) { m_selectAll = true; m_selectedCheckboxes.clear(); m_notSelectedCheckboxes.clear(); // Check all of the checkboxes for (CheckBox button : m_checkboxes) { button.setValue(true); m_selectedCheckboxes.add((Integer)button.getData()); } }
public void updateTextSelection() { textSelectionCheckBox.setValue(tableImpl.isTextSelectionEnabled()); }
private void updateCheckBox(CheckBox checkBox, Object rowId, boolean enabled) { checkBox.setValue(enabled); Collection<Field<?>> columns = getFieldsForItemId(rowId); columns.remove(checkBox); enableFields(columns, checkBox.getValue()); }
@Override public void selectionValueChanged(SelectionValueChangedEvent selectionValueChangedEvent) { if (selectionValueChangedEvent.getBean() == getData()) { selectedField.setValue(selectionValueChangedEvent.getNewValue()); } }
/** * Creates a new checkbox. */ public CheckBox() { registerRpc(rpc); registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent)); setValue(Boolean.FALSE); }
@Override public void readDesign(Element design, DesignContext designContext) { super.readDesign(design, designContext); if (design.hasAttr("checked")) { this.setValue(DesignAttributeHandler.readAttribute("checked", design.attributes(), Boolean.class), false, true); } }
final CheckBox button = new CheckBox(); button.setData(property.getValue()); button.setValue(isSelected((Integer) property.getValue())); button.addValueChangeListener(new ValueChangeListener() {
@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); } } };
public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Surveillance View configuration the default"); final View view = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().getDefaultView().equals(view.getName())); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().setDefaultView(view.getName()); } m_table.refreshRowCache(); SurveillanceViewProvider.getInstance().save(); ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved", "Default surveillance view"); } }); return checkBox; } }
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; } });
@Test public void checkBoxValueChangePropagatesToCustomField() throws Exception { // GIVEN baseItem = new JcrNewNodeAdapter(baseNode, baseNode.getPrimaryNodeType().getName()); checkBoxField = new CheckBoxFieldFactory(definition, baseItem, uiContext, i18NAuthoringSupport); checkBoxField.setComponentProvider(componentProvider); Field<Boolean> field = checkBoxField.createField(); CheckBox checkBox = (CheckBox) ((CheckBoxField) field).iterator().next(); // WHEN checkBox.setValue(true); // THEN assertEquals(true, checkBox.getValue()); assertEquals(true, field.getValue()); assertEquals(true, baseItem.getItemProperty(definition.getName()).getValue()); }
hasAlarmData.setValue(enable);