⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cardleveltagsdesigner.java

📁 WAP ide 代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      if (nodeType.indexOf(">") > -1)        nodeType = nodeType.substring(0, nodeType.length() - 1);      if (token.indexOf("<") < 0)        token = "<" + token;      if (nodeType.indexOf("/") > -1) { // closing node        parent = (EnhancedTreeNode) parent.getParent();      }      if (nodeType.equals("do")) { // create a new tree node of type do        doNode node = new doNode();        node.updateNode(token);        parent.add(node);        if (token.indexOf("/>") < 0)          parent = node;      }      if (nodeType.equals("go")) { // create a new tree node of type go        goNode node = new goNode();        node.updateNode(token);        parent.add(node);        if (token.indexOf("/>") < 0)          parent = node;      }      if (nodeType.equals("onevent")) { // create a new tree node of type onevent        oneventNode node = new oneventNode();        node.updateNode(token);        parent.add(node);        if (token.indexOf("/>") < 0)          parent = node;      }      if (nodeType.equals("timer")) { // create a new tree node of type timer        timerNode node = new timerNode();        node.updateNode(token);        parent.add(node);      }      if (nodeType.equals("noop")) { // create a new tree node of type noop        noopNode node = new noopNode();        node.updateNode(token);        parent.add(node);      }      if (nodeType.equals("prev")) { // create a new tree node of type prev        prevNode node = new prevNode();        node.updateNode(token);        parent.add(node);        if (token.indexOf("/>") < 0)          parent = node;      }      if (nodeType.equals("refresh")) { // create a new tree node of type refresh        refreshNode node = new refreshNode();        node.updateNode(token);        parent.add(node);        if (token.indexOf("/>") < 0)          parent = node;      }      if (nodeType.equals("postfield")) { // create a new tree node of type postfield        postfieldNode node = new postfieldNode();        node.updateNode(token);        parent.add(node);      }      if (nodeType.equals("setvar")) { // create a new tree node of type setvar        setvarNode node = new setvarNode();        node.updateNode(token);        parent.add(node);      }    }    return root;  }  /**   * removes eccess formatting data such as tabs and newline characters.   * @param String rawData - the data to be cleaned.   */  private String cleanupData(String rawData) {    String data = "";    StringTokenizer st = new StringTokenizer(rawData, "\n");    while (st.hasMoreTokens()) {      String temp = st.nextToken();      int i = temp.indexOf("<");      try {        data = data + temp.substring(i);      }      catch (StringIndexOutOfBoundsException strerr) {}    }    return data;  }  /**   * returns the data gathered by the dialog as a string of wml tags.   * @return data - the data formatted as wml.   */  public String getData() {    EnhancedTreeNode root = (EnhancedTreeNode) tm.getRoot();    Enumeration enum = root.preorderEnumeration();    String s = "";    int prevlevel = 0;    Vector stack = new Vector();    while (enum.hasMoreElements()) {      EnhancedTreeNode tn = (EnhancedTreeNode) enum.nextElement();      if (!tn.getUserObject().equals("root")) {        int level = tn.getLevel() - 1;        if (level < prevlevel) { // pop from the stack          int diff = prevlevel - level;          for (int x = 0; x < diff; x++) {            s = s + (String) stack.get(stack.size() - 1);            stack.remove(stack.size() - 1);          }        }        prevlevel = level;        int children = tn.getChildCount();        if (children > 0) {          stack.add(generateTabs(tn.getLevel() - 1) + generateCloseTag(tn) + "\n");          String temp = (String) tn.getUserObject();          if (temp.indexOf("/>") > -1) {            temp = temp.substring(0, temp.indexOf("/>"));            temp = temp + ">";            tn.setUserObject(temp);          }        }        else {          String temp = (String) tn.getUserObject();          if (temp.indexOf("/>") == -1) {            temp = temp.substring(0, temp.length() - 1);            temp = temp + "/>";            tn.setUserObject(temp);          }        }        s = s + generateTabs(tn.getLevel() - 1) + (String) tn.getUserObject() + "\n";      }    }    if (stack.size() > 0) {      int size = stack.size();      for (int x = 0; x < size; x++) {        s = s + (String) stack.get(stack.size() - 1);        stack.remove(stack.size() - 1);      }    }    return s;  }  /**   * Creates a string of tabs based on the level of the node   * @param int num - the node level.   * @return String tabs - the tabs.   */  private String generateTabs(int num) {    String tab = "";    for (int c = 0; c < num; c++)      tab = tab + "\t";    return tab;  }  /**   * Returns the proper clsoing tag based on the node type   * @param EnhancedTreeNode node - the selected node.   * @return String tag - the closing tag for the node.   */  private String generateCloseTag(EnhancedTreeNode node) {    String closetag = "";    if (node.getNodeType().equals("do"))      closetag = "</do>";    if (node.getNodeType().equals("go"))      closetag = "</go>";    if (node.getNodeType().equals("onevent"))      closetag = "</onevent>";    if (node.getNodeType().equals("prev"))      closetag = "</prev>";    if (node.getNodeType().equals("refresh"))      closetag = "</refresh>";    return closetag;  }  /**   * Adds a doNode to the tree.   */  public void addDoTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      doNode n = new doNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        doNode n = new doNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a goNode to the tree.   */  public void addGoTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      goNode n = new goNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        goNode n = new goNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a oneventNode to the tree.   */  public void addOneventTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      oneventNode n = new oneventNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        oneventNode n = new oneventNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a oneventNode to the tree.   * String type - the type of event to add:<br>   * onenterbackwards, onenterforwards, ontimer, onpick   */  public void addOneventTag(String type) {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      oneventNode n = new oneventNode(type);      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        oneventNode n = new oneventNode(type);        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a timerNode to the tree.   */  public void addTimerTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      timerNode n = new timerNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        timerNode n = new timerNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a prevNode to the tree.   */  public void addPrevTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      prevNode n = new prevNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        prevNode n = new prevNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a noopNode to the tree.   */  public void addNoopTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      noopNode n = new noopNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        noopNode n = new noopNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a refreshNode to the tree.   */  public void addRefreshTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      refreshNode n = new refreshNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        refreshNode n = new refreshNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a postfieldNode to the tree.   */  public void addPostfieldTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      postfieldNode n = new postfieldNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        postfieldNode n = new postfieldNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePath(n.getPath()));        updateTree();      }      catch (NullPointerException mainnullerr) {}    }  }  /**   * Adds a setvarNode to the tree.   */  public void addSetvarTag() {    try{      int cnt = path.getPathCount();      EnhancedTreeNode child = (EnhancedTreeNode) path.getPathComponent(cnt -1);      EnhancedTreeNode parent = (EnhancedTreeNode) child.getParent();      setvarNode n = new setvarNode();      tm.insertNodeInto(n, parent, parent.getChildCount());      TagTree.setSelectionPath(new TreePath(n.getPath()));      updateTree();    }    catch (NullPointerException nullerr) {      try{        EnhancedTreeNode parent = (EnhancedTreeNode) tm.getRoot();        setvarNode n = new setvarNode();        tm.insertNodeInto(n, parent, parent.getChildCount());        TagTree.setSelectionPath(new TreePa

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -