Mercurial > hg > truffle
annotate src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java @ 2955:bf4f8817e3bd
IdealGraphVisualizer: eliminate compiler warnings by replacing calls to deprecated API methods, introducing generics parameters where missing, and when absolutely necessary adding @SuppressWarnings annotations
author | Peter Hofer <peter.hofer@jku.at> |
---|---|
date | Wed, 15 Jun 2011 14:30:40 +0200 |
parents | 53ddfe305645 |
children | f22dc0a63f03 |
rev | line source |
---|---|
222 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
417
diff
changeset
|
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
222 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
417
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
417
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:
417
diff
changeset
|
21 * questions. |
222 | 22 * |
23 */ | |
24 package com.sun.hotspot.igv.bytecodes; | |
25 | |
26 import com.sun.hotspot.igv.data.Group; | |
27 import com.sun.hotspot.igv.data.InputGraph; | |
28 import com.sun.hotspot.igv.data.services.InputGraphProvider; | |
2898
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
29 import com.sun.hotspot.igv.util.LookupHistory; |
222 | 30 import java.awt.BorderLayout; |
31 import java.io.Serializable; | |
417 | 32 import javax.swing.SwingUtilities; |
222 | 33 import org.openide.ErrorManager; |
34 import org.openide.explorer.ExplorerManager; | |
35 import org.openide.explorer.ExplorerUtils; | |
36 import org.openide.explorer.view.BeanTreeView; | |
37 import org.openide.util.Lookup; | |
38 import org.openide.util.LookupEvent; | |
39 import org.openide.util.LookupListener; | |
40 import org.openide.util.NbBundle; | |
41 import org.openide.util.Utilities; | |
42 import org.openide.windows.TopComponent; | |
43 import org.openide.windows.WindowManager; | |
44 | |
45 /** | |
46 * @author Thomas Wuerthinger | |
47 */ | |
48 final class BytecodeViewTopComponent extends TopComponent implements ExplorerManager.Provider, LookupListener { | |
49 | |
50 private static BytecodeViewTopComponent instance; | |
51 private static final String PREFERRED_ID = "BytecodeViewTopComponent"; | |
52 private ExplorerManager manager; | |
53 private BeanTreeView treeView; | |
54 private Lookup.Result result = null; | |
55 private MethodNode rootNode; | |
56 | |
57 private BytecodeViewTopComponent() { | |
58 initComponents(); | |
59 setName(NbBundle.getMessage(BytecodeViewTopComponent.class, "CTL_BytecodeViewTopComponent")); | |
60 setToolTipText(NbBundle.getMessage(BytecodeViewTopComponent.class, "HINT_BytecodeViewTopComponent")); | |
61 | |
62 manager = new ExplorerManager(); | |
63 rootNode = new MethodNode(null, null, ""); | |
64 manager.setRootContext(rootNode); | |
65 | |
66 setLayout(new BorderLayout()); | |
67 | |
68 treeView = new BeanTreeView(); | |
69 treeView.setRootVisible(false); | |
70 this.add(BorderLayout.CENTER, treeView); | |
71 associateLookup(ExplorerUtils.createLookup(manager, getActionMap())); | |
72 } | |
73 | |
74 /** This method is called from within the constructor to | |
75 * initialize the form. | |
76 * WARNING: Do NOT modify this code. The content of this method is | |
77 * always regenerated by the Form Editor. | |
78 */ | |
79 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents | |
80 private void initComponents() { | |
81 | |
82 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); | |
83 this.setLayout(layout); | |
84 layout.setHorizontalGroup( | |
85 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) | |
86 .add(0, 400, Short.MAX_VALUE) | |
87 ); | |
88 layout.setVerticalGroup( | |
89 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) | |
90 .add(0, 300, Short.MAX_VALUE) | |
91 ); | |
92 }// </editor-fold>//GEN-END:initComponents | |
93 // Variables declaration - do not modify//GEN-BEGIN:variables | |
94 // End of variables declaration//GEN-END:variables | |
2898
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
95 |
222 | 96 /** |
97 * Gets default instance. Do not use directly: reserved for *.settings files only, | |
98 * i.e. deserialization routines; otherwise you could get a non-deserialized instance. | |
99 * To obtain the singleton instance, use {@link findInstance}. | |
100 */ | |
101 public static synchronized BytecodeViewTopComponent getDefault() { | |
102 if (instance == null) { | |
103 instance = new BytecodeViewTopComponent(); | |
104 } | |
105 return instance; | |
106 } | |
107 | |
108 /** | |
109 * Obtain the BytecodeViewTopComponent instance. Never call {@link #getDefault} directly! | |
110 */ | |
111 public static synchronized BytecodeViewTopComponent findInstance() { | |
112 TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); | |
113 if (win == null) { | |
114 ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find BytecodeView component. It will not be located properly in the window system."); | |
115 return getDefault(); | |
116 } | |
117 if (win instanceof BytecodeViewTopComponent) { | |
118 return (BytecodeViewTopComponent) win; | |
119 } | |
120 ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior."); | |
121 return getDefault(); | |
122 } | |
123 | |
124 @Override | |
125 public int getPersistenceType() { | |
126 return TopComponent.PERSISTENCE_ALWAYS; | |
127 } | |
128 | |
129 @Override | |
130 public void componentOpened() { | |
2955
bf4f8817e3bd
IdealGraphVisualizer: eliminate compiler warnings by replacing calls to deprecated API methods, introducing generics parameters where missing, and when absolutely necessary adding @SuppressWarnings annotations
Peter Hofer <peter.hofer@jku.at>
parents:
2898
diff
changeset
|
131 Lookup.Template<InputGraphProvider> tpl = new Lookup.Template<InputGraphProvider>(InputGraphProvider.class); |
222 | 132 result = Utilities.actionsGlobalContext().lookup(tpl); |
133 result.addLookupListener(this); | |
134 } | |
135 | |
136 @Override | |
137 public void componentClosed() { | |
138 result.removeLookupListener(this); | |
139 result = null; | |
140 } | |
141 | |
142 @Override | |
143 public Object writeReplace() { | |
144 return new ResolvableHelper(); | |
145 } | |
146 | |
147 @Override | |
148 protected String preferredID() { | |
149 return PREFERRED_ID; | |
150 } | |
151 | |
152 public ExplorerManager getExplorerManager() { | |
153 return manager; | |
154 } | |
155 | |
2898
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
156 @Override |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
157 public void requestActive() { |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
158 super.requestActive(); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
159 this.treeView.requestFocus(); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
160 } |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
161 |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
162 @Override |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
163 public boolean requestFocus(boolean temporary) { |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
164 this.treeView.requestFocus(); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
165 return super.requestFocus(temporary); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
166 } |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
167 |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
168 @Override |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
169 protected boolean requestFocusInWindow(boolean temporary) { |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
170 this.treeView.requestFocus(); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
171 return super.requestFocusInWindow(temporary); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
172 } |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
173 |
222 | 174 public void resultChanged(LookupEvent lookupEvent) { |
2898
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
175 final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); |
222 | 176 if (p != null) { |
417 | 177 SwingUtilities.invokeLater(new Runnable() { |
178 public void run() { | |
2898
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
179 InputGraph graph = p.getGraph(); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
180 if (graph != null) { |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
181 Group g = graph.getGroup(); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
182 rootNode.update(graph, g.getMethod()); |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
183 } |
53ddfe305645
IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary
Peter Hofer <peter.hofer@jku.at>
parents:
1552
diff
changeset
|
184 } |
417 | 185 }); |
186 } | |
222 | 187 } |
188 | |
189 final static class ResolvableHelper implements Serializable { | |
190 | |
191 private static final long serialVersionUID = 1L; | |
192 | |
193 public Object readResolve() { | |
194 return BytecodeViewTopComponent.getDefault(); | |
195 } | |
196 } | |
197 } |