annotate agent/src/share/classes/sun/jvm/hotspot/ui/FindByQueryPanel.java @ 692:23276f80d930

6825642: nsk sajdi tests fail with NullPointerException Reviewed-by: xlu, coleenp, kamg, swamyv
author acorn
date Thu, 02 Apr 2009 14:26:42 -0400
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.ui;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.awt.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.awt.event.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import javax.swing.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import javax.swing.event.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.ui.tree.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.utilities.soql.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 public class FindByQueryPanel extends SAPanel {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private JTextArea queryEditor;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private JEditorPane objectsEditor;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private SOQLEngine queryEngine;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public FindByQueryPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 queryEngine = SOQLEngine.getEngine();
a61af66fc99e Initial load
duke
parents:
diff changeset
45 HyperlinkListener hyperListener = new HyperlinkListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public void hyperlinkUpdate(HyperlinkEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 VM vm = VM.getVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
49 OopHandle handle = vm.getDebugger().parseAddress(e.getDescription()).addOffsetToAsOopHandle(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 showInspector(vm.getObjectHeap().newOop(handle));
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 };
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 objectsEditor = new JEditorPane();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 objectsEditor.setContentType("text/html");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 objectsEditor.setEditable(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 objectsEditor.addHyperlinkListener(hyperListener);
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 queryEditor = new JTextArea();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 JButton queryButton = new JButton("Execute");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 queryButton.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public void actionPerformed(ActionEvent ae) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 final StringBuffer buf = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 buf.append("<html><body>");
a61af66fc99e Initial load
duke
parents:
diff changeset
66 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 queryEngine.executeQuery(queryEditor.getText(),
a61af66fc99e Initial load
duke
parents:
diff changeset
68 new ObjectVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 public void visit(Object o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 if (o != null && o instanceof JSJavaObject) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 String oopAddr = ((JSJavaObject)o).getOop().getHandle().toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 buf.append("<a href='");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 buf.append(oopAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 buf.append("'>");
a61af66fc99e Initial load
duke
parents:
diff changeset
75 buf.append(oopAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 buf.append("</a>");
a61af66fc99e Initial load
duke
parents:
diff changeset
77 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 buf.append((o == null)? "null" : o.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 buf.append("<br>");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 });
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 buf.append("<b>");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 buf.append(e.getMessage());
a61af66fc99e Initial load
duke
parents:
diff changeset
88 buf.append("</b>");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 buf.append("</body></html>");
a61af66fc99e Initial load
duke
parents:
diff changeset
91 objectsEditor.setText(buf.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 });
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 JPanel topPanel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 topPanel.setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
97 topPanel.add(new JLabel("SOQL Query :"), BorderLayout.WEST);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 topPanel.add(new JScrollPane(queryEditor), BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 topPanel.add(queryButton, BorderLayout.EAST);
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 JPanel bottomPanel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 bottomPanel.setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
103 bottomPanel.add(new JScrollPane(objectsEditor), BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 splitPane.setDividerLocation(0.3);
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
109 add(splitPane, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }