/** * Mark a cell as containing the magical "otherwise" value. The magical "otherwise" value has the * meaning of all values other than those explicitly defined for this column. */ public void makeOtherwiseCell() { MergableGridWidget<DTColumnConfig> grid = widget.getGridWidget(); List<CellValue<?>> selections = grid.getSelectedCells(); CellValue<?> cell = selections.get(0); if (canAcceptOtherwiseValues(cell)) { // Set "otherwise" property on cell for (CellValue<?> cv : selections) { cv.addState(CellState.OTHERWISE); } grid.update(null); } }
/** * Check whether the given Cell can accept "otherwise" values * * @param cell * @return true if the Cell can accept "otherwise" values */ protected boolean canAcceptOtherwiseValues(CellValue<?> cell) { Coordinate c = cell.getCoordinate(); MergableGridWidget<DTColumnConfig> grid = widget.getGridWidget(); DynamicColumn<DTColumnConfig> column = grid.getColumns().get(c.getCol()); return canAcceptOtherwiseValues(column.getModelColumn()); }