Search in sources :

Example 11 with DMNGridData

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

the class BaseEditorDefinitionTest method testCacheWhenNotNested.

@Test
public void testCacheWhenNotNested() {
    final Optional<String> UUID = Optional.of("uuid");
    final GridDataCache.CacheResult<DMNGridData> result1 = definition.getData(UUID, definition.getModelClass());
    assertCacheResult(result1, false);
    final GridDataCache.CacheResult<DMNGridData> result2 = definition.getData(UUID, definition.getModelClass());
    assertCacheResult(result2, true);
    final DMNGridData uiModel1 = result1.getGridData();
    final DMNGridData uiModel2 = result2.getGridData();
    assertThat(uiModel1).isSameAs(uiModel2);
}
Also used : GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Test(org.junit.Test)

Example 12 with DMNGridData

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

the class BaseExpressionGridRenderingTest method getGrid.

@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
    final GridCellTuple parent = new GridCellTuple(0, 0, null);
    final HasExpression hasExpression = mock(HasExpression.class);
    final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
    final Optional<HasName> hasName = Optional.of(mock(HasName.class));
    return new BaseExpressionGrid(parent, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {

        @Override
        protected BaseUIModelMapper makeUiModelMapper() {
            return mapper;
        }

        @Override
        protected void initialiseUiColumns() {
        // Nothing for this test
        }

        @Override
        protected void initialiseUiModel() {
        // Nothing for this test
        }

        @Override
        protected boolean isHeaderHidden() {
            return isHeaderHidden;
        }
    };
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)

Example 13 with DMNGridData

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

the class ExpressionEditorColumnTest method mockEditor.

@SuppressWarnings("unchecked")
private BaseExpressionGrid mockEditor(final double padding, final double... widthOfCells) {
    final GridColumn.HeaderMetaData headerMetaData = mock(GridColumn.HeaderMetaData.class);
    final GridColumnRenderer gridColumnRenderer = mock(GridColumnRenderer.class);
    final BaseExpressionGrid gridWidget = mock(BaseExpressionGrid.class);
    final GridCellTuple parent = new GridCellTuple(0, 0, null);
    final HasExpression hasExpression = mock(HasExpression.class);
    final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
    final Optional<HasName> hasName = Optional.of(mock(HasName.class));
    return new BaseExpressionGrid(parent, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {

        @Override
        protected BaseUIModelMapper makeUiModelMapper() {
            return null;
        }

        @Override
        protected void initialiseUiColumns() {
            for (double width : widthOfCells) {
                model.appendColumn(new DMNGridColumn<GridWidget, Object>(headerMetaData, gridColumnRenderer, gridWidget) {

                    {
                        setMinimumWidth(width);
                        setWidth(width);
                    }
                });
            }
        }

        @Override
        protected void initialiseUiModel() {
        // Nothing for this test
        }

        @Override
        protected boolean isHeaderHidden() {
            return false;
        }

        @Override
        public double getPadding() {
            return padding;
        }
    };
}
Also used : GridColumnRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.columns.GridColumnRenderer) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn)

Example 14 with DMNGridData

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

the class FunctionGridTest method testInitialSetupFromDefinition.

@Test
public void testInitialSetupFromDefinition() {
    setupGrid(0);
    final GridData uiModel = grid.getModel();
    assertTrue(uiModel instanceof DMNGridData);
    assertEquals(1, uiModel.getColumnCount());
    assertTrue(uiModel.getColumns().get(0) instanceof ExpressionEditorColumn);
    assertEquals(1, uiModel.getRowCount());
    assertTrue(uiModel.getCell(0, 0).getValue() instanceof ExpressionCellValue);
    final ExpressionCellValue dcv = (ExpressionCellValue) uiModel.getCell(0, 0).getValue();
    assertEquals(literalExpressionEditor, dcv.getValue().get());
}
Also used : ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Test(org.junit.Test)

Example 15 with DMNGridData

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

the class AddInputClauseCommandTest method setUp.

@Before
public void setUp() throws Exception {
    this.dtable = new DecisionTable();
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.inputClause = new InputClause();
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) Before(org.junit.Before)

Aggregations

DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)21 Before (org.junit.Before)15 DecisionTable (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable)8 DecisionTableUIModelMapper (org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper)5 GridDataCache (org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache)5 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)4 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)4 Test (org.junit.Test)3 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)3 Context (org.kie.workbench.common.dmn.api.definition.v1_1.Context)2 InputClause (org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)2 OutputClause (org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause)2 Relation (org.kie.workbench.common.dmn.api.definition.v1_1.Relation)2 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)2 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)2 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)2 BaseGridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget)2 Invocation (org.kie.workbench.common.dmn.api.definition.v1_1.Invocation)1 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)1