@Override public boolean onNodeMouseEvent(final GridWidget gridWidget, final Point2D relativeLocation, final Optional<Integer> uiHeaderRowIndex, final Optional<Integer> uiHeaderColumnIndex, final Optional<Integer> uiRowIndex, final Optional<Integer> uiColumnIndex, final AbstractNodeMouseEvent event) { boolean isHandled = false; if (uiHeaderRowIndex.isPresent() && uiHeaderColumnIndex.isPresent()) { isHandled = handleHeaderCell(gridWidget, relativeLocation, uiHeaderRowIndex.get(), uiHeaderColumnIndex.get(), event); } if (!isHandled && uiRowIndex.isPresent() && uiColumnIndex.isPresent()) { isHandled = handleBodyCell(gridWidget, relativeLocation, uiRowIndex.get(), uiColumnIndex.get(), event); } if (isHandled) { if (!gridWidget.isSelected()) { selectionManager.select(gridWidget); } } return isHandled; }
@Test public void selectVisibleGridHeaderNonLinkedColumn() { when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(100); when(gridWidget.getLocation()).thenReturn(new Point2D(100, 100)); when(uiColumn.isLinked()).thenReturn(false); final BaseGridRendererHelper.ColumnInformation ci = new BaseGridRendererHelper.ColumnInformation(uiColumn, 0, 0); when(helper.getColumnInformation(any(Double.class))).thenReturn(ci); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(0), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(0), eq(event)); verify(selectionManager, never()).select(any(GridWidget.class)); verify(selectionManager, never()).selectLinkedColumn(eq(uiColumn)); }
/** * Checks if the {@link AbstractNodeMouseEvent} happened on a "linked" {@link GridColumn}. If * the {@link AbstractNodeMouseEvent} was found to have happened on a {@link GridWidget} "linked" column then * selection of the "linked" {@link GridColumn} is delegated to {@link GridSelectionManager#selectLinkedColumn(GridColumn)}. */ @Override public boolean handleHeaderCell(final GridWidget gridWidget, final Point2D relativeLocation, final int uiHeaderRowIndex, final int uiHeaderColumnIndex, final AbstractNodeMouseEvent event) { final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final double cx = relativeLocation.getX(); final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(cx); final GridColumn<?> column = ci.getColumn(); if (column == null) { return false; } //If linked scroll it into view if (column.isLinked()) { final GridColumn<?> link = column.getLink(); selectionManager.selectLinkedColumn(link); return true; } return false; } }
@Test public void selectVisibleGridHeaderNonLinkedColumn() { when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(100); when(gridWidget.getLocation()).thenReturn(new Point2D(100, 100)); when(uiColumn.isLinked()).thenReturn(false); final BaseGridRendererHelper.ColumnInformation ci = new BaseGridRendererHelper.ColumnInformation(uiColumn, 0, 0); when(helper.getColumnInformation(any(Double.class))).thenReturn(ci); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(0), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(0), eq(event)); verify(selectionManager, never()).select(any(GridWidget.class)); verify(selectionManager, never()).selectLinkedColumn(eq(uiColumn)); }
/** * Checks if the {@link AbstractNodeMouseEvent} happened on a "linked" {@link GridColumn}. If * the {@link AbstractNodeMouseEvent} was found to have happened on a {@link GridWidget} "linked" column then * selection of the "linked" {@link GridColumn} is delegated to {@link GridSelectionManager#selectLinkedColumn(GridColumn)}. */ @Override public boolean handleHeaderCell(final GridWidget gridWidget, final Point2D relativeLocation, final int uiHeaderRowIndex, final int uiHeaderColumnIndex, final AbstractNodeMouseEvent event) { final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final double cx = relativeLocation.getX(); final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(cx); final GridColumn<?> column = ci.getColumn(); if (column == null) { return false; } //If linked scroll it into view if (column.isLinked()) { final GridColumn<?> link = column.getLink(); selectionManager.selectLinkedColumn(link); return true; } return false; } }
eq(event)); verify(selectionManager, never()).select(any(GridWidget.class)); verify(selectionManager, times(1)).selectLinkedColumn(eq(uiLinkedColumn));
@Override public boolean onNodeMouseEvent(final GridWidget gridWidget, final Point2D relativeLocation, final Optional<Integer> uiHeaderRowIndex, final Optional<Integer> uiHeaderColumnIndex, final Optional<Integer> uiRowIndex, final Optional<Integer> uiColumnIndex, final AbstractNodeMouseEvent event) { boolean isHandled = false; if (uiHeaderRowIndex.isPresent() && uiHeaderColumnIndex.isPresent()) { isHandled = handleHeaderCell(gridWidget, relativeLocation, uiHeaderRowIndex.get(), uiHeaderColumnIndex.get(), event); } if (!isHandled && uiRowIndex.isPresent() && uiColumnIndex.isPresent()) { isHandled = handleBodyCell(gridWidget, relativeLocation, uiRowIndex.get(), uiColumnIndex.get(), event); } if (isHandled) { if (!gridWidget.isSelected()) { selectionManager.select(gridWidget); } } return isHandled; }
eq(event)); verify(selectionManager, never()).select(any(GridWidget.class)); verify(selectionManager, times(1)).selectLinkedColumn(eq(uiLinkedColumn));
final GridWidget parentGridWidget = parentSupplier.get().getGridWidget(); if (!parentGridWidget.isSelected()) { selectionManager.select(parentGridWidget);
@Test public void checkHeaderSelectionDelegation() { when(gridWidget.selectHeaderCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(1), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectHeaderCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); }
@Test public void checkHeaderSelectionDelegation() { when(gridWidget.selectHeaderCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(1), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectHeaderCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); }
@Test public void checkBodySelectionDelegation() { when(gridWidget.selectCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(1), event); verify(handler, times(1)).handleBodyCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); } }
@Test public void checkBodySelectionDelegation() { when(gridWidget.selectCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(1), event); verify(handler, times(1)).handleBodyCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); } }