Search in sources :

Example 16 with RowNumberColumn

use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testAdjustSelectionHandling_MoveDownWhenAtBottomAlready.

@Test
public void testAdjustSelectionHandling_MoveDownWhenAtBottomAlready() {
    grid.getModel().appendColumn(new RowNumberColumn());
    grid.getModel().appendRow(new BaseGridRow());
    grid.selectCell(0, 0, false, false);
    reset(grid);
    grid.adjustSelection(SelectionExtension.DOWN, false);
    verify(grid, never()).doAfterSelectionChange(anyInt(), anyInt());
}
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) Test(org.junit.Test)

Example 17 with RowNumberColumn

use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project kie-wb-common by kiegroup.

the class DMNGridPanelCellSelectionHandlerTest method mockGridWidget.

private BaseExpressionGrid mockGridWidget() {
    final BaseExpressionGrid gridWidget = mock(BaseExpressionGrid.class);
    final GridData gridData = new DMNGridData();
    when(gridWidget.getModel()).thenReturn(gridData);
    gridData.appendColumn(new RowNumberColumn());
    IntStream.range(0, 3).forEach(i -> {
        final GridColumn gridColumn = mock(GridColumn.class);
        final List<GridColumn.HeaderMetaData> headerMetaData = Collections.singletonList(mock(GridColumn.HeaderMetaData.class));
        when(gridColumn.getIndex()).thenReturn(i);
        when(gridColumn.getHeaderMetaData()).thenReturn(headerMetaData);
        gridData.appendColumn(gridColumn);
    });
    gridData.appendRow(new BaseGridRow());
    gridData.appendRow(new BaseGridRow());
    gridData.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) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)

Example 18 with RowNumberColumn

use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project kie-wb-common by kiegroup.

the class CommandUtilsTest method testUpdateParentInformation_WithMultipleColumns.

@Test
@SuppressWarnings("unchecked")
public void testUpdateParentInformation_WithMultipleColumns() {
    setupUiModel(Pair.newPair(new ExpressionEditorColumn(gridLayer, new BaseHeaderMetaData("column"), ExpressionEditorColumn.DEFAULT_WIDTH, gridWidget), (rowIndex) -> {
        final BaseExpressionGrid grid = mock(BaseExpressionGrid.class);
        final GridCellTuple gct = new GridCellTuple(rowIndex, 0, mock(GridWidget.class));
        when(grid.getParentInformation()).thenReturn(gct);
        return new ExpressionCellValue(Optional.of(grid));
    }), Pair.newPair(new RowNumberColumn(), (rowIndex) -> new BaseGridCellValue<>(rowIndex + 1)));
    assertParentInformationValues(0);
    gridData.moveColumnTo(0, gridData.getColumns().get(1));
    CommandUtils.updateParentInformation(gridData);
    assertParentInformationValues(1);
}
Also used : IntStream(java.util.stream.IntStream) CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Arrays(java.util.Arrays) BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Function(java.util.function.Function) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Assertions(org.assertj.core.api.Assertions) Assert.fail(org.junit.Assert.fail) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Pair(org.uberfire.commons.data.Pair) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Mockito.when(org.mockito.Mockito.when) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) List(java.util.List) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) DefaultCanvasCommandFactory(org.kie.workbench.common.dmn.client.commands.factory.DefaultCanvasCommandFactory) GridCellValue(org.uberfire.ext.wires.core.grids.client.model.GridCellValue) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) EventSourceMock(org.uberfire.mocks.EventSourceMock) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Test(org.junit.Test)

Example 19 with RowNumberColumn

use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project kie-wb-common by kiegroup.

the class RelationGrid method initialiseUiColumns.

@Override
public void initialiseUiColumns() {
    int uiColumnIndex = 0;
    final RowNumberColumn rowNumberColumn = new RowNumberColumn();
    rowNumberColumn.setWidth(getAndSetInitialWidth(uiColumnIndex++, rowNumberColumn.getWidth()));
    if (getExpression().get().isPresent()) {
        model.appendColumn(rowNumberColumn);
        final Relation e = getExpression().get().get();
        for (int index = 0; index < e.getColumn().size(); index++) {
            final GridColumn relationColumn = makeRelationColumn(uiColumnIndex++, e.getColumn().get(index));
            model.appendColumn(relationColumn);
        }
    }
    getRenderer().setColumnRenderConstraint((isSelectionLayer, gridColumn) -> true);
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn)

Example 20 with RowNumberColumn

use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project kie-wb-common by kiegroup.

the class RelationGridTest method testInitialiseUiColumns.

@Test
public void testInitialiseUiColumns() {
    final String columnHeader = "first column";
    relation.getColumn().add(new InformationItem() {

        {
            getName().setValue(columnHeader);
        }
    });
    expression = Optional.of(relation);
    setupGrid(0);
    assertEquals(2, grid.getModel().getColumns().size());
    assertTrue(grid.getModel().getColumns().get(0) instanceof RowNumberColumn);
    assertEquals(columnHeader, grid.getModel().getColumns().get(1).getHeaderMetaData().get(0).getTitle());
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Aggregations

RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)24 Test (org.junit.Test)17 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)11 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)9 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)9 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)9 ContextMenuHandler (com.google.gwt.event.dom.client.ContextMenuHandler)6 BaseGridColumn (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn)6 ArrayList (java.util.ArrayList)4 Before (org.junit.Before)4 ExpressionEditorColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn)4 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)3 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)3 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)2 BaseGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)2 DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)2 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)2 Layer (com.ait.lienzo.client.core.shape.Layer)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1