ScenarioInvokeContextMenuForSelectedCell extends KeyboardOperationInvokeContextMenuForSelectedCell { @Override public boolean isExecutable(final GridWidget gridWidget) { final GridData model = gridWidget.getModel(); return ((!model.getSelectedHeaderCells().isEmpty() && model.getSelectedCells().isEmpty()) || (model.getSelectedHeaderCells().isEmpty() && model.getSelectedCells().size() == 1)); } 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);  }
@Test public void isExecutable_NoSelection() { when(scenarioGridModelMock.getSelectedCells()).thenReturn(Collections.emptyList()); when(scenarioGridModelMock.getSelectedHeaderCells()).thenReturn(Collections.emptyList()); assertFalse(handler.isExecutable(scenarioGridMock)); }
@Test public void isExecutable_CellSelected() { when(scenarioGridModelMock.getSelectedCells()).thenReturn(Arrays.asList(selectedCell)); when(scenarioGridModelMock.getSelectedHeaderCells()).thenReturn(Collections.emptyList()); assertTrue(handler.isExecutable(scenarioGridMock)); }
@Test public void isExecutable_CellsSelected() { when(scenarioGridModelMock.getSelectedCells()).thenReturn(Arrays.asList(selectedCell, selectedCell2)); when(scenarioGridModelMock.getSelectedHeaderCells()).thenReturn(Collections.emptyList()); assertFalse(handler.isExecutable(scenarioGridMock)); }
@Test public void isExecutable_HeaderCellSelected() { when(scenarioGridModelMock.getSelectedCells()).thenReturn(Collections.emptyList()); when(scenarioGridModelMock.getSelectedHeaderCells()).thenReturn(Arrays.asList(selectedCell)); assertTrue(handler.isExecutable(scenarioGridMock)); }
@Test public void isExecutable_HeaderCellsSelected() { when(scenarioGridModelMock.getSelectedCells()).thenReturn(Collections.emptyList()); when(scenarioGridModelMock.getSelectedHeaderCells()).thenReturn(Arrays.asList(selectedCell, selectedCell2)); assertTrue(handler.isExecutable(scenarioGridMock)); }
@Test public void isExecutable_CellsAndHeaderCellsSelected() { when(scenarioGridModelMock.getSelectedCells()).thenReturn(Arrays.asList(selectedCell)); when(scenarioGridModelMock.getSelectedHeaderCells()).thenReturn(Arrays.asList(selectedCell2)); assertFalse(handler.isExecutable(scenarioGridMock)); }