Search in sources :

Example 1 with Select

use of com.vaadin.flow.component.select.Select in project karnak by OsiriX-Foundation.

the class MonitorView method buildwadoNodeListSelector.

private void buildwadoNodeListSelector() {
    wadoNodeListSelector = new Select<>();
    wadoNodeListSelector.setEmptySelectionAllowed(false);
    WadoNodeList pacsProdWadoNodeList = Util.readWadoNodes(this.getClass().getResource("/config/pacs-wado-web.csv"), "Public web");
    wadoNodeListSelector.setItems(pacsProdWadoNodeList);
    wadoNodeListSelector.addValueChangeListener((ValueChangeListener<ValueChangeEvent<WadoNodeList>>) event -> logic.wadoNodeListSelected(event.getValue()));
    if (!pacsProdWadoNodeList.isEmpty()) {
        wadoNodeListSelector.setValue(pacsProdWadoNodeList);
    }
}
Also used : DicomNodeList(org.karnak.backend.model.dicom.DicomNodeList) Html(com.vaadin.flow.component.Html) Select(com.vaadin.flow.component.select.Select) Util(org.karnak.frontend.dicom.Util) ValueChangeEvent(com.vaadin.flow.component.HasValue.ValueChangeEvent) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Div(com.vaadin.flow.component.html.Div) AbstractView(org.karnak.frontend.dicom.AbstractView) H6(com.vaadin.flow.component.html.H6) ValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener) WadoNodeList(org.karnak.backend.model.dicom.WadoNodeList) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) Button(com.vaadin.flow.component.button.Button) ValueChangeEvent(com.vaadin.flow.component.HasValue.ValueChangeEvent) WadoNodeList(org.karnak.backend.model.dicom.WadoNodeList)

Example 2 with Select

use of com.vaadin.flow.component.select.Select in project linkki by linkki-framework.

the class GenericAvailableValuesAspectDefinitionTest method testHandleNullItems_NativeSelect_NoNull.

@Test
public void testHandleNullItems_NativeSelect_NoNull() {
    GenericAvailableValuesAspectDefinition hasItemsAvailableValuesAspectDefinition = new GenericAvailableValuesAspectDefinition(AvailableValuesType.DYNAMIC);
    Select<TestEnum> nativeSelect = new Select<>();
    ComponentWrapper componentWrapper = new NoLabelComponentWrapper(nativeSelect, WrapperType.FIELD);
    hasItemsAvailableValuesAspectDefinition.handleNullItems(componentWrapper, new LinkedList<>(Arrays.asList(TestEnum.TWO)));
    assertThat(nativeSelect.isEmptySelectionAllowed(), is(false));
}
Also used : NoLabelComponentWrapper(org.linkki.core.ui.wrapper.NoLabelComponentWrapper) Select(com.vaadin.flow.component.select.Select) TestEnum(org.linkki.core.ui.bind.TestEnum) ComponentWrapper(org.linkki.core.binding.wrapper.ComponentWrapper) NoLabelComponentWrapper(org.linkki.core.ui.wrapper.NoLabelComponentWrapper) Test(org.junit.jupiter.api.Test)

Example 3 with Select

use of com.vaadin.flow.component.select.Select in project komunumo-server by komunumo.

the class PageDialog method createForm.

@Override
public void createForm(@NotNull final FormLayout formLayout, @NotNull final Binder<Page> binder) {
    final var parent = new Select<>(PageParent.values());
    final var pageUrl = new TextField("URL");
    final var title = new TextField("Title");
    final var content = new RichTextEditor();
    parent.setLabel("Parent");
    parent.setRequiredIndicatorVisible(true);
    parent.addValueChangeListener(changeEvent -> pageUrl.setPrefixComponent(new Span("%s/".formatted(URLUtil.createReadableUrl(changeEvent.getValue().getLiteral())))));
    pageUrl.setRequiredIndicatorVisible(true);
    pageUrl.setValueChangeMode(EAGER);
    title.setRequiredIndicatorVisible(true);
    title.setValueChangeMode(EAGER);
    formLayout.add(parent, pageUrl, title, new CustomLabel("Content"), content);
    binder.forField(parent).withValidator(Objects::nonNull, "Please select the parent navigation").bind(Page::getParent, Page::setParent);
    binder.forField(pageUrl).withValidator(new StringLengthValidator("Please enter the URL of the page (max. 255 chars)", 1, 255)).bind(Page::getPageUrl, Page::setPageUrl);
    binder.forField(title).withValidator(new StringLengthValidator("Please enter the title of the page (max. 255 chars)", 1, 255)).bind(Page::getTitle, Page::setTitle);
    binder.forField(content.asHtml()).withValidator(new StringLengthValidator("The content is too long (max. 8'000 chars)", 0, 8_000)).bind(Page::getContent, Page::setContent);
}
Also used : CustomLabel(org.komunumo.ui.component.CustomLabel) StringLengthValidator(com.vaadin.flow.data.validator.StringLengthValidator) Select(com.vaadin.flow.component.select.Select) TextField(com.vaadin.flow.component.textfield.TextField) Page(org.komunumo.data.entity.Page) RichTextEditor(com.vaadin.flow.component.richtexteditor.RichTextEditor) Span(com.vaadin.flow.component.html.Span)

Example 4 with Select

use of com.vaadin.flow.component.select.Select in project komunumo-server by komunumo.

the class MailTemplateDialog method createForm.

@Override
public void createForm(@NotNull final FormLayout formLayout, @NotNull final Binder<MailTemplateRecord> binder) {
    final var id = new Select<>(mailTemplateIds.stream().map(MailTemplateId::name).toArray(String[]::new));
    id.setRequiredIndicatorVisible(true);
    id.setLabel("ID");
    formLayout.add(id);
    final var subject = new TextField("Subject");
    subject.setRequiredIndicatorVisible(true);
    subject.setValueChangeMode(EAGER);
    formLayout.add(subject);
    final var contentText = new TextArea();
    contentText.setRequiredIndicatorVisible(true);
    formLayout.add(new CustomLabel("Content as plain text"), contentText);
    final var contentHTML = new RichTextEditor();
    contentHTML.setRequiredIndicatorVisible(true);
    formLayout.add(new CustomLabel("Content as formatted HTML"), contentHTML);
    binder.forField(id).withValidator(Objects::nonNull, "Please select the ID").bind(MailTemplateRecord::getId, MailTemplateRecord::setId);
    binder.forField(subject).withValidator(new StringLengthValidator("Please enter the subject (max. 255 chars)", 1, 255)).bind(MailTemplateRecord::getSubject, MailTemplateRecord::setSubject);
    binder.forField(contentText).withValidator(new StringLengthValidator("Please enter the content as plain text (max. 8'000 chars)", 1, 8_000)).bind(MailTemplateRecord::getContentText, MailTemplateRecord::setContentText);
    binder.forField(contentHTML.asHtml()).withValidator(new StringLengthValidator("Please enter the content as formattet HTML (max. 8'000 chars)", 1, 8_000)).bind(MailTemplateRecord::getContentHtml, MailTemplateRecord::setContentHtml);
    afterOpen = () -> id.setReadOnly(id.getValue() != null);
}
Also used : CustomLabel(org.komunumo.ui.component.CustomLabel) MailTemplateId(org.komunumo.data.entity.MailTemplateId) TextArea(com.vaadin.flow.component.textfield.TextArea) StringLengthValidator(com.vaadin.flow.data.validator.StringLengthValidator) Select(com.vaadin.flow.component.select.Select) TextField(com.vaadin.flow.component.textfield.TextField) RichTextEditor(com.vaadin.flow.component.richtexteditor.RichTextEditor) MailTemplateRecord(org.komunumo.data.db.tables.records.MailTemplateRecord)

Example 5 with Select

use of com.vaadin.flow.component.select.Select in project Test-Bench-Data by DanielMartensson.

the class UserSettingsView method init.

@PostConstruct
public void init() {
    // Create a text field, password field and a button
    Select<String> selectedUser = new Select<String>(masterName, slaveName);
    selectedUser.setLabel("Select user");
    PasswordField newPassword = new PasswordField("New password");
    Button save = new Button("Save new password");
    // Add a listener to the button
    save.addClickListener(e -> {
        // Check if it's selected
        if (selectedUser.isEmpty())
            return;
        // See if you have right to change the password
        if (userPasswordService.loggedInUserIsMaster()) {
            userPasswordService.changePassword(selectedUser.getValue(), newPassword.getValue());
            Notification.show("Success!", 3000, Position.BOTTOM_START);
        } else {
            Notification.show("You don't have master rights to change password!", 3000, Position.BOTTOM_START);
        }
    });
    add(selectedUser, newPassword, save);
}
Also used : Button(com.vaadin.flow.component.button.Button) Select(com.vaadin.flow.component.select.Select) PasswordField(com.vaadin.flow.component.textfield.PasswordField) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Select (com.vaadin.flow.component.select.Select)10 Div (com.vaadin.flow.component.html.Div)4 Button (com.vaadin.flow.component.button.Button)3 Span (com.vaadin.flow.component.html.Span)3 RichTextEditor (com.vaadin.flow.component.richtexteditor.RichTextEditor)3 TextField (com.vaadin.flow.component.textfield.TextField)3 StringLengthValidator (com.vaadin.flow.data.validator.StringLengthValidator)3 ValueChangeEvent (com.vaadin.flow.component.HasValue.ValueChangeEvent)2 ValueChangeListener (com.vaadin.flow.component.HasValue.ValueChangeListener)2 Html (com.vaadin.flow.component.Html)2 H6 (com.vaadin.flow.component.html.H6)2 Alignment (com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment)2 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)2 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)2 Test (org.junit.jupiter.api.Test)2 DicomNodeList (org.karnak.backend.model.dicom.DicomNodeList)2 WadoNodeList (org.karnak.backend.model.dicom.WadoNodeList)2 CustomLabel (org.komunumo.ui.component.CustomLabel)2 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)1 ComboBox (com.vaadin.flow.component.combobox.ComboBox)1