com.vaadin.flow.component.html.Hr Java Examples

The following examples show how to use com.vaadin.flow.component.html.Hr. 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: 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 #5
Source File: DependencyView.java    From flow with Apache License 2.0 5 votes vote down vote up
@Override
protected void onShow() {
    add(new Text(
            "This test initially loads a stylesheet which makes all text red, a JavaScript for logging window messages, a JavaScript for handling body click events and an HTML which sends a window message"),
            new Hr(), new Hr());

    Div clickBody = new Div();
    clickBody.setText("Hello, click the body please");
    clickBody.setId("hello");
    add(clickBody);

    NativeButton jsOrder = new NativeButton("Test JS order", e -> {
        getPage().addJavaScript("/test-files/js/set-global-var.js");
        getPage().addJavaScript("/test-files/js/read-global-var.js",
                LoadMode.LAZY);
    });
    jsOrder.setId("loadJs");

    NativeButton allBlue = new NativeButton(
            "Load 'everything blue' stylesheet", e -> {
                getPage().addStyleSheet(
                        "/test-files/css/allblueimportant.css");

            });
    allBlue.setId("loadBlue");

    NativeButton loadUnavailableResources = new NativeButton(
            "Load unavailable resources", e -> {
                getPage().addStyleSheet("/not-found.css");
                getPage().addJavaScript("/not-found.js");
            });
    loadUnavailableResources.setId("loadUnavailableResources");

    Div log = new Div();
    log.setId("log");

    add(jsOrder, allBlue, loadUnavailableResources, new Hr(), log);
}
 
Example #6
Source File: CompositeView.java    From flow with Apache License 2.0 5 votes vote down vote up
public CompositeView() {
    Div name = new Div();
    name.setText("Name on server: ");
    name.setId(CompositeNestedView.NAME_ID);

    NameField nameField = new NameField();
    nameField.setId(CompositeNestedView.NAME_FIELD_ID);
    nameField.addNameChangeListener(e -> {
        name.setText("Name on server: " + nameField.getName());
        String text = "Name value changed to " + nameField.getName()
                + " on the ";
        if (e.isFromClient()) {
            text += "client";
        } else {
            text += "server";
        }
        Div changeMessage = new Div();
        changeMessage.setText(text);
        add(changeMessage);
    });
    add(name, nameField, new Hr());

    Input serverInput = new Input();
    serverInput.setId(SERVER_INPUT_ID);
    NativeButton serverInputButton = createButton("Set",
            SERVER_INPUT_BUTTON_ID, e -> {
        nameField.setName(serverInput.getValue());
        serverInput.clear();
    });
    add(new Text("Enter a value to set the name on the server"),
            serverInput, serverInputButton);

    add(new Hr());

    PaperSliderComposite paperSliderComposite = new PaperSliderComposite();
    paperSliderComposite.setId(COMPOSITE_PAPER_SLIDER);
    add(paperSliderComposite);
}
 
Example #7
Source File: TemplateMappingDetectorView.java    From flow with Apache License 2.0 5 votes vote down vote up
@Override
protected void onShow() {
    TemplateMappingDetectorContainer container = new TemplateMappingDetectorContainer();
    TemplateMappingDetectorContainerParent containerParent = new TemplateMappingDetectorContainerParent();
    TemplateMappingDetectorContainerComposite composite = new TemplateMappingDetectorContainerComposite();
    composite.setId("composite");
    add(container, new Hr(), containerParent, new Hr(), composite);
}
 
Example #8
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 #9
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");
}
 
Example #10
Source File: AccountingView.java    From radman with MIT License 4 votes vote down vote up
SetAcctStopTimeDialog(UpdateListener<AccountingDto> updateListener) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setPadding(false);
    verticalLayout.setMargin(false);

    timestampField = new TextField("Timestamp");
    timestampField.setErrorMessage("Timestamp number is required");
    timestampField.setValueChangeMode(ValueChangeMode.EAGER);
    timestampField.addValueChangeListener(event -> isValid(event.getValue()));

    checkboxNow = new Checkbox("Now");
    Button setBtn = new Button("Set");
    Button cancelBtn = new Button("Cancel", event -> setOpened(false));

    checkboxNow.addValueChangeListener(event -> {
        if (event.getValue()) {
            timestampField.setValue(String.valueOf(Instant.now().getEpochSecond()));
        }
        timestampField.setEnabled(!event.getValue());
    });
    timestampField.addValueChangeListener(event -> setBtn.setEnabled(Objects.nonNull(event.getValue())));

    setBtn.setEnabled(false);
    setBtn.addClickListener(event -> {
        if (isValid(timestampField.getValue())) {
            try {
                long timestamp = Long.valueOf(timestampField.getValue());
                AccountingDto updatedAccountingDto = accountingService.setAcctStopTime(accountingDto,
                        new Date(timestamp * 1000));
                updateListener.onUpdated(this, updatedAccountingDto);
                setOpened(false);
            } catch (NotFoundException e) {
                e.printStackTrace();
            }
        }
    });

    HorizontalLayout controls = new HorizontalLayout();
    controls.add(cancelBtn, setBtn);
    verticalLayout.add(new H3("Set Acct Stop Time"), timestampField, checkboxNow, new Hr(), controls);
    verticalLayout.setHorizontalComponentAlignment(Alignment.END, controls);
    add(verticalLayout);

}
 
Example #11
Source File: MainLayout.java    From electron-java-app with Apache License 2.0 4 votes vote down vote up
private void initMenu() {
    var menuLayout = new HorizontalLayout();
    menuLayout.setSpacing(false);
    menuLayout.addClassName("window-header");
    menuLayout.setWidth("100%");

    var titleLabel = new MenuBar();
    titleLabel.addClassName("window-title");
    titleLabel.addThemeVariants(MenuBarVariant.LUMO_TERTIARY);

    var mainMenuItem = addMenuItem(titleLabel, "Tasks", VaadinIcon.TASKS);
    mainMenuItem.getSubMenu().addItem("About", selectedItem -> onMenuAbout());

    if (!VaadinService.getCurrent().getDeploymentConfiguration().isProductionMode()) {
        mainMenuItem.getSubMenu().addItem("Developer tools", selectedItem -> callElectronUiApi("devtools"));
    }

    mainMenuItem.getSubMenu().add(new Hr());
    mainMenuItem.getSubMenu().addItem("Exit", selectedItem -> onWindowExit());

    menuLayout.addAndExpand(titleLabel);

    var minimizeBtn = new Button(VaadinIcon.MINUS.create());
    minimizeBtn.addClickListener(event -> callElectronUiApi("minimize"));
    minimizeBtn.addClassName("window-control");
    minimizeBtn.addThemeVariants(ButtonVariant.LUMO_TERTIARY, ButtonVariant.LUMO_ICON);
    minimizeBtn.getElement().setProperty("title", "Minimize");

    var maximizeBtn = new Button(VaadinIcon.PLUS.create());
    maximizeBtn.addClickListener(event -> callElectronUiApi("maximize"));
    maximizeBtn.addClassName("window-control");
    maximizeBtn.addThemeVariants(ButtonVariant.LUMO_TERTIARY, ButtonVariant.LUMO_ICON);
    maximizeBtn.getElement().setProperty("title", "Maximize");

    var closeBtn = new Button(VaadinIcon.CLOSE.create());
    closeBtn.addClickListener(event -> onWindowExit());
    closeBtn.addClassName("window-control");
    closeBtn.addClassName("window-close");
    closeBtn.addThemeVariants(ButtonVariant.LUMO_TERTIARY, ButtonVariant.LUMO_ICON);
    closeBtn.getElement().setProperty("title", "Close");

    menuLayout.add(minimizeBtn, maximizeBtn, closeBtn);

    add(menuLayout);
}
 
Example #12
Source File: InfoView.java    From flow with Apache License 2.0 4 votes vote down vote up
private void separator() {
    add(new Hr());
}
 
Example #13
Source File: OrderedDependencyView.java    From flow with Apache License 2.0 4 votes vote down vote up
@Override
protected void onShow() {
    Html2Component html2Component = new Html2Component();
    html2Component.setId("component");
    add(html2Component, new Hr(), new Script2Component());
}