Search in sources :

Example 31 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class MoveRowsCommandTest method addUiModelRow.

@Override
protected void addUiModelRow(final int rowIndex) {
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("value" + rowIndex));
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 32 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class DeleteContextEntryCommandTest method testCanvasCommandUndoWithColumnsMultipleRows.

@Test
public void testCanvasCommandUndoWithColumnsMultipleRows() {
    addContextEntries(3);
    final GridRow firstRow = uiModel.getRow(0);
    final GridRow originalRow = uiModel.getRow(1);
    final GridRow lastRow = uiModel.getRow(2);
    makeCommand(1);
    uiModel.appendColumn(uiModelColumn);
    // Delete ContextEntry and then undo
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    reset(command, canvasOperation);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(3, uiModel.getRowCount());
    assertEquals(firstRow, uiModel.getRow(0));
    assertEquals(originalRow, uiModel.getRow(1));
    assertEquals(lastRow, uiModel.getRow(2));
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 33 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow 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 GridRow existingUiRow = new BaseGridRow();
    dtable.getRule().add(existingRule);
    uiModel.appendRow(existingUiRow);
    dtable.getInput().add(new InputClause());
    dtable.getOutput().add(new OutputClause());
    dtable.getAnnotations().add(new RuleAnnotationClause());
    makeCommand(1);
    uiModel.appendColumn(uiInputClauseColumn);
    uiModel.appendColumn(uiOutputClauseColumn);
    uiModel.appendColumn(uiRuleAnnotationClauseColumn);
    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.model.OutputClause) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) 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) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) Test(org.junit.Test)

Example 34 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow 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 GridRow existingUiRow = new BaseGridRow();
    dtable.getRule().add(existingRule);
    uiModel.appendRow(existingUiRow);
    makeCommand(1);
    uiModel.appendColumn(uiInputClauseColumn);
    uiModel.appendColumn(uiOutputClauseColumn);
    uiModel.appendColumn(uiRuleAnnotationClauseColumn);
    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) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) 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) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Example 35 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class MoveRowsCommandTest method appendRow.

private void appendRow(final int rowIndex, final String rowIdentifier) {
    final String inValue = "in " + rowIdentifier;
    final String outValue = "out " + rowIdentifier;
    dtable.getRule().add(new DecisionRule() {

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

                {
                    getText().setValue(inValue);
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    getText().setValue(outValue);
                }
            });
        }
    });
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>(inValue));
    uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>(outValue));
    rowsUnderTest.add(uiRow);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Aggregations

GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)54 Test (org.junit.Test)31 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)22 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)10 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)10 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)10 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)8 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)6 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)6 BaseGridCell (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell)6 ArrayList (java.util.ArrayList)4 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)4 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)4 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)3 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)3 HashMap (java.util.HashMap)2 Maps (org.kie.soup.commons.util.Maps)2 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)2 List (org.kie.workbench.common.dmn.api.definition.model.List)2 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)2