Search in sources :

Example 1 with BaseGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.

the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithHeader.

@Test
@SuppressWarnings("unchecked")
public void onContextMenu_WithGridWidget_WithHeader() {
    final int EVENT_X = (int) (COLUMN0_WIDTH + COLUMN1_WIDTH / 2);
    final int EVENT_Y = (int) (HEADER_HEIGHT / 2);
    when(nativeEvent.getClientX()).thenReturn(EVENT_X);
    when(nativeEvent.getClientY()).thenReturn(EVENT_Y);
    final BaseGrid gridWidget = mockGridWidget();
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
    final MockContextMenuHeaderMetaData headerMetaData = mock(MockContextMenuHeaderMetaData.class);
    when(gridColumn.getHeaderMetaData()).thenReturn(Collections.singletonList(headerMetaData));
    when(headerMetaData.getEditor()).thenReturn(Optional.of(editor));
    handler.onContextMenu(event);
    verify(editor).bind(eq(headerMetaData), eq(0), eq(1));
    verify(cellEditorControls).show(eq(editor), eq(EVENT_X), eq(EVENT_Y));
}
Also used : BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid) Test(org.junit.Test)

Example 2 with BaseGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.

the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithNullCell.

@Test
public void onContextMenu_WithGridWidget_WithNullCell() {
    when(nativeEvent.getClientX()).thenReturn((int) (COLUMN0_WIDTH / 2));
    when(nativeEvent.getClientY()).thenReturn((int) (ROW_HEIGHT + ROW_HEIGHT / 2));
    final BaseGrid gridWidget = mockGridWidget();
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
    handler.onContextMenu(event);
    verify(cellEditorControls, never()).show(any(HasCellEditorControls.Editor.class), anyInt(), anyInt());
}
Also used : BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid) Test(org.junit.Test)

Example 3 with BaseGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.

the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithCellValue.

@Test
@SuppressWarnings("unchecked")
public void onContextMenu_WithGridWidget_WithCellValue() {
    final int EVENT_X = (int) (COLUMN0_WIDTH / 2);
    final int EVENT_Y = (int) (HEADER_HEIGHT + ROW_HEIGHT + ROW_HEIGHT / 2);
    when(nativeEvent.getClientX()).thenReturn(EVENT_X);
    when(nativeEvent.getClientY()).thenReturn(EVENT_Y);
    final BaseGrid gridWidget = mockGridWidget();
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
    final MockCell cell = mock(MockCell.class);
    gridWidget.getModel().setCell(1, 0, () -> cell);
    when(cell.getEditor()).thenReturn(Optional.of(editor));
    handler.onContextMenu(event);
    verify(editor).bind(eq(gridWidget), eq(1), eq(0));
    verify(cellEditorControls).show(eq(editor), eq(EVENT_X), eq(EVENT_Y));
}
Also used : BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid) Test(org.junit.Test)

Example 4 with BaseGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.

the class DMNGridPanelContextMenuHandlerTest method mockGridWidget.

private BaseGrid mockGridWidget() {
    final BaseGrid gridWidget = spy(new BaseGrid(gridLayer, new BaseGridData(false), renderer, sessionManager, sessionCommandManager, canvasCommandFactory, refreshFormPropertiesEvent, domainObjectSelectionEvent, cellEditorControls, translationService) {

        @Override
        public Layer getLayer() {
            return gridLayer;
        }
    });
    gridWidget.getModel().appendColumn(new RowNumberColumn());
    gridWidget.getModel().appendColumn(gridColumn);
    gridWidget.getModel().appendRow(new BaseGridRow());
    gridWidget.getModel().appendRow(new BaseGridRow());
    return gridWidget;
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) Layer(com.ait.lienzo.client.core.shape.Layer) BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)

Example 5 with BaseGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid in project kie-wb-common by kiegroup.

the class DMNGridWidgetDnDMouseUpHandler method onNodeMouseUp.

@Override
public void onNodeMouseUp(final NodeMouseUpEvent event) {
    if (state.getOperation() == GridWidgetDnDHandlersState.GridWidgetHandlersOperation.COLUMN_RESIZE) {
        final GridWidget gridWidget = state.getActiveGridWidget();
        final List<GridColumn<?>> gridColumns = state.getActiveGridColumns();
        if (isBaseGrid(gridWidget) && isSingleDMNColumn(gridColumns)) {
            final BaseGrid uiGridWidget = (BaseGrid) gridWidget;
            final DMNGridColumn uiColumn = (DMNGridColumn) gridColumns.get(0);
            uiGridWidget.registerColumnResizeCompleted(uiColumn, state.getEventInitialColumnWidth());
        }
    }
    super.onNodeMouseUp(event);
}
Also used : DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)

Aggregations

BaseGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)12 Test (org.junit.Test)9 DMNGridColumn (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn)2 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)2 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)2 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)2 CellSelectionStrategy (org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy)2 Layer (com.ait.lienzo.client.core.shape.Layer)1 LinkedHashSet (java.util.LinkedHashSet)1 Optional (java.util.Optional)1 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)1 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)1 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)1 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)1 DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)1 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)1 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)1 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)1 GridColumnRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.columns.GridColumnRenderer)1