protected GridCell<T> assertCell(final GridCell<T> cell) { if (cell != null) { return cell; } return new BaseGridCell<>(makeDefaultCellValue()); }
@Override @SuppressWarnings("unchecked") public Range setCellValue(final int rowIndex, final int columnIndex, final GridCellValue<?> value) { return doSetCell(rowIndex, columnIndex, (pair) -> { final Optional<BaseGridCell> cell = Optional.ofNullable((BaseGridCell) getCell(pair.getKey(), pair.getValue())); final BaseGridCell c = cell.orElse(new BaseGridCell<>(value)); c.setValue(value); return c; }); }
private GridCell<String> assertCell(final GridCell<String> cell) { if (cell != null) { return cell; } return new BaseGridCell<String>(new BaseGridCellValue<String>("")); }
@Override @SuppressWarnings("unchecked") public Range setCellValue(final int rowIndex, final int columnIndex, final GridCellValue<?> value) { return doSetCell(rowIndex, columnIndex, (pair) -> { final Optional<BaseGridCell> cell = Optional.ofNullable((BaseGridCell) getCell(pair.getKey(), pair.getValue())); final BaseGridCell c = cell.orElse(new BaseGridCell<>(value)); c.setValue(value); return c; }); }
private GridCell<String> assertCell(final GridCell<String> cell) { if (cell != null) { return cell; } return new BaseGridCell<String>(new BaseGridCellValue<String>("")); } }
private GridCell<String> assertCell(final GridCell<String> cell) { if (cell != null) { return cell; } return new BaseGridCell<String>(new BaseGridCellValue<String>("")); } }
private GridCell<String> assertCell(final GridCell<String> cell) { if (cell != null) { return cell; } return new BaseGridCell<String>(new BaseGridCellValue<String>("")); }
@Override public Group render(final GridBodyCellRenderContext context) { final BaseGridCellValue<String> hasNameCellValue = new BaseGridCellValue<>(this.getName().getValue()); return RendererUtils.getCenteredCellText(context, new BaseGridCell<>(hasNameCellValue)); } };
@Test @SuppressWarnings("unchecked") public void editReadOnly() { when( access.isEditable() ).thenReturn( false ); final GridCell<Boolean> cell = new BaseGridCell<>( new BaseGridCellValue<>( true ) ); column.edit( cell, context, callback ); verify( callback, never() ).accept( any( BaseGridCellValue.class ) ); }
@Test @SuppressWarnings("unchecked") public void editTrueToFalse() { when( access.isEditable() ).thenReturn( true ); final GridCell<Boolean> cell = new BaseGridCell<>( new BaseGridCellValue<>( true ) ); column.edit( cell, context, callback ); verify( callback, times( 1 ) ).accept( callbackArgumentCaptor.capture() ); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertFalse( callbackArgument.getValue() ); }
@Test @SuppressWarnings("unchecked") public void editTrueToFalse() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(true)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertFalse(callbackArgument.getValue()); }
@Test @SuppressWarnings("unchecked") public void editFalseToTrue() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(false)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertTrue(callbackArgument.getValue()); } }
@Test @SuppressWarnings("unchecked") public void editTrueToFalse() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(true)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertFalse(callbackArgument.getValue()); }
@Test @SuppressWarnings("unchecked") public void editFalseToTrue() { when( access.isEditable() ).thenReturn( true ); final GridCell<Boolean> cell = new BaseGridCell<>( new BaseGridCellValue<>( false ) ); column.edit( cell, context, callback ); verify( callback, times( 1 ) ).accept( callbackArgumentCaptor.capture() ); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertTrue( callbackArgument.getValue() ); }
@Test @SuppressWarnings("unchecked") public void editFalseToTrue() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(false)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertTrue(callbackArgument.getValue()); } }
@Test public void renderCellWhenCellValueIsInEnumData() { setupEnums( "A", "A" ); when( access.isEditable() ).thenReturn( true ); final GridCell<String> cell = new BaseGridCell<>( new GuidedDecisionTableUiCell<>( "A" ) ); column.getColumnRenderer().renderCell( cell, context ); verify( bodyText, times( 1 ) ).setText( eq( "A" ) ); verify( uiModel, never() ).deleteCell( anyInt(), anyInt() ); }
@Test public void clearModelWhenCellValueIsNotInEnumData() { setupEnums( "B", "A" ); when( access.isEditable() ).thenReturn( true ); final GridCell<String> cell = new BaseGridCell<>( new GuidedDecisionTableUiCell<>( "B" ) ); column.getColumnRenderer().renderCell( cell, context ); verify( bodyText, times( 1 ) ).setText( eq( "" ) ); verify( uiModel, times( 1 ) ).deleteCell( anyInt(), anyInt() ); }
public static Group getNameAndDataTypeCellText(final InformationItemCell.HasNameAndDataTypeCell hasNameAndDataTypeCell, final GridBodyCellRenderContext context) { if (!hasNameAndDataTypeCell.hasData()) { final BaseGridCellValue<String> cell = new BaseGridCellValue<>(null, hasNameAndDataTypeCell.getPlaceHolderText()); return getCenteredCellText(context, new BaseGridCell<>(cell)); } return getNameAndDataTypeText(context.getRenderer().getTheme(), hasNameAndDataTypeCell.getName().getValue(), hasNameAndDataTypeCell.getTypeRef(), context.getCellWidth(), context.getCellHeight()); }
@Test public void testSetCellValueWhenExistingBaseGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(""))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }
@Test public void testSetCellValueWhenExistingBaseGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(""))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }