1 23 24 package org.enhydra.kelp.forte.node; 25 26 27 import java.io.IOException ; 28 import java.io.PrintWriter ; 29 import java.util.Enumeration ; 30 import org.openide.TopManager; 31 import org.openide.filesystems.FileObject; 32 import org.openide.filesystems.FileSystem; 33 import org.openide.windows.InputOutput; 34 import org.openide.nodes.*; 35 import org.openide.TopManager; 36 import org.openide.loaders.DataFolder; 37 import org.openide.DialogDescriptor; 38 import org.enhydra.kelp.forte.services.XMLCCompilerSupport; 39 import org.openide.loaders.CompilerSupport; 40 import org.openide.cookies.*; 41 import org.openide.loaders.*; 42 import java.net.URL ; 43 import java.io.File ; 44 45 46 47 public class Empty 48 { 49 protected static PrintWriter pw; 50 public static void main (String [] args) throws Exception 51 { 52 InputOutput io = TopManager.getDefault ().getIO ("NodeExp Results"); 53 io.select (); 54 pw = io.getOut(); 55 pw.println("starting test"); 56 57 58 Node desktopNode = TopManager.getDefault().getPlaces().nodes().projectDesktop(); 59 Node.Cookie cookie = desktopNode.getCookie(ProjectCookie.class); 60 61 if (cookie != null && cookie instanceof ProjectCookie) 62 pw.println("cookie on project Desktop"); 63 pw.println("DesktopNode name: " + desktopNode.getDisplayName()); 64 65 Children kids = desktopNode.getChildren(); 66 Enumeration nodes = kids.nodes(); 67 while (nodes.hasMoreElements()) 68 { 69 Node nextNode = (Node)nodes.nextElement(); 70 DataObject dob = (DataObject)nextNode.getCookie(DataObject.class); 71 if (dob instanceof DataShadow) 72 dob = ((DataShadow)dob).getOriginal(); 73 if (dob != null) 75 readFiles(dob.getPrimaryFile()); 76 } 77 78 pw.println ("Done."); 79 } 80 81 protected static void readNodes(Node container) 82 { 83 Node[] children = container.getChildren().getNodes(); 84 pw.println("reading node: " + container.getName() + " num children: " + children.length); 85 for (int i = 0; i < children.length; i++) 86 { 87 DataObject dob = (DataObject)children[i].getCookie(DataObject.class); 88 93 94 if ((dob != null) && (dob instanceof DataFolder) ) 95 readNodes(children[i]); 96 97 } 98 } 99 100 protected static void readFiles(FileObject container) 101 { 102 FileObject[] children = container.getChildren(); 103 pw.println("reading node: " + container.getName() + " num children: " + children.length); 104 for (int i = 0; i < children.length; i++) 105 { 106 if (children[i].isData()) 107 { 108 if (children[i].getExt().equals("html")) 109 { 110 pw.println("HTML FOUND: " + children[i].getPackageName('/')); 111 try 112 { 113 DataObject dob = DataObject.find(children[i]); 114 pw.println("data object found...class is: " + dob.getClass().toString()); 115 } 116 catch(DataObjectNotFoundException e) { 117 pw.println(e); 118 } 119 } 120 121 } 122 123 124 else if (children[i].isFolder()) 125 readFiles(children[i]); 126 127 } 128 } 129 } 130 | Popular Tags |