Source Code Cross Referenced for EditPanel.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:        /**
043:         * @author Ana von Klopp
044:         */package org.netbeans.modules.web.monitor.client;
045:
046:        import java.awt.Dialog;
047:        import java.awt.Dimension;
048:        import java.awt.event.*;
049:
050:        import java.io.IOException;
051:
052:        import java.net.*;
053:        import java.text.*;
054:
055:        import javax.swing.*;
056:        import javax.swing.event.*;
057:
058:        import java.util.*;
059:
060:        import java.util.logging.Level;
061:        import java.util.logging.Logger;
062:        import org.openide.DialogDescriptor;
063:        import org.openide.DialogDisplayer;
064:        import org.openide.NotifyDescriptor;
065:        import org.openide.util.HelpCtx;
066:        import org.openide.util.NbBundle;
067:
068:        import org.netbeans.modules.web.monitor.data.*;
069:
070:        class EditPanel extends javax.swing.JPanel implements  ActionListener,
071:                ChangeListener {
072:
073:            // Code to get the displaying of the tabbed panels correct.
074:            //
075:            private int displayType = 0;
076:            private static final int DISPLAY_TYPE_QUERY = 0;
077:            private static final int DISPLAY_TYPE_REQUEST = 1;
078:            private static final int DISPLAY_TYPE_COOKIES = 2;
079:            private static final int DISPLAY_TYPE_SERVER = 3;
080:            private static final int DISPLAY_TYPE_HEADERS = 4;
081:
082:            private transient Dimension tabD = new Dimension(450, 280);
083:
084:            private EditPanelQuery queryPanel;
085:            private EditPanelRequest requestPanel;
086:            private EditPanelCookies cookiesPanel;
087:            private EditPanelServer serverPanel;
088:            private EditPanelHeaders headersPanel;
089:
090:            private MonitorData monitorData = null;
091:
092:            // Do we need this to close it?
093:            private Dialog dialog = null;
094:            private DialogDescriptor editDialog = null;
095:
096:            private JButton sendButton;
097:            private JButton okButton;
098:            private JButton cancelButton;
099:
100:            /* These buttons were used for the feature that allows the user to
101:             * specify whether the browser's cookie should be used or whether
102:             * to replace it. In 3.6 ("Promotion B"), it is not
103:             * possible to configure the monitor to use user-specified
104:             * cookies, but I leave the method, in case it becomes possible in
105:             * the future. Basically, we can no longer set the cookie on the
106:             * server side (the Servlet APIs does not provide any method for
107:             * doing this) but we could technically tell the browser that
108:             * issues the replay request to send another cookie (the APIs for
109:             * that are not there now). If so, the feature can be
110:             * reintroduced. 
111:             * 
112:             * See also (PENDING) for other changes required to reintroduce
113:             * this feature. 
114:             */
115:            //private JToggleButton browserCookieButton, savedCookieButton; 
116:            //private static boolean useBrowserCookie = true;
117:            final static String METHOD = "method"; //NOI18N
118:            final static String GET = "GET"; //NOI18N
119:            final static String POST = "POST"; //NOI18N
120:            final static String PUT = "PUT"; //NOI18N
121:
122:            private static EditPanel instance = null;
123:
124:            static void displayEditPanel(TransactionNode node) {
125:                MonitorData md = null;
126:                // We retrieve the data from the file system, not from the 
127:                // cache
128:                md = Controller.getInstance().getMonitorData(
129:                        (TransactionNode) node, false, // from file
130:                        false); // don't cache
131:                if (md == null) {
132:                    // We couldn't get the data. 
133:                    String msg = NbBundle.getMessage(EditPanel.class,
134:                            "MSG_NoMonitorData");
135:                    Logger.getLogger("global").log(Level.INFO, msg);
136:                    return;
137:                }
138:
139:                if (md.getRequestData().getAttributeValue(METHOD).equals(POST))
140:                    Util.removeParametersFromQuery(md.getRequestData());
141:
142:                md.getRequestData().deleteCookie("jsessionid");
143:
144:                if (instance == null)
145:                    instance = new EditPanel();
146:
147:                //useBrowserCookie = MonitorAction.getController().getUseBrowserCookie();
148:                instance.showDialog(md);
149:            }
150:
151:            static synchronized EditPanel getInstance() {
152:                if (instance == null)
153:                    instance = new EditPanel();
154:                return instance;
155:            }
156:
157:            private EditPanel() {
158:
159:                createDialogButtons();
160:
161:                this .setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
162:
163:                queryPanel = new EditPanelQuery();
164:                requestPanel = new EditPanelRequest();
165:                cookiesPanel = new EditPanelCookies();
166:                serverPanel = new EditPanelServer();
167:                headersPanel = new EditPanelHeaders();
168:                getAccessibleContext().setAccessibleDescription(
169:                        NbBundle.getMessage(EditPanel.class,
170:                                "ACS_MON_Replay_panel"));
171:                JTabbedPane tabs = new JTabbedPane();
172:                tabs.getAccessibleContext().setAccessibleName(
173:                        NbBundle.getBundle(EditPanel.class).getString(
174:                                "ACS_MON_Replay_tabsName"));
175:                tabs.getAccessibleContext().setAccessibleDescription(
176:                        NbBundle.getBundle(EditPanel.class).getString(
177:                                "ACS_MON_Replay_tabsDesc"));
178:
179:                tabs.setPreferredSize(tabD);
180:                tabs.addTab(NbBundle.getBundle(EditPanel.class).getString(
181:                        "MON_Query_Panel_Tab"), queryPanel);
182:                tabs.addTab(NbBundle.getBundle(EditPanel.class).getString(
183:                        "MON_Request_Panel_Tab"), requestPanel);
184:                tabs.addTab(NbBundle.getBundle(EditPanel.class).getString(
185:                        "MON_Cookies_Panel_Tab"), cookiesPanel);
186:                tabs.addTab(NbBundle.getBundle(EditPanel.class).getString(
187:                        "MON_Server_Panel_Tab"), serverPanel);
188:                tabs.addTab(NbBundle.getBundle(EditPanel.class).getString(
189:                        "MON_Headers_Panel_Tab"), headersPanel);
190:                tabs.addChangeListener(this );
191:
192:                this .add(tabs);
193:                this .add(Box.createGlue());
194:                this .add(Box.createVerticalStrut(5));
195:                // Housekeeping
196:                this .setMaximumSize(this .getPreferredSize());
197:            }
198:
199:            void showDialog(MonitorData md) {
200:
201:                this .monitorData = md;
202:
203:                queryPanel.setData(monitorData);
204:                requestPanel.setData(monitorData);
205:                cookiesPanel.setData(monitorData);
206:                serverPanel.setData(monitorData);
207:                headersPanel.setData(monitorData);
208:
209:                Object[] options = {
210:                //createSessionButtonPanel(),
211:                        sendButton, cancelButton, };
212:
213:                editDialog = new DialogDescriptor(this , NbBundle.getBundle(
214:                        EditPanel.class).getString("MON_EditReplay_panel"),
215:                        false, options, options[0],
216:                        DialogDescriptor.BOTTOM_ALIGN, new HelpCtx(
217:                                "monitor_resend"), //NOI18N
218:                        this );
219:
220:                dialog = DialogDisplayer.getDefault().createDialog(editDialog);
221:                dialog.pack();
222:                dialog.setVisible(true);
223:            }
224:
225:            /**
226:             * Handle user input...
227:             */
228:
229:            public void actionPerformed(ActionEvent e) {
230:
231:                String str = new String();
232:                Object value = editDialog.getValue();
233:                if (value == null)
234:                    return;
235:                if (value instanceof  JButton)
236:                    str = ((JButton) value).getText();
237:                else
238:                    str = value.toString();
239:                if (str.equals(NbBundle.getBundle(EditPanel.class).getString(
240:                        "MON_Send"))) {
241:
242:                    String method = monitorData.getRequestData()
243:                            .getAttributeValue(METHOD);
244:
245:                    if (method.equals(GET))
246:                        Util.composeQueryString(monitorData.getRequestData());
247:
248:                    try {
249:                        MonitorAction.getController().replayTransaction(
250:                                monitorData);
251:                        dialog.dispose();
252:                    } catch (UnknownHostException uhe) {
253:                        // Notify the user that there is no host
254:
255:                        Object[] options = { okButton
256:                        //		    NbBundle.getBundle(EditPanel.class).getString("MON_OK"),
257:                        };
258:
259:                        NotifyDescriptor noServerDialog = new NotifyDescriptor(
260:                                NbBundle.getMessage(EditPanel.class,
261:                                        "MON_Exec_server_wrong", monitorData
262:                                                .getServerName()), NbBundle
263:                                        .getBundle(EditPanel.class).getString(
264:                                                "MON_Exec_server"),
265:                                NotifyDescriptor.DEFAULT_OPTION,
266:                                NotifyDescriptor.INFORMATION_MESSAGE, options,
267:                                options[0]);
268:                        DialogDisplayer.getDefault().notify(noServerDialog);
269:                        displayType = DISPLAY_TYPE_SERVER;
270:                        showData();
271:                    } catch (IOException ioe) {
272:                        // Notify the user that the server is not running
273:                        Object[] options = { NbBundle
274:                                .getBundle(EditPanel.class).getString("MON_OK"), };
275:
276:                        Object[] args = { monitorData.getServerName(),
277:                                monitorData.getServerPortAsString(), };
278:
279:                        NotifyDescriptor noServerDialog = new NotifyDescriptor(
280:                                NbBundle.getMessage(EditPanel.class,
281:                                        "MON_Exec_server_start", args),
282:                                NbBundle.getBundle(EditPanel.class).getString(
283:                                        "MON_Exec_server"),
284:                                NotifyDescriptor.DEFAULT_OPTION,
285:                                NotifyDescriptor.INFORMATION_MESSAGE, options,
286:                                options[0]);
287:                        DialogDisplayer.getDefault().notify(noServerDialog);
288:                    }
289:                } else if (str.equals(NbBundle.getBundle(EditPanel.class)
290:                        .getString("MON_Cancel")))
291:                    dialog.dispose();
292:            }
293:
294:            /**
295:             * Listens to events from the tab pane, displays different
296:             * categories of data accordingly. 
297:             */
298:            public void stateChanged(ChangeEvent e) {
299:                JTabbedPane p = (JTabbedPane) e.getSource();
300:                displayType = p.getSelectedIndex();
301:
302:                showData();
303:            }
304:
305:            void showData() {
306:
307:                if (displayType == DISPLAY_TYPE_QUERY)
308:                    queryPanel.setData(monitorData);
309:                else if (displayType == DISPLAY_TYPE_REQUEST)
310:                    requestPanel.setData(monitorData);
311:                else if (displayType == DISPLAY_TYPE_COOKIES)
312:                    cookiesPanel.setData(monitorData);
313:                else if (displayType == DISPLAY_TYPE_SERVER)
314:                    serverPanel.setData(monitorData);
315:                else if (displayType == DISPLAY_TYPE_HEADERS)
316:                    headersPanel.setData(monitorData);
317:            }
318:
319:            private void createDialogButtons() {
320:
321:                // Button used by the dialog descriptor
322:                sendButton = new JButton(NbBundle.getBundle(EditPanel.class)
323:                        .getString("MON_Send"));
324:                sendButton.setMnemonic(NbBundle.getBundle(EditPanel.class)
325:                        .getString("MON_Send_Mnemonic").charAt(0));
326:                sendButton.setToolTipText(NbBundle.getBundle(EditPanel.class)
327:                        .getString("ACS_MON_SendA11yDesc"));
328:
329:                okButton = new JButton(NbBundle.getBundle(EditPanel.class)
330:                        .getString("MON_OK"));
331:                okButton.setMnemonic(NbBundle.getBundle(EditPanel.class)
332:                        .getString("MON_OK_Mnemonic").charAt(0));
333:                okButton.setToolTipText(NbBundle.getBundle(EditPanel.class)
334:                        .getString("ACS_MON_OKA11yDesc"));
335:
336:                cancelButton = new JButton(NbBundle.getBundle(EditPanel.class)
337:                        .getString("MON_Cancel"));
338:                cancelButton.setMnemonic(NbBundle.getBundle(EditPanel.class)
339:                        .getString("MON_Cancel_Mnemonic").charAt(0));
340:                cancelButton.setToolTipText(NbBundle.getBundle(EditPanel.class)
341:                        .getString("ACS_MON_CancelA11yDesc"));
342:            }
343:        } // EditPanel
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.