コード例 #1
0
ファイル: VariableModel.java プロジェクト: TheAxeC/AxeSki
  @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();

  }
コード例 #2
0
ファイル: VariableModel.java プロジェクト: TheAxeC/AxeSki
  /**
   * 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();
  }