GridWidgetDnDMouseMoveHandler implements NodeMouseMoveHandler { protected void findMovableColumns(final GridWidget view, final BaseGridRendererHelper.RenderingInformation renderingInformation, final double headerRowsHeight, final double headerMinY, final double cx, final double cy) { if (renderingInformation == null) { return; } final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> allColumns = view.getModel().getColumns(); final List<GridColumn<?>> bodyColumns = bodyBlockInformation.getColumns(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); final double bodyX = bodyBlockInformation.getX(); final double floatingX = floatingBlockInformation.getX(); final double floatingWidth = floatingBlockInformation.getWidth(); double offsetX = bodyX; for (int headerColumnIndex = 0; headerColumnIndex < bodyColumns.size(); headerColumnIndex++) { final GridColumn<?> gridColumn = bodyColumns.get(headerColumnIndex); final double columnWidth = gridColumn.getWidth(); if (gridColumn.isVisible()) { final List<GridColumn.HeaderMetaData> headerMetaData = gridColumn.getHeaderMetaData(); final double headerRowHeight = headerRowsHeight / headerMetaData.size(); for (int headerRowIndex = 0; headerRowIndex < headerMetaData.size(); headerRowIndex++) { final GridColumn.HeaderMetaData md = headerMetaData.get(headerRowIndex); if (gridColumn.isMovable()) { if (cy < (headerRowIndex + 1) * headerRowHeight + headerMinY) { if (cx > floatingX + floatingWidth) { if (cx > offsetX && cx < offsetX + columnWidth) { final List<GridColumn<?>> blockColumns = getBlockColumns(allColumns, headerMetaData, headerRowIndex, allColumns.indexOf(gridColumn)); for (GridColumn<?> blockColumn : blockColumns) { if (floatingColumns.contains(blockColumn)) { return; } } state.setActiveGridWidget(view); state.setActiveGridColumns(blockColumns); state.setActiveHeaderMetaData(md); state.setOperation(GridWidgetDnDHandlersState.GridWidgetHandlersOperation.COLUMN_MOVE_PENDING); setCursor(Style.Cursor.MOVE); return; } } } } } offsetX = offsetX + columnWidth; } } } GridWidgetDnDMouseMoveHandler(final GridLayer layer,
                                         final GridWidgetDnDHandlersState state); @Override @SuppressWarnings("unchecked") void onNodeMouseMove(final NodeMouseMoveEvent event);  }
@Test public void findMovableColumns() { when(state.getOperation()).thenReturn(GridWidgetHandlersOperation.NONE); when(gridWidget.isVisible()).thenReturn(true); when(layer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget)); when(event.getX()).thenReturn(160); when(event.getY()).thenReturn(100); handler.onNodeMouseMove(event); verify(handler, times(1)).findGridColumn(eq(event)); verify(handler, times(1)).findMovableColumns(any(GridWidget.class), any(BaseGridRendererHelper.RenderingInformation.class), any(Double.class), any(Double.class), any(Double.class), any(Double.class)); verify(handler, never()).findMovableRows(any(GridWidget.class), any(BaseGridRendererHelper.RenderingInformation.class), any(Double.class), any(Double.class)); verify(handler, times(1)).findResizableColumn(any(GridWidget.class), any(BaseGridRendererHelper.RenderingInformation.class), any(Double.class)); verify(state, times(1)).setActiveGridWidget(eq(gridWidget)); verify(state, times(1)).setOperation(eq(GridWidgetHandlersOperation.COLUMN_MOVE_PENDING)); verify(state, times(1)).setActiveGridColumns(uiColumnsArgumentCaptor.capture()); final List<GridColumn<?>> uiColumns = uiColumnsArgumentCaptor.getValue(); assertNotNull(uiColumns); assertEquals(1, uiColumns.size()); assertTrue(uiColumns.contains(uiColumn2)); }