Java Code Examples for com.vaadin.flow.component.orderedlayout.HorizontalLayout#setJustifyContentMode()

The following examples show how to use com.vaadin.flow.component.orderedlayout.HorizontalLayout#setJustifyContentMode() . 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: UsersView.java    From radman with MIT License 6 votes vote down vote up
UserFormDialog() {
    TextField username = new TextField("Username");
    username.setValueChangeMode(ValueChangeMode.EAGER);
    TextField description = new TextField("Description");
    description.setValueChangeMode(ValueChangeMode.EAGER);

    binder = new BeanValidationBinder<>(RadiusUserDto.class);
    binder.bind(username, "username");
    binder.bind(description, "description");

    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(new FormLayout(username, description));
    add(new Hr());
    add(controlsLayout);
}
 
Example 2
Source File: UserGroupsView.java    From radman with MIT License 6 votes vote down vote up
UserGroupFormDialog() {

            TextField username = new TextField("Name");
            username.setValueChangeMode(ValueChangeMode.EAGER);
            TextField description = new TextField("Description");
            description.setValueChangeMode(ValueChangeMode.EAGER);

            binder = new BeanValidationBinder<>(RadiusGroupDto.class);
            binder.bind(username, "name");
            binder.bind(description, "description");

            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(new FormLayout(username, description));
            add(new Hr());
            add(controlsLayout);
        }
 
Example 3
Source File: NasGroupsView.java    From radman with MIT License 6 votes vote down vote up
NasGroupFormDialog(NasService nasService) {
    this.nasService = nasService;

    TextField groupname = new TextField("Group name");
    groupname.setValueChangeMode(ValueChangeMode.EAGER);
    TextField nasIpAddress = new TextField("IP address");
    nasIpAddress.setValueChangeMode(ValueChangeMode.EAGER);
    TextField nasPortId = new TextField("Port ID");
    nasPortId.setValueChangeMode(ValueChangeMode.EAGER);

    binder = new BeanValidationBinder<>(NasGroupDto.class);
    binder.bind(groupname, "groupName");
    binder.bind(nasIpAddress, "nasIpAddress");
    binder.bind(nasPortId, "nasPortId");

    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(new FormLayout(groupname, nasIpAddress, nasPortId));
    add(new Hr());
    add(controlsLayout);
}
 
Example 4
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 6 votes vote down vote up
public AbstractView() {

        HorizontalLayout layout = new HorizontalLayout();
        layout.setSizeFull();
        layout.setMargin(false);
        layout.add(new Label("< " + getViewName() + " >"));
        layout.setAlignItems(Alignment.CENTER);
        layout.setJustifyContentMode(JustifyContentMode.CENTER);

        add(layout);
        setMargin(false);
        setSizeFull();
        getElement()
                .getStyle()
                .set("overflow", "auto");
    }
 
Example 5
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 6 votes vote down vote up
public AbstractView() {

        HorizontalLayout layout = new HorizontalLayout();
        layout.setSizeFull();
        layout.setMargin(false);
        layout.add(new Label("< " + getViewName() + " >"));
        layout.setAlignItems(Alignment.CENTER);
        layout.setJustifyContentMode(JustifyContentMode.CENTER);

        add(layout);
        setMargin(false);
        setSizeFull();
        getElement()
                .getStyle()
                .set("overflow", "auto");
    }
 
Example 6
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 6 votes vote down vote up
public AbstractView() {

        HorizontalLayout layout = new HorizontalLayout();
        layout.setSizeFull();
        layout.setMargin(false);
        layout.add(new Label("< " + getViewName() + " >"));
        layout.setAlignItems(Alignment.CENTER);
        layout.setJustifyContentMode(JustifyContentMode.CENTER);

        add(layout);
        setMargin(false);
        setSizeFull();
        getElement()
                .getStyle()
                .set("overflow", "auto");
    }
 
Example 7
Source File: ConfirmationDialog.java    From radman with MIT License 5 votes vote down vote up
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 8
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
public AbstractView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(false);
    setMargin(false);
    Label label = new Label("< " + getViewName() + " >");
    layout.add(label);
    layout.setAlignItems(Alignment.CENTER);
    layout.setJustifyContentMode(JustifyContentMode.CENTER);
    add(layout);
    setSizeFull();
    getElement().getStyle().set("overflow", "auto");
}
 
Example 9
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
public AbstractView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(false);
    setMargin(false);
    Label label = new Label("< " + getViewName() + " >");
    layout.add(label);
    layout.setAlignItems(Alignment.CENTER);
    layout.setJustifyContentMode(JustifyContentMode.CENTER);
    add(layout);
    setSizeFull();
    getElement().getStyle().set("overflow", "auto");
}
 
Example 10
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
public AbstractView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(false);
    setMargin(false);
    Label label = new Label("< " + getViewName() + " >");
    layout.add(label);
    layout.setAlignItems(Alignment.CENTER);
    layout.setJustifyContentMode(JustifyContentMode.CENTER);
    add(layout);
    setSizeFull();
    getElement().getStyle().set("overflow", "auto");
}
 
Example 11
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
public AbstractView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(false);
    setMargin(false);
    Label label = new Label("< " + getViewName() + " >");
    layout.add(label);
    layout.setAlignItems(Alignment.CENTER);
    layout.setJustifyContentMode(JustifyContentMode.CENTER);
    add(layout);
    setSizeFull();
    getElement().getStyle().set("overflow", "auto");
}
 
Example 12
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
public AbstractView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(false);
    setMargin(false);
    Label label = new Label("< " + getViewName() + " >");
    layout.add(label);
    layout.setAlignItems(Alignment.CENTER);
    layout.setJustifyContentMode(JustifyContentMode.CENTER);
    add(layout);
    setSizeFull();
    getElement().getStyle().set("overflow", "auto");
}
 
Example 13
Source File: AbstractView.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
public AbstractView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(false);
    setMargin(false);
    Label label = new Label("< " + getViewName() + " >");
    layout.add(label);
    layout.setAlignItems(Alignment.CENTER);
    layout.setJustifyContentMode(JustifyContentMode.CENTER);
    add(layout);
    setSizeFull();
    getElement().getStyle().set("overflow", "auto");
}
 
Example 14
Source File: SystemUsersView.java    From radman with MIT License 4 votes vote down vote up
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 15
Source File: AttributesView.java    From radman with MIT License 4 votes vote down vote up
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 16
Source File: NasView.java    From radman with MIT License 4 votes vote down vote up
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");
}