Exemplo n.º 1
0
 public static Request addToNavbar(Request r, String name) {
   assert (!_navbar.containsKey(name));
   ArrayList<MenuItem> arl = new ArrayList();
   arl.add(new MenuItem(r, name));
   _navbar.put(name, arl);
   _navbarOrdering.add(name);
   return r;
 }
Exemplo n.º 2
0
 public static Request addToNavbar(Request r, String name, String category) {
   ArrayList<MenuItem> arl = _navbar.get(category);
   if (arl == null) {
     arl = new ArrayList();
     _navbar.put(category, arl);
     _navbarOrdering.add(category);
   }
   arl.add(new MenuItem(r, name));
   return r;
 }
Exemplo n.º 3
0
 public static void initializeNavBar() {
   StringBuilder sb = new StringBuilder();
   for (String s : _navbarOrdering) {
     ArrayList<MenuItem> arl = _navbar.get(s);
     if ((arl.size() == 1) && arl.get(0)._name.equals(s)) {
       arl.get(0).toHTML(sb);
     } else {
       sb.append("<li class='dropdown'>");
       sb.append("<a href='#' class='dropdown-toggle' data-toggle='dropdown'>");
       sb.append(s);
       sb.append("<b class='caret'></b>");
       sb.append("</a>");
       sb.append("<ul class='dropdown-menu'>");
       for (MenuItem i : arl) i.toHTML(sb);
       sb.append("</ul></li>");
     }
   }
   RString str = new RString(_htmlTemplate);
   str.replace("NAVBAR", sb.toString());
   str.replace("CONTENTS", "%CONTENTS");
   _htmlTemplate = str.toString();
 }