annotate agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/ClassBrowserPanel.java @ 2065:6da3527317ff

7003487: clhsdbproc stacktrace fails on x64 Reviewed-by: phh
author kevinw
date Fri, 17 Dec 2010 12:14:48 +0000
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
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.classbrowser;
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 javax.swing.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import javax.swing.event.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.ui.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.ui.action.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import com.sun.java.swing.ui.StatusBar;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import com.sun.java.swing.ui.CommonToolBar;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import com.sun.java.swing.action.ActionManager;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import com.sun.java.swing.action.DelegateAction;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public class ClassBrowserPanel extends JPanel implements ActionListener {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private StatusBar statusBar;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private ClassBrowserToolBar toolBar;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private JSplitPane splitPane;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private SAEditorPane classesEditor;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private SAEditorPane contentEditor;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private HTMLGenerator htmlGen;
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 public ClassBrowserPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 htmlGen = new HTMLGenerator();
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 HyperlinkListener hyperListener = new HyperlinkListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public void hyperlinkUpdate(HyperlinkEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 contentEditor.setText(htmlGen.genHTMLForHyperlink(e.getDescription()));
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 };
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 classesEditor = new SAEditorPane();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 classesEditor.addHyperlinkListener(hyperListener);
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 contentEditor = new SAEditorPane();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 contentEditor.addHyperlinkListener(hyperListener);
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 JPanel topPanel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 topPanel.setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
69 topPanel.add(new JScrollPane(classesEditor), BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 JPanel bottomPanel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 bottomPanel.setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
73 bottomPanel.add(new JScrollPane(contentEditor), BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 splitPane.setDividerLocation(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
79 add(splitPane, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 statusBar = new StatusBar();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 add(statusBar, BorderLayout.SOUTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 toolBar = new ClassBrowserToolBar(statusBar);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 add(toolBar, BorderLayout.NORTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 registerActions();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 public void setClassesText(String text) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 classesEditor.setText(text);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 splitPane.setDividerLocation(0.5);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public void setContentText(String text) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 contentEditor.setText(text);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 splitPane.setDividerLocation(0.5);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 private class ClassBrowserToolBar extends CommonToolBar {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 private JTextField searchTF;
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public ClassBrowserToolBar(StatusBar status) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 super(HSDBActionManager.getInstance(), status);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 protected void addComponents() {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 searchTF = new JTextField();
a61af66fc99e Initial load
duke
parents:
diff changeset
106 searchTF.setToolTipText("Find classes");
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Pressing Enter on the text field will search
a61af66fc99e Initial load
duke
parents:
diff changeset
109 InputMap im = searchTF.getInputMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 im.put(KeyStroke.getKeyStroke("ENTER"), "enterPressed");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 ActionMap am = searchTF.getActionMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 am.put("enterPressed", manager.getAction(FindClassesAction.VALUE_COMMAND));
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 add(searchTF);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 addButton(manager.getAction(FindClassesAction.VALUE_COMMAND));
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public String getFindText() {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return searchTF.getText();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 //
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // ActionListener implementation and actions support
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 public void actionPerformed(ActionEvent evt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 String command = evt.getActionCommand();
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (command.equals(FindClassesAction.VALUE_COMMAND)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 findClasses();
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 protected void registerActions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 registerAction(FindClassesAction.VALUE_COMMAND);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 private void registerAction(String actionName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 ActionManager manager = ActionManager.getInstance();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 DelegateAction action = manager.getDelegateAction(actionName);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 action.addActionListener(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 private void findClasses() {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 String findText = toolBar.getFindText();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (findText == null || findText.equals("")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 setContentText(htmlGen.genHTMLForWait("Finding classes ..."));
a61af66fc99e Initial load
duke
parents:
diff changeset
152 InstanceKlass[] klasses = SystemDictionaryHelper.findInstanceKlasses(findText);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if (klasses.length == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 setContentText(htmlGen.genHTMLForMessage("No class found with name containing '" + findText + "'"));
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 setContentText(htmlGen.genHTMLForKlassNames(klasses));
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }