KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > node > Empty


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Lisa Reese
21  *
22  */

23
24 package org.enhydra.kelp.forte.node;
25
26
27 import java.io.IOException JavaDoc;
28 import java.io.PrintWriter JavaDoc;
29 import java.util.Enumeration JavaDoc;
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 JavaDoc;
43 import java.io.File JavaDoc;
44
45
46
47 public class Empty
48 {
49     protected static PrintWriter JavaDoc pw;
50     public static void main (String JavaDoc[] args) throws Exception JavaDoc
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 JavaDoc 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 // pw.println(dob.toString());
74
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 // if (dob != null)// && (dob instanceof XMLCDataObject) )
89
// {
90
// pw.println("XMLC Object found: " + children[i].getName());
91
// }
92

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