Search in sources :

Example 31 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project komunumo-server by komunumo.

the class SponsorsView method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(TemplateRenderer.<SponsorEntity>of("<a style=\"font-weight: bold;\" href=\"[[item.website]]\" target=\"_blank\">[[item.name]]</a>").withProperty("name", SponsorEntity::name).withProperty("website", SponsorEntity::website)).setHeader("Name").setAutoWidth(true).setFlexGrow(1);
    grid.addColumn(TemplateRenderer.<SponsorEntity>of("<img style=\"max-width: 100%;\" src=\"[[item.logo]]\" /></span>").withProperty("logo", SponsorEntity::logo)).setHeader("Logo").setWidth("96px").setFlexGrow(0);
    grid.addColumn(SponsorEntity::level).setHeader("Level").setAutoWidth(true);
    grid.addColumn(sponsorEntity -> formatDate(sponsorEntity.validFrom())).setHeader("Valid from").setAutoWidth(true).setFlexGrow(0).setKey("validFrom");
    grid.addColumn(sponsorEntity -> formatDate(sponsorEntity.validTo())).setHeader("Valid to").setAutoWidth(true).setFlexGrow(0).setKey("validTo");
    grid.addColumn(new ComponentRenderer<>(sponsorEntity -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showSponsorDialog(sponsorEntity));
        editButton.setTitle("Edit this sponsor");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteSponsor(sponsorEntity));
        deleteButton.setTitle("Delete this sponsor");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) SponsorEntity(org.komunumo.data.entity.SponsorEntity) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 32 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project komunumo-server by komunumo.

the class KeywordsView method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(KeywordListEntity::keyword).setHeader("Keyword").setAutoWidth(true).setFlexGrow(0).setKey("keyword");
    grid.addColumn(KeywordListEntity::eventCount).setHeader("Events").setAutoWidth(true).setTextAlign(ColumnTextAlign.CENTER).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(keyword -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showKeywordDialog(keyword));
        editButton.setTitle("Edit this keyword");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteKeyword(keyword));
        deleteButton.setTitle("Delete this keyword");
        deleteButton.setEnabled(keyword.eventCount() == 0);
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : KeywordListEntity(org.komunumo.data.entity.KeywordListEntity) EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 33 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project komunumo-server by komunumo.

the class ConfigurationSetting method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(ConfigurationRecord::getKey).setHeader("Key").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(ConfigurationRecord::getValue).setHeader("Value").setAutoWidth(false).setFlexGrow(1);
    grid.addColumn(new ComponentRenderer<>(configurationRecord -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showEditDialog(configurationRecord));
        editButton.setTitle("Edit this configuration setting");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteConfiguration(configurationRecord));
        deleteButton.setTitle("Delete this configuration setting");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 34 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project karnak by OsiriX-Foundation.

the class DicomEchoSelectionDialog method buildDicomNodeRenderer.

private ComponentRenderer<Div, ConfigNode> buildDicomNodeRenderer() {
    return new ComponentRenderer<>(item -> {
        Div div = new Div();
        div.getStyle().set("line-height", "92%");
        Span spanDescription = new Span(item.getName());
        spanDescription.getStyle().set("font-weight", "500");
        HtmlComponent htmlLineBreak = new HtmlComponent("BR");
        Span spanOtherAttributes = new Span(item.getAet() + " | " + item.getHostname() + " | " + item.getPort());
        spanOtherAttributes.getStyle().set("font-size", "75%");
        div.add(spanDescription, htmlLineBreak, spanOtherAttributes);
        return div;
    });
}
Also used : Div(com.vaadin.flow.component.html.Div) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) HtmlComponent(com.vaadin.flow.component.HtmlComponent) Span(com.vaadin.flow.component.html.Span)

Example 35 with ComponentRenderer

use of com.vaadin.flow.data.renderer.ComponentRenderer in project furms by unity-idm.

the class AuditLogView method createCommunityGrid.

private Grid<AuditLogGridModel> createCommunityGrid() {
    Grid<AuditLogGridModel> grid = new DenseGrid<>(AuditLogGridModel.class);
    Column<AuditLogGridModel> timestamp = grid.addComponentColumn(model -> {
        if (model.data.isEmpty())
            return new Div(new Label(model.timestamp.format(dateTimeFormatter)));
        Icon icon = grid.isDetailsVisible(model) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create();
        return new Div(icon, new Label(model.timestamp.format(dateTimeFormatter)));
    }).setHeader(getTranslation("view.fenix-admin.audit-log.grid.1")).setSortable(true).setComparator(model -> model.timestamp);
    grid.addColumn(model -> model.originator).setHeader(getTranslation("view.fenix-admin.audit-log.grid.2")).setSortable(true).setComparator(model -> model.originator);
    grid.addColumn(model -> getTranslation("view.fenix-admin.audit-log.operation." + model.operation)).setHeader(getTranslation("view.fenix-admin.audit-log.grid.3")).setSortable(true).setComparator(comparing(model -> model.operation));
    grid.addColumn(model -> getTranslation("view.fenix-admin.audit-log.action." + model.action)).setHeader(getTranslation("view.fenix-admin.audit-log.grid.4")).setSortable(true).setComparator(comparing(model -> model.action));
    grid.addColumn(model -> model.name).setHeader(getTranslation("view.fenix-admin.audit-log.grid.5")).setSortable(true).setComparator(comparing(model -> model.name));
    grid.addColumn(model -> model.id).setHeader(getTranslation("view.fenix-admin.audit-log.grid.6")).setSortable(true).setComparator(comparing(model -> model.id));
    grid.sort(ImmutableList.of(new GridSortOrder<>(timestamp, SortDirection.DESCENDING)));
    grid.setItemDetailsRenderer(new ComponentRenderer<>(c -> AuditLogDetailsComponentFactory.create(c.data)));
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    return grid;
}
Also used : ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) UTCTimeUtils.convertToZoneTime(io.imunity.furms.utils.UTCTimeUtils.convertToZoneTime) SortDirection(com.vaadin.flow.data.provider.SortDirection) ZonedDateTime(java.time.ZonedDateTime) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) Div(com.vaadin.flow.component.html.Div) Label(com.vaadin.flow.component.html.Label) HashMap(java.util.HashMap) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) AuditLogService(io.imunity.furms.api.audit_log.AuditLogService) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) ImmutableList(com.google.common.collect.ImmutableList) DenseGrid(io.imunity.furms.ui.components.DenseGrid) MultiselectComboBox(org.vaadin.gatanaso.MultiselectComboBox) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Map(java.util.Map) Operation(io.imunity.furms.domain.audit_log.Operation) ANGLE_RIGHT(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_RIGHT) Comparator.comparing(java.util.Comparator.comparing) TypeReference(com.fasterxml.jackson.core.type.TypeReference) UserService(io.imunity.furms.api.users.UserService) Icon(com.vaadin.flow.component.icon.Icon) Action(io.imunity.furms.domain.audit_log.Action) Grid(com.vaadin.flow.component.grid.Grid) UIContext(io.imunity.furms.ui.user_context.UIContext) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Set(java.util.Set) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) AuditLogDetailsComponentFactory(io.imunity.furms.ui.components.AuditLogDetailsComponentFactory) FURMSUser(io.imunity.furms.domain.users.FURMSUser) SearchLayout(io.imunity.furms.ui.components.administrators.SearchLayout) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) ANGLE_DOWN(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_DOWN) GridSortOrder(com.vaadin.flow.component.grid.GridSortOrder) FurmsDateTimePicker(io.imunity.furms.ui.components.FurmsDateTimePicker) FenixAdminMenu(io.imunity.furms.ui.views.fenix.menu.FenixAdminMenu) Column(com.vaadin.flow.component.grid.Grid.Column) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) DateTimeFormatter(java.time.format.DateTimeFormatter) Div(com.vaadin.flow.component.html.Div) GridSortOrder(com.vaadin.flow.component.grid.GridSortOrder) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Label(com.vaadin.flow.component.html.Label) Icon(com.vaadin.flow.component.icon.Icon)

Aggregations

ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)49 Div (com.vaadin.flow.component.html.Div)33 Route (com.vaadin.flow.router.Route)30 Grid (com.vaadin.flow.component.grid.Grid)23 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)20 List (java.util.List)19 Icon (com.vaadin.flow.component.icon.Icon)18 NativeButton (com.vaadin.flow.component.html.NativeButton)14 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)14 TemplateRenderer (com.vaadin.flow.data.renderer.TemplateRenderer)14 Collectors (java.util.stream.Collectors)14 Label (com.vaadin.flow.component.html.Label)13 Span (com.vaadin.flow.component.html.Span)12 EnhancedButton (org.komunumo.ui.component.EnhancedButton)12 Component (com.vaadin.flow.component.Component)10 H2 (com.vaadin.flow.component.html.H2)10 ArrayList (java.util.ArrayList)10 Element (com.vaadin.flow.dom.Element)9 Collections (java.util.Collections)9 UI (com.vaadin.flow.component.UI)8