@Test @SuppressWarnings("unchecked") public void testUpdateParentInformation_WithExpressionColumnNullValues() { setupUiModelNullValues(Pair.newPair(new ExpressionEditorColumn(gridLayer, new BaseHeaderMetaData("column"), ExpressionEditorColumn.DEFAULT_WIDTH, gridWidget), (rowIndex) -> { final BaseExpressionGrid grid = mock(BaseExpressionGrid.class); final GridCellTuple gct = new GridCellTuple(rowIndex, 0, mock(GridWidget.class)); when(grid.getParentInformation()).thenReturn(gct); return new ExpressionCellValue(Optional.of(grid)); })); try { CommandUtils.updateParentInformation(gridData); } catch (Exception e) { fail(); } }
public static void updateParentInformation(final GridData uiModel) { final Optional<ExpressionEditorColumn> expressionColumn = uiModel .getColumns() .stream() .filter(c -> c instanceof ExpressionEditorColumn) .map(c -> (ExpressionEditorColumn) c) .findFirst(); expressionColumn.ifPresent(c -> { final int columnIndex = uiModel.getColumns().indexOf(c); for (int rowIndex = 0; rowIndex < uiModel.getRowCount(); rowIndex++) { final GridCell<?> cell = uiModel.getCell(rowIndex, columnIndex); if (cell != null) { final GridCellValue<?> value = cell.getValue(); if (value instanceof ExpressionCellValue) { final ExpressionCellValue ecv = (ExpressionCellValue) value; if (ecv.getValue().isPresent()) { final BaseExpressionGrid beg = ecv.getValue().get(); beg.getParentInformation().setRowIndex(rowIndex); beg.getParentInformation().setColumnIndex(columnIndex); } } } } }); }
CommandUtils { public static void updateParentInformation(final GridData uiModel) { final Optional<ExpressionEditorColumn> expressionColumn = uiModel .getColumns() .stream() .filter(c -> c instanceof ExpressionEditorColumn) .map(c -> (ExpressionEditorColumn) c) .findFirst(); expressionColumn.ifPresent(c -> { final int columnIndex = uiModel.getColumns().indexOf(c); for (int rowIndex = 0; rowIndex < uiModel.getRowCount(); rowIndex++) { final GridCell<?> cell = uiModel.getCell(rowIndex, columnIndex); if (cell != null) { final GridCellValue<?> value = cell.getValue(); if (value instanceof ExpressionCellValue) { final ExpressionCellValue ecv = (ExpressionCellValue) value; if (ecv.getValue().isPresent()) { final BaseExpressionGrid beg = ecv.getValue().get(); beg.getParentInformation().setRowIndex(rowIndex); beg.getParentInformation().setColumnIndex(columnIndex); } } } } }); } }
CommandUtils { public static void updateParentInformation(final GridData uiModel) { final Optional<ExpressionEditorColumn> expressionColumn = uiModel .getColumns() .stream() .filter(c -> c instanceof ExpressionEditorColumn) .map(c -> (ExpressionEditorColumn) c) .findFirst(); expressionColumn.ifPresent(c -> { final int columnIndex = uiModel.getColumns().indexOf(c); for (int rowIndex = 0; rowIndex < uiModel.getRowCount(); rowIndex++) { final GridCell<?> cell = uiModel.getCell(rowIndex, columnIndex); if (cell != null) { final GridCellValue<?> value = cell.getValue(); if (value instanceof ExpressionCellValue) { final ExpressionCellValue ecv = (ExpressionCellValue) value; if (ecv.getValue().isPresent()) { final BaseExpressionGrid beg = ecv.getValue().get(); beg.getParentInformation().setRowIndex(rowIndex); beg.getParentInformation().setColumnIndex(columnIndex); } } } } }); }  }
CommandUtils { public static void updateParentInformation(final GridData uiModel) { final Optional<ExpressionEditorColumn> expressionColumn = uiModel .getColumns() .stream() .filter(c -> c instanceof ExpressionEditorColumn) .map(c -> (ExpressionEditorColumn) c) .findFirst(); expressionColumn.ifPresent(c -> { final int columnIndex = uiModel.getColumns().indexOf(c); for (int rowIndex = 0; rowIndex < uiModel.getRowCount(); rowIndex++) { final GridCell<?> cell = uiModel.getCell(rowIndex, columnIndex); if (cell != null) { final GridCellValue<?> value = cell.getValue(); if (value instanceof ExpressionCellValue) { final ExpressionCellValue ecv = (ExpressionCellValue) value; if (ecv.getValue().isPresent()) { final BaseExpressionGrid beg = ecv.getValue().get(); beg.getParentInformation().setRowIndex(rowIndex); beg.getParentInformation().setColumnIndex(columnIndex); } } } } }); }  static void updateRowNumbers(final GridData uiModel,
                                        final IntStream rangeOfRowsToUpdate); static void moveRows(final List<T> allRows,
                                    final List<T> rowsToMove,
                                    final int index); static void moveComponentWidths(final int index,
                                           final int oldIndex,
                                           final List<Double> componentWidths,
                                           final List<Integer> uiColumnIndexes); static void updateParentInformation(final GridData uiModel); static Optional<GridCellValue<?>> extractGridCellValue(final GridCellTuple cellTuple); }
CommandUtils { public static void updateParentInformation(final GridData uiModel) { final Optional<ExpressionEditorColumn> expressionColumn = uiModel .getColumns() .stream() .filter(c -> c instanceof ExpressionEditorColumn) .map(c -> (ExpressionEditorColumn) c) .findFirst(); expressionColumn.ifPresent(c -> { final int columnIndex = uiModel.getColumns().indexOf(c); for (int rowIndex = 0; rowIndex < uiModel.getRowCount(); rowIndex++) { final GridCell<?> cell = uiModel.getCell(rowIndex, columnIndex); if (cell != null) { final GridCellValue<?> value = cell.getValue(); if (value instanceof ExpressionCellValue) { final ExpressionCellValue ecv = (ExpressionCellValue) value; if (ecv.getValue().isPresent()) { final BaseExpressionGrid beg = ecv.getValue().get(); beg.getParentInformation().setRowIndex(rowIndex); beg.getParentInformation().setColumnIndex(columnIndex); } } } } }); }  static void updateRowNumbers(final GridData uiModel,
                                        final IntStream rangeOfRowsToUpdate); static void moveRows(final List<T> allRows,
                                    final List<T> rowsToMove,
                                    final int index); static void moveComponentWidths(final int index,
                                           final int oldIndex,
                                           final List<Double> componentWidths,
                                           final List<Integer> uiColumnIndexes); static void updateParentInformation(final GridData uiModel); static Optional<GridCellValue<?>> extractGridCellValue(final GridCellTuple cellTuple);  }