use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class InvocationGridData method moveRowsTo.
@Override
public void moveRowsTo(final int index, final List<GridRow> rows) {
expression.ifPresent(invocation -> {
final AbstractCanvasHandler handler = (AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler();
sessionCommandManager.execute(handler, new MoveRowsCommand(invocation, delegate, index, rows, canvasOperation));
});
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler 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);
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler 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();
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler 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();
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler 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();
}
Aggregations