Exemplo n.º 1
0
  /**
   * The name of the variable is changed and its views and references are notified.
   *
   * @param name new name of the variable
   */
  public void setName(String name) {
    TopLevelModel top;
    if (name.trim().equals("")) {
      _name = "";
      _error = false;
      _name = "";
      return;
    }

    // if block is in an toplevelBlock and toplevel already contains the new name
    if (((top = searchTopLevel()) != null) && top.containsVariable(name)) {

      if (!_error) top.removeVariable(_name);
      _error = true;

    } else if ((top = searchTopLevel()) != null && !top.containsVariable(name)) {
      if (!_error) top.removeVariable(_name);
      top.addVariable(name);

      _error = false;
    } else {
      _error = false;
    }

    this._name = name;
    updateView();
  }
Exemplo n.º 2
0
  @Override
  public void changeParent(BlockModel p) {
    TopLevelModel top;
    // check if the toplevel if found if so remove this variable form
    // its variable if there was no error.
    if ((top = searchTopLevel()) != null && !_error) {
      top.removeVariable(_name);
      setParent(p);
      return;
    }
    setParent(p);
    _error = true;
    setName(_name);
    // updateView();

  }