Search in sources :

Example 46 with DMNGridRow

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

the class ExpressionEditorColumnTest method testMinimalWidthTwoCellsSumWithPadding.

/**
 * (10)[100](10)
 * (10)[50][60](10)
 * (10)[105](10)
 */
@Test
public void testMinimalWidthTwoCellsSumWithPadding() throws Exception {
    gridData.appendColumn(column);
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    mockCellsWithPadding(0, 0, PADDING, 100);
    mockCellsWithPadding(1, 0, PADDING, 50, 60);
    mockCellsWithPadding(2, 0, PADDING, 105);
    Assertions.assertThat(column.getMinimumWidth()).isEqualTo(130);
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Test(org.junit.Test)

Example 47 with DMNGridRow

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

the class DecisionTableUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiInputClauseColumn);
    this.uiModel.appendColumn(uiOutputClauseColumn);
    this.uiModel.appendColumn(uiDescriptionColumn);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiOutputClauseColumn).getIndex();
    doReturn(3).when(uiDescriptionColumn).getIndex();
    this.dtable = new DecisionTable();
    this.dtable.getInput().add(new InputClause());
    this.dtable.getOutput().add(new OutputClause());
    this.dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests() {

                {
                    setText("i1");
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    setText("o1");
                }
            });
            setDescription(new Description("desc1"));
        }
    });
    this.dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests() {

                {
                    setText("i2");
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    setText("o2");
                }
            });
            setDescription(new Description("desc2"));
        }
    });
    this.mapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
    this.cellValueSupplier = Optional::empty;
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Optional(java.util.Optional) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Before(org.junit.Before)

Example 48 with DMNGridRow

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

the class FunctionUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    doReturn(0).when(uiExpressionEditorColumn).getIndex();
    doReturn(uiModel).when(gridWidget).getModel();
    // Core Editor definitions
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    // Supplementary Editor definitions
    final ExpressionEditorDefinitions supplementaryEditorDefinitions = new ExpressionEditorDefinitions();
    supplementaryEditorDefinitions.add(supplementaryEditorDefinition);
    doReturn(supplementaryEditorDefinitions).when(supplementaryEditorDefinitionsSupplier).get();
    doReturn(Optional.of(context)).when(supplementaryEditorDefinition).getModelClass();
    doReturn(Optional.of(context)).when(supplementaryEditor).getExpression();
    doReturn(Optional.of(supplementaryEditor)).when(supplementaryEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    this.function = new FunctionDefinition();
    this.mapper = new FunctionUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(function), expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, listSelector, 0);
    this.cellValueSupplier = Optional::empty;
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 49 with DMNGridRow

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

the class LiteralExpressionUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    uiModel = new BaseGridData();
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendColumn(uiLiteralExpressionColumn);
    doReturn(0).when(uiLiteralExpressionColumn).getIndex();
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parentGridUiModel.getCell(eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX))).thenReturn(parentGridUiCell);
    when(parentGridUiCell.getSelectionStrategy()).thenReturn(parentGridUiCellCellSelectionStrategy);
    literalExpression = new LiteralExpression();
    mapper = new LiteralExpressionUIModelMapper(() -> uiModel, () -> Optional.of(literalExpression), listSelector, new GridCellTuple(PARENT_ROW_INDEX, PARENT_COLUMN_INDEX, parentGridWidget));
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 50 with DMNGridRow

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

the class InvocationGrid method addParameterBinding.

void addParameterBinding(final int index) {
    expression.ifPresent(invocation -> {
        final Binding binding = new Binding();
        final InformationItem parameter = new InformationItem();
        parameter.setName(new Name("p" + invocation.getBinding().size()));
        binding.setParameter(parameter);
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddParameterBindingCommand(invocation, binding, model, new DMNGridRow(), index, uiModelMapper, this::synchroniseView));
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) AddParameterBindingCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.AddParameterBindingCommand) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Aggregations

DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)67 Test (org.junit.Test)32 Before (org.junit.Before)16 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)13 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)12 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)12 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)12 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)11 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)10 Optional (java.util.Optional)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)6 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)6 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)6 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)6 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)5 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)4 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)4