Search in sources :

Example 51 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 initialiseUiModel.

@Override
protected void initialiseUiModel() {
    expression.ifPresent(invocation -> {
        invocation.getBinding().stream().forEach(binding -> {
            model.appendRow(new DMNGridRow());
            uiModelMapper.fromDMNModel(model.getRowCount() - 1, InvocationUIModelMapper.ROW_NUMBER_COLUMN_INDEX);
            uiModelMapper.fromDMNModel(model.getRowCount() - 1, InvocationUIModelMapper.BINDING_PARAMETER_COLUMN_INDEX);
            uiModelMapper.fromDMNModel(model.getRowCount() - 1, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX);
        });
    });
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)

Example 52 with DMNGridRow

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

the class DeleteContextEntryCommandTest method addContextEntries.

private void addContextEntries(final int entriesCount) {
    final int originalRowCount = uiModel.getRowCount();
    for (int i = 0; i < originalRowCount; i++) {
        uiModel.deleteRow(0);
    }
    context.getContextEntry().clear();
    for (int i = 0; i < entriesCount; i++) {
        context.getContextEntry().add(new ContextEntry());
        uiModel.appendRow(new DMNGridRow());
    }
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)

Example 53 with DMNGridRow

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

the class MoveRowsCommandTest method addUiModelRow.

protected void addUiModelRow(final int rowIndex) {
    final DMNGridRow uiRow = new DMNGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("name" + rowIndex));
    uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>("editor" + rowIndex));
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)

Example 54 with DMNGridRow

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

the class AddDecisionRuleCommandTest method testCanvasCommandExecuteInsertBelowThenUndo.

@Test
public void testCanvasCommandExecuteInsertBelowThenUndo() {
    // The default behaviour of tests in this class is to "insert above"
    final DecisionRule existingRule = new DecisionRule();
    final DMNGridRow existingUiRow = new DMNGridRow();
    dtable.getRule().add(existingRule);
    uiModel.appendRow(existingUiRow);
    makeCommand(1);
    uiModel.appendColumn(uiInputClauseColumn);
    uiModel.appendColumn(uiOutputClauseColumn);
    uiModel.appendColumn(uiDescriptionColumn);
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
    final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(canvasHandler);
    graphCommand.execute(graphCommandExecutionContext);
    canvasCommand.execute(canvasHandler);
    canvasCommand.undo(canvasHandler);
    assertEquals(1, uiModel.getRowCount());
    assertEquals(existingUiRow, uiModel.getRow(0));
    // one time in execute(), one time in undo()
    verify(canvasOperation, times(2)).execute();
    verify(command, times(2)).updateRowNumbers();
    verify(command, times(2)).updateParentInformation();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Test(org.junit.Test)

Example 55 with DMNGridRow

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

the class AddDecisionRuleCommandTest method testCanvasCommandExecuteInsertBelow.

@Test
public void testCanvasCommandExecuteInsertBelow() {
    // The default behaviour of tests in this class is to "insert above"
    final DecisionRule existingRule = new DecisionRule();
    final DMNGridRow existingUiRow = new DMNGridRow();
    dtable.getRule().add(existingRule);
    uiModel.appendRow(existingUiRow);
    dtable.getInput().add(new InputClause());
    dtable.getOutput().add(new OutputClause());
    makeCommand(1);
    uiModel.appendColumn(uiInputClauseColumn);
    uiModel.appendColumn(uiOutputClauseColumn);
    uiModel.appendColumn(uiDescriptionColumn);
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
    final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(canvasHandler);
    graphCommand.execute(graphCommandExecutionContext);
    canvasCommand.execute(canvasHandler);
    assertEquals(2, uiModel.getRowCount());
    assertEquals(existingUiRow, uiModel.getRow(0));
    assertEquals(uiModelRow, uiModel.getRow(1));
    assertDefaultUiRowValues(1);
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) Test(org.junit.Test)

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