Search in sources :

Example 41 with Grid

use of com.vaadin.flow.component.grid.Grid in project docs by vaadin.

the class DialogResizable method createDialogLayout.

private static VerticalLayout createDialogLayout() {
    Grid<Person> grid = new Grid<>(Person.class, false);
    grid.addColumn(Person::getFirstName).setHeader("First name");
    grid.addColumn(Person::getLastName).setHeader("Last name");
    grid.addColumn(Person::getEmail).setHeader("Email");
    grid.addColumn(Person::getProfession).setHeader("Profession");
    grid.addColumn(Person::getMembership).setHeader("Membership");
    List<Person> people = DataService.getPeople();
    grid.setItems(people);
    VerticalLayout dialogLayout = new VerticalLayout(grid);
    dialogLayout.setPadding(false);
    dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
    dialogLayout.getStyle().set("min-width", "300px").set("max-width", "100%").set("height", "100%");
    return dialogLayout;
}
Also used : Grid(com.vaadin.flow.component.grid.Grid) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Person(com.vaadin.demo.domain.Person)

Example 42 with Grid

use of com.vaadin.flow.component.grid.Grid in project WebComponentKit by itsoulltd.

the class AbstractJsqlDataSource method prepareGridUI.

@Override
public GridDataSource prepareGridUI(Grid<E> grid) {
    super.prepareGridUI(grid);
    updateCellFooter(grid);
    int length = grid.getColumns().size();
    Grid.Column last = grid.getColumns().get(length - 1);
    HorizontalLayout buttonCell = new HorizontalLayout(new Button(" < ", previousAction), new Button(" > ", nextAction));
    buttonCell.setPadding(false);
    buttonCell.setSpacing(true);
    buttonCell.setSizeFull();
    buttonCell.setAlignItems(FlexComponent.Alignment.CENTER);
    last.setFooter(buttonCell);
    return this;
}
Also used : Button(com.vaadin.flow.component.button.Button) Grid(com.vaadin.flow.component.grid.Grid) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 43 with Grid

use of com.vaadin.flow.component.grid.Grid in project aire-components by aire-ux.

the class ModuleGridTest method ensureModuleGridHasCorrectLayout.

@ViewTest
void ensureModuleGridHasCorrectLayout(@Context TestContext context, @Context Instantiator instantiator) {
    val grid = instantiator.createComponent(ModuleGrid.class);
    val $ = context.downTo(grid);
    val columns = $.select(Grid.Column.class);
    assertEquals(columns.size(), 5);
}
Also used : lombok.val(lombok.val) Grid(com.vaadin.flow.component.grid.Grid) ViewTest(com.aire.ux.test.ViewTest)

Example 44 with Grid

use of com.vaadin.flow.component.grid.Grid 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)

Example 45 with Grid

use of com.vaadin.flow.component.grid.Grid in project furms by unity-idm.

the class CommunityAllocationComponent method createCommunityGrid.

private Grid<CommunityAllocationGridModel> createCommunityGrid() {
    Grid<CommunityAllocationGridModel> grid = new DenseGrid<>(CommunityAllocationGridModel.class);
    grid.addComponentColumn(model -> {
        Icon icon = grid.isDetailsVisible(model) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create();
        return new Div(icon, new Text(model.siteName));
    }).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.1")).setSortable(true);
    grid.addComponentColumn(model -> new RouterLink(model.name, CommunityAllocationFormView.class, model.id)).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.2")).setSortable(true).setComparator(model -> model.name.toLowerCase());
    grid.addColumn(model -> model.resourceCreditName).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.3")).setSortable(true);
    grid.addColumn(model -> model.resourceTypeName).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.4")).setSortable(true);
    grid.addColumn(model -> model.amountWithUnit).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.5")).setSortable(true).setComparator(comparing(model -> model.amountWithUnit.amount));
    grid.addColumn(model -> model.distributedWithUnit).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.6")).setSortable(true).setComparator(comparing(model -> model.distributedWithUnit.amount));
    grid.addColumn(model -> model.remainingWithUnit).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.7")).setSortable(true).setComparator(comparing(model -> model.remainingWithUnit.amount));
    grid.addComponentColumn(model -> new ResourceProgressBar(model.amountWithUnit.amount, model.consumed, 0)).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.8")).setComparator(comparing(model -> model.consumed));
    grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.fenix-admin.resource-credits-allocation.grid.column.9")).setTextAlign(ColumnTextAlign.END);
    grid.setItemDetailsRenderer(new ComponentRenderer<>(model -> AllocationDetailsComponentFactory.create(model.creationTime, model.validFrom, model.validTo)));
    return grid;
}
Also used : Div(com.vaadin.flow.component.html.Div) VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Component(com.vaadin.flow.component.Component) Composite(com.vaadin.flow.component.Composite) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) Div(com.vaadin.flow.component.html.Div) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) CommunityAllocationService(io.imunity.furms.api.community_allocation.CommunityAllocationService) DenseGrid(io.imunity.furms.ui.components.DenseGrid) RouterLink(com.vaadin.flow.router.RouterLink) SPLINE_CHART(com.vaadin.flow.component.icon.VaadinIcon.SPLINE_CHART) UI(com.vaadin.flow.component.UI) ANGLE_RIGHT(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_RIGHT) Comparator.comparing(java.util.Comparator.comparing) Icon(com.vaadin.flow.component.icon.Icon) Text(com.vaadin.flow.component.Text) VaadinExceptionHandler.getResultOrException(io.imunity.furms.ui.utils.VaadinExceptionHandler.getResultOrException) AllocationDetailsComponentFactory(io.imunity.furms.ui.components.AllocationDetailsComponentFactory) Grid(com.vaadin.flow.component.grid.Grid) TRASH(com.vaadin.flow.component.icon.VaadinIcon.TRASH) EDIT(com.vaadin.flow.component.icon.VaadinIcon.EDIT) RouterGridLink(io.imunity.furms.ui.components.RouterGridLink) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar) ANGLE_DOWN(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_DOWN) Button(com.vaadin.flow.component.button.Button) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) Dialog(com.vaadin.flow.component.dialog.Dialog) Collections(java.util.Collections) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) RouterLink(com.vaadin.flow.router.RouterLink) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Text(com.vaadin.flow.component.Text) Icon(com.vaadin.flow.component.icon.Icon) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar)

Aggregations

Grid (com.vaadin.flow.component.grid.Grid)73 Route (com.vaadin.flow.router.Route)41 Div (com.vaadin.flow.component.html.Div)38 List (java.util.List)26 NativeButton (com.vaadin.flow.component.html.NativeButton)22 Person (com.vaadin.flow.data.bean.Person)22 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)21 H2 (com.vaadin.flow.component.html.H2)17 Collections (java.util.Collections)16 Button (com.vaadin.flow.component.button.Button)15 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)14 ArrayList (java.util.ArrayList)13 Collectors (java.util.stream.Collectors)13 Component (com.vaadin.flow.component.Component)12 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)12 Column (com.vaadin.flow.component.grid.Grid.Column)12 Label (com.vaadin.flow.component.html.Label)12 Span (com.vaadin.flow.component.html.Span)11 TextField (com.vaadin.flow.component.textfield.TextField)10 DenseGrid (io.imunity.furms.ui.components.DenseGrid)10