BaseCellSelectionManager implements CellSelectionManager { @Override public boolean selectHeaderCell(final Point2D rp, final boolean isShiftKeyDown, final boolean isControlKeyDown) { final Integer uiHeaderRowIndex = CoordinateUtilities.getUiHeaderRowIndex(gridWidget, rp); final Integer uiHeaderColumnIndex = CoordinateUtilities.getUiColumnIndex(gridWidget, rp.getX()); if (uiHeaderRowIndex == null || uiHeaderColumnIndex == null) { return false; } return selectHeaderCell(uiHeaderRowIndex, uiHeaderColumnIndex, isShiftKeyDown, isControlKeyDown); } BaseCellSelectionManager(final GridWidget gridWidget); @Override boolean selectCell(final Point2D rp,
                              final boolean isShiftKeyDown,
                              final boolean isControlKeyDown); @Override boolean selectCell(final int uiRowIndex,
                              final int uiColumnIndex,
                              final boolean isShiftKeyDown,
                              final boolean isControlKeyDown); @Override boolean selectHeaderCell(final Point2D rp,
                                    final boolean isShiftKeyDown,
                                    final boolean isControlKeyDown); @Override boolean selectHeaderCell(final int uiHeaderRowIndex,
                                    final int uiHeaderColumnIndex,
                                    final boolean isShiftKeyDown,
                                    final boolean isControlKeyDown); @Override boolean adjustSelection(final SelectionExtension direction,
                                   final boolean isShiftKeyDown); @Override boolean startEditingCell(final Point2D rp); @Override boolean startEditingCell(final int uiRowIndex,
                                    final int uiColumnIndex);  }
@Test public void selectHeaderCellWithPoint() { cellSelectionManager.selectHeaderCell(new Point2D(col1.getWidth() + col2.getWidth() / 2, HEADER_HEIGHT / 2), false, false); final List<GridData.SelectedCell> selectedHeaderCells = gridWidgetData.getSelectedHeaderCells(); assertEquals(1, selectedHeaderCells.size()); assertEquals(0, selectedHeaderCells.get(0).getRowIndex()); assertEquals(1, selectedHeaderCells.get(0).getColumnIndex()); assertNull(gridWidgetData.getSelectedCellsOrigin()); }
@Test public void selectHeaderCellWithCoordinate() { cellSelectionManager.selectHeaderCell(0, 1, false, false); final List<GridData.SelectedCell> selectedHeaderCells = gridWidgetData.getSelectedHeaderCells(); assertEquals(1, selectedHeaderCells.size()); assertEquals(0, selectedHeaderCells.get(0).getRowIndex()); assertEquals(1, selectedHeaderCells.get(0).getColumnIndex()); assertNull(gridWidgetData.getSelectedCellsOrigin()); }