protected GridCellValue<T> assertCellValue(final GridCellValue<T> cellValue) { if (cellValue != null) { if (cellValue.getValue() != null) { return cellValue; } } return makeDefaultCellValue(); }
protected boolean isPlaceHolderToBeShown(final GridCell<T> cell) { return cell.getValue() != null && cell.getValue().getValue() == null && cell.getValue().getPlaceHolder() != null; } }
@Override public Group renderCell(final GridCell<String> cell, final GridBodyCellRenderContext context) { if (isToReturnNull(cell)) { return null; } final GridRenderer renderer = context.getRenderer(); final GridRendererTheme theme = renderer.getTheme(); final Text text = theme.getPlaceholderText(); final String value = cell.getValue().getPlaceHolder(); return internalRenderCell(cell, context, text, value); } }
private Optional<?> getCellValue(GridCell<?> gridCell) { if (gridCell == null || gridCell.getValue() == null) { return Optional.empty(); } return Optional.ofNullable(gridCell.getValue().getValue()); } }
protected boolean isPlaceHolderToBeShown(final GridCell<T> cell) { return cell.getValue() != null && cell.getValue().getValue() == null && cell.getValue().getPlaceHolder() != null; } }
protected boolean isToReturnNull(final GridCell<T> cell) { return cell == null || cell.getValue() == null || (cell.getValue().getValue() == null && cell.getValue().getPlaceHolder() == null); }
protected boolean isToReturnNull(final GridCell<T> cell) { return cell == null || cell.getValue() == null || (cell.getValue().getValue() == null && cell.getValue().getPlaceHolder() == null); }
@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())); } }
@Test public void testRenderingPlaceHolder() { doReturn(cellValue).when(cell).getValue(); doReturn(null).when(cellValue).getValue(); doReturn(PLACEHOLDER).when(cellValue).getPlaceHolder(); final Group g = renderer.renderCell(cell, context); assertNotNull(g); assertEquals(1, g.getChildNodes().size()); assertEquals(placeHolderText, g.getChildNodes().get(0)); verify(placeHolderText, times(1)).setText(eq(PLACEHOLDER)); }
@Override public void edit(final GridCell<Boolean> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<Boolean>> callback) { callback.accept(new BaseGridCellValue<>(!cell.getValue().getValue())); } }
@Test public void testRenderingPlaceHolder() { doReturn(cellValue).when(cell).getValue(); doReturn(null).when(cellValue).getValue(); doReturn(PLACEHOLDER).when(cellValue).getPlaceHolder(); final Group g = renderer.renderCell(cell, context); assertNotNull(g); assertEquals(1, g.getChildNodes().size()); assertEquals(placeHolderText, g.getChildNodes().get(0)); verify(placeHolderText, times(1)).setText(eq(PLACEHOLDER)); }
@Override public void edit(final GridCell<Boolean> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<Boolean>> callback) { callback.accept(new BaseGridCellValue<>(!cell.getValue().getValue())); } }
public static Group getCenteredCellText(final GridBodyCellRenderContext context, final GridCell<String> gridCell) { final GridRenderer gridRenderer = context.getRenderer(); final GridRendererTheme theme = gridRenderer.getTheme(); final Group g = GWT.create(Group.class); String value = gridCell.getValue().getValue(); final Text t; if (!StringUtils.isEmpty(value)) { t = theme.getBodyText(); } else { value = gridCell.getValue().getPlaceHolder(); t = theme.getPlaceholderText(); } t.setText(value); t.setListening(false); t.setX(context.getCellWidth() / 2); t.setY(context.getCellHeight() / 2); g.add(t); return g; }
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(); }
/** * 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(); }
private static <T> boolean hasValue(final GridCell<T> cell) { if (cell == null || cell.getValue() == null || cell.getValue().getValue() == null) { return false; } return true; } }
@Override @SuppressWarnings("unchecked") public void flush(final String value) { String actualValue = value != null && value.isEmpty() ? null : value; if (scenarioGridCell != null) { scenarioGridCell.setEditingMode(false); String cellValue = scenarioGridCell.getValue().getValue(); if (Objects.equals(actualValue, cellValue)) { return; } } internalFlush(actualValue); }