public ColumnModel<Integer> buildColumnModel() { ColumnModel<Integer> cm = new ColumnModel<>(columnConfigs); for (HeaderGroupConfig headerGroupConfig : headerGroupConfigs) { cm.addHeaderGroup(headerGroupConfig.getRow(), headerGroupConfig.getColumn(), headerGroupConfig); } return cm; }
public void maybeUpdateSortingView(List<SortModel> sorting) { if(!currentSorting.equals(sorting)) { ColumnModel<Integer> columnModel = grid.getColumnModel(); ColumnHeader<Integer> tableHeading = grid.getView().getHeader(); if (sorting.isEmpty()) { tableHeading.updateSortIcon(-1, SortDir.ASC); } else { SortModel sortModel = sorting.get(0); for (int i = 0; i < columnModel.getColumnCount(); i++) { String path = columnModel.getValueProvider(i).getPath(); if (path.equals(sortModel.getField())) { tableHeading.updateSortIcon(i, sortModel.getDir() == org.activityinfo.model.query.SortDir.ASC ? SortDir.ASC : SortDir.DESC); break; } } } currentSorting = sorting; } }
private ColumnModel<Point> buildColumnModel(DimensionSet dimensionSet) { List<ColumnConfig<Point, ?>> columns = new ArrayList<>(); for (int i = 0; i < dimensionSet.getCount(); i++) { ColumnConfig<Point, String> column = new ColumnConfig<>(new PointDimProvider(i)); column.setHeader(dimensionSet.getDimension(i).getLabel()); column.setSortable(false); column.setHideable(false); columns.add(column); } ColumnConfig<Point, Double> valueColumn = new ColumnConfig<>(new PointValueProvider()); valueColumn.setHeader(I18N.CONSTANTS.value()); valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LOCALE_END); valueColumn.setSortable(false); valueColumn.setHideable(false); columns.add(valueColumn); return new ColumnModel<>(columns); }
private int addHeaderGroups(ColumnModel<PivotRow> cm, PivotTable.Node parent, int row, int col) { int leafCount = parent.getLeaves().size(); // Add one group for the name of this Dimension cm.addHeaderGroup(row, col, new HeaderGroupConfig(parent.getDimension().getLabel(), 1, leafCount)); for (PivotTable.Node child : parent.getChildren()) { if (child.isLeaf()) { col++; } else { cm.addHeaderGroup(row + 1, col, new HeaderGroupConfig(child.getCategoryLabel(), 1, child.getLeaves().size())); col = addHeaderGroups(cm, child, row + 2, col); } } return col; }
private void changeColumnWidth(ColumnResizeEvent e) { ColumnConfig<Integer, Object> column = grid.getColumnModel().getColumn(e.getColumnIndex()); LOGGER.info("Column " + column.getValueProvider().getPath() + " resized to " + e.getColumnWidth() + "px"); tableUpdater.updateColumnWidth(column.getValueProvider().getPath(), e.getColumnWidth()); }
@Override protected void doSort(int colIndex, SortDir sortDir) { String field = grid.getColumnModel().getValueProvider(colIndex).getPath(); org.activityinfo.model.query.SortDir dir; // sortDir is null if the column header is clicked to // toggle the sort direction if(sortDir == null) { if(isFieldSortedAscending(field)) { dir = org.activityinfo.model.query.SortDir.DESC; } else { dir = org.activityinfo.model.query.SortDir.ASC; } } else if(sortDir == SortDir.ASC) { dir = org.activityinfo.model.query.SortDir.ASC; } else { dir = org.activityinfo.model.query.SortDir.DESC; } fireEvent(new SortChangeEvent(field, dir)); }
/** * Creates a context menu for the given column, including sort menu items and column visibility sub-menu. * * @param colIndex the column index * @return the context menu for the given column */ protected Menu createContextMenu(final int colIndex) { final Menu menu = new Menu(); if (cm.isSortable(colIndex)) { MenuItem item = new MenuItem(); item.setText(DefaultMessages.getMessages().gridView_sortAscText()); item.setIcon(header.getAppearance().sortAscendingIcon()); item.addSelectionHandler(event -> doSort(colIndex, SortDir.ASC)); menu.add(item); item = new MenuItem(); item.setText(DefaultMessages.getMessages().gridView_sortDescText()); item.setIcon(header.getAppearance().sortDescendingIcon()); item.addSelectionHandler(event -> doSort(colIndex, SortDir.DESC)); menu.add(item); item = new MenuItem(); item.setText(I18N.CONSTANTS.clearSort()); item.addSelectionHandler(event -> fireEvent(new SortChangeEvent())); menu.add(item); } return menu; }
ColumnModel<PivotRow> columnModel = new ColumnModel<>(columns);