コード例 #1
0
ファイル: ModulesPanel.java プロジェクト: samskivert/coreen
  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(" }"));
      }
    }
  }
コード例 #2
0
ファイル: ModulesPanel.java プロジェクト: samskivert/coreen
  protected void initContents(Def[] modules) {
    if (modules.length == 0) {
      _modules.add(Widgets.newLabel("No modules in this project?"));
      return;
    }

    // build the module hierarchy
    char modSep = '.'; // TODO
    ModuleNode root = ModuleNode.createTree(modSep, modules);

    // now flatten it into a bunch of links
    if (root.mod != null) {
      addModuleLabels(root, "", modSep, DEF_THRESH); // one nameless top-level module
    } else {
      for (ModuleNode top : root.children) {
        addModuleLabels(top, "", modSep, DEF_THRESH);
      }
    }
  }