Exemplo n.º 1
0
 /**
  * Reads all of the files in the given directory and adds them as children of the directory tree
  * node. Requires that the passed node represents a directory.
  */
 private void readDirectory(Node parentNode, File parentDir) {
   File[] children = parentDir.listFiles();
   if (children == null) return;
   if (verbose) {
     System.out.print(".");
     System.out.flush();
   }
   for (int i = 0; i < children.length; i++) {
     File child = children[i];
     children[i] = null;
     boolean isDir = child.isDirectory();
     boolean mustSkip = false;
     if (isDir) {
       for (Iterator iter = subdirsToIgnore.iterator(); iter.hasNext(); ) {
         if (child.getName().equals((String) iter.next())) {
           mustSkip = true;
           break;
         }
       }
     }
     if (!mustSkip) {
       Node childNode = new Node(child);
       parentNode.addChild(childNode);
       if (isDir) {
         readDirectory(childNode, child);
       }
     }
   }
 }
Exemplo n.º 2
0
 public Node<ResourceName> queryMDSAsTree(PackageName packageName) {
   Node<ResourceName> tree = new Node<ResourceName>(packageName);
   List<ResourceName> resourceNames = queryMDS(packageName);
   for (ResourceName r : resourceNames) {
     Node<ResourceName> newNode = new Node<ResourceName>(r);
     if (r instanceof PackageName) {
       newNode.addChildrenOf(queryMDSAsTree((PackageName) r));
     }
     tree.addChild(newNode);
   }
   return tree;
 }
Exemplo n.º 3
0
 public void add(String str) {
   Node n = root, t;
   char arr[] = str.toCharArray();
   for (int i = 0; i < arr.length; i++) {
     t = n.getChild(arr[i]);
     if (t == null) {
       t = n.addChild(arr[i]);
       if (i == arr.length - 1) {
         t.value = str;
       }
     }
     n = t;
   }
 }
Exemplo n.º 4
0
    boolean insert(Node p, List<Node> Qi, int level) {
      Node parent = null;
      List<Node> nQi = new ArrayList<Node>();
      for (Node q : Qi) {
        if (dist(p, q) <= layerSize[level]) {
          nQi.add(q);
          parent = q;
        }
      }

      if (parent == null) // separation holds
      return true;

      for (Node q : Qi)
        for (Node ch : q.getChildren(level)) if (dist(p, ch) <= layerSize[level]) nQi.add(ch);

      if (insert(p, nQi, level + 1)) parent.addChild(p, level);

      return false;
    }
  void buildStructure(final Node root, final boolean activate) throws Exception {
    doAndWaitForBuilder(
        () -> {
          myCom = root.addChild("com");
          myIntellij = myCom.addChild("intellij");
          myOpenApi = myIntellij.addChild("openapi");
          myFabrique = root.addChild("jetbrains").addChild("fabrique");
          myIde = myFabrique.addChild("ide");
          myRunner = root.addChild("xUnit").addChild("runner");
          myRcp = root.addChild("org").addChild("eclipse").addChild("rcp");

          if (activate) {
            getBuilder().getUi().activate(true);
          }
        });
  }