@Test public void testGraphCommandExecuteWithNoRows() { makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getColumn().size()); assertEquals(0, relation.getRow().size()); }
@Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; }
DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                       VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } }
DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                       VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationColumnCommand(final Relation relation,
                                       final GridData uiModel,
                                       final int uiColumnIndex,
                                       final RelationUIModelMapper uiModelMapper,
                                       final org.uberfire.mvp.Command executeCanvasOperation,
                                       final org.uberfire.mvp.Command undoCanvasOperation); }
DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                       VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationColumnCommand(final Relation relation,
                                       final GridData uiModel,
                                       final int uiColumnIndex,
                                       final RelationUIModelMapper uiModelMapper,
                                       final org.uberfire.mvp.Command executeCanvasOperation,
                                       final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation(); }
DeleteRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                       VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getComponentWidths().remove(uiColumnIndex); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getRow().forEach(row -> row.getExpression().remove(iiIndex)); relation.getColumn().remove(iiIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; relation.getColumn().add(iiIndex, oldInformationItem); IntStream.range(0, relation.getRow().size()) .forEach(rowIndex -> { final HasExpression hasExpression = oldColumnData.get(rowIndex); relation.getRow().get(rowIndex).getExpression().add(iiIndex, hasExpression); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationColumnCommand(final Relation relation,
                                       final GridData uiModel,
                                       final int uiColumnIndex,
                                       final RelationUIModelMapper uiModelMapper,
                                       final org.uberfire.mvp.Command executeCanvasOperation,
                                       final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation();  }