Java Code Examples for com.vaadin.flow.component.formlayout.FormLayout#setMaxWidth()
The following examples show how to use
com.vaadin.flow.component.formlayout.FormLayout#setMaxWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfirmationDialog.java From radman with MIT License | 5 votes |
public ConfirmationDialog(String maxWidth) { contentLayout.setMargin(false); contentLayout.setPadding(false); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidthFull(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.add(cancelBtn); controlsLayout.add(confirmBtn); FormLayout layout = new FormLayout(); layout.setMaxWidth(maxWidth == null ? "500px" : maxWidth); layout.add(title); layout.add(contentLayout); layout.add(new Hr()); layout.add(controlsLayout); add(layout); cancelBtn.addClickListener(event -> { if (Objects.nonNull(cancelListener)) { cancelListener.onCancel(this); } else { setOpened(false); } }); confirmBtn.addClickListener(event -> { if (Objects.nonNull(confirmListener)) { confirmListener.onConfirm(); } }); }
Example 2
Source File: SystemUsersView.java From radman with MIT License | 4 votes |
SystemUserEditDialog(UpdateListener<SystemUserDto> updateListener) { FormLayout formLayout = new FormLayout(); formLayout.add(new H3("Edit system user")); ComboBox<RoleDto> role = new ComboBox<>("Role", RoleDto.values()); role.setPreventInvalidInput(true); role.setWidthFull(); binder = new Binder<>(SystemUserDto.class); binder.forField(role) .asRequired("Role is required") .withValidator((Validator<RoleDto>) (value, context) -> { if (value == null) { return ValidationResult.error("System user access role is required."); } return ValidationResult.ok(); }) .bind(SystemUserDto::getRole, SystemUserDto::setRole); Button saveBtn = new Button("Save", event -> { BinderValidationStatus<SystemUserDto> validationStatus = binder.validate(); if (validationStatus.isOk()) { try { SystemUserDto userDto = binder.getBean(); userDto = service.updateSystemUser(userDto); updateListener.onUpdated(this, userDto); setOpened(false); } catch (Exception e) { log.warn("Failed to update system user. Reason = '{}'", e.getMessage()); ErrorNotification.show("Error", "Ooops, something went wrong, try again please"); } } }); Button cancelBtn = new Button("Cancel", event -> setOpened(false)); HorizontalLayout controls = new HorizontalLayout(); controls.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controls.add(cancelBtn, saveBtn); controls.setWidthFull(); formLayout.add(role); formLayout.add(new Hr()); formLayout.add(controls); formLayout.setMaxWidth("400px"); add(formLayout); }
Example 3
Source File: AttributesView.java From radman with MIT License | 4 votes |
AttributeEditDialog(AttributeService attributeService, UpdateListener<T> updateListener) { this.attributeService = attributeService; FormLayout formLayout = new FormLayout(); formLayout.add(new H3(getDialogTitle())); TextArea description = new TextArea("Description"); description.setValueChangeMode(ValueChangeMode.EAGER); description.setWidthFull(); binder = new Binder<>(getClazz()); binder.forField(description).bind(AttributeDto::getDescription, AttributeDto::setDescription); Button cancelBtn = new Button("Cancel", event -> setOpened(false)); Button saveBtn = new Button("Save", event -> { BinderValidationStatus<T> validationStatus = binder.validate(); if (validationStatus.isOk()) { try { T attributeDto = binder.getBean(); attributeDto = save(attributeDto); updateListener.onUpdated(this, attributeDto); setOpened(false); } catch (Exception e) { log.warn("Failed to update attribute. Reason = '{}'", e.getMessage()); ErrorNotification.show("Error", "Ooops, something went wrong, try again please"); } } }); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.setWidthFull(); controlsLayout.add(cancelBtn); controlsLayout.add(saveBtn); formLayout.add(description); formLayout.add(new Hr()); formLayout.add(controlsLayout); formLayout.setMaxWidth("500px"); add(formLayout); }
Example 4
Source File: NasView.java From radman with MIT License | 4 votes |
NasFormDialog(NasService nasService) { this.nasService = nasService; TextField name = new TextField("Name"); name.setValueChangeMode(ValueChangeMode.EAGER); TextField shortName = new TextField("Short name"); shortName.setValueChangeMode(ValueChangeMode.EAGER); TextField type = new TextField("Type"); type.setValueChangeMode(ValueChangeMode.EAGER); NumberField port = new NumberField("Port"); port.setValueChangeMode(ValueChangeMode.EAGER); PasswordField secret = new PasswordField("Secret"); secret.setValueChangeMode(ValueChangeMode.EAGER); TextField server = new TextField("Server"); server.setValueChangeMode(ValueChangeMode.EAGER); TextField community = new TextField("Community"); community.setValueChangeMode(ValueChangeMode.EAGER); TextArea description = new TextArea("Description"); description.setValueChangeMode(ValueChangeMode.EAGER); FormLayout formLayout = new FormLayout(); formLayout.setWidthFull(); formLayout.setMaxWidth("700px"); formLayout.add(name, shortName, server, port, secret, type, community, description); formLayout.setResponsiveSteps( new FormLayout.ResponsiveStep("0px", 1), new FormLayout.ResponsiveStep("450px", 2)); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.add(new Button("Cancel", event -> setOpened(false))); controlsLayout.add(getConfirmBtn()); controlsLayout.setWidthFull(); add(new H3(getDialogTitle())); add(formLayout); add(new Hr()); add(controlsLayout); binder = new BeanValidationBinder<>(NasDto.class); binder.bind(name, "nasName"); binder.bind(shortName, "shortName"); binder.bind(type, "type"); binder.forField(port) .withConverter(new DoubleToIntegerConverter("Port must be number " + "between 1 and " + 65535 + ".")) .bind("ports"); binder.bind(secret, "secret"); binder.bind(server, "server"); binder.bind(community, "community"); binder.bind(description, "description"); }