/*
   * (non-Javadoc)
   *
   * @see org.eclipse.gef.commands.Command#undo()
   */
  @Override
  public void undo() {
    if (parentFormula instanceof UnaryFormula) {
      ((UnaryFormula) parentFormula).setChild(null);
    } else if (parentFormula instanceof BinaryFormula) {
      if (firstChild) {
        ((BinaryFormula) parentFormula).setLeft(null);
      } else {
        ((BinaryFormula) parentFormula).setRight(null);
      }
    }

    SendNotify.sendAddFormulaNotify(parentFormula, null);
  }
Ejemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see henshineditor.actions.condition.CreateConditionTreeAction#run()
   */
  @Override
  public void run() {
    Not not = HenshinFactory.eINSTANCE.createNot();
    Command command = null;
    if (parentFormula == null) {
      command = new CreateConditionCommand(premise, not);
    } else {
      command = new CreateFormulaCommand(premise, parentFormula, not);

      if (parentFormula instanceof BinaryFormula) {
        BinaryFormula binaryFormula = (BinaryFormula) parentFormula;
        if (binaryFormula.getLeft() != null && binaryFormula.getRight() == null) {
          command = new CreateFormulaCommand(premise, parentFormula, not, false);
        }
      }
    }

    execute(command);
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.gef.commands.Command#execute()
   */
  @Override
  public void execute() {
    if (toAdd instanceof NestedCondition) {
      final NestedCondition ac = (NestedCondition) toAdd;
      if (ac.getConclusion() == null) {
        final Graph graph = HenshinFactory.eINSTANCE.createGraph();
        graph.setName(ModelUtil.getDistinctNCName(premise));
        ac.setConclusion(graph);
      }
    }

    if (parentFormula instanceof UnaryFormula) {
      ((UnaryFormula) parentFormula).setChild(toAdd);
    } else if (parentFormula instanceof BinaryFormula) {
      if (firstChild) {
        ((BinaryFormula) parentFormula).setLeft(toAdd);
      } else {
        ((BinaryFormula) parentFormula).setRight(toAdd);
      }
    }

    SendNotify.sendAddFormulaNotify(parentFormula, toAdd);
  }