KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > filesystems > data > JavaSrc


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.filesystems.data;
21
22 import java.awt.Image JavaDoc;
23 import java.awt.Toolkit JavaDoc;
24 import java.awt.datatransfer.Transferable JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.ResourceBundle JavaDoc;
27
28 import org.openide.nodes.*;
29 import org.openide.actions.*;
30 import org.openide.loaders.DataFolder;
31 import org.openide.util.datatransfer.NewType;
32 import org.openide.util.actions.SystemAction;
33 import org.openide.util.HelpCtx;
34 import org.openide.util.NbBundle;
35
36 /** Dummy class, serves as a template for generating java files.
37 */

38 public final class JavaSrc {
39
40     /** Actions which this node supports */
41     static SystemAction[] staticActions;
42     /** Actions of this node when it is top level actions node */
43     static SystemAction[] topStaticActions;
44
45     private static final Node.PropertySet[] NO_PROPERTIES = new Node.PropertySet[0];
46
47     public JavaSrc() {
48     }
49
50     /** Constructs this node with given node to filter.
51     */

52     JavaSrc(DataFolder folder) {
53     }
54
55     public HelpCtx getHelpCtx () {
56         return new HelpCtx (Object JavaDoc.class);
57     }
58
59     /** Support for new types that can be created in this node.
60     * @return array of new type operations that are allowed
61     */

62     public NewType[] getNewTypes () {
63         return new NewType[0];
64     }
65
66     protected void createPasteTypes (Transferable JavaDoc t, List JavaDoc s) {
67         s.clear ();
68     }
69
70     /** Actions.
71     * @return array of actions for this node
72     */

73     public SystemAction[] getActions () {
74         if (staticActions == null)
75             topStaticActions = new SystemAction [] {
76                                    SystemAction.get (FileSystemAction.class),
77                                    null,
78                                    SystemAction.get(ToolsAction.class),
79                                    SystemAction.get(PropertiesAction.class),
80                                };
81         return topStaticActions;
82     }
83
84     /** Creates properties for this node */
85     public Node.PropertySet[] getPropertySets () {
86         return NO_PROPERTIES;
87     }
88
89     public boolean canDestroy () {
90         return false;
91     }
92
93     public boolean canCut () {
94         return false;
95     }
96
97     public boolean canRename () {
98         return false;
99     }
100
101     /** Children for the JavaSrc. Creates JavaSrcs or
102     * ItemNodes as filter subnodes...
103     */

104     static final class ActionsPoolChildren extends FilterNode.Children {
105
106         /** @param or original node to take children from */
107         public ActionsPoolChildren (DataFolder folder) {
108             super(folder.getNodeDelegate ());
109         }
110
111         /** Overriden, returns JavaSrc filters of original nodes.
112         *
113         * @param node node to create copy of
114         * @return JavaSrc filter of the original node
115         */

116         protected Node copyNode (Node node) {
117             DataFolder df = (DataFolder)node.getCookie(DataFolder.class);
118             if (df != null) {
119                 return null;
120             }
121             return new ActionItemNode(node);
122         }
123
124     }
125
126     static final class ActionItemNode extends FilterNode {
127         /** Icons for this node */
128         static Image JavaDoc itemIcon;
129         static Image JavaDoc itemIcon32;
130
131         /** Actions which this node supports */
132         static SystemAction[] staticActions;
133
134         /** Constructs new filter node for Action item */
135         ActionItemNode (Node filter) {
136             super(filter, Children.LEAF);
137         }
138
139         /*
140         public Image getIcon (int type) {
141             if ((type == java.beans.BeanInfo.ICON_COLOR_16x16) ||
142                     (type == java.beans.BeanInfo.ICON_MONO_16x16)) {
143                 if (itemIcon == null)
144                     itemIcon = Toolkit.getDefaultToolkit ().getImage (
145                                    getClass ().getResource ("/org/netbeans/core/resources/action.gif")); // NOI18N
146                 return itemIcon;
147             } else {
148                 if (itemIcon32 == null)
149                     itemIcon32 = Toolkit.getDefaultToolkit ().getImage (
150                                      getClass ().getResource ("/org/netbeans/core/resources/action32.gif")); // NOI18N
151                 return itemIcon32;
152             }
153         }
154
155         public Image getOpenedIcon (int type) {
156             return getIcon (type);
157         }
158         */

159
160         /** Actions.
161         * @return array of actions for this node
162         */

163         public SystemAction[] getActions () {
164             if (staticActions == null) {
165                 staticActions = new SystemAction [] {
166                                     SystemAction.get(CopyAction.class),
167                                     null,
168                                     SystemAction.get(ToolsAction.class),
169                                     SystemAction.get(PropertiesAction.class),
170                                 };
171             }
172             return staticActions;
173         }
174
175         /** Disallows renaming.
176         */

177         public boolean canRename () {
178             return false;
179         }
180
181         public boolean canDestroy () {
182             return false;
183         }
184
185         public boolean canCut () {
186             return false;
187         }
188
189         /** Creates properties for this node */
190         public Node.PropertySet[] getPropertySets () {
191             /*
192             ResourceBundle bundle = NbBundle.getBundle(Object.class);
193             // default sheet with "properties" property set // NOI18N
194             Sheet sheet = Sheet.createDefault();
195             sheet.get(Sheet.PROPERTIES).put(
196                 new PropertySupport.Name(
197                     this,
198                     bundle.getString("PROP_ActionItemName"),
199                     bundle.getString("HINT_ActionItemName")
200                 )
201             );
202             return sheet.toArray();
203              */

204             return new Node.PropertySet[] { };
205         }
206
207     } // end of ActionItemNode
208

209 }
210
Popular Tags