public void onInsertColumn(final int index) { final List<GridData.SelectedCell> selectedCells = gridData.getSelectedCells(); final List<Integer> rowsWithASelection = selectedCells.stream() .filter(sc -> { final int ri = sc.getRowIndex(); final int ci = sc.getColumnIndex(); final int _ci = ColumnIndexUtilities.findUiColumnIndex(gridData.getColumns(), ci); final GridCell<?> cell = gridData.getCell(ri, _ci); return cell != null && cell.getSelectionStrategy() instanceof RowSelectionStrategy; }) .map(GridData.SelectedCell::getRowIndex) .collect(Collectors.toList()); rowsWithASelection.forEach(rowIndex -> onSelectCell(rowIndex, index)); }
public void onInsertColumn(final int index) { final List<GridData.SelectedCell> selectedCells = gridData.getSelectedCells(); final List<Integer> rowsWithASelection = selectedCells.stream() .filter(sc -> { final int ri = sc.getRowIndex(); final int ci = sc.getColumnIndex(); final int _ci = ColumnIndexUtilities.findUiColumnIndex(gridData.getColumns(), ci); final GridCell<?> cell = gridData.getCell(ri, _ci); return cell != null && cell.getSelectionStrategy() instanceof RowSelectionStrategy; }) .map(GridData.SelectedCell::getRowIndex) .collect(Collectors.toList()); rowsWithASelection.forEach(rowIndex -> onSelectCell(rowIndex, index)); }
@Override public boolean selectCell(final int uiRowIndex, final int uiColumnIndex, final boolean isShiftKeyDown, final boolean isControlKeyDown) { if (uiRowIndex < 0 || uiRowIndex > gridModel.getRowCount() - 1) { return false; } if (uiColumnIndex < 0 || uiColumnIndex > gridModel.getColumnCount() - 1) { return false; } CellSelectionStrategy strategy; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { strategy = RangeSelectionStrategy.INSTANCE; } else { strategy = cell.getSelectionStrategy(); } if (strategy == null) { return false; } //Handle selection return strategy.handleSelection(gridModel, uiRowIndex, uiColumnIndex, isShiftKeyDown, isControlKeyDown); }
@Before public void setup() { this.contextMenuSupport = new GuidedDecisionTableModellerContextMenuSupport(cellContextMenu, rowContextMenu); when(event.getNativeEvent()).thenReturn(nativeEvent); when(event.getRelativeElement()).thenReturn(element); when(element.getAbsoluteLeft()).thenReturn(0); when(element.getScrollLeft()).thenReturn(0); when(element.getAbsoluteTop()).thenReturn(0); when(element.getScrollTop()).thenReturn(0); when(element.getOwnerDocument()).thenReturn(document); when(document.getScrollLeft()).thenReturn(0); when(document.getScrollTop()).thenReturn(0); when(nativeEvent.getShiftKey()).thenReturn(false); when(nativeEvent.getCtrlKey()).thenReturn(false); when(nativeEvent.getClientX()).thenReturn(50); when(nativeEvent.getClientY()).thenReturn(50); when(uiCell.getSelectionStrategy()).thenReturn(cellSelectionStrategy); }
@Override public boolean selectCell(final int uiRowIndex, final int uiColumnIndex, final boolean isShiftKeyDown, final boolean isControlKeyDown) { if (uiRowIndex < 0 || uiRowIndex > gridModel.getRowCount() - 1) { return false; } if (uiColumnIndex < 0 || uiColumnIndex > gridModel.getColumnCount() - 1) { return false; } CellSelectionStrategy strategy; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { strategy = RangeSelectionStrategy.INSTANCE; } else { strategy = cell.getSelectionStrategy(); } if (strategy == null) { return false; } //Handle selection return strategy.handleSelection(gridModel, uiRowIndex, uiColumnIndex, isShiftKeyDown, isControlKeyDown); }
private void selectCell(final int uiRowIndex, final int uiColumnIndex, final GuidedDecisionTableView gridView, final boolean isShiftKeyDown, final boolean isControlKeyDown) { // Lookup CellSelectionManager for cell final GridData gridModel = gridView.getModel(); CellSelectionStrategy selectionStrategy; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { selectionStrategy = RangeSelectionStrategy.INSTANCE; } else { selectionStrategy = cell.getSelectionStrategy(); } if (selectionStrategy == null) { return; } // Handle selection if (selectionStrategy.handleSelection(gridModel, uiRowIndex, uiColumnIndex, isShiftKeyDown, isControlKeyDown)) { gridView.getLayer().batch(); } } }
private void selectCell(final int uiRowIndex, final int uiColumnIndex, final GuidedDecisionTableView gridView, final boolean isShiftKeyDown, final boolean isControlKeyDown) { // Lookup CellSelectionManager for cell final GridData gridModel = gridView.getModel(); CellSelectionStrategy selectionStrategy; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { selectionStrategy = RangeSelectionStrategy.INSTANCE; } else { selectionStrategy = cell.getSelectionStrategy(); } if (selectionStrategy == null) { return; } // Handle selection if (selectionStrategy.handleSelection(gridModel, uiRowIndex, uiColumnIndex, isShiftKeyDown, isControlKeyDown)) { gridView.getLayer().batch(); } } }
@Test @SuppressWarnings("unchecked") public void onContextMenuWithoutCellSelectionManager() { final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(); final GridData uiModel = dtPresenter.getView().getModel(); final GridColumn uiColumn = new RowNumberColumn(); uiModel.appendColumn(uiColumn); when(columnInformation.getColumn()).thenReturn(uiColumn); when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {{ add(dtPresenter); }}); final GridCell uiCell = mock(GridCell.class); when(uiModel.getCell(any(Integer.class), any(Integer.class))).thenReturn(uiCell); when(uiCell.getSelectionStrategy()).thenReturn(null); final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter); handler.onContextMenu(event); verify(layer, never()).batch(); }