Search in sources :

Example 1 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project karnak by OsiriX-Foundation.

the class FormDICOM method init.

public void init(Binder<DestinationEntity> binder, ButtonSaveDeleteCancel buttonSaveDeleteCancel) {
    this.binder = binder;
    this.deIdentificationComponent.init(this.binder);
    this.filterBySOPClassesForm.init(this.binder);
    this.destinationCondition.init(this.binder);
    notificationComponent.init(this.binder);
    transferSyntaxComponent.init(this.binder);
    transcodeOnlyUncompressedComponent.init(this.binder);
    setSizeFull();
    aeTitle = new TextField("AETitle");
    description = new TextField("Description");
    hostname = new TextField("Hostname");
    port = new TextField("Port");
    useaetdest = new Checkbox("Use AETitle destination");
    activate = new Checkbox("Enable destination");
    // Define layout
    VerticalLayout destinationLayout = new VerticalLayout(UIS.setWidthFull(new HorizontalLayout(aeTitle, description)), destinationCondition, UIS.setWidthFull(new HorizontalLayout(hostname, port)));
    VerticalLayout transferLayout = new VerticalLayout(new HorizontalLayout(transferSyntaxComponent, transcodeOnlyUncompressedComponent));
    VerticalLayout useaetdestLayout = new VerticalLayout(new HorizontalLayout(useaetdest));
    VerticalLayout activateLayout = new VerticalLayout(activate);
    // Set padding
    destinationLayout.setPadding(true);
    transferLayout.setPadding(true);
    useaetdestLayout.setPadding(true);
    activateLayout.setPadding(true);
    // Add components
    add(UIS.setWidthFull(new BoxShadowComponent(destinationLayout)), UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(transferLayout))), UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(useaetdestLayout))), UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(notificationComponent))), UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(deIdentificationComponent))), UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(filterBySOPClassesForm))), UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(activateLayout))), UIS.setWidthFull(buttonSaveDeleteCancel));
    setElements();
    setBinder();
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) TextField(com.vaadin.flow.component.textfield.TextField) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) BoxShadowComponent(org.karnak.frontend.component.BoxShadowComponent) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 2 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project karnak by OsiriX-Foundation.

the class FormSTOW method init.

public void init(Binder<DestinationEntity> binder, ButtonSaveDeleteCancel buttonSaveDeleteCancel) {
    setSizeFull();
    this.binder = binder;
    this.deIdentificationComponent.init(this.binder);
    this.filterBySOPClassesForm.init(this.binder);
    this.destinationCondition.init(binder);
    notificationComponent.init(binder);
    transferSyntaxComponent.init(this.binder);
    transcodeOnlyUncompressedComponent.init(this.binder);
    this.description = new TextField("Description");
    this.url = new TextField("URL");
    this.urlCredentials = new TextField("URL credentials");
    this.headers = new TextArea("Headers");
    this.switchingAlbumsView = new SwitchingAlbumsView();
    this.activate = new Checkbox("Enable destination");
    // Define layout
    VerticalLayout destinationLayout = new VerticalLayout(UIS.setWidthFull(new HorizontalLayout(description)), destinationCondition, UIS.setWidthFull(new HorizontalLayout(url, urlCredentials)), UIS.setWidthFull(headers));
    VerticalLayout transferLayout = new VerticalLayout(new HorizontalLayout(transferSyntaxComponent, transcodeOnlyUncompressedComponent));
    VerticalLayout activateLayout = new VerticalLayout(activate);
    VerticalLayout switchingLayout = new VerticalLayout(switchingAlbumsView);
    // Set padding
    transferLayout.setPadding(true);
    destinationLayout.setPadding(true);
    activateLayout.setPadding(true);
    activateLayout.setPadding(true);
    // Add components
    add(UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(destinationLayout))));
    add(UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(transferLayout))));
    add(UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(notificationComponent))));
    add(UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(deIdentificationComponent))));
    add(UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(filterBySOPClassesForm))));
    add(UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(switchingLayout))));
    add(UIS.setWidthFull(new BoxShadowComponent(UIS.setWidthFull(activateLayout))));
    add(UIS.setWidthFull(buttonSaveDeleteCancel));
    setElements();
    setBinder();
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) TextField(com.vaadin.flow.component.textfield.TextField) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) BoxShadowComponent(org.karnak.frontend.component.BoxShadowComponent) SwitchingAlbumsView(org.karnak.frontend.kheops.SwitchingAlbumsView) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 3 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project WebComponentKit by itsoulltd.

the class AbstractBeanEditor method getValueField.

protected HasValue getValueField(Property prop) {
    HasValue hasValue = null;
    if (prop.getType() == DataType.BOOL) {
        Checkbox box = new Checkbox();
        box.setLabel(prop.getKey());
        if (prop.getValue() != null)
            box.setValue((Boolean) prop.getValue());
        else
            box.setIndeterminate(true);
        hasValue = box;
    } else if (prop.getType() == DataType.SQLDATE) {
        DatePicker datePicker = new DatePicker();
        datePicker.setValue(LocalDate.now());
        datePicker.setClearButtonVisible(true);
        hasValue = datePicker;
    } else if (prop.getType() == DataType.SQLTIMESTAMP) {
        TimePicker timePicker = new TimePicker();
        timePicker.setValue(LocalTime.now());
        timePicker.setClearButtonVisible(true);
        hasValue = timePicker;
    } else {
        TextField field = new TextField();
        field.setLabel(prop.getKey());
        hasValue = field;
    }
    return hasValue;
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) TextField(com.vaadin.flow.component.textfield.TextField) DatePicker(com.vaadin.flow.component.datepicker.DatePicker)

Example 4 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class GridViewEditorPage method createBufferedEditor.

private void createBufferedEditor() {
    Div message = new Div();
    message.setId("buffered-editor-msg");
    Grid<Person> grid = new Grid<>();
    List<Person> persons = getItems();
    grid.setItems(persons);
    Column<Person> nameColumn = grid.addColumn(Person::getFirstName).setHeader("Name");
    Column<Person> subscriberColumn = grid.addColumn(Person::isSubscriber).setHeader("Subscriber");
    Binder<Person> binder = new Binder<>(Person.class);
    Editor<Person> editor = grid.getEditor();
    editor.setBinder(binder);
    editor.setBuffered(true);
    Div validationStatus = new Div();
    validationStatus.setId("validation");
    TextField field = new TextField();
    binder.forField(field).withValidator(name -> name.startsWith("Person"), "Name should start with Person").withStatusLabel(validationStatus).bind("firstName");
    nameColumn.setEditorComponent(field);
    Checkbox checkbox = new Checkbox();
    binder.bind(checkbox, "subscriber");
    subscriberColumn.setEditorComponent(checkbox);
    Collection<Button> editButtons = Collections.newSetFromMap(new WeakHashMap<>());
    Column<Person> editorColumn = grid.addComponentColumn(person -> {
        Button edit = new Button("Edit");
        edit.addClassName("edit");
        edit.addClickListener(e -> {
            editor.editItem(person);
            field.focus();
        });
        edit.setEnabled(!editor.isOpen());
        editButtons.add(edit);
        return edit;
    });
    editor.addOpenListener(e -> editButtons.stream().forEach(button -> button.setEnabled(!editor.isOpen())));
    editor.addCloseListener(e -> editButtons.stream().forEach(button -> button.setEnabled(!editor.isOpen())));
    Button save = new Button("Save", e -> editor.save());
    save.addClassName("save");
    Button cancel = new Button("Cancel", e -> editor.cancel());
    cancel.addClassName("cancel");
    // Add a keypress listener that listens for an escape key up event.
    // Note! some browsers return key as Escape and some as Esc
    grid.getElement().addEventListener("keyup", event -> editor.cancel()).setFilter("event.key === 'Escape' || event.key === 'Esc'");
    Div buttons = new Div(save, cancel);
    editorColumn.setEditorComponent(buttons);
    editor.addSaveListener(event -> message.setText(event.getItem().getFirstName() + ", " + event.getItem().isSubscriber()));
    grid.setId("buffered-editor");
    addCard("Grid Editor", "Editor in Buffered Mode", message, validationStatus, grid);
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) EmailValidator(com.vaadin.flow.data.validator.EmailValidator) Collection(java.util.Collection) Editor(com.vaadin.flow.component.grid.editor.Editor) Binder(com.vaadin.flow.data.binder.Binder) Div(com.vaadin.flow.component.html.Div) ArrayList(java.util.ArrayList) Route(com.vaadin.flow.router.Route) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) List(java.util.List) Button(com.vaadin.flow.component.button.Button) Column(com.vaadin.flow.component.grid.Grid.Column) Person(com.vaadin.flow.data.bean.Person) Collections(java.util.Collections) TextField(com.vaadin.flow.component.textfield.TextField) WeakHashMap(java.util.WeakHashMap) Grid(com.vaadin.flow.component.grid.Grid) Div(com.vaadin.flow.component.html.Div) Binder(com.vaadin.flow.data.binder.Binder) Button(com.vaadin.flow.component.button.Button) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) TextField(com.vaadin.flow.component.textfield.TextField) Person(com.vaadin.flow.data.bean.Person)

Example 5 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class GridViewEditorPage method createNotBufferedDynamicEditor.

private void createNotBufferedDynamicEditor() {
    Div message = new Div();
    message.setId("not-buffered-dynamic-editor-msg");
    Grid<Person> grid = new Grid<>();
    List<Person> persons = new ArrayList<>();
    persons.addAll(createItems());
    grid.setItems(persons);
    Column<Person> nameColumn = grid.addColumn(Person::getFirstName).setHeader("Name");
    Column<Person> subscriberColumn = grid.addColumn(Person::isSubscriber).setHeader("Subscriber");
    Column<Person> emailColumn = grid.addColumn(Person::getEmail).setHeader("E-mail");
    Binder<Person> binder = new Binder<>(Person.class);
    Editor<Person> editor = grid.getEditor();
    editor.setBinder(binder);
    TextField field = new TextField();
    // Close the editor in case of backward navigation between components
    field.getElement().addEventListener("keydown", event -> grid.getEditor().closeEditor()).setFilter("event.key === 'Tab' && event.shiftKey");
    binder.bind(field, "firstName");
    nameColumn.setEditorComponent(field);
    Checkbox checkbox = new Checkbox();
    binder.bind(checkbox, "subscriber");
    subscriberColumn.setEditorComponent(checkbox);
    // Close the editor in case of forward navigation between components
    checkbox.getElement().addEventListener("keydown", event -> {
        if (!checkbox.getValue()) {
            grid.getEditor().closeEditor();
        }
    }).setFilter("event.key === 'Tab' && !event.shiftKey");
    TextField emailField = new TextField();
    emailColumn.setEditorComponent(item -> {
        if (item.isSubscriber()) {
            binder.bind(emailField, "email");
            return emailField;
        } else {
            return null;
        }
    });
    // Close the editor in case of forward navigation between components
    emailField.getElement().addEventListener("keydown", event -> grid.getEditor().closeEditor()).setFilter("event.key === 'Tab' && !event.shiftKey");
    grid.addItemDoubleClickListener(event -> {
        grid.getEditor().editItem(event.getItem());
        field.focus();
    });
    // Re-validates the editors every time something changes on the Binder.
    // This is needed for the email column to turn into nothing when the
    // checkbox is deselected, for example.
    binder.addValueChangeListener(event -> {
        // Only updates from the client-side should be taken into account
        if (event.isFromClient()) {
            grid.getEditor().refresh();
        }
    });
    grid.addItemClickListener(event -> {
        if (binder.getBean() != null) {
            message.setText(binder.getBean().getFirstName() + ", " + binder.getBean().isSubscriber() + ", " + binder.getBean().getEmail());
        }
    });
    grid.setId("not-buffered-dynamic-editor");
    addCard("Grid Editor", "Dynamic Editor in Not Buffered Mode", message, grid);
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) EmailValidator(com.vaadin.flow.data.validator.EmailValidator) Collection(java.util.Collection) Editor(com.vaadin.flow.component.grid.editor.Editor) Binder(com.vaadin.flow.data.binder.Binder) Div(com.vaadin.flow.component.html.Div) ArrayList(java.util.ArrayList) Route(com.vaadin.flow.router.Route) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) List(java.util.List) Button(com.vaadin.flow.component.button.Button) Column(com.vaadin.flow.component.grid.Grid.Column) Person(com.vaadin.flow.data.bean.Person) Collections(java.util.Collections) TextField(com.vaadin.flow.component.textfield.TextField) WeakHashMap(java.util.WeakHashMap) Grid(com.vaadin.flow.component.grid.Grid) ArrayList(java.util.ArrayList) Div(com.vaadin.flow.component.html.Div) Binder(com.vaadin.flow.data.binder.Binder) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) TextField(com.vaadin.flow.component.textfield.TextField) Person(com.vaadin.flow.data.bean.Person)

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