@Test public void testGraphCommandAllow() throws Exception { makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT); final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler); assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.allow(graphCommandExecutionContext)); }
@Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { dtable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; dtable.getInput().add(clauseIndex, inputClause); final InputClauseLiteralExpression le = new InputClauseLiteralExpression(); inputClause.setInputExpression(le); le.getText().setValue(name); dtable.getRule().forEach(rule -> { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); rule.getInputEntry().add(clauseIndex, ut); ut.setParent(rule); }); inputClause.setParent(dtable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = dtable.getInput().indexOf(inputClause); dtable.getRule().forEach(rule -> rule.getInputEntry().remove(clauseIndex)); dtable.getInput().remove(inputClause); return GraphCommandResultBuilder.SUCCESS; } }; }
AddInputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                 VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { dtable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; dtable.getInput().add(clauseIndex, inputClause); final InputClauseLiteralExpression le = new InputClauseLiteralExpression(); inputClause.setInputExpression(le); le.getText().setValue(name); dtable.getRule().forEach(rule -> { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); rule.getInputEntry().add(clauseIndex, ut); ut.setParent(rule); }); inputClause.setParent(dtable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = dtable.getInput().indexOf(inputClause); dtable.getRule().forEach(rule -> rule.getInputEntry().remove(clauseIndex)); dtable.getInput().remove(inputClause); return GraphCommandResultBuilder.SUCCESS; } }; } }
AddInputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                 VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { dtable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; dtable.getInput().add(clauseIndex, inputClause); final InputClauseLiteralExpression le = new InputClauseLiteralExpression(); inputClause.setInputExpression(le); le.getText().setValue(name); dtable.getRule().forEach(rule -> { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); rule.getInputEntry().add(clauseIndex, ut); ut.setParent(rule); }); inputClause.setParent(dtable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = dtable.getInput().indexOf(inputClause); dtable.getRule().forEach(rule -> rule.getInputEntry().remove(clauseIndex)); dtable.getInput().remove(inputClause); return GraphCommandResultBuilder.SUCCESS; } }; } AddInputClauseCommand(final DecisionTable dtable,
                                 final InputClause inputClause,
                                 final GridData uiModel,
                                 final Supplier<InputClauseColumn> uiModelColumnSupplier,
                                 final int uiColumnIndex,
                                 final DecisionTableUIModelMapper uiModelMapper,
                                 final org.uberfire.mvp.Command executeCanvasOperation,
                                 final org.uberfire.mvp.Command undoCanvasOperation); }
AddInputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                 VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { dtable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; dtable.getInput().add(clauseIndex, inputClause); final InputClauseLiteralExpression le = new InputClauseLiteralExpression(); inputClause.setInputExpression(le); le.getText().setValue(name); dtable.getRule().forEach(rule -> { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); rule.getInputEntry().add(clauseIndex, ut); ut.setParent(rule); }); inputClause.setParent(dtable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = dtable.getInput().indexOf(inputClause); dtable.getRule().forEach(rule -> rule.getInputEntry().remove(clauseIndex)); dtable.getInput().remove(inputClause); return GraphCommandResultBuilder.SUCCESS; } }; } AddInputClauseCommand(final DecisionTable dtable,
                                 final InputClause inputClause,
                                 final GridData uiModel,
                                 final Supplier<InputClauseColumn> uiModelColumnSupplier,
                                 final int uiColumnIndex,
                                 final DecisionTableUIModelMapper uiModelMapper,
                                 final org.uberfire.mvp.Command executeCanvasOperation,
                                 final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation(); }
AddInputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                 VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { dtable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; dtable.getInput().add(clauseIndex, inputClause); final InputClauseLiteralExpression le = new InputClauseLiteralExpression(); inputClause.setInputExpression(le); le.getText().setValue(name); dtable.getRule().forEach(rule -> { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); rule.getInputEntry().add(clauseIndex, ut); ut.setParent(rule); }); inputClause.setParent(dtable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = dtable.getInput().indexOf(inputClause); dtable.getRule().forEach(rule -> rule.getInputEntry().remove(clauseIndex)); dtable.getInput().remove(inputClause); return GraphCommandResultBuilder.SUCCESS; } }; } AddInputClauseCommand(final DecisionTable dtable,
                                 final InputClause inputClause,
                                 final GridData uiModel,
                                 final Supplier<InputClauseColumn> uiModelColumnSupplier,
                                 final int uiColumnIndex,
                                 final DecisionTableUIModelMapper uiModelMapper,
                                 final org.uberfire.mvp.Command executeCanvasOperation,
                                 final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation();  }