1 package org.enhydra.kelp.jbuilder.node; 2 3 import com.borland.jbuilder.node.JBProject; 4 import com.borland.primetime.node.Node; 5 import com.borland.primetime.vfs.Url; 6 import com.borland.primetime.vfs.VFS; 7 import com.borland.primetime.vfs.Filesystem; 8 import com.borland.primetime.node.FileNode; 9 import com.borland.primetime.node.FolderNode; 10 import com.borland.primetime.node.LightweightNode; 11 12 20 21 public class NodeUtil { 22 31 public static void doAddFiles(JBProject jbProject, 32 Node parent, 33 Url url) throws Exception { 34 Url[] urls = VFS.getChildren(url, Filesystem.TYPE_FILE); 35 if (urls.length > 0) { 36 for (int j = 0; j < urls.length; j++) { 37 if ((jbProject.findNode(urls[j]) == null) 38 && checkIfVisibleFile(urls[j])) { 39 FileNode node = new FileNode(jbProject, parent, urls[j]); 40 } 41 } 42 } 43 } 44 45 56 public static void doAddFolders(JBProject jbProject, 57 Node parent, 58 Url url) throws Exception { 59 FolderNode node = null; 60 LightweightNode nodes[] = jbProject.findNodes(url.getName()); 61 for (int i = 0; i < nodes.length; i++) { 62 if (nodes[i].getParent() == parent) { 63 node = (FolderNode)nodes[i]; 64 } 65 } 66 if (node == null) 67 node = new FolderNode(jbProject, parent, url.getName()); 68 69 doAddFiles(jbProject, node, url); 70 71 Url[] urls = VFS.getChildren(url, Filesystem.TYPE_DIRECTORY); 72 if (urls.length > 0) { 73 for (int j = 0; j < urls.length; j++) { 74 doAddFolders(jbProject, node, urls[j]); 75 } 76 } 77 } 78 79 88 private static boolean checkIfVisibleFile(Url url) { 89 return (url.getFileObject().getAbsolutePath().endsWith("~") != true); 90 } 91 92 } | Popular Tags |