annotate agent/src/share/classes/sun/jvm/hotspot/ui/FindPanel.java @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents a61af66fc99e
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) 2000, 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;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.awt.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.awt.event.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import javax.swing.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import javax.swing.text.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.*;
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.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 /** Uses {@link sun.jvm.hotspot.utilities.PointerFinder} to provide a
a61af66fc99e Initial load
duke
parents:
diff changeset
38 graphical user interface to the VM's debugging utility "find". */
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public class FindPanel extends JPanel {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // UI widgets we need permanent handles to
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private JTextField addressField;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private JTextArea textArea;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private JLabel statusLabel;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public FindPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
50 Box hbox = Box.createHorizontalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 hbox.add(new JLabel("Address: "));
a61af66fc99e Initial load
duke
parents:
diff changeset
52 addressField = new JTextField(20);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 hbox.add(addressField);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 statusLabel = new JLabel();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 hbox.add(statusLabel);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 add(hbox, BorderLayout.NORTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 JScrollPane scroller = new JScrollPane();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 textArea = new JTextArea();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 textArea.setEditable(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 textArea.setLineWrap(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 textArea.setWrapStyleWord(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 scroller.getViewport().add(textArea);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 add(scroller, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 addressField.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 Address a = VM.getVM().getDebugger().parseAddress(addressField.getText());
a61af66fc99e Initial load
duke
parents:
diff changeset
70 PointerLocation loc = PointerFinder.find(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 ByteArrayOutputStream bos = new ByteArrayOutputStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 loc.printOn(new PrintStream(bos));
a61af66fc99e Initial load
duke
parents:
diff changeset
73 clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 textArea.append(bos.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
75 statusLabel.setText("");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 catch (NumberFormatException ex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 statusLabel.setText("<parse error>");
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 catch (AddressException ex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 statusLabel.setText("<bad address>");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 catch (Exception ex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 ex.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 statusLabel.setText("<error during find>");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 });
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 private void clear() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 Document doc = textArea.getDocument();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (doc.getLength() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 doc.remove(0, doc.getLength());
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 catch (BadLocationException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }