001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.core.ui;
043:
044: import java.awt.Image;
045: import java.beans.BeanInfo;
046: import javax.swing.Action;
047: import org.netbeans.core.LoaderPoolNode;
048: import org.openide.actions.PropertiesAction;
049: import org.openide.actions.ReorderAction;
050: import org.openide.actions.ToolsAction;
051: import org.openide.nodes.FilterNode;
052: import org.openide.nodes.Node;
053: import org.openide.nodes.Node.PropertySet;
054: import org.openide.util.Utilities;
055: import org.openide.util.actions.SystemAction;
056:
057: /**
058: * Set of basic nodes for the visualization of IDE state
059: * @author Petr Hamernik, Dafe Simonek
060: */
061: public final class UINodes {
062:
063: private final static String objectTypesIconURL = "org/netbeans/core/resources/objectTypes.gif"; // NOI18N
064: private final static String objectTypesIcon32URL = "org/netbeans/core/resources/objectTypes32.gif"; // NOI18N
065:
066: /** empty array of property sets */
067: private static final PropertySet[] NO_PROPERTY_SETS = {};
068:
069: /** Constructor */
070: private UINodes() {
071: }
072:
073: /** Creates object types node.
074: * @see "core/ui/src/org/netbeans/core/ui/resources/layer.xml"
075: */
076: public static Node createObjectTypes() {
077: return new ObjectTypesNode();
078: }
079:
080: private static class IconSubstituteNode extends FilterNode {
081:
082: /** icons for the IconSubstituteNode */
083: private String iconURL, icon32URL;
084:
085: IconSubstituteNode(Node ref, String iconURL, String icon32URL) {
086: super (ref);
087: this .iconURL = iconURL;
088: this .icon32URL = icon32URL;
089: }
090:
091: public Image getIcon(int type) {
092: if ((type == BeanInfo.ICON_COLOR_16x16)
093: || (type == BeanInfo.ICON_MONO_16x16)) {
094: return Utilities.loadImage(iconURL);
095: } else {
096: return Utilities.loadImage(icon32URL);
097: }
098: }
099:
100: public Image getOpenedIcon(int type) {
101: return getIcon(type);
102: }
103:
104: public String getHtmlDisplayName() {
105: return null;
106: }
107:
108: /** @return empty property sets. */
109: public PropertySet[] getPropertySets() {
110: return NO_PROPERTY_SETS;
111: }
112:
113: public boolean canDestroy() {
114: return false;
115: }
116:
117: public boolean canCut() {
118: return false;
119: }
120:
121: public boolean canRename() {
122: return false;
123: }
124: }
125:
126: /** Node representing object types folder */
127: private static class ObjectTypesNode extends IconSubstituteNode {
128:
129: public ObjectTypesNode() {
130: this (LoaderPoolNode.getLoaderPoolNode());
131: }
132:
133: public ObjectTypesNode(Node ref) {
134: super (ref, objectTypesIconURL, objectTypesIcon32URL);
135: }
136:
137: public Action[] getActions(boolean context) {
138: return new Action[] {
139: SystemAction.get(ReorderAction.class), null,
140: SystemAction.get(ToolsAction.class),
141: SystemAction.get(PropertiesAction.class) };
142: }
143: }
144:
145: }
|