assert displayIndex != -1 : "Tried to remove a column which is not included in columnOrder. This should not be possible as all columns should be in columnOrder."; columnKeys.remove(columnId); columnIds.remove(column.getId()); column.remove(); removeDataGenerator(column.getDataGenerator()); + column.getId() + " cannot be removed from the grid");
"Editor component cannot be null"); String propertyName = getId(); if (propertyName == null) { throw new IllegalStateException(
@Override public List<P> getPropertyColumns() { List<Column<T, ?>> columns = getGrid().getColumns(); if (columns != null && !columns.isEmpty()) { List<P> properties = new ArrayList<>(columns.size()); for (Column<T, ?> column : columns) { properties.add(getColumnProperty(column.getId())); } return properties; } return Collections.emptyList(); }
while (it.hasNext()) { Grid.Column c = it.next(); String columnId = c.getId(); if (!Arrays.asList(getVisibleColumns()).contains(columnId)) { grid.removeColumn(columnId);
GridSortOrder<E> sortOrder = sortOrders.get(0); columnsElem.addAttribute("sortColumnId", sortOrder.getSorted().getId()); columnsElem.addAttribute("sortDirection", sortOrder.getDirection().toString());
protected void setupGridColumnProperties(Grid.Column<E, ?> gridColumn, Column<E> column) { if (gridColumn.getId() == null) { gridColumn.setId(column.getId()); } else if (!Objects.equals(gridColumn.getId(), column.getId())) { log.warn("Trying to copy column settings with mismatched ids. Grid.Column: " + gridColumn.getId() + "; DataGrid.Column: " + column.getId());
/** * Sets the I18N values for the Grid itself, and also iterates the columns for column ids which are I18NKeys, and translates those as well * * @param grid the Grid to process * @param annotationValues the annotation values to apply * @param annotationInfo used primarily to identify the Field, and therefore its name */ protected void processGrid(Grid grid, AnnotationValues annotationValues, AnnotationInfo annotationInfo) { // do the grid itself applyAnnotationValues(grid, annotationValues, annotationInfo); // now do the column headers Locale locale = annotationValues.locale.isPresent() ? annotationValues.locale.get() : currentLocale.getLocale(); final List<Grid.Column> columns = grid.getColumns(); I18NKeyConverter converter = new I18NKeyConverter(); for (Grid.Column column : columns) { try { I18NKey columnKey = converter.convertToModel(column.getId()); String header = translate.from(columnKey, locale); column.setCaption(header); } catch (Exception e) { log.debug("Column id {} is not an I18NKey", column.getId()); } } }
protected boolean isSortPropertySettingsChanged(String settingsSortColumnId, String settingsSortDirection) { List<GridSortOrder<E>> sortOrders = component.getSortOrder(); String columnId = null; String sortDirection = null; if (!sortOrders.isEmpty()) { GridSortOrder<E> sortOrder = sortOrders.get(0); columnId = sortOrder.getSorted().getId(); sortDirection = sortOrder.getDirection().toString(); } if (!Objects.equals(columnId, settingsSortColumnId) || !Objects.equals(sortDirection, settingsSortDirection)) { return true; } return false; }
protected void removeColumnId(Grid.Column<E, ?> gridColumn) { component.removeColumnId(gridColumn.getId()); }
/** * Adds a {@link PropertyVisibilityListener} that gets notified when a property column is hidden or shown. * @param listener Listener to add (not null) * @return the listener registration */ public Registration addPropertyVisibilityListener(final PropertyVisibilityListener<P> listener) { ObjectUtils.argumentNotNull(listener, "Listener must be not null"); return getGrid().addColumnVisibilityChangeListener(e -> listener.onPropertyVisibilityChanged( getColumnProperty(e.getColumn().getId()), e.isHidden(), e.isUserOriginated())); }
/** * Adds a {@link PropertyResizeListener} that gets notified when a property column is resized. * @param listener Listener to add (not null) * @return the listener registration */ public Registration addPropertyResizeListener(final PropertyResizeListener<P> listener) { ObjectUtils.argumentNotNull(listener, "Listener must be not null"); return getGrid() .addColumnResizeListener(e -> listener.onPropertyResized(getColumnProperty(e.getColumn().getId()), (int) e.getColumn().getWidth(), e.isUserOriginated())); }
@Override public String getId() { if (gridColumn != null) { return gridColumn.getId(); } return id; }
public BiPredicate<Grid.Column, T> getCellEditorAvailability() { return (column, item) -> getColumns().keySet().stream() .filter(columnDefinition -> StringUtils.equals(columnDefinition.getName(), column.getId())) .findFirst() .map(columnDefinition -> actionExecutionService.getAvailabilityFilter(SelectedItems.of(item)).test(columnDefinition.getEditor().getAvailability())) .orElse(false); } }
/** * Add an {@link ItemClickListener} to be notified when user clicks on an item row. * @param listener Listener to add (not null) * @return the listener registration */ public Registration addItemClickListener(final ItemClickListener<T, P> listener) { ObjectUtils.argumentNotNull(listener, "Listener must be not null"); return getGrid().addItemClickListener(e -> listener.onItemClick(e.getItem(), getColumnProperty(e.getColumn().getId()), e.getRowIndex(), e.getMouseEventDetails())); }
@Override protected void doWriteDesign(Element design, DesignContext designContext) { super.doWriteDesign(design, designContext); if (getColumnByInternalId(getState(false).hierarchyColumnId) != null) { String hierarchyColumn = getColumnByInternalId( getState(false).hierarchyColumnId).getId(); DesignAttributeHandler.writeAttribute("hierarchy-column", design.attributes(), hierarchyColumn, null, String.class, designContext); } }