HeaderSingleCellSelectionStrategy extends BaseCellSelectionStrategy { @Override public boolean handleSelection(final GridData model, final int uiHeaderRowIndex, final int uiHeaderColumnIndex, final boolean isShiftKeyDown, final boolean isControlKeyDown) { final List<GridData.SelectedCell> originalSelections = new ArrayList<>(model.getSelectedHeaderCells()); final List<GridColumn<?>> gridColumns = model.getColumns(); final List<GridColumn.HeaderMetaData> headerMetaData = gridColumns.get(uiHeaderColumnIndex).getHeaderMetaData(); final int blockStartColumnIndex = ColumnIndexUtilities.getHeaderBlockStartColumnIndex(gridColumns, headerMetaData.get(uiHeaderRowIndex), uiHeaderRowIndex, uiHeaderColumnIndex); final int blockEndColumnIndex = ColumnIndexUtilities.getHeaderBlockEndColumnIndex(gridColumns, headerMetaData.get(uiHeaderRowIndex), uiHeaderRowIndex, uiHeaderColumnIndex); model.clearSelections(); IntStream.range(blockStartColumnIndex, blockEndColumnIndex + 1) .forEach(blockColumnIndex -> model.selectHeaderCell(uiHeaderRowIndex, blockColumnIndex)); return hasSelectionChanged(model.getSelectedHeaderCells(), originalSelections); }  @Override boolean handleSelection(final GridData model,
                                   final int uiHeaderRowIndex,
                                   final int uiHeaderColumnIndex,
                                   final boolean isShiftKeyDown,
                                   final boolean isControlKeyDown); static CellSelectionStrategy INSTANCE; }
@Test public void testSingleHeaderCell() { assertTrue(strategy.handleSelection(uiModel, 0, 0, false, false)); assertCellSelections(0, 0, 1); assertTrue(strategy.handleSelection(uiModel, 0, 1, false, false)); assertCellSelections(0, 1, 1); }
@Test public void testBlockHeaderCell() { final GridColumn<?> gc3 = new BaseGridTest.MockMergableGridColumn<>("col3", 100); final GridColumn<?> gc4 = new BaseGridTest.MockMergableGridColumn<>("col4", 100); uiModel.appendColumn(gc3); uiModel.appendColumn(gc4); gc1.getHeaderMetaData().set(0, gc2.getHeaderMetaData().get(0)); gc3.getHeaderMetaData().set(0, gc4.getHeaderMetaData().get(0)); assertTrue(strategy.handleSelection(uiModel, 0, 0, false, false)); assertCellSelections(0, 0, 2); assertTrue(strategy.handleSelection(uiModel, 0, 2, false, false)); assertCellSelections(0, 2, 2); }