Source Code Cross Referenced for PaletteItemNode.java in  » IDE-Netbeans » soa » org » netbeans » modules » soa » mapper » common » palette » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » soa » org.netbeans.modules.soa.mapper.common.palette 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        package org.netbeans.modules.soa.mapper.common.palette;
021:
022:        import javax.swing.Action;
023:
024:        import org.openide.loaders.DataObject;
025:        import org.openide.loaders.InstanceDataObject;
026:        import org.openide.util.actions.SystemAction;
027:
028:        import org.netbeans.modules.soa.mapper.common.ui.palette.IPaletteItem;
029:
030:        /**
031:         * The PaletteItemNode is a Node representing the Item of Component Palette in
032:         * the tree under Environment.
033:         *
034:         * @author    Tientien Li
035:         * @created   September 5, 2003
036:         */
037:        public class PaletteItemNode extends org.openide.nodes.FilterNode
038:                implements  IPaletteItem {
039:
040:            /**
041:             * generated Serialized Version UID
042:             */
043:
044:            //  static final long serialVersionUID = -2098259549820241091L;
045:            /**
046:             * Name of the template property.
047:             */
048:            public static final String PROP_IS_CONTAINER = "isContainer";
049:            // NOI18N
050:
051:            /**
052:             * Field staticActions
053:             */
054:            private static SystemAction[] staticActions;
055:
056:            /**
057:             * Creates a new palette node
058:             *
059:             * @param original  the original node to copy from
060:             */
061:            public PaletteItemNode(org.openide.nodes.Node original) {
062:                super (original, org.openide.nodes.FilterNode.Children.LEAF);
063:                initializeTooltip();
064:            }
065:
066:            /**
067:             * Return the name of the PaletteItemNode object
068:             *
069:             * @return   The name value
070:             */
071:            public String getName() {
072:                String name = this .getDisplayName();
073:                if (name == null) {
074:                    return super .getName();
075:                }
076:                return name;
077:            }
078:
079:            /**
080:             * get the palette item node Icon
081:             *
082:             * @return   the icon image
083:             */
084:            public java.awt.Image getIcon() {
085:                return getIcon(java.beans.BeanInfo.ICON_COLOR_16x16);
086:            }
087:
088:            /**
089:             * get the palette item node ToolTip
090:             *
091:             * @return   the tooltip text
092:             */
093:            public String getToolTip() {
094:                return getShortDescription();
095:            }
096:
097:            /**
098:             * get a palette item node Attribute
099:             *
100:             * @param attr  the requested palette item node attribute
101:             * @return      the attribute value
102:             */
103:            public Object getItemAttribute(String attr) {
104:
105:                DataObject obj = (DataObject) getOriginal().getCookie(
106:                        DataObject.class);
107:
108:                if (obj != null) {
109:                    return obj.getPrimaryFile().getAttribute(attr);
110:                    // NOI18N
111:                }
112:
113:                return null;
114:            }
115:
116:            // -----------------------------------------------------------------------
117:            // Other methods
118:
119:            /**
120:             * get the palette item node Display Name
121:             *
122:             * @return   the display name
123:             */
124:            public String getDisplayName() {
125:                String name = getAttributeDisplayName();
126:
127:                if (name == null) {
128:                    name = getExplicitDisplayName();
129:                }
130:
131:                if (name != null) {
132:                    return name;
133:                }
134:
135:                org.openide.cookies.InstanceCookie ic = (InstanceDataObject) getCookie(InstanceDataObject.class);
136:
137:                return (ic != null) ? ic.instanceName() : super 
138:                        .getDisplayName();
139:            }
140:
141:            /**
142:             * Gets the attributeDisplayName attribute of the PaletteItemNode object
143:             *
144:             * @return   The attributeDisplayName value
145:             */
146:            String getAttributeDisplayName() {
147:                String localName = (String) this .getItemAttribute("LocalName");
148:                if (localName == null) {
149:                    return null;
150:                }
151:
152:                // test if localname is a key in the default bundle.
153:                String bundleLocalName = getStringFromDefaultBundle(localName);
154:                return (bundleLocalName == null) ? localName : bundleLocalName;
155:            }
156:
157:            /**
158:             * get the palette item node explicit, i.e., long, Display Name
159:             *
160:             * @return   the explicity display name
161:             */
162:            String getExplicitDisplayName() {
163:
164:                String name = getOriginal().getName();
165:                String displayName = getOriginal().getDisplayName();
166:
167:                if (org.openide.loaders.DataNode.getShowFileExtensions()) {
168:                    DataObject obj = (DataObject) getOriginal().getCookie(
169:                            DataObject.class);
170:
171:                    if (obj != null) {
172:                        String ext = "." + obj.getPrimaryFile().getExt();
173:
174:                        if (displayName.endsWith(ext)) {
175:                            displayName = displayName.substring(0, displayName
176:                                    .length()
177:                                    - ext.length());
178:                        }
179:                    }
180:                }
181:
182:                return name.equals(displayName) ? null : displayName;
183:            }
184:
185:            /**
186:             * Creates properties for this node
187:             *
188:             * @return   the list of node properties
189:             */
190:            public org.openide.nodes.Node.PropertySet[] getPropertySets() {
191:
192:                java.util.ResourceBundle bundle = PaletteManager.getBundle();
193:
194:                // default sheet with "properties" property set // NOI18N
195:                org.openide.nodes.Sheet sheet = org.openide.nodes.Sheet
196:                        .createDefault();
197:
198:                return sheet.toArray();
199:            }
200:
201:            /**
202:             * destroy the palette item node
203:             *
204:             * @throws java.io.IOException  if encounter IO errors
205:             */
206:            public void destroy() throws java.io.IOException {
207:                super .destroy();
208:            }
209:
210:            /**
211:             * can this palette item node be renamed
212:             *
213:             * @return   true if the node can be renamed
214:             */
215:            public boolean canRename() {
216:
217:                DataObject dobj = (DataObject) getCookie(DataObject.class);
218:
219:                return (dobj != null) && !(dobj instanceof  InstanceDataObject);
220:            }
221:
222:            /**
223:             * Set up the associated node actions.
224:             *
225:             * @return   array of actions for this node
226:             */
227:            public Action[] getActions(boolean context) {
228:
229:                if (staticActions == null) {
230:                    staticActions = new SystemAction[] {
231:                            SystemAction
232:                                    .get(org.openide.actions.CustomizeAction.class),
233:                            null,
234:                            SystemAction
235:                                    .get(org.openide.actions.MoveUpAction.class),
236:                            SystemAction
237:                                    .get(org.openide.actions.MoveDownAction.class),
238:                            null,
239:                            SystemAction
240:                                    .get(org.openide.actions.CutAction.class),
241:                            SystemAction
242:                                    .get(org.openide.actions.CopyAction.class),
243:                            null,
244:                            SystemAction
245:                                    .get(org.openide.actions.DeleteAction.class),
246:                            null,
247:                            SystemAction
248:                                    .get(org.openide.actions.ToolsAction.class),
249:                            SystemAction
250:                                    .get(org.openide.actions.PropertiesAction.class), };
251:                }
252:
253:                return staticActions;
254:            }
255:
256:            /**
257:             * Description of the Method
258:             */
259:            private void initializeTooltip() {
260:                String tooltip = (String) this .getItemAttribute("Tooltip");
261:                if (tooltip == null) {
262:                    this .setShortDescription("");
263:                    return;
264:                }
265:
266:                // test if tooltip is a key in the default bundle.
267:                String bundleTooltip = getStringFromDefaultBundle(tooltip);
268:                if (bundleTooltip == null) {
269:                    this .setShortDescription(tooltip);
270:                } else {
271:                    this .setShortDescription(bundleTooltip);
272:                }
273:            }
274:
275:            /**
276:             * Gets the stringFromDefaultBundle attribute of the PaletteItemNode object
277:             *
278:             * @param key  Description of the Parameter
279:             * @return     The stringFromDefaultBundle value
280:             */
281:            private String getStringFromDefaultBundle(String key) {
282:                String defaultBundle = (String) this 
283:                        .getItemAttribute("SystemFileSystem.localizingBundle");
284:                if (defaultBundle != null) {
285:                    java.util.ResourceBundle bundle = org.openide.util.NbBundle
286:                            .getBundle(defaultBundle);
287:                    try {
288:                        if (bundle != null) {
289:                            return bundle.getString(key);
290:                        }
291:                    } catch (java.util.MissingResourceException m) {
292:                        // it is a test of resource existence, save to igrone exception
293:                    }
294:                }
295:                return null;
296:            }
297:        }
w___ww__.__j_ava__2___s___._c___om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.