Search in sources :

Example 6 with AbstractCanvasGraphCommand

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

the class SessionPreviewImplTest method checkVetoUndoCommands.

@Test
public void checkVetoUndoCommands() {
    final AbstractCanvasGraphCommand command = new MockVetoUndoCommand();
    preview.handleCanvasUndoCommandExecutedEvent(makeCommandUndoContext(command));
    verify(canvasCommandManager, never()).undo(any(AbstractCanvasHandler.class), any(AbstractCanvasGraphCommand.class));
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) Test(org.junit.Test) BaseCommandsTest(org.kie.workbench.common.dmn.client.session.BaseCommandsTest)

Example 7 with AbstractCanvasGraphCommand

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

the class BaseExpressionGrid method getUpdateStunnerTitleCommand.

protected Optional<AbstractCanvasGraphCommand> getUpdateStunnerTitleCommand(final String value) {
    AbstractCanvasGraphCommand command = null;
    if (nodeUUID.isPresent()) {
        final String uuid = nodeUUID.get();
        final AbstractCanvasHandler canvasHandler = (AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler();
        final Element<?> element = canvasHandler.getGraphIndex().get(uuid);
        if (element.getContent() instanceof Definition) {
            final Definition definition = (Definition) element.getContent();
            final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition());
            if (nameId != null) {
                command = (AbstractCanvasGraphCommand) canvasCommandFactory.updatePropertyValue(element, nameId, value);
            }
        }
    }
    return Optional.ofNullable(command);
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Example 8 with AbstractCanvasGraphCommand

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

the class DecisionTableGridTest method testOutputClauseHasNameWrapperForHeaderMetaData.

@Test
@SuppressWarnings("unchecked")
public void testOutputClauseHasNameWrapperForHeaderMetaData() {
    setupGrid(makeHasNameForDecision(), 0);
    // More than one OutputClause column is required before the tested wrapper is instantiated.
    addOutputClause(3);
    final DecisionTable dtable = expression.get();
    final OutputClause outputClause = dtable.getOutput().get(0);
    final GridColumn.HeaderMetaData outputClauseHeaderMetaData = grid.getModel().getColumns().get(2).getHeaderMetaData().get(1);
    assertThat(outputClause.getName()).isEqualTo(outputClauseHeaderMetaData.getTitle());
    reset(sessionCommandManager);
    extractHeaderMetaData(1, 2).setValue(new Name(NAME_NEW));
    verify(sessionCommandManager).execute(eq(canvasHandler), compositeCommandCaptor.capture());
    ((AbstractCanvasGraphCommand) compositeCommandCaptor.getValue().getCommands().get(0)).execute(canvasHandler);
    assertThat(outputClause.getName()).isEqualTo(NAME_NEW);
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) HasName(org.kie.workbench.common.dmn.api.definition.HasName) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 9 with AbstractCanvasGraphCommand

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

the class BaseExpressionGrid method getUpdateStunnerTitleCommand.

protected <V> Optional<AbstractCanvasGraphCommand> getUpdateStunnerTitleCommand(final V value) {
    AbstractCanvasGraphCommand command = null;
    if (getNodeUUID().isPresent()) {
        final String uuid = getNodeUUID().get();
        final AbstractCanvasHandler canvasHandler = (AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler();
        final Element<?> element = canvasHandler.getGraphIndex().get(uuid);
        if (element.getContent() instanceof Definition) {
            final Definition definition = (Definition) element.getContent();
            final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition());
            if (nameId != null) {
                command = (AbstractCanvasGraphCommand) canvasCommandFactory.updatePropertyValue(element, nameId, value);
            }
        }
    }
    return Optional.ofNullable(command);
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Aggregations

AbstractCanvasGraphCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand)9 Test (org.junit.Test)6 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)5 BaseCommandsTest (org.kie.workbench.common.dmn.client.session.BaseCommandsTest)4 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)2 BaseCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.BaseCanvasHandler)2 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)2 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)1 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)1 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)1 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)1 DMNGridColumn (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn)1 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)1