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();
}
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();
}
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;
}
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);
}
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);
}
Aggregations