CellContextUtilities { public static GridBodyCellEditContext makeHeaderCellRenderContext(final GridWidget gridWidget, final BaseGridRendererHelper.RenderingInformation ri, final BaseGridRendererHelper.ColumnInformation ci, final int uiHeaderRowIndex) { return makeHeaderCellRenderContext(gridWidget, ri, ci, null, uiHeaderRowIndex); }  static GridBodyCellEditContext makeCellRenderContext(final GridWidget gridWidget,
                                                                final BaseGridRendererHelper.RenderingInformation ri,
                                                                final BaseGridRendererHelper.ColumnInformation ci,
                                                                final int uiRowIndex); static GridBodyCellEditContext makeHeaderCellRenderContext(final GridWidget gridWidget,
                                                                      final BaseGridRendererHelper.RenderingInformation ri,
                                                                      final BaseGridRendererHelper.ColumnInformation ci,
                                                                      final int uiHeaderRowIndex); static GridBodyCellEditContext makeHeaderCellRenderContext(final GridWidget gridWidget,
                                                                      final BaseGridRendererHelper.RenderingInformation ri,
                                                                      final BaseGridRendererHelper.ColumnInformation ci,
                                                                      final Point2D rp,
                                                                      final int uiHeaderRowIndex); static void editSelectedCell(final GridWidget gridWidget); static void editSelectedCell(final GridWidget gridWidget,
                                        final Point2D relativeLocation);  }
@Test public void testMakeHeaderRenderContextNoBlockMultipleColumns() { final List<GridColumn<?>> allColumns = new ArrayList<>(); final GridColumn<?> uiColumn1 = mockGridColumn(25.0); final GridColumn<?> uiColumn2 = mockGridColumn(50.0); final GridColumn<?> uiColumn3 = mockGridColumn(100.0); allColumns.add(uiColumn1); allColumns.add(uiColumn2); allColumns.add(uiColumn3); doReturn(allColumns).when(ri).getAllColumns(); doReturn(uiColumn2).when(ci).getColumn(); doReturn(25.0).when(ci).getOffsetX(); doReturn(1).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(25.0, context.getAbsoluteCellX(), 0.0); assertEquals(50.0, context.getCellWidth(), 0.0); }
@Test public void testMakeHeaderRenderContextLeadBlock() { final List<GridColumn<?>> allColumns = new ArrayList<>(); final GridColumn<?> uiColumn1 = mockGridColumn(25.0); final GridColumn<?> uiColumn2 = mockGridColumn(50.0, uiColumn1.getHeaderMetaData()); allColumns.add(uiColumn1); allColumns.add(uiColumn2); doReturn(allColumns).when(ri).getAllColumns(); doReturn(uiColumn2).when(ci).getColumn(); doReturn(25.0).when(ci).getOffsetX(); doReturn(1).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(25.0, context.getAbsoluteCellX(), 0.0); assertEquals(75.0, context.getCellWidth(), 0.0); }
@Test public void testMakeHeaderRenderContextDifferentColumnHeaderMetaDataRows_Column0_Row0() { final List<GridColumn<?>> allColumns = setupHeadersWithDifferentColumnHeaderMetaDataRows(); doReturn(allColumns).when(ri).getAllColumns(); doReturn(allColumns.get(0)).when(ci).getColumn(); doReturn(0.0).when(ci).getOffsetX(); doReturn(0).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(0.0, context.getAbsoluteCellX(), 0.0); assertEquals(0.0, context.getAbsoluteCellY(), 0.0); assertEquals(50.0, context.getCellWidth(), 0.0); assertEquals(HEADER_ROW_HEIGHT, context.getCellHeight(), 0.0); }
@Test public void testMakeHeaderRenderContextDifferentColumnHeaderMetaDataRows_Column0_Row1() { final List<GridColumn<?>> allColumns = setupHeadersWithDifferentColumnHeaderMetaDataRows(); doReturn(allColumns).when(ri).getAllColumns(); doReturn(allColumns.get(0)).when(ci).getColumn(); doReturn(0.0).when(ci).getOffsetX(); doReturn(0).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 1); assertNotNull(context); assertEquals(0.0, context.getAbsoluteCellX(), 0.0); assertEquals(25.0, context.getAbsoluteCellY(), 0.0); assertEquals(50.0, context.getCellWidth(), 0.0); assertEquals(HEADER_ROW_HEIGHT, context.getCellHeight(), 0.0); }
@Test public void testMakeHeaderRenderContextDifferentColumnHeaderMetaDataRows_Column1_Row0() { final List<GridColumn<?>> allColumns = setupHeadersWithDifferentColumnHeaderMetaDataRows(); doReturn(allColumns).when(ri).getAllColumns(); doReturn(allColumns.get(1)).when(ci).getColumn(); doReturn(50.0).when(ci).getOffsetX(); doReturn(1).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(50.0, context.getAbsoluteCellX(), 0.0); assertEquals(0.0, context.getAbsoluteCellY(), 0.0); assertEquals(50.0, context.getCellWidth(), 0.0); assertEquals(HEADER_HEIGHT, context.getCellHeight(), 0.0); }
@Test public void testMakeHeaderRenderContextLeadBlockWithExtraLeadNonBlockColumn() { final List<GridColumn<?>> allColumns = new ArrayList<>(); final GridColumn<?> uiColumn1 = mockGridColumn(25.0); final GridColumn<?> uiColumn2 = mockGridColumn(50.0); final GridColumn<?> uiColumn3 = mockGridColumn(75.0, uiColumn2.getHeaderMetaData()); allColumns.add(uiColumn1); allColumns.add(uiColumn2); allColumns.add(uiColumn3); doReturn(allColumns).when(ri).getAllColumns(); doReturn(uiColumn3).when(ci).getColumn(); doReturn(75.0).when(ci).getOffsetX(); doReturn(2).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(75.0, context.getAbsoluteCellX(), 0.0); assertEquals(125.0, context.getCellWidth(), 0.0); }
@Test public void testMakeHeaderRenderContextTailBlock() { final List<GridColumn<?>> allColumns = new ArrayList<>(); final GridColumn<?> uiColumn1 = mockGridColumn(25.0); final GridColumn<?> uiColumn2 = mockGridColumn(50.0, uiColumn1.getHeaderMetaData()); allColumns.add(uiColumn1); allColumns.add(uiColumn2); doReturn(allColumns).when(ri).getAllColumns(); doReturn(uiColumn1).when(ci).getColumn(); doReturn(0.0).when(ci).getOffsetX(); doReturn(0).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(0.0, context.getAbsoluteCellX(), 0.0); assertEquals(75.0, context.getCellWidth(), 0.0); }
@Test public void testMakeHeaderRenderContextTailBlockWithExtraTailNonBlockColumn() { final List<GridColumn<?>> allColumns = new ArrayList<>(); final GridColumn<?> uiColumn1 = mockGridColumn(25.0); final GridColumn<?> uiColumn2 = mockGridColumn(50.0, uiColumn1.getHeaderMetaData()); final GridColumn<?> uiColumn3 = mockGridColumn(100.0); allColumns.add(uiColumn1); allColumns.add(uiColumn2); allColumns.add(uiColumn3); doReturn(allColumns).when(ri).getAllColumns(); doReturn(uiColumn1).when(ci).getColumn(); doReturn(0.0).when(ci).getOffsetX(); doReturn(0).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(0.0, context.getAbsoluteCellX(), 0.0); assertEquals(75.0, context.getCellWidth(), 0.0); }
@Test public void testMakeHeaderRenderContextNoBlock() { final List<GridColumn<?>> allColumns = new ArrayList<>(); final GridColumn<?> uiColumn = mockGridColumn(100.0); allColumns.add(uiColumn); doReturn(allColumns).when(ri).getAllColumns(); doReturn(uiColumn).when(ci).getColumn(); doReturn(0.0).when(ci).getOffsetX(); doReturn(0).when(ci).getUiColumnIndex(); final GridBodyCellRenderContext context = CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, rp, 0); assertNotNull(context); assertEquals(0.0, context.getAbsoluteCellX(), 0.0); assertEquals(100.0, context.getCellWidth(), 0.0); }