com.vaadin.flow.component.orderedlayout.FlexComponent Java Examples
The following examples show how to use
com.vaadin.flow.component.orderedlayout.FlexComponent.
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: 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 #2
Source File: NotificationsOverlayView.java From vaadin-app-layout with Apache License 2.0 | 6 votes |
private void initViews() { views.clear(); if (holder.getNotificationSize() > 0) { views.addAll(this.holder.getNotificationCards()); } else { noNotificationsLabel = new Label(noNotificationText); noNotificationsLabel.getStyle().set("color", "var(--app-layout-notification-font-color)") .set("font-size", "var(--app-layout-font-size-menu)"); VerticalLayout labelWrapper = new VerticalLayout(noNotificationsLabel); labelWrapper.setAlignItems(FlexComponent.Alignment.CENTER); labelWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER); Card wrapper = new Card(labelWrapper); wrapper.setWidthFull(); wrapper.setBackground("var(--lumo-base-color)"); wrapper.setWidth("100%"); wrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER); views.add(wrapper); } }
Example #3
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 #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: 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 #6
Source File: SearchView.java From vaadin-app-layout with Apache License 2.0 | 6 votes |
public SearchView() { getElement().getStyle().set("width", "100%"); setVerticalAlign(VerticalOrientation.TOP); setWithBackdrop(false); searchFieldWrapper.getStyle() .set("background", "var(--app-layout-bar-background-base-color)") .set("height", "var(--app-bar-height)") .set("box-shadow", "var(--app-layout-bar-shadow)") .set("padding", "var(--app-layout-bar-padding)") .set("z-index", "1"); searchFieldWrapper.setWidthFull(); searchFieldWrapper.setAlignItems(FlexComponent.Alignment.CENTER); searchFieldWrapper.setSpacing(false); searchField.getStyle().set("--lumo-contrast-10pct", "transparent"); searchField.setValueChangeMode(ValueChangeMode.EAGER); searchField.setWidthFull(); closeButton.setWidth("var(--app-bar-height)"); closeButton.setHeight("var(--app-bar-height)"); closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY); closeButton.addClickListener(event -> { searchField.clear(); close(); }); add(searchFieldWrapper); }
Example #7
Source File: LoadingResultNotification.java From radman with MIT License | 5 votes |
public static void show(String title, LoadingResult result) { Notification notification = new Notification(); notification.setDuration(5000); notification.add(new H3(title)); VerticalLayout description = new VerticalLayout(); description.setMargin(false); description.setSpacing(false); description.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER); description.add(row(label("Loaded", "100px"), label(result.getLoaded()))); description.add(row(label("Duplicate", "100px"), label(result.getDuplicate()))); description.add(row(label("Errored", "100px"), label(result.getErrored()))); notification.add(description); notification.setPosition(Notification.Position.TOP_END); notification.open(); }
Example #8
Source File: AbstractLeftAppLayoutBase.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
AbstractLeftAppLayoutBase() { getClassNames().addAll(asList("app-layout-behaviour-" + getStyleName(), Styles.APP_LAYOUT)); FlexLayout appBarContentHolder = new FlexLayout(titleWrapper, appBarElementWrapper); appBarContentHolder.setSizeFull(); appBarContentHolder.getElement().setAttribute("slot", "app-bar-content"); appBarElementWrapper.getStyle().set("flex", "0 1 0px"); appBarElementWrapper.add(appBarElementContainer); appBarElementWrapper.getStyle().set("flex-direction", "var(--app-layout-app-bar-flex-direction)"); appBarElementWrapper.setWidthFull(); appBarElementWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.END); appBarElementContainer.getStyle().set("flex-direction", "var(--app-layout-app-bar-flex-direction)"); appBarElementContainer.setWidthFull(); titleWrapper.getStyle().set("flex-direction", "var(--app-layout-app-bar-flex-direction)"); titleWrapper.setWidthFull(); menuElements = new Div(); menuElements.setHeightFull(); menuElements.getElement().setAttribute("slot", "drawer-content"); contentHolder = new Div(); contentHolder.setSizeFull(); contentHolder.getElement().setAttribute("slot", "application-content"); titleWrapper.setHeightFull(); titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); titleWrapper.getElement().getStyle().set("flex", "1 1").set("overflow", "hidden"); getElement().getClassList().add("app-layout"); getElement().appendChild(appBarContentHolder.getElement(), menuElements.getElement(), contentHolder.getElement()); menuButton.setIcon(VaadinIcon.MENU.create()); menuButton.addThemeNames(ButtonVariant.LUMO_TERTIARY.getVariantName(), ButtonVariant.LUMO_ICON.getVariantName(), ButtonVariant.LUMO_LARGE.getVariantName()); }
Example #9
Source File: TopLayouts.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
public void setTitleComponent(Component component) { HorizontalLayout wrapper = new HorizontalLayout(component); wrapper.setWidthFull(); titleWrapper.add(wrapper); this.title = component; titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); }
Example #10
Source File: TopLayouts.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
public Top() { contentPanel.setSizeFull(); getElement().getClassList().addAll(Arrays.asList("app-layout-behaviour-" + getStyleName(), "app-layout")); appBar.add(titleWrapper, paperTabWrapper, appBarElementWrapper); paperTabWrapper.setFlexGrow(1.0, titleWrapper); paperTabWrapper.setWidth("100%"); paperTabWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER); appBar.setWidth("100%"); appBar.setHeight("100%"); appBarElements = new Div(); appBarElements.setHeight("100%"); appBarElements.getElement().setAttribute("slot", "app-bar-content"); contentHolder = new Div(); contentHolder.setHeight("100%"); contentHolder.setWidth("100%"); contentHolder.getElement().setAttribute("slot", "application-content"); appBarElements.add(appBar); appBarElementWrapper.setSpacing(false); appBarElementWrapper.add(appBarElementContainer); appBarElementContainer.setHeight("100%"); appBarElementWrapper.setAlignItems(FlexComponent.Alignment.START); titleWrapper.setHeight("100%"); titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); menuButton.setIcon(VaadinIcon.ARROW_LEFT.create()); menuButton.addThemeNames(ButtonVariant.LUMO_TERTIARY.getVariantName(), ButtonVariant.LUMO_ICON.getVariantName(), ButtonVariant.LUMO_LARGE.getVariantName()); getElement().appendChild(appBarElements.getElement(), contentHolder.getElement()); }
Example #11
Source File: AppBarBuilder.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
@Override public FlexLayout build() { FlexLayout layout = new FlexLayout(components.toArray(new Component[0])); layout.getStyle().set("flex-direction", "var(--app-layout-app-bar-flex-direction)"); layout.setWidthFull(); layout.setAlignItems(FlexComponent.Alignment.CENTER); return layout; }
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: NotificationsOverlayView.java From vaadin-app-layout with Apache License 2.0 | 5 votes |
public NotificationsOverlayView() { getElement().getStyle().set("width", "100%"); overlayTitle.getElement().getStyle().set("width", "100%"); setVerticalAlign(VerticalOrientation.TOP); backButton.addClickListener(buttonClickEvent -> close()); clearButton.addClickListener(buttonClickEvent -> holder.clearNotifications()); appBarWrapper.getStyle() .set("background", "var(--app-layout-bar-background-base-color)") .set("height", "var(--app-bar-height)") .set("box-shadow", "var(--app-layout-bar-shadow)") .set("padding", "var(--app-layout-bar-padding)") .set("flex-shrink", "0") .set("z-index", "1"); appBarWrapper.setWidthFull(); appBarWrapper.setAlignItems(FlexComponent.Alignment.CENTER); wrapper.setSizeFull(); wrapper.setAlignItems(FlexComponent.Alignment.CENTER); wrapper.setMargin(false); wrapper.setPadding(false); wrapper.setSpacing(false); wrapper.getStyle() .set("max-width", "100vw") .set("height", "100vh"); results.getStyle() .set("overflow-y", "auto") .set("max-width", "100%") .set("min-width", "40%") .set("--lumo-size-m", "var(--lumo-size-xl)") .set("--lumo-contrast-10pct", "transparent"); results.setHeightFull(); results.setWidth("unset"); add(wrapper); }
Example #14
Source File: TopLayouts.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public void setIconComponent(Component appBarIconComponent) { titleWrapper.getElement().insertChild(0, appBarIconComponent.getElement()); titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); }
Example #15
Source File: SearchOverlayView.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public SearchOverlayView() { getElement().getStyle().set("width", "100%"); setVerticalAlign(VerticalOrientation.TOP); searchFieldWrapper.getStyle() .set("background", "var(--app-layout-bar-background-base-color)") .set("height", "var(--app-bar-height)") .set("box-shadow", "var(--app-layout-bar-shadow)") .set("padding", "var(--app-layout-bar-padding)") .set("flex-shrink", "0") .set("z-index", "1"); searchFieldWrapper.setWidthFull(); searchFieldWrapper.setAlignItems(FlexComponent.Alignment.CENTER); searchField.getStyle().set("--lumo-contrast-10pct", "transparent"); searchField.addValueChangeListener(event -> { results.removeAll(); List<T> result = dataProvider.fetch(queryProvider.apply(event.getValue())).collect(Collectors.toList()); result.stream() .map(t -> new QueryPair<>(t, dataViewProvider.apply(t))) .forEach(clickNotifier -> { results.add((Component) clickNotifier.getNotifier()); clickNotifier.getNotifier().addClickListener(clickEvent -> { if (closeOnQueryResult) { this.close(); } if (queryResultListener != null) { queryResultListener.accept(clickNotifier.getQuery()); } }); }); }); searchField.setValueChangeMode(ValueChangeMode.EAGER); searchField.setWidthFull(); results.setSizeFull(); results.setMargin(false); results.getStyle().set("overflow", "auto"); closeButton.addClickListener(event -> { searchField.clear(); close(); }); wrapper.setSizeFull(); wrapper.setAlignItems(FlexComponent.Alignment.CENTER); wrapper.setMargin(false); wrapper.setPadding(false); wrapper.setSpacing(false); wrapper.getStyle() .set("max-width", "100vw") .set("height", "100vh"); results.getStyle() .set("overflow-y", "auto") .set("max-width", "100%") .set("min-width", "40%") .set("--lumo-size-m", "var(--lumo-size-xl)") .set("--lumo-contrast-10pct", "transparent"); results.setHeightFull(); results.setWidth("unset"); add(wrapper); }
Example #16
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 #17
Source File: AbstractTwoComponentsCrudLayout.java From crudui with Apache License 2.0 | 4 votes |
public AbstractTwoComponentsCrudLayout() { Component mainLayout = buildMainLayout(); getContent().add(mainLayout); setSizeFull(); firstComponent.setMargin(false); firstComponent.setPadding(false); firstComponent.setSpacing(false); secondComponent.setMargin(true); secondComponent.setPadding(false); secondComponent.setSpacing(true); firstComponentHeaderLayout.setVisible(false); firstComponentHeaderLayout.setSpacing(true); firstComponentHeaderLayout.setMargin(false); secondComponentHeaderLayout.setVisible(false); secondComponentHeaderLayout.setSpacing(true); toolbarLayout.setVisible(false); // FIXME figure out replacement // toolbarLayout.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); addToolbarLayout(toolbarLayout); filterLayout.setVisible(false); filterLayout.setSpacing(true); filterLayout.setMargin(true); firstComponentHeaderLayout.add(filterLayout); filterLayout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.CENTER); Icon icon = VaadinIcon.SEARCH.create(); icon.getStyle().set("padding-left", "1em"); icon.setSize(".9em"); filterLayout.add(icon); mainComponentLayout.setSizeFull(); mainComponentLayout.setMargin(false); mainComponentLayout.setPadding(false); firstComponent.add(mainComponentLayout); firstComponent.expand(mainComponentLayout); formCaptionLayout.setMargin(true); formComponentLayout.setSizeFull(); formComponentLayout.setMargin(false); formComponentLayout.setPadding(false); secondComponent.add(formComponentLayout); secondComponent.expand(formComponentLayout); setFormCaption(CrudOperation.DELETE, "Are you sure you want to delete this item?"); }
Example #18
Source File: AbstractLeftAppLayoutBase.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public void setTitleComponent(Component component) { titleWrapper.replace(this.title, component); this.title = component; this.title.getElement().getStyle().set("display", "var(--app-layout-app-bar-large-object-display)"); titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); }
Example #19
Source File: WindowBasedCrudLayout.java From crudui with Apache License 2.0 | 4 votes |
public WindowBasedCrudLayout() { getContent().setPadding(false); getContent().setMargin(false); getContent().add(mainLayout); mainLayout.setSizeFull(); mainLayout.setMargin(false); mainLayout.setPadding(false); mainLayout.setSpacing(false); setSizeFull(); headerLayout.setVisible(false); headerLayout.setSpacing(true); headerLayout.setMargin(true); toolbarLayout.setVisible(false); // FIXME find out Lumo style equivalent // toolbarLayout.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); headerLayout.add(toolbarLayout); filterLayout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.CENTER); filterLayout.setVisible(false); filterLayout.setSpacing(true); headerLayout.add(filterLayout); Icon icon = VaadinIcon.SEARCH.create(); icon.setSize(".9em"); filterLayout.add(icon); mainComponentLayout.setWidth("100%"); mainComponentLayout.setHeight(null); mainComponentLayout.setMargin(false); mainComponentLayout.setPadding(false); mainComponentLayout.setId("mainComponentLayout"); mainLayout.add(mainComponentLayout); mainLayout.expand(mainComponentLayout); setWindowCaption(CrudOperation.ADD, "Add"); setWindowCaption(CrudOperation.UPDATE, "Update"); setWindowCaption(CrudOperation.DELETE, "Are you sure you want to delete this item?"); }
Example #20
Source File: AbstractLeftAppLayoutBase.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public void setIconComponent(Component appBarIconComponent) { titleWrapper.getElement().insertChild(0, appBarIconComponent.getElement()); titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); }
Example #21
Source File: TopLayouts.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public void setIconComponent(Component appBarIconComponent) { titleWrapper.getElement().insertChild(0, appBarIconComponent.getElement()); titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); }
Example #22
Source File: TopLayouts.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public TopLarge() { contentPanel.setSizeFull(); paperTabWrapper.getElement().getStyle() .set("flex-grow", "1") .set("flex-shrink", "1") .set("align-self", "flex-end"); paperTabWrapper.setWidthFull(); paperTabWrapper.setHeight("var(--app-layout-bar-height)"); paperTabWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER); getElement().getClassList().addAll(Arrays.asList("app-layout-behaviour-" + getStyleName(), "app-layout")); appBar.add(titleWrapper, appBarElementWrapper); appBar.setFlexGrow(1.0, titleWrapper); appBar.setWidthFull(); appBar.setHeightFull(); appBarWrapper.add(appBar, paperTabWrapper); appBarWrapper.setMargin(false); appBarWrapper.setPadding(false); appBarWrapper.setSpacing(false); appBarElements = new Div(); appBarElements.setHeightFull(); appBarElements.getElement().setAttribute("slot", "app-bar-content"); contentElement = new Div(); contentElement.setHeightFull(); contentElement.setWidthFull(); contentElement.getElement().setAttribute("slot", "application-content"); appBarElements.add(appBarWrapper); appBarElementWrapper.setSpacing(false); appBarElementWrapper.add(appBarElementContainer); appBarElementContainer.setHeightFull(); appBarElementWrapper.setAlignItems(FlexComponent.Alignment.START); titleWrapper.setHeightFull(); titleWrapper.setWidthFull(); titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); titleWrapper.setHeight("var(--app-layout-bar-height)"); appBarElementWrapper.setAlignItems(FlexComponent.Alignment.START); appBarElementWrapper.setHeight("var(--app-layout-bar-height)"); menuButton.setIcon(VaadinIcon.ARROW_LEFT.create()); menuButton.addThemeNames(ButtonVariant.LUMO_TERTIARY.getVariantName(), ButtonVariant.LUMO_ICON.getVariantName(), ButtonVariant.LUMO_LARGE.getVariantName()); getElement().appendChild(appBarElements.getElement(), contentElement.getElement()); }
Example #23
Source File: TopLayouts.java From vaadin-app-layout with Apache License 2.0 | 4 votes |
public void setTitleComponent(Component component) { titleWrapper.add(new HorizontalLayout(component)); this.title = component; titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER); }
Example #24
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 #25
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 #26
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"); }
Example #27
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); }
Example #28
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 #29
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); }