Java Code Examples for com.vaadin.flow.component.orderedlayout.HorizontalLayout#add()
The following examples show how to use
com.vaadin.flow.component.orderedlayout.HorizontalLayout#add() .
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: AbstractView.java From vaadin-app-layout with Apache License 2.0 | 6 votes |
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 2
Source File: UserGroupsView.java From radman with MIT License | 6 votes |
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: AbstractAutoGeneratedCrudFormFactory.java From crudui with Apache License 2.0 | 6 votes |
protected Component buildFooter(CrudOperation operation, T domainObject, ComponentEventListener<ClickEvent<Button>> cancelButtonClickListener, ComponentEventListener<ClickEvent<Button>> operationButtonClickListener) { Button operationButton = buildOperationButton(operation, domainObject, operationButtonClickListener); Button cancelButton = buildCancelButton(cancelButtonClickListener); HorizontalLayout footerLayout = new HorizontalLayout(); footerLayout.setSizeUndefined(); footerLayout.setSpacing(true); footerLayout.setPadding(false); if (cancelButton != null) { footerLayout.add(cancelButton); } if (operationButton != null) { footerLayout.add(operationButton); } return footerLayout; }
Example 4
Source File: UsersView.java From radman with MIT License | 6 votes |
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 5
Source File: TopNavigationLink.java From vaadin-app-layout with Apache License 2.0 | 6 votes |
public TopNavigationLink(String caption, Component icon, Class<? extends Component> className) { super(); this.className = className; HorizontalLayout wrapper = new HorizontalLayout(); if (icon != null){ wrapper.add(icon); } if(caption != null){ wrapper.add(new Label(caption)); } wrapper.setAlignItems(FlexComponent.Alignment.CENTER); wrapper.setHeight("100%"); add(wrapper); UpNavigationHelper.registerNavigationRoute(className); setRoute(UI.getCurrent().getRouter(), className); setHighlightCondition((routerLink, event) -> UpNavigationHelper.shouldHighlight(className, event.getLocation())); }
Example 6
Source File: NasGroupsView.java From radman with MIT License | 6 votes |
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 7
Source File: AbstractView.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
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); add(layout); setSizeFull(); getElement().getStyle().set("overflow", "auto"); }
Example 8
Source File: AbstractView.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
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: ServiceTestingView.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
public ServiceTestingView(@Autowired RSocketBrokerHandlerRegistry handlerRegistry, @Autowired ServiceRoutingSelector routingSelector) { this.handlerRegistry = handlerRegistry; this.routingSelector = routingSelector; HorizontalLayout horizontalLayout = new HorizontalLayout(); VerticalLayout serviceCallForm = makeServiceCallForm(); // Compose layout horizontalLayout.add(serviceCallForm); add(horizontalLayout); }
Example 10
Source File: AppConfigView.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
VerticalLayout makeConfigForm() { VerticalLayout content = new VerticalLayout(); appName = new TextField("App Name"); appName.setWidth("300px"); configName = new TextField("Key"); configName.setWidth("300px"); configValue = new TextArea("Value"); configValue.setWidth("600px"); HorizontalLayout buttons = new HorizontalLayout(); saveButton = new Button("Save", buttonClickEvent -> { String key = appName.getValue() + ":" + configName.getValue(); AppConfigEvent appConfigEvent = new AppConfigEvent(appName.getValue(), configName.getValue(), configValue.getValue()); configurationService.put(key, configValue.getValue()) .doOnSuccess(aVoid -> Notification.show("Saved Successfully")) .then(brokerManager.broadcast(appConfigEvent.toCloudEvent(URI.create("broker:" + brokerManager.localBroker().getIp())))) .subscribe(); }); content.add(new H3("Key/Value")); content.add(appName); content.add(configName); content.add(configValue); buttons.add(saveButton); buttons.add(new Button("New Configuration", buttonClickEvent -> { clearForm(); })); content.add(buttons); return content; }
Example 11
Source File: AppConfigView.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
public AppConfigView(@Autowired ConfigurationService configurationService, @Autowired RSocketBrokerManager brokerManager) { this.configurationService = configurationService; this.brokerManager = brokerManager; HorizontalLayout horizontalLayout = new HorizontalLayout(); VerticalLayout appList = makeAppList(); VerticalLayout content = makeConfigForm(); // Compose layout horizontalLayout.add(appList, content); add(horizontalLayout); }
Example 12
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 13
Source File: AbstractView.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
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: LoadingResultNotification.java From radman with MIT License | 4 votes |
private static HorizontalLayout row(Component... components) { HorizontalLayout layout = new HorizontalLayout(); layout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.START); layout.add(components); return layout; }
Example 15
Source File: JwtGeneratorView.java From alibaba-rsocket-broker with Apache License 2.0 | 4 votes |
VerticalLayout makeGeneratorForm() { VerticalLayout content = new VerticalLayout(); appNameText = new TextField("App Name"); appNameText.setWidth("300px"); appNameText.setPlaceholder("your-app-name"); ownersText = new TextField("Owners"); ownersText.setWidth("300px"); orgIdsText = new TextField("Org IDs"); orgIdsText.setPlaceholder("1"); orgIdsText.setWidth("300px"); serviceAccountsText = new TextField("Service Accounts"); serviceAccountsText.setValue("default"); serviceAccountsText.setWidth("300px"); rolesText = new TextField("Roles"); rolesText.setWidth("300px"); rolesText.setValue("user"); authoritiesText = new TextField("Authorities"); rolesText.setWidth("300px"); rolesText.setValue(""); tokenTextArea = new TextArea("JWT Token"); tokenTextArea.setWidth("800px"); tokenTextArea.setHeight("240px"); tokenTextArea.setReadOnly(true); rolesText.setWidth("200px"); HorizontalLayout buttons = new HorizontalLayout(); generateBtn = new Button("Generate", buttonClickEvent -> { String appName = appNameText.getValue(); String[] orgIds = orgIdsText.getValue().trim().split("[,;\\s]*"); String[] serviceAccounts = serviceAccountsText.getValue().trim().split("[,;\\s]*"); String[] owners = ownersText.getValue().trim().split("[,;\\s]*"); String[] roles = rolesText.getValue().trim().split("[,;\\s]*"); String[] authorities = authoritiesText.getValue().trim().split("[,;\\s]*"); try { String token = authenticationService.generateCredentials(UUID.randomUUID().toString(), orgIds, serviceAccounts, roles, authorities, appName, owners); tokenTextArea.setValue(token); } catch (Exception ignore) { } }); content.add(appNameText); content.add(ownersText); content.add(orgIdsText); content.add(serviceAccountsText); content.add(rolesText); content.add(authoritiesText); content.add(tokenTextArea); buttons.add(generateBtn); buttons.add(new Button("Clear", buttonClickEvent -> { clearForm(); })); content.add(buttons); return content; }
Example 16
Source File: AccountingView.java From radman with MIT License | 4 votes |
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 17
Source File: AccountingView.java From radman with MIT License | 4 votes |
private void buildView() { setHeightFull(); setSpacing(false); Grid<AccountingDto> grid = new Grid<>(AccountingDto.class, false); grid.addColumns("username", "callingStationId", "nasIpAddress", "serviceType"); grid.addColumn(new LocalDateTimeRenderer<>((ValueProvider<AccountingDto, LocalDateTime>) accountingDto -> { if (Objects.isNull(accountingDto.getAcctStartTime())) { return null; } return LocalDateTime.ofInstant(accountingDto.getAcctStartTime().toInstant(), TimeZone.getDefault().toZoneId()); })).setSortProperty("acctStartTime").setHeader("Acct Start Time"); grid.addColumn(new LocalDateTimeRenderer<>((ValueProvider<AccountingDto, LocalDateTime>) accountingDto -> { if (Objects.isNull(accountingDto.getAcctStopTime())) { return null; } return LocalDateTime.ofInstant(accountingDto.getAcctStopTime().toInstant(), TimeZone.getDefault().toZoneId()); })).setSortProperty("acctStopTime").setHeader("Acct Stop Time"); grid.addColumns("acctTerminateCause", "framedIpAddress", "framedProtocol"); grid.addColumns("acctAuthentic", "acctInputOctets", "acctInterval", "acctOutputOctets", "acctSessionId"); grid.addColumn(accountingDto -> { if (Objects.isNull(accountingDto.getAcctSessionTime())) { return null; } return DurationFormatUtils.formatDurationHMS(accountingDto.getAcctSessionTime()); }).setSortProperty("acctSessionTime").setHeader("Acct Session Time"); grid.addColumns("acctUniqueId", "acctUpdateTime", "calledStationId", "connectInfoStart", "connectInfoStop", "nasPortId", "nasPortType", "radAcctId", "realm"); DataProvider<AccountingDto, Object> dataProvider = new SpringDataProviderBuilder<>( (pageable, o) -> accountingService.pageAccountingRecords(filter, pageable), value -> accountingService.countAccountingRecords(filter)) .withDefaultSort("acctStartTime", SortDirection.DESCENDING) .build(); grid.setDataProvider(dataProvider); grid.getColumns().forEach(column -> column.setResizable(true)); grid.setColumnReorderingAllowed(true); grid.setMinHeight("500px"); grid.setHeight("100%"); TextField search = new TextField(event -> { filter.setSearchText(event.getValue()); grid.getDataProvider().refreshAll(); }); search.setValueChangeMode(ValueChangeMode.EAGER); search.setPlaceholder("Search..."); SetAcctStopTimeDialog setAcctStopTimeDialog = new SetAcctStopTimeDialog((source, bean) -> grid.getDataProvider().refreshItem(bean)); Button setAcctStopTimeButton = new Button("Set Acct Stop Time", event -> { Optional<AccountingDto> optional = grid.getSelectionModel().getFirstSelectedItem(); optional.ifPresent(setAcctStopTimeDialog::set); }); setAcctStopTimeButton.setEnabled(false); grid.asSingleSelect().addValueChangeListener(event -> setAcctStopTimeButton.setEnabled(Objects.nonNull(event.getValue()))); Checkbox onlyActiveSessions = new Checkbox("Filter only active sessions"); onlyActiveSessions.setValue(filter.isSearchOnlyActiveSessions()); onlyActiveSessions.addValueChangeListener(event -> { filter.setSearchOnlyActiveSessions(event.getValue()); grid.getDataProvider().refreshAll(); }); add(new H4("Data from Radius DB - \"radacct\" table")); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.BASELINE); horizontalLayout.add(new H3("Accounting")); horizontalLayout.add(setAcctStopTimeButton); horizontalLayout.add(search); horizontalLayout.add(onlyActiveSessions); add(horizontalLayout); add(grid); }
Example 18
Source File: DashboardView.java From alibaba-rsocket-broker with Apache License 2.0 | 4 votes |
public DashboardView(@Autowired RSocketBrokerHandlerRegistry handlerRegistry, @Autowired ServiceRoutingSelector serviceRoutingSelector, @Autowired RSocketBrokerManager rSocketBrokerManager) { this.handlerRegistry = handlerRegistry; this.serviceRoutingSelector = serviceRoutingSelector; this.rSocketBrokerManager = rSocketBrokerManager; setAlignItems(Alignment.CENTER); //---- top HorizontalLayout top = new HorizontalLayout(); top.setAlignItems(Alignment.CENTER); add(top); // brokers panel Panel brokersPanel = new Panel("Brokers"); brokersPanel.add(brokersCount); top.add(brokersPanel); // apps panel Panel appsPanel = new Panel("Apps"); appsPanel.add(appsCount); top.add(appsPanel); // services panel Panel servicePanel = new Panel("Services"); servicePanel.add(servicesCount); top.add(servicePanel); // connections panel Panel connectionPanel = new Panel("Connections"); connectionPanel.add(connectionsCount); top.add(connectionPanel); // requests count panel Panel requestsPanel = new Panel("Requests"); requestsPanel.add(requestsCounter); top.add(requestsPanel); //--- last ten apps Div div2 = new Div(); div2.add(new H3("Last apps")); appMetadataGrid.addColumn(AppMetadata::getName).setHeader("App Name"); appMetadataGrid.addColumn(AppMetadata::getIp).setHeader("IP"); appMetadataGrid.addColumn(AppMetadata::getConnectedAt).setHeader("Timestamp"); appMetadataGrid.setWidth("1024px"); div2.add(appMetadataGrid); add(div2); }
Example 19
Source File: NotificationView.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public NotificationView(T info, NotificationHolder<T> holder, NotificationListener listener, boolean isNotification) { this.info = info; this.holder = holder; this.isNotification = isNotification; setWidth("100%"); setAlignItems(Alignment.CENTER); Label title = new Label(info.getTitle()); title.getElement().getStyle() .set("font-size", "15px") .set("font-weight", "500"); Label dot = new Label("ยท"); dot.getElement().getStyle() .set("margin-left", "5px"); Label timeAgo = new Label(holder.getDateTimeFormatter().apply(info)); timeAgo.getElement().getStyle() .set("font-size", "13px") .set("margin-left", "5px") .set("font-weight", "300"); Label description = new Label(info.getDescription()); description.setWidth("100%"); description.getElement().getStyle() .set("font-size", "15px") .set("font-weight", "400") .set("white-space", "nowrap") .set("text-overflow", "ellipsis") .set("overflow", "hidden"); HorizontalLayout descriptionWrapper = new HorizontalLayout(description); descriptionWrapper.setWidth("100%"); if (info.getImage() != null) { RoundImage image = new RoundImage(info.getImage()); descriptionWrapper.add(image); } if (!isNotification) { setHighlightBorder(!info.isRead()); } HorizontalLayout headerLine = new HorizontalLayout(title, dot, timeAgo); headerLine.setSpacing(false); headerLine.setAlignItems(FlexComponent.Alignment.CENTER); wrapper = new VerticalLayout(headerLine, descriptionWrapper); wrapper.setMargin(false); wrapper.setPadding(false); wrapper.setSpacing(false); wrapper.getElement().setAttribute("theme", "spacing-s"); wrapper.getStyle().set("overflow", "hidden"); add(wrapper); setNotificationListener(listener); if (!isNotification) { if (info.isDismissable()) { dismissButton = new IconButton(VaadinIcon.CLOSE_SMALL.create(), paperIconButtonClickEvent -> { if (listener != null) { listener.onDismiss(); } }); dismissButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY); dismissButton.setSizeUndefined(); add(dismissButton); getElement().getStyle().set("padding-right", "0"); } } }
Example 20
Source File: UserToGroupView.java From radman with MIT License | 4 votes |
private void buildView() { setHeightFull(); setSpacing(false); RoleDto role = securityService.getLoggedUserRole(); Grid<RadiusUserToGroupDto> grid = new Grid<>(RadiusUserToGroupDto.class, false); grid.addColumns("username", "groupName", "userInRadman", "groupInRadman"); DataProvider<RadiusUserToGroupDto, Object> dataProvider = new SpringDataProviderBuilder<>( (pageable, o) -> userService.pageRadiusUserToGroupRecords(filter, pageable), value -> userService.countRadiusUserToGroupRecords(filter)) .withDefaultSort("username", SortDirection.ASCENDING) .build(); grid.setDataProvider(dataProvider); grid.setSortableColumns("username", "groupName"); grid.setColumnReorderingAllowed(true); grid.setMinHeight("500px"); grid.setHeight("100%"); Button addUserToGroup = new Button("Add user to group", event -> { AddUserToGroupDialog addDialog = new AddUserToGroupDialog( (source, bean) -> grid.getDataProvider().refreshAll()); addDialog.startAdding(); }); addUserToGroup.setEnabled(role == RoleDto.ADMIN); ConfirmationDialog deleteDialog = new ConfirmationDialog(); deleteDialog.setTitle("Delete User to Group mapping"); deleteDialog.setDescription("Are you sure?"); deleteDialog.setConfirmButtonCaption("Delete"); deleteDialog.setConfirmListener(() -> { Optional<RadiusUserToGroupDto> optional = grid.getSelectionModel().getFirstSelectedItem(); try { optional.ifPresent(userService::removeRadiusUserFromGroup); grid.getDataProvider().refreshAll(); } catch (Exception e) { log.warn("Failed to delete user to group mapping. Reason = '{}'", e.getMessage()); ErrorNotification.show("Error", "Ooops, something went wrong, try again please"); } deleteDialog.setOpened(false); }); Button removeUserFromGroup = new Button("Remove user from group", event -> deleteDialog.setOpened(true)); removeUserFromGroup.setEnabled(false); grid.asSingleSelect().addValueChangeListener(event -> removeUserFromGroup.setEnabled(Objects.nonNull(event.getValue()) && role == RoleDto.ADMIN)); TextField search = new TextField(event -> { filter.setSearchText(event.getValue()); grid.getDataProvider().refreshAll(); }); search.setValueChangeMode(ValueChangeMode.EAGER); search.setPlaceholder("Search..."); add(new H4("Data from Radius DB - \"radusergroup\" table")); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.BASELINE); horizontalLayout.add(new H3("Users to Groups")); horizontalLayout.add(addUserToGroup); horizontalLayout.add(removeUserFromGroup); horizontalLayout.add(search); add(horizontalLayout); add(grid); }