KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > ui > UINodes


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.netbeans.core.ui;
21
22 import java.awt.Image JavaDoc;
23 import java.beans.BeanInfo JavaDoc;
24 import javax.swing.Action JavaDoc;
25 import org.netbeans.core.LoaderPoolNode;
26 import org.openide.actions.PropertiesAction;
27 import org.openide.actions.ReorderAction;
28 import org.openide.actions.ToolsAction;
29 import org.openide.nodes.FilterNode;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.Node.PropertySet;
32 import org.openide.util.Utilities;
33 import org.openide.util.actions.SystemAction;
34
35 /**
36  * Set of basic nodes for the visualization of IDE state
37  * @author Petr Hamernik, Dafe Simonek
38  */

39 public final class UINodes {
40     
41     private final static String JavaDoc objectTypesIconURL = "org/netbeans/core/resources/objectTypes.gif"; // NOI18N
42
private final static String JavaDoc objectTypesIcon32URL = "org/netbeans/core/resources/objectTypes32.gif"; // NOI18N
43

44     /** empty array of property sets */
45     private static final PropertySet[] NO_PROPERTY_SETS = {};
46
47     /** Constructor */
48     private UINodes() {
49     }
50
51     /** Creates object types node.
52      * @see "core/ui/src/org/netbeans/core/ui/resources/layer.xml"
53     */

54     public static Node createObjectTypes () {
55         return new ObjectTypesNode ();
56     }
57
58
59     private static class IconSubstituteNode extends FilterNode {
60
61         /** icons for the IconSubstituteNode */
62         private String JavaDoc iconURL, icon32URL;
63
64         IconSubstituteNode (Node ref, String JavaDoc iconURL, String JavaDoc icon32URL) {
65             super (ref);
66             this.iconURL = iconURL;
67             this.icon32URL = icon32URL;
68         }
69
70         public Image JavaDoc getIcon (int type) {
71             if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) {
72                 return Utilities.loadImage (iconURL);
73             }
74             else {
75                 return Utilities.loadImage (icon32URL);
76             }
77         }
78
79         public Image JavaDoc getOpenedIcon (int type) {
80             return getIcon(type);
81         }
82         
83         public String JavaDoc getHtmlDisplayName() {
84             return null;
85         }
86
87         /** @return empty property sets. */
88         public PropertySet[] getPropertySets () {
89             return NO_PROPERTY_SETS;
90         }
91
92         public boolean canDestroy () {
93             return false;
94         }
95
96         public boolean canCut () {
97             return false;
98         }
99
100         public boolean canRename () {
101             return false;
102         }
103     }
104
105     /** Node representing object types folder */
106     private static class ObjectTypesNode extends IconSubstituteNode {
107
108         public ObjectTypesNode() {
109             this (LoaderPoolNode.getLoaderPoolNode());
110         }
111
112         public ObjectTypesNode(Node ref) {
113             super(ref, objectTypesIconURL, objectTypesIcon32URL);
114         }
115
116         public Action JavaDoc[] getActions(boolean context) {
117             return new Action JavaDoc[] {
118                 SystemAction.get(ReorderAction.class),
119                 null,
120                 SystemAction.get(ToolsAction.class),
121                 SystemAction.get(PropertiesAction.class)
122             };
123         }
124     }
125     
126 }
127
Popular Tags