@Test public void testManageHeaderRightClick_NoColumnGroup() { final int clickPointX = 5; final int clickPointY = 6; doReturn(clickPointX).when(contextNativeEventMock).getClientX(); doReturn(clickPointY).when(contextNativeEventMock).getClientY(); doReturn("").when(informationHeaderMetaDataMock).getColumnGroup(); doReturn("EXPECT").when(informationHeaderMetaDataMock).getTitle(); assertThat(scenarioContextMenuRegistry.manageRightClick(scenarioGridMock, contextMenuEventMock)) .as("Context menu according to column title") .isTrue(); verify(headerExpectedContextMenuMock).show(eq(GridWidget.SIMULATION), eq(clickPointX), eq(clickPointY)); verifyZeroInteractions(expectedContextMenuMock); }
public boolean manageRightClick(final ScenarioGrid scenarioGrid, final ContextMenuEvent event) { final int canvasX = CoordinateUtilities.getRelativeXOfEvent(event); final int canvasY = CoordinateUtilities.getRelativeYOfEvent(event); final Point2D gridClickPoint = CoordinateUtilities.convertDOMToGridCoordinate(scenarioGrid, new Point2D(canvasX, canvasY)); boolean isHeader = true; Integer uiRowIndex = CoordinateUtilities.getUiHeaderRowIndex(scenarioGrid, gridClickPoint); if (uiRowIndex == null) { uiRowIndex = CoordinateUtilities.getUiRowIndex(scenarioGrid, gridClickPoint.getY()); isHeader = false; } if (uiRowIndex == null) { return false; } final Integer uiColumnIndex = CoordinateUtilities.getUiColumnIndex(scenarioGrid, gridClickPoint.getX()); if (uiColumnIndex == null) { return false; } return manageRightClick(scenarioGrid, event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY(), uiRowIndex, uiColumnIndex, isHeader); }
ScenarioContextMenuRegistry { public boolean manageRightClick(final ScenarioGrid scenarioGrid, final ContextMenuEvent event) { final int canvasX = CoordinateUtilities.getRelativeXOfEvent(event); final int canvasY = CoordinateUtilities.getRelativeYOfEvent(event); final Point2D gridClickPoint = CoordinateUtilities.convertDOMToGridCoordinate(scenarioGrid, new Point2D(canvasX, canvasY)); boolean isHeader = true; Integer uiRowIndex = CoordinateUtilities.getUiHeaderRowIndex(scenarioGrid, gridClickPoint); if (uiRowIndex == null) { uiRowIndex = CoordinateUtilities.getUiRowIndex(scenarioGrid, gridClickPoint.getY()); isHeader = false; } if (uiRowIndex == null) { return false; } final Integer uiColumnIndex = CoordinateUtilities.getUiColumnIndex(scenarioGrid, gridClickPoint.getX()); if (uiColumnIndex == null) { return false; } return manageRightClick(scenarioGrid, event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY(), uiRowIndex, uiColumnIndex, isHeader); } }
ScenarioContextMenuRegistry { public boolean manageRightClick(final ScenarioGrid scenarioGrid, final ContextMenuEvent event) { final int canvasX = CoordinateUtilities.getRelativeXOfEvent(event); final int canvasY = CoordinateUtilities.getRelativeYOfEvent(event); final Point2D gridClickPoint = CoordinateUtilities.convertDOMToGridCoordinate(scenarioGrid, new Point2D(canvasX, canvasY)); boolean isHeader = true; Integer uiRowIndex = CoordinateUtilities.getUiHeaderRowIndex(scenarioGrid, gridClickPoint); if (uiRowIndex == null) { uiRowIndex = CoordinateUtilities.getUiRowIndex(scenarioGrid, gridClickPoint.getY()); isHeader = false; } if (uiRowIndex == null) { return false; } final Integer uiColumnIndex = CoordinateUtilities.getUiColumnIndex(scenarioGrid, gridClickPoint.getX()); if (uiColumnIndex == null) { return false; } return manageRightClick(scenarioGrid, event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY(), uiRowIndex, uiColumnIndex, isHeader); } @Inject  ScenarioContextMenuRegistry(final OtherContextMenu otherContextMenu,
                                       final HeaderGivenContextMenu headerGivenContextMenu,
                                       final HeaderExpectedContextMenu headerExpectedContextMenu,
                                       final GivenContextMenu givenContextMenu,
                                       final ExpectedContextMenu expectedContextMenu,
                                       final GridContextMenu gridContextMenu); }
ScenarioContextMenuRegistry { public boolean manageRightClick(final ScenarioGrid scenarioGrid, final ContextMenuEvent event) { final int canvasX = CoordinateUtilities.getRelativeXOfEvent(event); final int canvasY = CoordinateUtilities.getRelativeYOfEvent(event); final Point2D gridClickPoint = CoordinateUtilities.convertDOMToGridCoordinate(scenarioGrid, new Point2D(canvasX, canvasY)); boolean isHeader = true; Integer uiRowIndex = CoordinateUtilities.getUiHeaderRowIndex(scenarioGrid, gridClickPoint); if (uiRowIndex == null) { uiRowIndex = CoordinateUtilities.getUiRowIndex(scenarioGrid, gridClickPoint.getY()); isHeader = false; } if (uiRowIndex == null) { return false; } final Integer uiColumnIndex = CoordinateUtilities.getUiColumnIndex(scenarioGrid, gridClickPoint.getX()); if (uiColumnIndex == null) { return false; } return manageRightClick(scenarioGrid, event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY(), uiRowIndex, uiColumnIndex, isHeader); } @Inject  ScenarioContextMenuRegistry(final OtherContextMenu otherContextMenu,
                                       final HeaderGivenContextMenu headerGivenContextMenu,
                                       final HeaderExpectedContextMenu headerExpectedContextMenu,
                                       final GivenContextMenu givenContextMenu,
                                       final ExpectedContextMenu expectedContextMenu,
                                       final GridContextMenu gridContextMenu); void setEventBus(final EventBus eventBus); void hideMenus(); boolean manageRightClick(final ScenarioGrid scenarioGrid,
                                    final ContextMenuEvent event); boolean manageRightClick(final ScenarioGrid scenarioGrid,
                                    final int clientXPosition,
                                    final int clientYPosition,
                                    final Integer uiRowIndex,
                                    final Integer uiColumnIndex,
                                    final boolean isHeader); void setErrorReportPopoverPresenter(ErrorReportPopoverPresenter errorReportPopoverPresenter); void hideErrorReportPopover(); }
ScenarioContextMenuRegistry { public boolean manageRightClick(final ScenarioGrid scenarioGrid, final ContextMenuEvent event) { final int canvasX = CoordinateUtilities.getRelativeXOfEvent(event); final int canvasY = CoordinateUtilities.getRelativeYOfEvent(event); final Point2D gridClickPoint = CoordinateUtilities.convertDOMToGridCoordinate(scenarioGrid, new Point2D(canvasX, canvasY)); boolean isHeader = true; Integer uiRowIndex = CoordinateUtilities.getUiHeaderRowIndex(scenarioGrid, gridClickPoint); if (uiRowIndex == null) { uiRowIndex = CoordinateUtilities.getUiRowIndex(scenarioGrid, gridClickPoint.getY()); isHeader = false; } if (uiRowIndex == null) { return false; } final Integer uiColumnIndex = CoordinateUtilities.getUiColumnIndex(scenarioGrid, gridClickPoint.getX()); if (uiColumnIndex == null) { return false; } return manageRightClick(scenarioGrid, event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY(), uiRowIndex, uiColumnIndex, isHeader); } @Inject  ScenarioContextMenuRegistry(final OtherContextMenu otherContextMenu,
                                       final HeaderGivenContextMenu headerGivenContextMenu,
                                       final HeaderExpectedContextMenu headerExpectedContextMenu,
                                       final GivenContextMenu givenContextMenu,
                                       final ExpectedContextMenu expectedContextMenu,
                                       final GridContextMenu gridContextMenu); void setEventBus(final EventBus eventBus); void hideMenus(); boolean manageRightClick(final ScenarioGrid scenarioGrid,
                                    final ContextMenuEvent event); boolean manageRightClick(final ScenarioGrid scenarioGrid,
                                    final int clientXPosition,
                                    final int clientYPosition,
                                    final Integer uiRowIndex,
                                    final Integer uiColumnIndex,
                                    final boolean isHeader); void setErrorReportPopoverPresenter(ErrorReportPopoverPresenter errorReportPopoverPresenter); void hideErrorReportPopover();  }