Search in sources :

Example 26 with Checkbox

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));
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Test(org.junit.jupiter.api.Test)

Example 27 with Checkbox

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));
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Test(org.junit.jupiter.api.Test)

Example 28 with Checkbox

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;
}
Also used : Div(com.vaadin.flow.component.html.Div) FormLayout(com.vaadin.flow.component.formlayout.FormLayout) ValueChangeEvent(com.vaadin.flow.component.HasValue.ValueChangeEvent) TextArea(com.vaadin.flow.component.textfield.TextArea) FieldTypeDefinition(ch.akros.marketplace.administration.dataservice.entity.FieldTypeDefinition) EFieldTypeDefinition(ch.akros.marketplace.administration.constants.EFieldTypeDefinition) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) TextField(com.vaadin.flow.component.textfield.TextField) NumberField(com.vaadin.flow.component.textfield.NumberField) ResponsiveStep(com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep)

Example 29 with Checkbox

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();
}
Also used : AllowedRoles(org.togetherjava.tjbot.logwatcher.accesscontrol.AllowedRoles) LogUtils(org.togetherjava.tjbot.logwatcher.util.LogUtils) MainLayout(org.togetherjava.tjbot.logwatcher.views.MainLayout) java.util(java.util) CssImport(com.vaadin.flow.component.dependency.CssImport) LogRepository(org.togetherjava.tjbot.logwatcher.logs.LogRepository) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) LocalDateTime(java.time.LocalDateTime) com.vaadin.flow.component(com.vaadin.flow.component) SessionDestroyEvent(com.vaadin.flow.server.SessionDestroyEvent) PageTitle(com.vaadin.flow.router.PageTitle) Route(com.vaadin.flow.router.Route) ZoneOffset(java.time.ZoneOffset) Grid(com.vaadin.flow.component.grid.Grid) PermitAll(javax.annotation.security.PermitAll) StreamWatcher(org.togetherjava.tjbot.logwatcher.watcher.StreamWatcher) LogEventsConstants(org.togetherjava.tjbot.logwatcher.constants.LogEventsConstants) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Logevents(org.togetherjava.tjbot.db.generated.tables.pojos.Logevents) Collectors(java.util.stream.Collectors) GridCrud(org.vaadin.crudui.crud.impl.GridCrud) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) LocalDateTimeRenderer(com.vaadin.flow.data.renderer.LocalDateTimeRenderer) Button(com.vaadin.flow.component.button.Button) EnhancedDialog(com.vaadin.componentfactory.EnhancedDialog) VaadinService(com.vaadin.flow.server.VaadinService) DateTimeFormatter(java.time.format.DateTimeFormatter) Role(org.togetherjava.tjbot.logwatcher.accesscontrol.Role) Button(com.vaadin.flow.component.button.Button) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Grid(com.vaadin.flow.component.grid.Grid) EnhancedDialog(com.vaadin.componentfactory.EnhancedDialog)

Example 30 with Checkbox

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);
    });
}
Also used : ComponentEventListener(com.vaadin.flow.component.ComponentEventListener) ConceptListUpdateRequestedEvent(org.archcnl.ui.common.andtriplets.triplet.events.ConceptListUpdateRequestedEvent) RulesWidgetRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent) TextArea(com.vaadin.flow.component.textfield.TextArea) Registration(com.vaadin.flow.shared.Registration) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) StatementComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.verbcomponents.StatementComponent) SubjectComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.subjectcomponents.SubjectComponent) ComponentEvent(com.vaadin.flow.component.ComponentEvent) RelationListUpdateRequestedEvent(org.archcnl.ui.common.andtriplets.triplet.events.RelationListUpdateRequestedEvent) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Button(com.vaadin.flow.component.button.Button) DetermineStatementComponentEvent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.events.DetermineStatementComponentEvent) SaveRuleButtonPressedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.events.SaveRuleButtonPressedEvent) RulesOrMappingEditorView(org.archcnl.ui.inputview.rulesormappingeditorview.RulesOrMappingEditorView) Optional(java.util.Optional) Button(com.vaadin.flow.component.button.Button) TextArea(com.vaadin.flow.component.textfield.TextArea) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) SubjectComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.subjectcomponents.SubjectComponent) RulesWidgetRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent) StatementComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.verbcomponents.StatementComponent) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

Checkbox (com.vaadin.flow.component.checkbox.Checkbox)68 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)16 Div (com.vaadin.flow.component.html.Div)14 TextField (com.vaadin.flow.component.textfield.TextField)14 Route (com.vaadin.flow.router.Route)14 Button (com.vaadin.flow.component.button.Button)12 Grid (com.vaadin.flow.component.grid.Grid)12 Label (com.vaadin.flow.component.html.Label)12 Collectors (java.util.stream.Collectors)10 Component (com.vaadin.flow.component.Component)8 NativeButton (com.vaadin.flow.component.html.NativeButton)8 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)8 Optional (java.util.Optional)8 Binder (com.vaadin.flow.data.binder.Binder)7 EmailValidator (com.vaadin.flow.data.validator.EmailValidator)7 Set (java.util.Set)7 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)6 PageTitle (io.imunity.furms.ui.components.PageTitle)6 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)6 DateTimeFormatter (java.time.format.DateTimeFormatter)6