use of com.vaadin.flow.component.grid.Grid in project furms by unity-idm.
the class ProjectsView method createProjectGrid.
private Grid<ProjectGridModel> createProjectGrid() {
Grid<ProjectGridModel> grid = new DenseGrid<>(ProjectGridModel.class);
Grid.Column<ProjectGridModel> firstColumn = grid.addComponentColumn(project -> {
Component component = new Span(project.name);
if (project.status.equals(ACTIVE))
component = new RouterLink(project.name, ProjectView.class, project.id);
return component;
}).setHeader(getTranslation("view.user-settings.projects.grid.column.1")).setSortable(true).setComparator(comparing(project -> project.name)).setComparator(project -> project.name.toLowerCase());
grid.addColumn(project -> project.description).setHeader(getTranslation("view.user-settings.projects.grid.column.2")).setSortable(true);
grid.addColumn(project -> getTranslation(project.status.gridText)).setHeader(getTranslation("view.user-settings.projects.grid.column.3")).setTextAlign(ColumnTextAlign.END).setSortable(true);
grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.user-settings.projects.grid.column.4")).setTextAlign(ColumnTextAlign.END);
grid.sort(ImmutableList.of(new GridSortOrder<>(firstColumn, SortDirection.ASCENDING)));
return grid;
}
use of com.vaadin.flow.component.grid.Grid in project furms by unity-idm.
the class PendingRequestsView method createPendingMessagesGrid.
private Grid<PendingMessageGridModel> createPendingMessagesGrid(Map<CorrelationId, Checkbox> checkboxes, Component mainContextMenu) {
Grid<PendingMessageGridModel> grid;
grid = new DenseGrid<>(PendingMessageGridModel.class);
grid.addComponentColumn(pendingMessageGridModel -> {
Checkbox checkbox = new Checkbox();
checkboxes.put(pendingMessageGridModel.id, checkbox);
HorizontalLayout horizontalLayout = new HorizontalLayout(checkbox, grid.isDetailsVisible(pendingMessageGridModel) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create(), new Paragraph(getTranslationOrDefault("view.site-admin.pending-requests.page.grid.operation-type." + pendingMessageGridModel.operationType, pendingMessageGridModel.operationType)));
horizontalLayout.setAlignItems(CENTER);
return horizontalLayout;
}).setHeader(new HorizontalLayout(mainContextMenu, new Label(getTranslation("view.site-admin.pending-requests.page.grid.1")))).setFlexGrow(2);
grid.addColumn(model -> model.status).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.2")).setSortable(true);
grid.addColumn(model -> model.sentAt.format(dateTimeFormatter)).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.3")).setSortable(true);
grid.addColumn(model -> Optional.ofNullable(model.ackAt).map(ackTime -> ackTime.format(dateTimeFormatter)).orElse("")).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.4")).setSortable(true);
grid.addColumn(model -> model.retryAmount).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.5")).setSortable(true);
grid.addComponentColumn(this::createContextMenu).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.6")).setTextAlign(ColumnTextAlign.END);
grid.setItemDetailsRenderer(new ComponentRenderer<>(data -> {
Paragraph json = new Paragraph(data.json);
json.getStyle().set("font-family", "monospace");
json.getStyle().set("word-wrap", "break-word");
json.getElement().getStyle().set("white-space", "pre-wrap");
return json;
}));
return grid;
}
use of com.vaadin.flow.component.grid.Grid in project furms by unity-idm.
the class InvitationsView method createInvitationGrid.
private Grid<InvitationGridModel> createInvitationGrid(Map<InvitationId, Checkbox> checkboxes, Component mainContextMenu) {
final Grid<InvitationGridModel> grid;
grid = new DenseGrid<>(InvitationGridModel.class);
grid.addComponentColumn(invitationGridModel -> {
Checkbox checkbox = new Checkbox();
checkboxes.put(invitationGridModel.id, checkbox);
return new HorizontalLayout(checkbox, new Label(invitationGridModel.resourceName));
}).setHeader(new HorizontalLayout(mainContextMenu, new Label(getTranslation("view.user-settings.invitations.grid.1"))));
grid.addColumn(x -> x.role).setHeader(getTranslation("view.user-settings.invitations.grid.2")).setSortable(true);
grid.addColumn(x -> x.originator).setHeader(getTranslation("view.user-settings.invitations.grid.3")).setSortable(true);
grid.addColumn(x -> x.expiration.format(dateTimeFormatter)).setHeader(getTranslation("view.user-settings.invitations.grid.4")).setSortable(true);
grid.addComponentColumn(x -> createContextMenu(x.id)).setHeader(getTranslation("view.user-settings.invitations.grid.5")).setTextAlign(ColumnTextAlign.END);
return grid;
}
use of com.vaadin.flow.component.grid.Grid in project linkki by linkki-framework.
the class TestUiUtil method getColumnHeaders.
public static List<String> getColumnHeaders(Grid<?> grid) {
Method getHeaderRendererMethod;
Field templateField;
try {
getHeaderRendererMethod = Column.class.getSuperclass().getDeclaredMethod("getHeaderRenderer");
getHeaderRendererMethod.setAccessible(true);
templateField = Renderer.class.getDeclaredField("template");
templateField.setAccessible(true);
} catch (NoSuchMethodException | NoSuchFieldException | SecurityException | IllegalArgumentException e) {
throw new RuntimeException(e);
}
return grid.getColumns().stream().map(c -> getColumnHeader(c, getHeaderRendererMethod, templateField)).collect(Collectors.toList());
}
use of com.vaadin.flow.component.grid.Grid in project docs by vaadin.
the class GridDynamicHeight method setupGrid.
private void setupGrid() {
// tag::snippet[]
grid = new Grid<>(Person.class, false);
grid.setAllRowsVisible(true);
// end::snippet[]
grid.addColumn(Person::getFullName).setHeader("Name");
grid.addColumn(Person::getEmail).setHeader("Email");
grid.addColumn(person -> person.getAddress().getPhone()).setHeader("Phone");
grid.addColumn(new ComponentRenderer<>(Button::new, (button, person) -> {
button.addThemeVariants(ButtonVariant.LUMO_ICON, ButtonVariant.LUMO_ERROR, ButtonVariant.LUMO_TERTIARY);
button.addClickListener(e -> this.removeInvitation(person));
button.setIcon(new Icon(VaadinIcon.TRASH));
})).setHeader("Manage");
grid.setItems(invitedPeople);
hint = new Div();
hint.setText("No invitation has been sent");
hint.getStyle().set("padding", "var(--lumo-size-l)").set("text-align", "center").set("font-style", "italic").set("color", "var(--lumo-contrast-70pct)");
add(hint, grid);
}
Aggregations