Search in sources :

Example 11 with AbstractCanvasHandler

use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.

the class DMNEditDecisionToolboxActionTest method testAction.

@Test
public void testAction() {
    final MouseClickEvent event = mock(MouseClickEvent.class);
    final ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
    assertEquals(tested, cascade);
    final ArgumentCaptor<EditExpressionEvent> eventCaptor = ArgumentCaptor.forClass(EditExpressionEvent.class);
    verify(editExpressionEvent, times(1)).fire(eventCaptor.capture());
    final EditExpressionEvent editExprEvent = eventCaptor.getValue();
    assertEquals(E_UUID, editExprEvent.getNodeUUID());
    assertEquals(decision, editExprEvent.getHasExpression());
    assertEquals(decision, editExprEvent.getHasName().get());
    assertEquals(session, editExprEvent.getSession());
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Test(org.junit.Test)

Example 12 with AbstractCanvasHandler

use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.

the class AddContextEntryCommandTest method testCanvasCommandExecuteMultipleEntries.

@Test
public void testCanvasCommandExecuteMultipleEntries() {
    makeCommand();
    // first row
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> firstEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, firstEntryCanvasCommand.execute(handler));
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    // second row
    final ContextEntry secondRowEntry = new ContextEntry() {

        {
            setVariable(new InformationItem() {

                {
                    setName(new Name("last entry"));
                }
            });
        }
    };
    final DMNGridRow uiSecondModelRow = new DMNGridRow();
    command = spy(new AddContextEntryCommand(context, secondRowEntry, uiModel, uiSecondModelRow, context.getContextEntry().size() - 1, uiModelMapper, canvasOperation));
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> secondEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, secondEntryCanvasCommand.execute(handler));
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    assertEquals(3, uiModel.getRowCount());
    assertEquals(uiModelRow, uiModel.getRows().get(0));
    assertEquals(uiSecondModelRow, uiModel.getRows().get(1));
    assertEquals(uiDefaultResultModelRow, uiModel.getRows().get(2));
    assertEquals(3, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiNameColumn, uiModel.getColumns().get(1));
    assertEquals(uiExpressionEditorColumn, uiModel.getColumns().get(2));
    assertEquals(3, uiModel.getRows().get(0).getCells().size());
    assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
    assertEquals("variable", uiModel.getCell(0, 1).getValue().getValue());
    assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
    assertEquals(3, uiModel.getRows().get(1).getCells().size());
    assertEquals(2, uiModel.getCell(1, 0).getValue().getValue());
    assertEquals("last entry", uiModel.getCell(1, 1).getValue().getValue());
    assertTrue(uiModel.getCell(1, 2).getValue() instanceof ExpressionCellValue);
    // Default row
    assertEquals(1, uiModel.getRows().get(2).getCells().size());
    assertTrue(uiModel.getCell(2, 2).getValue() instanceof ExpressionCellValue);
    verify(canvasOperation, times(2)).execute();
}
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) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 13 with AbstractCanvasHandler

use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.

the class SessionTreeExplorerScreen method doOpenDiagram.

@Override
protected void doOpenDiagram() {
    final AbstractCanvasHandler handler = getCanvasHandler();
    if (handler != null) {
        explorer.show(handler);
        view.showScreenView(explorer);
    }
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)

Example 14 with AbstractCanvasHandler

use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.

the class DeleteContextEntryCommandTest method testCanvasCommandExecuteWithColumnsMultipleRows.

@Test
public void testCanvasCommandExecuteWithColumnsMultipleRows() {
    addContextEntries(3);
    final GridRow firstRow = uiModel.getRow(0);
    final GridRow lastRow = uiModel.getRow(2);
    makeCommand(1);
    uiModel.appendColumn(uiModelColumn);
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    assertEquals(2, uiModel.getRowCount());
    assertEquals(2, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
    assertEquals(uiModelColumn, uiModel.getColumns().get(1));
    assertEquals(firstRow, uiModel.getRow(0));
    assertEquals(lastRow, uiModel.getRow(1));
    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) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 15 with AbstractCanvasHandler

use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.

the class AddParameterBindingCommandTest method testCanvasCommandExecuteMultipleEntries.

@Test
public void testCanvasCommandExecuteMultipleEntries() {
    // first row
    final String firstRowText = "p0";
    makeCommand();
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> firstEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, firstEntryCanvasCommand.execute(handler));
    // second row
    final String secondRowText = "second entry";
    final DMNGridRow uiSecondModelRow = new DMNGridRow();
    makeCommand(1, secondRowText, uiSecondModelRow);
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> secondEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, secondEntryCanvasCommand.execute(handler));
    // third row
    final String thirdRowText = "third entry";
    final DMNGridRow uiThirdModelRow = new DMNGridRow();
    makeCommand(0, thirdRowText, uiThirdModelRow);
    command.newGraphCommand(handler).execute(gce);
    final Command<AbstractCanvasHandler, CanvasViolation> thirdEntryCanvasCommand = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, thirdEntryCanvasCommand.execute(handler));
    assertEquals(3, uiModel.getRowCount());
    assertEquals(uiThirdModelRow, uiModel.getRows().get(0));
    assertEquals(uiModelRow, uiModel.getRows().get(1));
    assertEquals(uiSecondModelRow, uiModel.getRows().get(2));
    assertEquals(3, uiModel.getColumnCount());
    assertEquals(uiRowNumberColumn, uiModel.getColumns().get(ROW_NUMBER_COLUMN_INDEX));
    assertEquals(uiNameColumn, uiModel.getColumns().get(BINDING_PARAMETER_COLUMN_INDEX));
    assertEquals(uiExpressionEditorColumn, uiModel.getColumns().get(BINDING_EXPRESSION_COLUMN_INDEX));
    assertRowValues(0, 1, thirdRowText);
    assertRowValues(1, 2, firstRowText);
    assertRowValues(2, 3, secondRowText);
    verify(canvasOperation, times(3)).execute();
}
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) Test(org.junit.Test)

Aggregations

AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)60 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)37 Test (org.junit.Test)30 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)15 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)10 Node (org.kie.workbench.common.stunner.core.graph.Node)10 Command (org.kie.workbench.common.stunner.core.command.Command)9 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)9 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)9 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)8 Edge (org.kie.workbench.common.stunner.core.graph.Edge)8 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)7 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)6 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)6 Collectors (java.util.stream.Collectors)5 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)5 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)5 CanvasCommandFactory (org.kie.workbench.common.stunner.core.client.command.CanvasCommandFactory)5