use of org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasCommand in project kie-wb-common by kiegroup.
the class SetKindCommand method newCanvasCommand.
@Override
protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) {
return new AbstractCanvasCommand() {
@Override
public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) {
final GridData gridData = cellTuple.getGridWidget().getModel();
gridData.setCellValue(cellTuple.getRowIndex(), cellTuple.getColumnIndex(), cellTuple.getValue());
canvasOperation.execute();
return CanvasCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) {
if (oldCellValue.isPresent()) {
cellTuple.getGridWidget().getModel().setCellValue(cellTuple.getRowIndex(), cellTuple.getColumnIndex(), oldCellValue.get());
} else {
cellTuple.getGridWidget().getModel().deleteCell(cellTuple.getRowIndex(), cellTuple.getColumnIndex());
}
canvasOperation.execute();
return CanvasCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasCommand in project kie-wb-common by kiegroup.
the class SetCellValueCommand method newCanvasCommand.
@Override
protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler context) {
return new AbstractCanvasCommand() {
@Override
public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) {
final GridData gridData = cellTuple.getGridWidget().getModel();
gridData.setCellValue(cellTuple.getRowIndex(), cellTuple.getColumnIndex(), cellTuple.getValue());
canvasOperation.execute();
return CanvasCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) {
if (oldCellValue.isPresent()) {
cellTuple.getGridWidget().getModel().setCellValue(cellTuple.getRowIndex(), cellTuple.getColumnIndex(), oldCellValue.get());
} else {
cellTuple.getGridWidget().getModel().deleteCell(cellTuple.getRowIndex(), cellTuple.getColumnIndex());
}
canvasOperation.execute();
return CanvasCommandResultBuilder.SUCCESS;
}
};
}
Aggregations