private static void addVariableNodes(
      SimpleTreeNode owner, VariableContext m, Icon icon, int nodetype, int permission) {
    owner.removeAllChildren();

    Iterator it = m.names(nodetype);

    while (it.hasNext()) {
      String element = (String) it.next();

      SimpleTreeNode node =
          createVariableNode(m.getVariable(element), icon, nodetype, permission, element);

      owner.add(node);
    }
  }
  /**
   * DOCUMENT ME!
   *
   * @param selected DOCUMENT ME!
   * @param oldKey DOCUMENT ME!
   * @param newKey DOCUMENT ME!
   * @param newVal DOCUMENT ME!
   * @return DOCUMENT ME!
   */
  public boolean replaceVariable(
      SimpleTreeNode selected, String oldKey, String newKey, Object newVal) {
    vm.replaceVariable(oldKey, newKey, newVal);

    Variable var = (Variable) selected.getUserObject();
    var.setVariable(newVal);
    var.setDisplayName(newKey);
    var.setVariableName(newKey);

    return true;
  }
  private static SimpleTreeNode asTree1(VariableContext context) {
    SimpleTreeNode rootNode =
        new SimpleTreeNode(new Variable(App.messages.getString("res.205"), 0), variableIcon);

    SimpleTreeNode catagory =
        new SimpleTreeNode(
            new Variable(App.messages.getString("res.206"), INSERTABLE),
            parameterIcon,
            VariableTree.PARAMETER_CATAGORY);

    addVariableNodes(
        catagory,
        context,
        parameterIcon,
        VariableContext.PARAMETER,
        REMOVABLE | EDITABLE | SETTABLE);

    rootNode.add(catagory);
    catagory =
        new SimpleTreeNode(
            new Variable(App.messages.getString("res.207"), INSERTABLE),
            formulaIcon,
            VariableTree.FORMULA_CATAGORY);

    addVariableNodes(
        catagory, context, formulaIcon, VariableContext.FORMULA, REMOVABLE | EDITABLE | SETTABLE);

    rootNode.add(catagory);

    commandNode =
        new SimpleTreeNode(
            new Variable(App.messages.getString("res.208"), INSERTABLE),
            commandIcon,
            VariableTree.COMMAND_CATAGORY);

    addVariableNodes(
        commandNode,
        context,
        commandIcon,
        VariableContext.COMMAND,
        REMOVABLE | EDITABLE | SETTABLE);

    rootNode.add(commandNode);

    catagory =
        new SimpleTreeNode(
            new Variable(App.messages.getString("res.209"), 0),
            componentIcon,
            VariableTree.COMPONENT_CATAGORY);

    addVariableNodes(catagory, context, componentIcon, VariableContext.COMPONENT, SETTABLE);
    rootNode.add(catagory);

    SimpleTreeNode sytemCatagory =
        new SimpleTreeNode(
            new Variable(App.messages.getString("res.210"), 0), sysIcon, SYSTEM_CATAGORY);
    String[] vars = VariableContext.getSystemVariables();

    for (int i = 0; i < vars.length; i++) {
      sytemCatagory.add(
          new SimpleTreeNode(
              new Variable(vars[i], SETTABLE, vars[i]), sysIcon, VariableContext.SYSTEM0));
    }

    rootNode.add(sytemCatagory);

    return rootNode;
  }
 /**
  * DOCUMENT ME!
  *
  * @param type DOCUMENT ME!
  * @return DOCUMENT ME!
  */
 public Iterator variables(int type) {
   return vm.variables(type);
 }
 /**
  * DOCUMENT ME!
  *
  * @return DOCUMENT ME!
  */
 public Iterator variables() {
   return vm.variables();
 }
 /**
  * DOCUMENT ME!
  *
  * @param oldKey DOCUMENT ME!
  * @param newKey DOCUMENT ME!
  * @param newVal DOCUMENT ME!
  * @return DOCUMENT ME!
  */
 public boolean replace(String oldKey, String newKey, Object newVal) {
   return vm.replace(oldKey, newKey, newVal);
 }
 /**
  * DOCUMENT ME!
  *
  * @param varName DOCUMENT ME!
  * @return DOCUMENT ME!
  */
 public Object getVariable(String varName) {
   return vm.getVariable(varName);
 }
 /** DOCUMENT ME! */
 public void clear() {
   vm.clear();
 }