Example usage for com.vaadin.ui CheckBox setValue

List of usage examples for com.vaadin.ui CheckBox setValue

Introduction

In this page you can find the example usage for com.vaadin.ui CheckBox setValue.

Prototype

@Override
public void setValue(Boolean value) 

Source Link

Document

Sets the value of this CheckBox.

Usage

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.WidgetTestApplication.java

License:Apache License

private void addOverallProgressSwitcher() {
    final CheckBox cb = new CheckBox("Overall progress");
    cb.setValue(true);
    cb.addValueChangeListener(new Property.ValueChangeListener() {
        @Override//  ww  w.j a v a  2s .c  o m
        public void valueChange(Property.ValueChangeEvent event) {
            uploadStateWindow.setOverallProgressVisible(cb.getValue());
        }
    });
    form.addComponent(cb);
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.WidgetTestApplication.java

License:Apache License

private void addUploadAttachedCheckBoxes() {
    for (final MultiFileUpload multiFileUpload : uploads) {
        final CheckBox cb = new CheckBox(multiFileUpload.getCaption() + " attached");
        cb.setValue(true);
        cb.addValueChangeListener(new Property.ValueChangeListener() {
            @Override/*from  w w  w.j  a  va2  s.c om*/
            public void valueChange(Property.ValueChangeEvent event) {
                if (cb.getValue()) {
                    form.addComponent(multiFileUpload, 0);
                } else {
                    form.removeComponent(multiFileUpload);
                }
            }
        });
        form.addComponent(cb);
    }
}

From source file:de.catma.ui.analyzer.MarkupResultPanel.java

License:Open Source License

private void selectAllForKwic(boolean selected) {
    for (Object o : resultTable.getItemIds()) {
        if (resultTable.getParent(o) == null) {
            CheckBox cbVisibleInKwic = (CheckBox) resultTable.getItem(o)
                    .getItemProperty(TreePropertyName.visible).getValue();
            cbVisibleInKwic.setValue(selected);
        }/*from  ww  w. j  ava  2s.  c om*/
    }
}

From source file:de.catma.ui.analyzer.PhraseResultPanel.java

License:Open Source License

private void selectAllForKwic(boolean selected) {
    for (Object o : resultTable.getItemIds()) {
        if (resultTable.getParent(o) == null) {
            CheckBox cbVisibleInKwic = (CheckBox) resultTable.getItem(o)
                    .getItemProperty(TreePropertyName.visibleInKwic).getValue();
            cbVisibleInKwic.setValue(selected);
        }/*from   ww w .  j av  a 2s.  co m*/
    }
}

From source file:de.catma.ui.repository.CorpusContentSelectionDialog.java

License:Open Source License

private CheckBox createCheckBox(final boolean editable) {
    CheckBox cb = new CheckBox();

    cb.setValue(true);
    cb.setImmediate(true);//from ww  w .  j a va2 s.c om

    cb.addValidator(new Validator() {

        public boolean isValid(Object value) {
            return editable || ((Boolean) value);
        }

        public void validate(Object value) throws InvalidValueException {
            if (!editable && !(Boolean) value) {
                throw new InvalidValueException("Source Document has to be included!");
            }
        }
    });

    cb.setInvalidAllowed(false);

    return cb;
}

From source file:de.catma.ui.tagger.MarkupCollectionsPanel.java

License:Open Source License

private CheckBox createCheckbox(final TagsetDefinition tagsetDefinition) {
    CheckBox cbShowTagInstances = new CheckBox();
    cbShowTagInstances.setImmediate(true);
    cbShowTagInstances.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            boolean selected = event.getButton().booleanValue();
            for (TagDefinition tagDefinition : tagsetDefinition) {
                if (tagDefinition.getParentUuid().isEmpty()) {
                    Item tagDefItem = markupCollectionsTree.getItem(tagDefinition);
                    Property visibleProp = tagDefItem.getItemProperty(MarkupCollectionsTreeProperty.visible);
                    CheckBox cb = (CheckBox) visibleProp.getValue();
                    cb.setValue(selected);
                    fireTagDefinitionSelected(tagDefinition, selected);
                }/*from   www.  jav  a2 s.  c  o  m*/
            }
        }
    });
    return cbShowTagInstances;
}

From source file:de.catma.ui.tagger.MarkupCollectionsPanel.java

License:Open Source License

private void handleUserMarkupCollectionSelectionRequest(boolean selected,
        UserMarkupCollection userMarkupCollection) {
    if (selected) {
        for (UserMarkupCollection umc : userMarkupCollectionManager) {
            if (!umc.equals(userMarkupCollection)) {
                Item umcItem = markupCollectionsTree.getItem(umc);
                if (umcItem != null) {
                    Object writeablePropertyValue = umcItem
                            .getItemProperty(MarkupCollectionsTreeProperty.writable).getValue();

                    if ((writeablePropertyValue != null) && (writeablePropertyValue instanceof CheckBox)) {
                        CheckBox cbWritable = (CheckBox) writeablePropertyValue;
                        cbWritable.setValue(false);
                    }//  ww  w . jav  a2s.  c o m
                } else {
                    logger.warning("[" + getApplication().getUser() + "] could not find UserMarkupCollection "
                            + umc + "#" + umc.getId() + " in the MarkupCollectionsPanel.Tree!");
                }
            }
        }
        currentWritableUserMarkupColl = userMarkupCollection;
    } else {
        currentWritableUserMarkupColl = null;

    }
    fireWritableUserMarkupCollectionSelected(userMarkupCollection, selected);
}

From source file:de.catma.ui.tagger.MarkupCollectionsPanel.java

License:Open Source License

private void fireTagDefinitionSelected(TagDefinition tagDefinition, boolean selected) {
    UserMarkupCollection userMarkupCollection = getUserMarkupCollection(tagDefinition);
    List<TagReference> tagReferences = userMarkupCollection.getTagReferences(tagDefinition, true);

    List<TagDefinition> children = userMarkupCollection.getChildren(tagDefinition);
    if (children != null) {
        for (Object childId : children) {
            Object visiblePropertyValue = markupCollectionsTree.getItem(childId)
                    .getItemProperty(MarkupCollectionsTreeProperty.visible).getValue();

            if ((visiblePropertyValue != null) && (visiblePropertyValue instanceof CheckBox)) {
                CheckBox cbVisible = (CheckBox) visiblePropertyValue;
                cbVisible.setValue(selected);
            }//www . j a va 2  s  . c  o  m
        }
    }

    propertyChangeSupport.firePropertyChange(MarkupCollectionPanelEvent.tagDefinitionSelected.name(),
            selected ? null : tagReferences, selected ? tagReferences : null);
}

From source file:de.catma.ui.tagger.PropertyEditDialog.java

License:Open Source License

private void initActions(final SaveCancelListener<Set<Property>> saveCancelListener) {

    newValueInput.addValueChangeListener(new ValueChangeListener() {

        @Override//w  w  w . j  a  v  a 2  s. c om
        public void valueChange(ValueChangeEvent event) {
            btSave.setEnabled(newValueInput.getValue() == null);
            if (newValueInput.getValue() == null) {
                btSave.setDescription("");
            } else {
                btSave.setDescription("Please use either the + button to add your adhoc value<br>"
                        + "or empty the input field first!");
            }

        }
    });

    // we assume that having an input text on blur was intended
    // as a new value that one can set with the btAdd Button
    // therefore we need to set the input string as a value of the ComboBox
    newValueInput.addBlurListener(new BlurListener() {

        @Override
        public void blur(BlurEvent event) {

            String currentInputText = ((FilterExposingComboBox) newValueInput).getCurrentFilterString();

            if ((currentInputText != null) && !currentInputText.trim().isEmpty()) {
                if (!newValueInput.getItemIds().contains(currentInputText)) {
                    newValueInput.addItem(currentInputText);
                }
                newValueInput.setValue(currentInputText);
            } else {
                newValueInput.clear();
            }
        }
    });

    btCancel.addClickListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(PropertyEditDialog.this);
            saveCancelListener.cancelPressed();
        }
    });

    btSave.addClickListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            for (Property p : changedProperties) {
                p.setPropertyValueList(new PropertyValueList(changeBuffer.get(p)));
            }
            UI.getCurrent().removeWindow(PropertyEditDialog.this);
            saveCancelListener.savePressed(changedProperties);
        }
    });

    btAdd.addClickListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            Object selection = propertyTree.getValue();
            final Property property = getProperty(selection);
            final String pValue = (String) newValueInput.getValue();

            if ((pValue == null) || (pValue.isEmpty())) {
                Notification.show("Info", "The value can not be empty!", Type.TRAY_NOTIFICATION);
                return;
            }
            if (property == null) {
                Notification.show("Info", "Please select exactly one Property from the list first!",
                        Type.TRAY_NOTIFICATION);
                return;
            }

            List<String> valueBuffer = getValueListBuffer(property);
            if (valueBuffer.contains(pValue) || property.getPropertyDefinition().getPossibleValueList()
                    .getPropertyValueList().getValues().contains(pValue)) {
                Notification.show("Info", "This value already exists. Please choose another name!",
                        Type.TRAY_NOTIFICATION);
                return;
            }

            propertyValuesBuffer.addValue(pValue);

            String pValueItemId = property.getPropertyDefinition().getUuid() + "_" + pValue;
            CheckBox cb = createCheckBox(property, pValue);
            propertyTree.addItem(new Object[] { null, pValue, cb }, pValueItemId);
            cb.setValue(true);

            propertyTree.setParent(pValueItemId, property);
            propertyTree.setChildrenAllowed(pValueItemId, false);
            newValueInput.setValue(null);
            btSave.setEnabled(true);
        }
    });
}

From source file:de.decidr.ui.view.uibuilder.FieldBuilder.java

License:Apache License

@Override
public Field createControl(String label, String value) {
    CheckBox field = new CheckBox(label);
    field.setValue(value.equals(TBoolean.YES.value()));
    return field;
}