Example #1
0
 public void print(MenuExtra m, int l) {
   for (int i = 0; i < l; ++i) System.out.print(' ');
   System.out.println(m.getLabel() + " " + m.getPath());
   for (Iterator i = m.iterator(); i.hasNext(); ) {
     Map.Entry entry = (Map.Entry) i.next();
     MenuExtra m2 = (MenuExtra) entry.getValue();
     print(m2, l + 1);
   }
 }
Example #2
0
  public synchronized MenuExtra getMenu() {
    try {
      create(folders);
    } catch (Exception e) {
      e.printStackTrace();
    }

    MenuExtra res = (MenuExtra) menu.clone();
    addChilds(menu, res);
    if (res != null) res.setCollapsed(false);
    // print(res, 0);
    return res;
  }
Example #3
0
  void addChilds(MenuExtra menu, MenuExtra res) {
    if (DEBUG_ME) System.out.println("gerando " + menu.getLabel());
    Iterator i = menu.iterator();
    while (i.hasNext()) {
      Map.Entry entry = (Map.Entry) i.next();
      MenuExtra m = (MenuExtra) entry.getValue();
      MenuExtra r = (MenuExtra) m.clone();

      addChilds(m, r);
      if (r.hasChildren() || r.hasPath()) {
        res.addChild(r);
      }
    }
  }
Example #4
0
  void loadDoc(MenuExtra menu, Element elem) {
    menu.setLabel(elem.getAttribute("label"));
    menu.setPath(elem.getAttribute("path"));

    if ("false".equals(elem.getAttribute("collapsed"))) menu.setCollapsed(false);

    menu.setId(id++);
    for (Element el = next(elem.getFirstChild()); el != null; el = next(el.getNextSibling())) {
      MenuExtra m = new MenuExtra();
      m.setLabel(String.valueOf(id));
      menu.addChild(m);
      loadDoc(m, el);
    }
  }