Beispiel #1
0
  protected void addModuleLabels(
      ModuleNode node,
      String prefix,
      String fullPrefix,
      char modSep,
      int nest,
      List<Deferral> deferred,
      int defthres) {
    // if we have a deferral list and more than two children, defer ourselves until later
    if (nest > 0 && node.countMods() > defthres) {
      deferred.add(new Deferral(fullPrefix, node));
      return;
    }

    boolean atRoot = node.name.equals("");
    if (node.mod != null) {
      final Def mod = node.mod;
      _modules.add(Widgets.newInlineLabel(" " + prefix));
      Widget label =
          Widgets.newActionLabel(
              node.name,
              new ClickHandler() {
                public void onClick(ClickEvent event) {
                  Value<Boolean> showing = _showing.get(mod.id);
                  showing.update(!showing.get());
                }
              });
      Bindings.bindStateStyle(_showing.get(mod.id), _rsrc.styles().selected(), null, label);
      _modules.add(label);
      new Shower(_showing.get(mod.id), _moddefs) {
        protected Widget createWidget() {
          return createModulePanel(mod);
        }
      };
      prefix = "";
      nest += 1;

    } else if (node.children.size() > 1) {
      _modules.add(Widgets.newInlineLabel(" "));
      _modules.add(Widgets.newLabel(prefix + node.name));
      prefix = "";
      nest += 1;

    } else if (!atRoot) {
      prefix = prefix + node.name + modSep;
    }

    fullPrefix = fullPrefix + node.name + modSep;
    if (node.children.size() > 0) {
      if (prefix.length() == 0 && !atRoot) {
        _modules.add(Widgets.newInlineLabel(" {"));
      }
      for (ModuleNode child : node.children) {
        addModuleLabels(child, prefix, fullPrefix, modSep, nest, deferred, defthres);
      }
      if (prefix.length() == 0 && !atRoot) {
        _modules.add(Widgets.newInlineLabel(" }"));
      }
    }
  }
Beispiel #2
0
 protected Widget makeLabel(Def def) {
   if (def == null) {
     return Widgets.newInlineLabel("");
   }
   SpanWidget label =
       new SpanWidget.Plain(StringUtil.isBlank(def.name) ? "<anon>" : def.name, def);
   if (def.id != _defId) {
     new UsePopup.Popper(def.id, label, UsePopup.TYPE, _defmap, true).setGroup(_pgroup);
   }
   return DefUtil.adornDef(def, label);
 }