@Test public void perform_HeaderCellsSelected() { when(scenarioGridModelMock.getSelectedCells()).thenReturn(Collections.emptyList()); when(scenarioGridModelMock.getSelectedHeaderCells()).thenReturn(Arrays.asList(selectedCell, selectedCell2)); handler.perform(scenarioGridMock, false, false); verify(scenarioContextMenuRegistry, times(1)).manageRightClick(eq(scenarioGridMock), eq(0), eq(0), anyInt(), anyInt(), eq(true)); }
@Override public boolean perform(final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown) { final GridData model = gridWidget.getModel(); if (!model.getSelectedHeaderCells().isEmpty() && !model.getSelectedCells().isEmpty()) { return false; } GridData.SelectedCell origin = null; boolean isHeader = false; if (!model.getSelectedHeaderCells().isEmpty()) { origin = model.getSelectedHeaderCells().get(0); isHeader = true; } else if (model.getSelectedCells().size() == 1) { origin = model.getSelectedCellsOrigin(); } if (origin == null) { return false; } final int uiRowIndex = origin.getRowIndex(); final int uiColumnIndex = ColumnIndexUtilities.findUiColumnIndex(model.getColumns(), origin.getColumnIndex()); final GridColumn<?> column = model.getColumns().get(uiColumnIndex); if (column instanceof ScenarioGridColumn) { final Point2D middleXYCell = this.getMiddleXYCell(gridWidget, column, isHeader, uiRowIndex, gridLayer); return scenarioContextMenuRegistry.manageRightClick((ScenarioGrid) gridWidget, (int) middleXYCell.getX(), (int) middleXYCell.getY(), uiRowIndex, uiColumnIndex, isHeader); } return false; }
ScenarioInvokeContextMenuForSelectedCell extends KeyboardOperationInvokeContextMenuForSelectedCell { @Override public boolean perform(final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown) { final GridData model = gridWidget.getModel(); if (!model.getSelectedHeaderCells().isEmpty() && !model.getSelectedCells().isEmpty()) { return false; } GridData.SelectedCell origin = null; boolean isHeader = false; if (!model.getSelectedHeaderCells().isEmpty()) { origin = model.getSelectedHeaderCells().get(0); isHeader = true; } else if (model.getSelectedCells().size() == 1) { origin = model.getSelectedCellsOrigin(); } if (origin == null) { return false; } final int uiRowIndex = origin.getRowIndex(); final int uiColumnIndex = ColumnIndexUtilities.findUiColumnIndex(model.getColumns(), origin.getColumnIndex()); final GridColumn<?> column = model.getColumns().get(uiColumnIndex); if (column instanceof ScenarioGridColumn) { final Point2D middleXYCell = this.getMiddleXYCell(gridWidget, column, isHeader, uiRowIndex, gridLayer); return scenarioContextMenuRegistry.manageRightClick((ScenarioGrid) gridWidget, (int) middleXYCell.getX(), (int) middleXYCell.getY(), uiRowIndex, uiColumnIndex, isHeader); } return false; } }
ScenarioInvokeContextMenuForSelectedCell extends KeyboardOperationInvokeContextMenuForSelectedCell { @Override public boolean perform(final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown) { final GridData model = gridWidget.getModel(); if (!model.getSelectedHeaderCells().isEmpty() && !model.getSelectedCells().isEmpty()) { return false; } GridData.SelectedCell origin = null; boolean isHeader = false; if (!model.getSelectedHeaderCells().isEmpty()) { origin = model.getSelectedHeaderCells().get(0); isHeader = true; } else if (model.getSelectedCells().size() == 1) { origin = model.getSelectedCellsOrigin(); } if (origin == null) { return false; } final int uiRowIndex = origin.getRowIndex(); final int uiColumnIndex = ColumnIndexUtilities.findUiColumnIndex(model.getColumns(), origin.getColumnIndex()); final GridColumn<?> column = model.getColumns().get(uiColumnIndex); if (column instanceof ScenarioGridColumn) { final Point2D middleXYCell = this.getMiddleXYCell(gridWidget, column, isHeader, uiRowIndex, gridLayer); return scenarioContextMenuRegistry.manageRightClick((ScenarioGrid) gridWidget, (int) middleXYCell.getX(), (int) middleXYCell.getY(), uiRowIndex, uiColumnIndex, isHeader); } return false; } ScenarioInvokeContextMenuForSelectedCell(final GridLayer gridLayer, final ScenarioContextMenuRegistry
            scenarioContextMenuRegistry); }
ScenarioInvokeContextMenuForSelectedCell extends KeyboardOperationInvokeContextMenuForSelectedCell { @Override public boolean perform(final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown) { final GridData model = gridWidget.getModel(); if (!model.getSelectedHeaderCells().isEmpty() && !model.getSelectedCells().isEmpty()) { return false; } GridData.SelectedCell origin = null; boolean isHeader = false; if (!model.getSelectedHeaderCells().isEmpty()) { origin = model.getSelectedHeaderCells().get(0); isHeader = true; } else if (model.getSelectedCells().size() == 1) { origin = model.getSelectedCellsOrigin(); } if (origin == null) { return false; } final int uiRowIndex = origin.getRowIndex(); final int uiColumnIndex = ColumnIndexUtilities.findUiColumnIndex(model.getColumns(), origin.getColumnIndex()); final GridColumn<?> column = model.getColumns().get(uiColumnIndex); if (column instanceof ScenarioGridColumn) { final Point2D middleXYCell = this.getMiddleXYCell(gridWidget, column, isHeader, uiRowIndex, gridLayer); return scenarioContextMenuRegistry.manageRightClick((ScenarioGrid) gridWidget, (int) middleXYCell.getX(), (int) middleXYCell.getY(), uiRowIndex, uiColumnIndex, isHeader); } return false; } ScenarioInvokeContextMenuForSelectedCell(final GridLayer gridLayer, final ScenarioContextMenuRegistry
            scenarioContextMenuRegistry); @Override boolean isExecutable(final GridWidget gridWidget); @Override boolean perform(final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown); }
ScenarioInvokeContextMenuForSelectedCell extends KeyboardOperationInvokeContextMenuForSelectedCell { @Override public boolean perform(final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown) { final GridData model = gridWidget.getModel(); if (!model.getSelectedHeaderCells().isEmpty() && !model.getSelectedCells().isEmpty()) { return false; } GridData.SelectedCell origin = null; boolean isHeader = false; if (!model.getSelectedHeaderCells().isEmpty()) { origin = model.getSelectedHeaderCells().get(0); isHeader = true; } else if (model.getSelectedCells().size() == 1) { origin = model.getSelectedCellsOrigin(); } if (origin == null) { return false; } final int uiRowIndex = origin.getRowIndex(); final int uiColumnIndex = ColumnIndexUtilities.findUiColumnIndex(model.getColumns(), origin.getColumnIndex()); final GridColumn<?> column = model.getColumns().get(uiColumnIndex); if (column instanceof ScenarioGridColumn) { final Point2D middleXYCell = this.getMiddleXYCell(gridWidget, column, isHeader, uiRowIndex, gridLayer); return scenarioContextMenuRegistry.manageRightClick((ScenarioGrid) gridWidget, (int) middleXYCell.getX(), (int) middleXYCell.getY(), uiRowIndex, uiColumnIndex, isHeader); } return false; } ScenarioInvokeContextMenuForSelectedCell(final GridLayer gridLayer, final ScenarioContextMenuRegistry
            scenarioContextMenuRegistry); @Override boolean isExecutable(final GridWidget gridWidget); @Override boolean perform(final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown);  }