Source Code Cross Referenced for TransactionNode.java in  » IDE-Netbeans » web.core » org » netbeans » modules » web » monitor » client » 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 » web.core » org.netbeans.modules.web.monitor.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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-2007 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.modules.web.monitor.client;
043:
044:        import org.openide.nodes.Children;
045:        import org.openide.util.actions.*;
046:        import org.openide.nodes.AbstractNode;
047:        import org.openide.util.actions.SystemAction;
048:        import org.openide.util.Utilities;
049:
050:        import java.util.StringTokenizer;
051:        import java.text.DateFormat;
052:        import java.util.Date;
053:        import java.awt.Image;
054:        import org.netbeans.modules.web.monitor.data.Constants;
055:
056:        public class TransactionNode extends AbstractNode {
057:
058:            String id, method, uri, name = null, timestamp = null;
059:            boolean current;
060:            private int statusCode;
061:            static boolean showTimeStamp = true;
062:
063:            public TransactionNode(String id, String method, String uri,
064:                    boolean current, int statusCode) {
065:
066:                super (Children.LEAF);
067:
068:                this .id = id;
069:                this .method = method;
070:                this .uri = uri;
071:                this .current = current;
072:                this .statusCode = statusCode;
073:
074:                setProperties();
075:            }
076:
077:            public TransactionNode(String id, String method, String uri,
078:                    Children ch, boolean current, int statusCode) {
079:
080:                super (ch);
081:
082:                this .id = id;
083:                this .method = method;
084:                this .uri = uri;
085:                this .current = current;
086:                this .statusCode = statusCode;
087:
088:                setProperties();
089:            }
090:
091:            // This method is incomplete, URI may need to be truncated... 
092:            public String getLongName() {
093:
094:                StringBuffer buf = new StringBuffer(method);
095:                buf.append(" "); //NOI18N
096:                buf.append(uri);
097:                if (timestamp == null)
098:                    setTimeStamp();
099:                buf.append(" "); //NOI18N
100:                buf.append(timestamp);
101:
102:                return buf.toString();
103:            }
104:
105:            public Image getIcon(int type) {
106:                Image base;
107:                // Get icon
108:                if (method.equals(Constants.Http.GET)) {
109:                    base = Utilities
110:                            .loadImage("org/netbeans/modules/web/monitor/client/icons/get.gif");
111:                    // Post icon
112:                } else if (method.equals(Constants.Http.POST)) {
113:                    base = Utilities
114:                            .loadImage("org/netbeans/modules/web/monitor/client/icons/post.gif"); // NOI18N
115:                    // Other 
116:                } else {
117:                    base = Utilities
118:                            .loadImage("org/netbeans/modules/web/monitor/client/icons/other.gif"); // NOI18N
119:                }
120:
121:                Image badge;
122:                if (statusCode >= 400 || statusCode < 0) {
123:                    badge = Utilities
124:                            .loadImage("org/netbeans/modules/web/monitor/client/icons/infoBadge.gif"); // NOI18N
125:                } else if (statusCode >= 300) {
126:                    badge = Utilities
127:                            .loadImage("org/netbeans/modules/web/monitor/client/icons/warningBadge.gif"); // NOI18N
128:                } else if (statusCode >= 200) {
129:                    return base;
130:                } else {
131:                    badge = Utilities
132:                            .loadImage("org/netbeans/modules/web/monitor/client/icons/errorBadge.gif"); // NOI18N
133:                }
134:                return Utilities.mergeImages(base, badge, 0, 0);
135:            }
136:
137:            public Image getOpenedIcon(int type) {
138:                return getIcon(type);
139:            }
140:
141:            public String getID() {
142:                return id;
143:            }
144:
145:            public String getMethod() {
146:                return method;
147:            }
148:
149:            public String getURI() {
150:                return uri;
151:            }
152:
153:            public boolean isCurrent() {
154:                return current;
155:            }
156:
157:            public void setCurrent(boolean b) {
158:                current = b;
159:            }
160:
161:            /* Getter for set of actions that should be present in the
162:             * popup menu of this node. This set is used in construction of
163:             * menu returned from getContextMenu and specially when a menu for
164:             * more nodes is constructed.
165:             *
166:             * @return array of system actions that should be in popup menu
167:             */
168:
169:            protected SystemAction[] createActions() {
170:
171:                if (current) {
172:                    return new SystemAction[] {
173:                            SystemAction.get(SaveAction.class), null,
174:                            SystemAction.get(ReplayAction.class),
175:                            SystemAction.get(EditReplayAction.class), null,
176:                            SystemAction.get(DeleteAction.class) };
177:                }
178:
179:                return new SystemAction[] {
180:                        SystemAction.get(ReplayAction.class),
181:                        SystemAction.get(EditReplayAction.class), null,
182:                        SystemAction.get(DeleteAction.class), };
183:            }
184:
185:            public SystemAction[] getActions() {
186:
187:                if (current) {
188:                    return new SystemAction[] {
189:                            SystemAction.get(SaveAction.class), null,
190:                            SystemAction.get(ReplayAction.class),
191:                            SystemAction.get(EditReplayAction.class), null,
192:                            SystemAction.get(DeleteAction.class) };
193:                }
194:
195:                return new SystemAction[] {
196:                        SystemAction.get(ReplayAction.class),
197:                        SystemAction.get(EditReplayAction.class), null,
198:                        SystemAction.get(DeleteAction.class), };
199:            }
200:
201:            /** Can this node be copied?
202:             * @return <code>true</code> in the default implementation
203:             */
204:            public boolean canCopy() {
205:                return true;
206:            }
207:
208:            /** Can this node be cut?
209:             * @return <code>false</code> in the default implementation
210:             */
211:            public boolean canCut() {
212:                return false;
213:            }
214:
215:            /** 
216:             * Set whether the timestamp is shown or not
217:             */
218:            public static void toggleTimeStamp() {
219:                if (showTimeStamp)
220:                    showTimeStamp = false;
221:                else
222:                    showTimeStamp = true;
223:            }
224:
225:            /** 
226:             * Is the timestamp showing
227:             */
228:            public static boolean showTimeStamp() {
229:                return showTimeStamp;
230:            }
231:
232:            private void setProperties() {
233:                setNameString();
234:                setShortDescription(uri);
235:            }
236:
237:            public void setNameString() {
238:
239:                String name = null;
240:                if (uri.equals("/"))
241:                    name = uri; //NOI18N
242:                else {
243:                    StringTokenizer st = new StringTokenizer(uri, "/"); //NOI18N
244:                    while (st.hasMoreTokens())
245:                        name = st.nextToken();
246:                }
247:
248:                StringBuilder buf = new StringBuilder(method);
249:                buf.append(' '); //NOI18N
250:                buf.append(name);
251:                if (showTimeStamp) {
252:                    if (timestamp == null)
253:                        setTimeStamp();
254:                    buf.append(' '); //NOI18N
255:                    buf.append(timestamp);
256:                }
257:                setName(buf.toString());
258:            }
259:
260:            private void setTimeStamp() {
261:
262:                try {
263:                    long ldate = Long.valueOf(id).longValue();
264:                    Date date = new Date(ldate);
265:
266:                    StringBuilder buf = new StringBuilder('['); //NOI18N
267:                    DateFormat df = DateFormat
268:                            .getTimeInstance(DateFormat.SHORT);
269:                    buf.append(df.format(date));
270:                    buf.append(" "); //NOI18N
271:                    df = DateFormat.getDateInstance(DateFormat.SHORT);
272:                    buf.append(df.format(date));
273:                    buf.append(']'); //NOI18N
274:                    timestamp = buf.toString();
275:                } catch (Exception e) {
276:                }
277:            }
278:
279:            public String toString() {
280:                StringBuilder buf = new StringBuilder("TransactionNode: "); //NOI18N
281:                buf.append(this .getName());
282:                buf.append('\n'); //NOI18N
283:                buf.append("id="); //NOI18N
284:                buf.append(id);
285:
286:                buf.append('\n'); //NOI18N
287:                buf.append("method="); //NOI18N
288:                buf.append(method);
289:
290:                buf.append('\n'); //NOI18N
291:                buf.append("uri="); //NOI18N
292:                buf.append(uri);
293:
294:                buf.append('\n'); //NOI18N
295:                buf.append("current="); //NOI18N
296:                buf.append(String.valueOf(current));
297:                buf.append('\n'); //NOI18N
298:
299:                return buf.toString();
300:            }
301:        } // TransactionNode
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.