private int findUiColumnIndex(final int modelColumnIndex) { final List<GridColumn<?>> columns = uiModel.getColumns(); for (int uiColumnIndex = 0; uiColumnIndex < columns.size(); uiColumnIndex++) { final GridColumn<?> c = columns.get(uiColumnIndex); if (c.getIndex() == modelColumnIndex) { return uiColumnIndex; } } throw new IllegalStateException("Column was not found!"); }
private boolean isSelectionInColumns(final GridData.SelectedCell sc) { final int scColumnIndex = sc.getColumnIndex(); for (GridColumn<?> column : columns) { final int columnIndex = column.getIndex(); if (scColumnIndex == columnIndex) { return true; } } return false; } }
@Override public GridCell<?> getCell(final int rowIndex, final int columnIndex) { if (rowIndex < 0 || rowIndex > rows.size() - 1) { return null; } final int _columnIndex = columns.get(columnIndex).getIndex(); return rows.get(rowIndex).getCells().get(_columnIndex); }
private int findUiColumnIndex(final int modelColumnIndex) { final List<GridColumn<?>> columns = uiModel.getColumns(); for (int uiColumnIndex = 0; uiColumnIndex < columns.size(); uiColumnIndex++) { final GridColumn<?> c = columns.get(uiColumnIndex); if (c.getIndex() == modelColumnIndex) { return uiColumnIndex; } } throw new IllegalStateException("Column was not found!"); }
private boolean isSelectionInColumns(final GridData.SelectedCell sc) { final int scColumnIndex = sc.getColumnIndex(); for (GridColumn<?> column : columns) { final int columnIndex = column.getIndex(); if (scColumnIndex == columnIndex) { return true; } } return false; } }
@Override public GridCell<?> getCell(final int rowIndex, final int columnIndex) { if (rowIndex < 0 || rowIndex > rows.size() - 1) { return null; } final int _columnIndex = columns.get(columnIndex).getIndex(); return rows.get(rowIndex).getCells().get(_columnIndex); }
private int getLogicalColumnIndex(GridData model) { final int columnIndex = model.getColumns().indexOf(this); return columnIndex != -1 ? model.getColumns().get(columnIndex).getIndex() : -1; } }
@Override public void expandCell(final int rowIndex, final int columnIndex) { //Data needs to be merged to expand cells if (!isMerged) { return; } final int _columnIndex = columns.get(columnIndex).getIndex(); final GridRow row = rows.get(rowIndex); final GridCell<?> cell = row.getCells().get(_columnIndex); if (cell == null) { return; } indexManager.onExpandCell(rowIndex, _columnIndex); }
@Override public void expandCell(final int rowIndex, final int columnIndex) { //Data needs to be merged to expand cells if (!isMerged) { return; } final int _columnIndex = columns.get(columnIndex).getIndex(); final GridRow row = rows.get(rowIndex); final GridCell<?> cell = row.getCells().get(_columnIndex); if (cell == null) { return; } indexManager.onExpandCell(rowIndex, _columnIndex); }
private int findUiColumnIndex(final int modelColumnIndex) { final List<GridColumn<?>> columns = activeDecisionTable.getView().getModel().getColumns(); for (int uiColumnIndex = 0; uiColumnIndex < columns.size(); uiColumnIndex++) { final GridColumn<?> c = columns.get(uiColumnIndex); if (c.getIndex() == modelColumnIndex) { return uiColumnIndex; } } throw new IllegalStateException("Column was not found!"); } }
private int findUiColumnIndex(final int modelColumnIndex) { final List<GridColumn<?>> columns = activeDecisionTable.getView().getModel().getColumns(); for (int uiColumnIndex = 0; uiColumnIndex < columns.size(); uiColumnIndex++) { final GridColumn<?> c = columns.get(uiColumnIndex); if (c.getIndex() == modelColumnIndex) { return uiColumnIndex; } } throw new IllegalStateException("Column was not found!"); } }
@Override public void updateColumn(final int index, final GridColumn<?> column) { //Destroy existing column final GridColumn<?> existing = columns.get(index); if (existing.getColumnRenderer() instanceof HasDOMElementResources) { ((HasDOMElementResources) existing.getColumnRenderer()).destroyResources(); } //Replace existing with new column column.setIndex(columns.get(index).getIndex()); columns.set(index, column); //Clear column data for (GridRow row : rows) { ((BaseGridRow) row).deleteCell(column.getIndex()); } }
@Override public void updateColumn(final int index, final GridColumn<?> column) { //Destroy existing column final GridColumn<?> existing = columns.get(index); if (existing.getColumnRenderer() instanceof HasDOMElementResources) { ((HasDOMElementResources) existing.getColumnRenderer()).destroyResources(); } //Replace existing with new column column.setIndex(columns.get(index).getIndex()); columns.set(index, column); //Clear column data for (GridRow row : rows) { ((BaseGridRow) row).deleteCell(column.getIndex()); } }
public void onInsertRow(final int rowIndex) { if (!gridData.isMerged()) { return; } final List<GridColumn<?>> columns = gridData.getColumns(); for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) { final GridColumn<?> column = columns.get(columnIndex); final int _columnIndex = column.getIndex(); if (rowIndex > 0) { updateMergeMetaData(rowIndex - 1, _columnIndex); } if (rowIndex < gridData.getRowCount() - 1) { updateMergeMetaData(rowIndex + 1, _columnIndex); } } }
private GridData.Range selectCellMerged(final int rowIndex, final int columnIndex) { //Find affected rows for merged data final List<GridColumn<?>> columns = gridData.getColumns(); final int _columnIndex = columns.get(columnIndex).getIndex(); final int minRowIndex = findMinRowIndex(rowIndex, _columnIndex); final int maxRowIndex = findMaxRowIndex(rowIndex, _columnIndex); //Select all applicable rows' cells selectCellsNotMerged(minRowIndex, columnIndex, 1, maxRowIndex - minRowIndex + 1); return new GridData.Range(minRowIndex, maxRowIndex); }
private GridData.Range selectCellMerged(final int rowIndex, final int columnIndex) { //Find affected rows for merged data final List<GridColumn<?>> columns = gridData.getColumns(); final int _columnIndex = columns.get(columnIndex).getIndex(); final int minRowIndex = findMinRowIndex(rowIndex, _columnIndex); final int maxRowIndex = findMaxRowIndex(rowIndex, _columnIndex); //Select all applicable rows' cells selectCellsNotMerged(minRowIndex, columnIndex, 1, maxRowIndex - minRowIndex + 1); return new GridData.Range(minRowIndex, maxRowIndex); }
@Test public void testEditWhenDataCellSelectedSecondColumn() { final GridColumn.HeaderMetaData headerMetaDataC1 = mock(GridColumn.HeaderMetaData.class); final GridColumn.HeaderMetaData headerMetaDataC2 = mock(GridColumn.HeaderMetaData.class); final GridColumn<?> gridColumnOne = mockGridColumn(100.0, Arrays.asList(headerMetaDataC1)); final GridColumn<?> gridColumnTwo = mockGridColumn(100.0, Arrays.asList(headerMetaDataC2)); doReturn(0).when(gridColumnOne).getIndex(); doReturn(1).when(gridColumnTwo).getIndex(); gridWidget.getModel().appendColumn(gridColumnOne); gridWidget.getModel().appendColumn(gridColumnTwo); gridWidget.getModel().appendRow(new BaseGridRow()); gridWidget.getModel().selectCell(0, 1); CellContextUtilities.editSelectedCell(gridWidget); verify(headerMetaDataC1, never()).edit(any(GridBodyCellEditContext.class)); verify(headerMetaDataC2, never()).edit(any(GridBodyCellEditContext.class)); verify(gridWidget).startEditingCell(0, 1); }
@Test public void testEditWhenDataCellSelectedSecondColumn() { final GridColumn.HeaderMetaData headerMetaDataC1 = mock(GridColumn.HeaderMetaData.class); final GridColumn.HeaderMetaData headerMetaDataC2 = mock(GridColumn.HeaderMetaData.class); final GridColumn<?> gridColumnOne = mockGridColumn(100.0, Arrays.asList(headerMetaDataC1)); final GridColumn<?> gridColumnTwo = mockGridColumn(100.0, Arrays.asList(headerMetaDataC2)); doReturn(0).when(gridColumnOne).getIndex(); doReturn(1).when(gridColumnTwo).getIndex(); gridWidget.getModel().appendColumn(gridColumnOne); gridWidget.getModel().appendColumn(gridColumnTwo); gridWidget.getModel().appendRow(new BaseGridRow()); gridWidget.getModel().selectCell(0, 1); CellContextUtilities.editSelectedCell(gridWidget); verify(headerMetaDataC1, never()).edit(any(GridBodyCellEditContext.class)); verify(headerMetaDataC2, never()).edit(any(GridBodyCellEditContext.class)); verify(gridWidget).startEditingCell(0, 1); }
@Test public void testEditWhenDataCellSelectedSecondRow() { final GridColumn.HeaderMetaData headerMetaData = mock(GridColumn.HeaderMetaData.class); final GridColumn<?> gridColumn = mockGridColumn(100.0, Arrays.asList(headerMetaData)); doReturn(0).when(gridColumn).getIndex(); gridWidget.getModel().appendColumn(gridColumn); gridWidget.getModel().appendRow(new BaseGridRow()); gridWidget.getModel().appendRow(new BaseGridRow()); gridWidget.getModel().selectCell(1, 0); CellContextUtilities.editSelectedCell(gridWidget); verify(headerMetaData, never()).edit(any(GridBodyCellEditContext.class)); verify(gridWidget).startEditingCell(1, 0); }
@Test public void testEditWhenDataCellSelectedSecondRow() { final GridColumn.HeaderMetaData headerMetaData = mock(GridColumn.HeaderMetaData.class); final GridColumn<?> gridColumn = mockGridColumn(100.0, Arrays.asList(headerMetaData)); doReturn(0).when(gridColumn).getIndex(); gridWidget.getModel().appendColumn(gridColumn); gridWidget.getModel().appendRow(new BaseGridRow()); gridWidget.getModel().appendRow(new BaseGridRow()); gridWidget.getModel().selectCell(1, 0); CellContextUtilities.editSelectedCell(gridWidget); verify(headerMetaData, never()).edit(any(GridBodyCellEditContext.class)); verify(gridWidget).startEditingCell(1, 0); }