use of com.vaadin.flow.component.checkbox.Checkbox in project linkki by linkki-framework.
the class UICheckBoxIntegrationTest method testNullInputIfRequired.
@Test
@Override
void testNullInputIfRequired() {
Checkbox checkBox = getDynamicComponent();
getDefaultPmo().setRequired(true);
modelChanged();
assertThat(checkBox.isRequiredIndicatorVisible(), is(true));
TestUiUtil.setUserOriginatedValue(checkBox, true);
assertThat(getDefaultModelObject().getValue(), is(true));
TestUiUtil.setUserOriginatedValue(checkBox, false);
assertThat(getDefaultModelObject().getValue(), is(false));
}
use of com.vaadin.flow.component.checkbox.Checkbox in project linkki by linkki-framework.
the class UICheckBoxIntegrationTest method testSetValueWithObjectBooleanInModelObject.
@Test
void testSetValueWithObjectBooleanInModelObject() {
TestModelObjectWithObjectBoolean modelObject = new TestModelObjectWithObjectBoolean();
Checkbox checkBox = createFirstComponent(modelObject);
assertThat(modelObject.getValue(), is(nullValue()));
TestUiUtil.setUserOriginatedValue(checkBox, Boolean.TRUE);
assertThat(modelObject.getValue(), is(true));
TestUiUtil.setUserOriginatedValue(checkBox, Boolean.FALSE);
assertThat(modelObject.getValue(), is(false));
TestUiUtil.setUserOriginatedValue(checkBox, true);
assertThat(modelObject.getValue(), is(true));
TestUiUtil.setUserOriginatedValue(checkBox, false);
assertThat(modelObject.getValue(), is(false));
modelObject.setValue(Boolean.TRUE);
getBindingContext().modelChanged();
assertThat(checkBox.getValue(), is(true));
modelObject.setValue(Boolean.FALSE);
getBindingContext().modelChanged();
assertThat(checkBox.getValue(), is(false));
modelObject.setValue(null);
getBindingContext().modelChanged();
assertThat(checkBox.getValue(), is(false));
TestUiUtil.setUserOriginatedValue(checkBox, true);
modelObject.setValue(null);
getBindingContext().modelChanged();
assertThat(checkBox.getValue(), is(false));
}
use of com.vaadin.flow.component.checkbox.Checkbox in project Akros-Marketplace by AkrosAG.
the class FieldTypeView method createEditorFormComponents.
private Component createEditorFormComponents() {
Div div = new Div();
FormLayout formLayout = new FormLayout();
formLayout.setResponsiveSteps(new ResponsiveStep("0", 1, LabelsPosition.TOP));
ValueChangeListener<ValueChangeEvent<?>> listener = getUpdateSaveButtonValueChangeListener();
txtFieldTypeId = new NumberField("fieldTypeId (Column: FIELD_TYPE_ID)");
txtFieldTypeId.setReadOnly(true);
txtDescription = new TextArea("description (Column: DESCRIPTION)");
txtDescription.setClassName("full-width");
txtDescription.setRequired(true);
txtDescription.setHeightFull();
txtDescription.setValueChangeMode(ValueChangeMode.LAZY);
txtDescription.addValueChangeListener(listener);
txtDescription.setId(TEXT_CONTROL_DESCRIPTION);
txtShortDescription = new TextField("shortDescription (Column: SHORT_DESCRIPTON)");
txtShortDescription.setClassName("full-width");
txtShortDescription.setRequired(true);
txtShortDescription.setValueChangeMode(ValueChangeMode.LAZY);
txtShortDescription.addValueChangeListener(listener);
comboFieldTypeDefinitions = new ComboBox<FieldTypeDefinition>("fieldTypeDefinitionId (Column: FIELD_TYPE_DEFINITION_ID)", fieldTypeDefinitionService.list());
comboFieldTypeDefinitions.setItemLabelGenerator(e -> String.format("%d: %s", e.getFieldTypeDefinitionId(), e.getDescription()));
comboFieldTypeDefinitions.setRequired(true);
comboFieldTypeDefinitions.addValueChangeListener(listener);
txtMinValue = new NumberField("minValue (Column: MIN_VALUE)");
txtMinValue.setClassName("full-width");
txtMinValue.setRequiredIndicatorVisible(true);
txtMinValue.setValueChangeMode(ValueChangeMode.LAZY);
txtMinValue.addValueChangeListener(listener);
txtMaxValue = new NumberField("maxValue (Column: MAX_VALUE)");
txtMaxValue.setClassName("full-width");
txtMaxValue.setRequiredIndicatorVisible(true);
txtMaxValue.setValueChangeMode(ValueChangeMode.LAZY);
txtMaxValue.addValueChangeListener(listener);
chkOffer = new Checkbox("offer (Column: OFFER)");
chkOffer.setClassName("full-width");
chkSearch = new Checkbox("search (Column: SEARCH)");
chkSearch.setClassName("full-width");
chkRequired = new Checkbox("required (Column: REQUIRED)");
chkRequired.setClassName("full-width");
chkSearchable = new Checkbox("searchable (Column: SEARCHABLE)");
chkSearchable.setClassName("full-width");
txtSortNumber = new NumberField("sortNumber (Column: SORT_NUMBER)");
txtSortNumber.setClassName("full-width");
txtSortNumber.setRequiredIndicatorVisible(true);
txtSortNumber.setValueChangeMode(ValueChangeMode.LAZY);
txtSortNumber.addValueChangeListener(listener);
formLayout.add(txtFieldTypeId, txtDescription, txtShortDescription, comboFieldTypeDefinitions, txtMinValue, txtMaxValue, chkOffer, chkSearch, chkRequired, chkSearchable, txtSortNumber);
div.add(formLayout);
return div;
}
use of com.vaadin.flow.component.checkbox.Checkbox in project TJ-Bot by Together-Java.
the class StreamedView method onChangeColumns.
private void onChangeColumns(ClickEvent<Button> event) {
final EnhancedDialog dialog = new EnhancedDialog();
dialog.setHeader("Choose the Columns you want to see.");
final Set<String> columns = this.grid.getGrid().getColumns().stream().map(Grid.Column::getKey).collect(Collectors.toSet());
final List<Checkbox> checkBoxes = new ArrayList<>();
final List<String> fields = Arrays.asList(LogEventsConstants.FIELD_INSTANT, LogEventsConstants.FIELD_THREAD, LogEventsConstants.FIELD_LOGGER_LEVEL, LogEventsConstants.FIELD_LOGGER_NAME, LogEventsConstants.FIELD_MESSAGE, LogEventsConstants.FIELD_LOGGER_FQCN);
for (String field : fields) {
Checkbox c = new Checkbox(field);
c.setValue(columns.contains(c.getLabel()));
checkBoxes.add(c);
}
dialog.setContent(checkBoxes.toArray(Component[]::new));
dialog.setFooter(new Button("Accept", evt -> this.onOkay(dialog, checkBoxes)), new Button("Cancel", e -> dialog.close()));
dialog.open();
}
use of com.vaadin.flow.component.checkbox.Checkbox in project ArchCNL by Mari-Wie.
the class RuleCreatorView method initializeLayout.
private void initializeLayout(Optional<String> ruleString) {
subject = new SubjectComponent();
subject.addListener(RelationListUpdateRequestedEvent.class, this::fireEvent);
subject.addListener(ConceptListUpdateRequestedEvent.class, this::fireEvent);
subject.addListener(DetermineStatementComponentEvent.class, event -> verb.determineVerbComponent(event.getSource().getFirstModifierValue()));
verb = new StatementComponent();
verb.addListener(RelationListUpdateRequestedEvent.class, this::fireEvent);
verb.addListener(ConceptListUpdateRequestedEvent.class, this::fireEvent);
buttonsLayout = new HorizontalLayout();
saveButton = new Button("Save Rule", e -> saveRule());
cancelButton = new Button("Cancel", click -> fireEvent(new RulesWidgetRequestedEvent(this, true)));
expertmodeCheckbox = new Checkbox("Activate Expertmode");
expertmodeCheckbox.addClickListener(e -> activateExpertMode(expertmodeCheckbox.getValue()));
buttonsLayout.setVerticalComponentAlignment(Alignment.CENTER, expertmodeCheckbox);
buttonsLayout.setPadding(true);
buttonsLayout.add(saveButton, cancelButton, expertmodeCheckbox);
archRuleTextArea = new TextArea("Create new architecture rule");
archRuleTextArea.setWidthFull();
add(subject, verb, buttonsLayout);
ruleString.ifPresent(rule -> {
archRuleTextArea.setValue(rule);
expertmodeCheckbox.setValue(true);
activateExpertMode(true);
});
}
Aggregations