private Optional<?> getCellValue(GridCell<?> gridCell) { if (gridCell == null || gridCell.getValue() == null) { return Optional.empty(); } return Optional.ofNullable(gridCell.getValue().getValue()); } }
@Override public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) { dmnModel.get().ifPresent(literalExpression -> literalExpression.getText().setValue((String) cell.get().orElse(new BaseGridCellValue<>("")).getValue())); } }
private static <T> boolean hasValue(final GridCell<T> cell) { if (cell == null || cell.getValue() == null || cell.getValue().getValue() == null) { return false; } return true; } }
/** * Show the popup * @param value The value to show in the editor. * @param callback Callback to invoke when the popup is "OK'ed". */ public void edit(final GridCellValue<String> value, final Consumer<GridCellValue<String>> callback) { this.value = value; this.callback = callback; textBox.setText(value == null ? "" : value.getValue()); show(); }
protected Function<GridCellValueTuple, Command> newHeaderHasValueCommand() { return (gcv) -> { final String title = gcv.getValue().getValue().toString(); return new SetHeaderValueCommand(title, extractEditableHeaderMetaData(gcv), gridLayer::batch); }; }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, (e) -> e.setValue(assertCellValue(assertCell(cell).getValue()).getValue()), (e) -> e.setFocus(true)); }
@Override public void edit(final GridCell<String> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<String>> callback) { factory.attachDomElement(context, e -> e.getWidget().setValue(assertCell(cell).getValue().getValue()), e -> e.getWidget().setFocus(true)); }
@Test public void testRendering() { doReturn(cellValue).when(cell).getValue(); doReturn(getValueToRender()).when(cellValue).getValue(); final Group g = renderer.renderCell(cell, context); assertNotNull(g); assertEquals(1, g.getChildNodes().size()); assertEquals(text, g.getChildNodes().get(0)); }
@Test public void testInitialisationOfBooleanCellsWithoutDefaultValue() throws VetoException { setupBooleanColumn((c) -> {/*Nothing*/ }); modelSynchronizer.appendRow(); assertFalse(model.getData().get(0).get(2).getBooleanValue()); assertFalse((Boolean) uiModel.getCell(0, 2).getValue().getValue()); }
@Test public void testDeleteRowNumbers() throws VetoException { modelSynchronizer.appendRow(); modelSynchronizer.appendRow(); modelSynchronizer.deleteRow(0); assertEquals(1, uiModel.getRow(0).getCells().get(0).getValue().getValue()); assertEquals(1, model.getData().get(0).get(0).getNumericValue()); }
@Test public void testInitialisationOfBooleanCellsWithNullDefaultValue() throws VetoException { setupBooleanColumn((c) -> c.setDefaultValue(new DTCellValue52((Boolean) null))); modelSynchronizer.appendRow(); assertFalse(model.getData().get(0).get(2).getBooleanValue()); assertFalse((Boolean) uiModel.getCell(0, 2).getValue().getValue()); }
@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 testSetCellValueWhenExistingCustomGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new CustomGridCell<>(new BaseGridCellValue<>("hello"))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(CustomGridCell.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); }