author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 25859 | jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XSheet.java@3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
12851
diff
changeset
|
2 |
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.tools.jconsole.inspector; |
|
27 |
||
1017
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
28 |
|
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
29 |
import java.awt.BorderLayout; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
30 |
import java.awt.Color; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
31 |
import java.awt.Component; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
32 |
import java.awt.Dimension; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
33 |
import java.awt.event.ActionEvent; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
34 |
import java.awt.event.ActionListener; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
35 |
import java.io.IOException; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
36 |
|
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
37 |
import javax.management.IntrospectionException; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
38 |
import javax.management.NotificationListener; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
39 |
import javax.management.MBeanInfo; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
40 |
import javax.management.InstanceNotFoundException; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
41 |
import javax.management.ReflectionException; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
42 |
import javax.management.MBeanAttributeInfo; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
43 |
import javax.management.MBeanOperationInfo; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
44 |
import javax.management.MBeanNotificationInfo; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
45 |
import javax.management.Notification; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
46 |
import javax.swing.BorderFactory; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
47 |
import javax.swing.JButton; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
48 |
import javax.swing.JOptionPane; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
49 |
import javax.swing.JPanel; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
50 |
import javax.swing.JScrollPane; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
51 |
import javax.swing.JTextArea; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
52 |
import javax.swing.SwingWorker; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
53 |
import javax.swing.border.LineBorder; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
54 |
import javax.swing.tree.DefaultMutableTreeNode; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
55 |
import javax.swing.tree.DefaultTreeModel; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
56 |
|
2 | 57 |
import sun.tools.jconsole.*; |
58 |
import sun.tools.jconsole.inspector.XNodeInfo.Type; |
|
59 |
||
60 |
@SuppressWarnings("serial") |
|
61 |
public class XSheet extends JPanel |
|
62 |
implements ActionListener, NotificationListener { |
|
63 |
||
64 |
private JPanel mainPanel; |
|
65 |
private JPanel southPanel; |
|
66 |
// Node being currently displayed |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
67 |
private volatile DefaultMutableTreeNode currentNode; |
2 | 68 |
// MBean being currently displayed |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
69 |
private volatile XMBean mbean; |
2 | 70 |
// XMBeanAttributes container |
71 |
private XMBeanAttributes mbeanAttributes; |
|
72 |
// XMBeanOperations container |
|
73 |
private XMBeanOperations mbeanOperations; |
|
74 |
// XMBeanNotifications container |
|
75 |
private XMBeanNotifications mbeanNotifications; |
|
76 |
// XMBeanInfo container |
|
77 |
private XMBeanInfo mbeanInfo; |
|
78 |
// Refresh JButton (mbean attributes case) |
|
79 |
private JButton refreshButton; |
|
80 |
// Subscribe/Unsubscribe/Clear JButton (mbean notifications case) |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
81 |
private JButton clearButton, subscribeButton, unsubscribeButton; |
2 | 82 |
// Reference to MBeans tab |
83 |
private MBeansTab mbeansTab; |
|
84 |
||
85 |
public XSheet(MBeansTab mbeansTab) { |
|
86 |
this.mbeansTab = mbeansTab; |
|
87 |
setupScreen(); |
|
88 |
} |
|
89 |
||
90 |
public void dispose() { |
|
91 |
clear(); |
|
92 |
XDataViewer.dispose(mbeansTab); |
|
93 |
mbeanNotifications.dispose(); |
|
94 |
} |
|
95 |
||
96 |
private void setupScreen() { |
|
97 |
setLayout(new BorderLayout()); |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
98 |
setBorder(BorderFactory.createLineBorder(Color.GRAY)); |
2 | 99 |
// add main panel to XSheet |
100 |
mainPanel = new JPanel(); |
|
101 |
mainPanel.setLayout(new BorderLayout()); |
|
102 |
add(mainPanel, BorderLayout.CENTER); |
|
103 |
// add south panel to XSheet |
|
104 |
southPanel = new JPanel(); |
|
105 |
add(southPanel, BorderLayout.SOUTH); |
|
106 |
// create the refresh button |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
107 |
refreshButton = new JButton(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
108 |
refreshButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON)); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
109 |
refreshButton.setToolTipText(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON_TOOLTIP); |
2 | 110 |
refreshButton.addActionListener(this); |
111 |
// create the clear button |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
112 |
clearButton = new JButton(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
113 |
clearButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON)); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
114 |
clearButton.setToolTipText(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON_TOOLTIP); |
2 | 115 |
clearButton.addActionListener(this); |
116 |
// create the subscribe button |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
117 |
subscribeButton = new JButton(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
118 |
subscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON)); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
119 |
subscribeButton.setToolTipText(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP); |
2 | 120 |
subscribeButton.addActionListener(this); |
121 |
// create the unsubscribe button |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
122 |
unsubscribeButton = new JButton(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
123 |
unsubscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON)); |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
124 |
unsubscribeButton.setToolTipText(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP); |
2 | 125 |
unsubscribeButton.addActionListener(this); |
126 |
// create XMBeanAttributes container |
|
127 |
mbeanAttributes = new XMBeanAttributes(mbeansTab); |
|
128 |
// create XMBeanOperations container |
|
129 |
mbeanOperations = new XMBeanOperations(mbeansTab); |
|
130 |
mbeanOperations.addOperationsListener(this); |
|
131 |
// create XMBeanNotifications container |
|
132 |
mbeanNotifications = new XMBeanNotifications(); |
|
133 |
mbeanNotifications.addNotificationsListener(this); |
|
134 |
// create XMBeanInfo container |
|
135 |
mbeanInfo = new XMBeanInfo(); |
|
136 |
} |
|
137 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
138 |
private boolean isSelectedNode(DefaultMutableTreeNode n, DefaultMutableTreeNode cn) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
139 |
return (cn == n); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
140 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
141 |
|
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
142 |
// Call on EDT |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
143 |
private void showErrorDialog(Object message, String title) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
144 |
new ThreadDialog(this, message, title, JOptionPane.ERROR_MESSAGE).run(); |
2 | 145 |
} |
146 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
147 |
public boolean isMBeanNode(DefaultMutableTreeNode node) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
148 |
Object userObject = node.getUserObject(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
149 |
if (userObject instanceof XNodeInfo) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
150 |
XNodeInfo uo = (XNodeInfo) userObject; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
151 |
return uo.getType().equals(Type.MBEAN); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
152 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
153 |
return false; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
154 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
155 |
|
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
156 |
// Call on EDT |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
157 |
public synchronized void displayNode(DefaultMutableTreeNode node) { |
2 | 158 |
clear(); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
159 |
displayEmptyNode(); |
2 | 160 |
if (node == null) { |
161 |
return; |
|
162 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
163 |
currentNode = node; |
2 | 164 |
Object userObject = node.getUserObject(); |
165 |
if (userObject instanceof XNodeInfo) { |
|
166 |
XNodeInfo uo = (XNodeInfo) userObject; |
|
167 |
switch (uo.getType()) { |
|
168 |
case MBEAN: |
|
169 |
displayMBeanNode(node); |
|
170 |
break; |
|
171 |
case NONMBEAN: |
|
172 |
displayEmptyNode(); |
|
173 |
break; |
|
174 |
case ATTRIBUTES: |
|
175 |
displayMBeanAttributesNode(node); |
|
176 |
break; |
|
177 |
case OPERATIONS: |
|
178 |
displayMBeanOperationsNode(node); |
|
179 |
break; |
|
180 |
case NOTIFICATIONS: |
|
181 |
displayMBeanNotificationsNode(node); |
|
182 |
break; |
|
183 |
case ATTRIBUTE: |
|
184 |
case OPERATION: |
|
185 |
case NOTIFICATION: |
|
186 |
displayMetadataNode(node); |
|
187 |
break; |
|
188 |
default: |
|
189 |
displayEmptyNode(); |
|
190 |
break; |
|
191 |
} |
|
192 |
} else { |
|
193 |
displayEmptyNode(); |
|
194 |
} |
|
195 |
} |
|
196 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
197 |
// Call on EDT |
2 | 198 |
private void displayMBeanNode(final DefaultMutableTreeNode node) { |
199 |
final XNodeInfo uo = (XNodeInfo) node.getUserObject(); |
|
200 |
if (!uo.getType().equals(Type.MBEAN)) { |
|
201 |
return; |
|
202 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
203 |
mbean = (XMBean) uo.getData(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
204 |
SwingWorker<MBeanInfo, Void> sw = new SwingWorker<MBeanInfo, Void>() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
205 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
206 |
public MBeanInfo doInBackground() throws InstanceNotFoundException, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
207 |
IntrospectionException, ReflectionException, IOException { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
208 |
return mbean.getMBeanInfo(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
209 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
210 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
211 |
protected void done() { |
2 | 212 |
try { |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
213 |
MBeanInfo mbi = get(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
214 |
if (mbi != null) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
215 |
if (!isSelectedNode(node, currentNode)) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
216 |
return; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
217 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
218 |
mbeanInfo.addMBeanInfo(mbean, mbi); |
2 | 219 |
invalidate(); |
220 |
mainPanel.removeAll(); |
|
221 |
mainPanel.add(mbeanInfo, BorderLayout.CENTER); |
|
222 |
southPanel.setVisible(false); |
|
223 |
southPanel.removeAll(); |
|
224 |
validate(); |
|
225 |
repaint(); |
|
226 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
227 |
} catch (Exception e) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
228 |
Throwable t = Utils.getActualException(e); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
229 |
if (JConsole.isDebug()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
230 |
System.err.println("Couldn't get MBeanInfo for MBean [" + |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
231 |
mbean.getObjectName() + "]"); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
232 |
t.printStackTrace(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
233 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
234 |
showErrorDialog(t.toString(), |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
235 |
Messages.PROBLEM_DISPLAYING_MBEAN); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
236 |
} |
2 | 237 |
} |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
238 |
}; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
239 |
sw.execute(); |
2 | 240 |
} |
241 |
||
242 |
// Call on EDT |
|
243 |
private void displayMetadataNode(final DefaultMutableTreeNode node) { |
|
244 |
final XNodeInfo uo = (XNodeInfo) node.getUserObject(); |
|
245 |
final XMBeanInfo mbi = mbeanInfo; |
|
246 |
switch (uo.getType()) { |
|
247 |
case ATTRIBUTE: |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
248 |
SwingWorker<MBeanAttributeInfo, Void> sw = |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
249 |
new SwingWorker<MBeanAttributeInfo, Void>() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
250 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
251 |
public MBeanAttributeInfo doInBackground() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
252 |
Object attrData = uo.getData(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
253 |
mbean = (XMBean) ((Object[]) attrData)[0]; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
254 |
MBeanAttributeInfo mbai = |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
255 |
(MBeanAttributeInfo) ((Object[]) attrData)[1]; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
256 |
mbeanAttributes.loadAttributes(mbean, new MBeanInfo( |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
257 |
null, null, new MBeanAttributeInfo[]{mbai}, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
258 |
null, null, null)); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
259 |
return mbai; |
2 | 260 |
} |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
261 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
262 |
protected void done() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
263 |
try { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
264 |
MBeanAttributeInfo mbai = get(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
265 |
if (!isSelectedNode(node, currentNode)) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
266 |
return; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
267 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
268 |
invalidate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
269 |
mainPanel.removeAll(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
270 |
JPanel attributePanel = |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
271 |
new JPanel(new BorderLayout()); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
272 |
JPanel attributeBorderPanel = |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
273 |
new JPanel(new BorderLayout()); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
274 |
attributeBorderPanel.setBorder( |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
275 |
BorderFactory.createTitledBorder( |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
276 |
Messages.ATTRIBUTE_VALUE)); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
277 |
JPanel attributeValuePanel = |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
278 |
new JPanel(new BorderLayout()); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
279 |
attributeValuePanel.setBorder( |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
280 |
LineBorder.createGrayLineBorder()); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
281 |
attributeValuePanel.add(mbeanAttributes.getTableHeader(), |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
282 |
BorderLayout.PAGE_START); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
283 |
attributeValuePanel.add(mbeanAttributes, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
284 |
BorderLayout.CENTER); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
285 |
attributeBorderPanel.add(attributeValuePanel, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
286 |
BorderLayout.CENTER); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
287 |
JPanel refreshButtonPanel = new JPanel(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
288 |
refreshButtonPanel.add(refreshButton); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
289 |
attributeBorderPanel.add(refreshButtonPanel, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
290 |
BorderLayout.SOUTH); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
291 |
refreshButton.setEnabled(true); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
292 |
attributePanel.add(attributeBorderPanel, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
293 |
BorderLayout.NORTH); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
294 |
mbi.addMBeanAttributeInfo(mbai); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
295 |
attributePanel.add(mbi, BorderLayout.CENTER); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
296 |
mainPanel.add(attributePanel, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
297 |
BorderLayout.CENTER); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
298 |
southPanel.setVisible(false); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
299 |
southPanel.removeAll(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
300 |
validate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
301 |
repaint(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
302 |
} catch (Exception e) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
303 |
Throwable t = Utils.getActualException(e); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
304 |
if (JConsole.isDebug()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
305 |
System.err.println("Problem displaying MBean " + |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
306 |
"attribute for MBean [" + |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
307 |
mbean.getObjectName() + "]"); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
308 |
t.printStackTrace(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
309 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
310 |
showErrorDialog(t.toString(), |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
311 |
Messages.PROBLEM_DISPLAYING_MBEAN); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
312 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
313 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
314 |
}; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
315 |
sw.execute(); |
2 | 316 |
break; |
317 |
case OPERATION: |
|
318 |
Object operData = uo.getData(); |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
319 |
mbean = (XMBean) ((Object[]) operData)[0]; |
2 | 320 |
MBeanOperationInfo mboi = |
321 |
(MBeanOperationInfo) ((Object[]) operData)[1]; |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
322 |
mbeanOperations.loadOperations(mbean, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
323 |
new MBeanInfo(null, null, null, null, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
324 |
new MBeanOperationInfo[]{mboi}, null)); |
2 | 325 |
invalidate(); |
326 |
mainPanel.removeAll(); |
|
327 |
JPanel operationPanel = new JPanel(new BorderLayout()); |
|
328 |
JPanel operationBorderPanel = new JPanel(new BorderLayout()); |
|
329 |
operationBorderPanel.setBorder(BorderFactory.createTitledBorder( |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
330 |
Messages.OPERATION_INVOCATION)); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
331 |
operationBorderPanel.add(new JScrollPane(mbeanOperations)); |
2 | 332 |
operationPanel.add(operationBorderPanel, BorderLayout.NORTH); |
333 |
mbi.addMBeanOperationInfo(mboi); |
|
334 |
operationPanel.add(mbi, BorderLayout.CENTER); |
|
335 |
mainPanel.add(operationPanel, BorderLayout.CENTER); |
|
336 |
southPanel.setVisible(false); |
|
337 |
southPanel.removeAll(); |
|
338 |
validate(); |
|
339 |
repaint(); |
|
340 |
break; |
|
341 |
case NOTIFICATION: |
|
342 |
Object notifData = uo.getData(); |
|
343 |
invalidate(); |
|
344 |
mainPanel.removeAll(); |
|
345 |
mbi.addMBeanNotificationInfo((MBeanNotificationInfo) notifData); |
|
346 |
mainPanel.add(mbi, BorderLayout.CENTER); |
|
347 |
southPanel.setVisible(false); |
|
348 |
southPanel.removeAll(); |
|
349 |
validate(); |
|
350 |
repaint(); |
|
351 |
break; |
|
352 |
} |
|
353 |
} |
|
354 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
355 |
// Call on EDT |
2 | 356 |
private void displayMBeanAttributesNode(final DefaultMutableTreeNode node) { |
357 |
final XNodeInfo uo = (XNodeInfo) node.getUserObject(); |
|
358 |
if (!uo.getType().equals(Type.ATTRIBUTES)) { |
|
359 |
return; |
|
360 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
361 |
mbean = (XMBean) uo.getData(); |
1017
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
362 |
final XMBean xmb = mbean; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
363 |
SwingWorker<MBeanInfo,Void> sw = new SwingWorker<MBeanInfo,Void>() { |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
364 |
@Override |
1017
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
365 |
public MBeanInfo doInBackground() throws InstanceNotFoundException, |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
366 |
IntrospectionException, ReflectionException, IOException { |
1017
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
367 |
MBeanInfo mbi = xmb.getMBeanInfo(); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
368 |
return mbi; |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
369 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
370 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
371 |
protected void done() { |
2 | 372 |
try { |
1017
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
373 |
MBeanInfo mbi = get(); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
374 |
if (mbi != null && mbi.getAttributes() != null && |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
375 |
mbi.getAttributes().length > 0) { |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
376 |
|
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
377 |
mbeanAttributes.loadAttributes(xmb, mbi); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
378 |
|
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
379 |
if (!isSelectedNode(node, currentNode)) { |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
380 |
return; |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
381 |
} |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
382 |
invalidate(); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
383 |
mainPanel.removeAll(); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
384 |
JPanel borderPanel = new JPanel(new BorderLayout()); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
385 |
borderPanel.setBorder(BorderFactory.createTitledBorder( |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
386 |
Messages.ATTRIBUTE_VALUES)); |
1017
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
387 |
borderPanel.add(new JScrollPane(mbeanAttributes)); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
388 |
mainPanel.add(borderPanel, BorderLayout.CENTER); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
389 |
// add the refresh button to the south panel |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
390 |
southPanel.removeAll(); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
391 |
southPanel.add(refreshButton, BorderLayout.SOUTH); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
392 |
southPanel.setVisible(true); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
393 |
refreshButton.setEnabled(true); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
394 |
validate(); |
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
395 |
repaint(); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
396 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
397 |
} catch (Exception e) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
398 |
Throwable t = Utils.getActualException(e); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
399 |
if (JConsole.isDebug()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
400 |
System.err.println("Problem displaying MBean " + |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
401 |
"attributes for MBean [" + |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
402 |
mbean.getObjectName() + "]"); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
403 |
t.printStackTrace(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
404 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
405 |
showErrorDialog(t.toString(), |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
406 |
Messages.PROBLEM_DISPLAYING_MBEAN); |
2 | 407 |
} |
408 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
409 |
}; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
410 |
sw.execute(); |
2 | 411 |
} |
412 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
413 |
// Call on EDT |
2 | 414 |
private void displayMBeanOperationsNode(final DefaultMutableTreeNode node) { |
415 |
final XNodeInfo uo = (XNodeInfo) node.getUserObject(); |
|
416 |
if (!uo.getType().equals(Type.OPERATIONS)) { |
|
417 |
return; |
|
418 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
419 |
mbean = (XMBean) uo.getData(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
420 |
SwingWorker<MBeanInfo, Void> sw = new SwingWorker<MBeanInfo, Void>() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
421 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
422 |
public MBeanInfo doInBackground() throws InstanceNotFoundException, |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
423 |
IntrospectionException, ReflectionException, IOException { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
424 |
return mbean.getMBeanInfo(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
425 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
426 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
427 |
protected void done() { |
2 | 428 |
try { |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
429 |
MBeanInfo mbi = get(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
430 |
if (mbi != null) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
431 |
if (!isSelectedNode(node, currentNode)) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
432 |
return; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
433 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
434 |
mbeanOperations.loadOperations(mbean, mbi); |
2 | 435 |
invalidate(); |
436 |
mainPanel.removeAll(); |
|
437 |
JPanel borderPanel = new JPanel(new BorderLayout()); |
|
438 |
borderPanel.setBorder(BorderFactory.createTitledBorder( |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
439 |
Messages.OPERATION_INVOCATION)); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
440 |
borderPanel.add(new JScrollPane(mbeanOperations)); |
2 | 441 |
mainPanel.add(borderPanel, BorderLayout.CENTER); |
442 |
southPanel.setVisible(false); |
|
443 |
southPanel.removeAll(); |
|
444 |
validate(); |
|
445 |
repaint(); |
|
446 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
447 |
} catch (Exception e) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
448 |
Throwable t = Utils.getActualException(e); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
449 |
if (JConsole.isDebug()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
450 |
System.err.println("Problem displaying MBean " + |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
451 |
"operations for MBean [" + |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
452 |
mbean.getObjectName() + "]"); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
453 |
t.printStackTrace(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
454 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
455 |
showErrorDialog(t.toString(), |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
456 |
Messages.PROBLEM_DISPLAYING_MBEAN); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
457 |
} |
2 | 458 |
} |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
459 |
}; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
460 |
sw.execute(); |
2 | 461 |
} |
462 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
463 |
// Call on EDT |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
464 |
private void displayMBeanNotificationsNode(DefaultMutableTreeNode node) { |
2 | 465 |
final XNodeInfo uo = (XNodeInfo) node.getUserObject(); |
466 |
if (!uo.getType().equals(Type.NOTIFICATIONS)) { |
|
467 |
return; |
|
468 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
469 |
mbean = (XMBean) uo.getData(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
470 |
mbeanNotifications.loadNotifications(mbean); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
471 |
updateNotifications(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
472 |
invalidate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
473 |
mainPanel.removeAll(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
474 |
JPanel borderPanel = new JPanel(new BorderLayout()); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
475 |
borderPanel.setBorder(BorderFactory.createTitledBorder( |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
476 |
Messages.NOTIFICATION_BUFFER)); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
477 |
borderPanel.add(new JScrollPane(mbeanNotifications)); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
478 |
mainPanel.add(borderPanel, BorderLayout.CENTER); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
479 |
// add the subscribe/unsubscribe/clear buttons to the south panel |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
480 |
southPanel.removeAll(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
481 |
southPanel.add(subscribeButton, BorderLayout.WEST); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
482 |
southPanel.add(unsubscribeButton, BorderLayout.CENTER); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
483 |
southPanel.add(clearButton, BorderLayout.EAST); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
484 |
southPanel.setVisible(true); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
485 |
subscribeButton.setEnabled(true); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
486 |
unsubscribeButton.setEnabled(true); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
487 |
clearButton.setEnabled(true); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
488 |
validate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
489 |
repaint(); |
2 | 490 |
} |
491 |
||
492 |
// Call on EDT |
|
493 |
private void displayEmptyNode() { |
|
494 |
invalidate(); |
|
495 |
mainPanel.removeAll(); |
|
496 |
southPanel.removeAll(); |
|
497 |
validate(); |
|
498 |
repaint(); |
|
499 |
} |
|
500 |
||
501 |
/** |
|
502 |
* Subscribe button action. |
|
503 |
*/ |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
504 |
private void registerListener() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
505 |
new SwingWorker<Void, Void>() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
506 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
507 |
public Void doInBackground() |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
508 |
throws InstanceNotFoundException, IOException { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
509 |
mbeanNotifications.registerListener(currentNode); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
510 |
return null; |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
511 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
512 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
513 |
protected void done() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
514 |
try { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
515 |
get(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
516 |
updateNotifications(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
517 |
validate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
518 |
} catch (Exception e) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
519 |
Throwable t = Utils.getActualException(e); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
520 |
if (JConsole.isDebug()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
521 |
System.err.println("Problem adding listener"); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
522 |
t.printStackTrace(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
523 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
524 |
showErrorDialog(t.getMessage(), |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
525 |
Messages.PROBLEM_ADDING_LISTENER); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
526 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
527 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
528 |
}.execute(); |
2 | 529 |
} |
530 |
||
531 |
/** |
|
532 |
* Unsubscribe button action. |
|
533 |
*/ |
|
534 |
private void unregisterListener() { |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
535 |
new SwingWorker<Boolean, Void>() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
536 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
537 |
public Boolean doInBackground() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
538 |
return mbeanNotifications.unregisterListener(currentNode); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
539 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
540 |
@Override |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
541 |
protected void done() { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
542 |
try { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
543 |
if (get()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
544 |
updateNotifications(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
545 |
validate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
546 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
547 |
} catch (Exception e) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
548 |
Throwable t = Utils.getActualException(e); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
549 |
if (JConsole.isDebug()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
550 |
System.err.println("Problem removing listener"); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
551 |
t.printStackTrace(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
552 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
553 |
showErrorDialog(t.getMessage(), |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
554 |
Messages.PROBLEM_REMOVING_LISTENER); |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
555 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
556 |
} |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
557 |
}.execute(); |
2 | 558 |
} |
559 |
||
560 |
/** |
|
561 |
* Refresh button action. |
|
562 |
*/ |
|
563 |
private void refreshAttributes() { |
|
564 |
mbeanAttributes.refreshAttributes(); |
|
565 |
} |
|
566 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
567 |
// Call on EDT |
2 | 568 |
private void updateNotifications() { |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
569 |
if (mbeanNotifications.isListenerRegistered(mbean)) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
570 |
long received = mbeanNotifications.getReceivedNotifications(mbean); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
571 |
updateReceivedNotifications(currentNode, received, false); |
2 | 572 |
} else { |
573 |
clearNotifications(); |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
/** |
|
578 |
* Update notification node label in MBean tree: "Notifications[received]". |
|
579 |
*/ |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
580 |
// Call on EDT |
2 | 581 |
private void updateReceivedNotifications( |
582 |
DefaultMutableTreeNode emitter, long received, boolean bold) { |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
583 |
String text = Messages.NOTIFICATIONS + "[" + received + "]"; |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
584 |
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) mbeansTab.getTree().getLastSelectedPathComponent(); |
2 | 585 |
if (bold && emitter != selectedNode) { |
586 |
text = "<html><b>" + text + "</b></html>"; |
|
587 |
} |
|
588 |
updateNotificationsNodeLabel(emitter, text); |
|
589 |
} |
|
590 |
||
591 |
/** |
|
592 |
* Update notification node label in MBean tree: "Notifications". |
|
593 |
*/ |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
594 |
// Call on EDT |
2 | 595 |
private void clearNotifications() { |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
596 |
updateNotificationsNodeLabel(currentNode, |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
597 |
Messages.NOTIFICATIONS); |
2 | 598 |
} |
599 |
||
600 |
/** |
|
601 |
* Update notification node label in MBean tree: "Notifications[0]". |
|
602 |
*/ |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
603 |
// Call on EDT |
2 | 604 |
private void clearNotifications0() { |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
605 |
updateNotificationsNodeLabel(currentNode, |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
606 |
Messages.NOTIFICATIONS + "[0]"); |
2 | 607 |
} |
608 |
||
609 |
/** |
|
610 |
* Update the label of the supplied MBean tree node. |
|
611 |
*/ |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
612 |
// Call on EDT |
2 | 613 |
private void updateNotificationsNodeLabel( |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
614 |
DefaultMutableTreeNode node, String label) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
615 |
synchronized (mbeansTab.getTree()) { |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
616 |
invalidate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
617 |
XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
618 |
XNodeInfo newUserObject = new XNodeInfo( |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
619 |
oldUserObject.getType(), oldUserObject.getData(), |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
620 |
label, oldUserObject.getToolTipText()); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
621 |
node.setUserObject(newUserObject); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
622 |
DefaultTreeModel model = |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
623 |
(DefaultTreeModel) mbeansTab.getTree().getModel(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
624 |
model.nodeChanged(node); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
625 |
validate(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
626 |
repaint(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
627 |
} |
2 | 628 |
} |
629 |
||
630 |
/** |
|
631 |
* Clear button action. |
|
632 |
*/ |
|
633 |
// Call on EDT |
|
634 |
private void clearCurrentNotifications() { |
|
635 |
mbeanNotifications.clearCurrentNotifications(); |
|
636 |
if (mbeanNotifications.isListenerRegistered(mbean)) { |
|
637 |
// Update notifs in MBean tree "Notifications[0]". |
|
638 |
// |
|
639 |
// Notification buffer has been cleared with a listener been |
|
640 |
// registered so add "[0]" at the end of the node label. |
|
641 |
// |
|
642 |
clearNotifications0(); |
|
643 |
} else { |
|
644 |
// Update notifs in MBean tree "Notifications". |
|
645 |
// |
|
646 |
// Notification buffer has been cleared without a listener been |
|
647 |
// registered so don't add "[0]" at the end of the node label. |
|
648 |
// |
|
649 |
clearNotifications(); |
|
650 |
} |
|
651 |
} |
|
652 |
||
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
653 |
// Call on EDT |
2 | 654 |
private void clear() { |
655 |
mbeanAttributes.stopCellEditing(); |
|
656 |
mbeanAttributes.emptyTable(); |
|
657 |
mbeanAttributes.removeAttributes(); |
|
658 |
mbeanOperations.removeOperations(); |
|
659 |
mbeanNotifications.stopCellEditing(); |
|
660 |
mbeanNotifications.emptyTable(); |
|
661 |
mbeanNotifications.disableNotifications(); |
|
662 |
mbean = null; |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
663 |
currentNode = null; |
2 | 664 |
} |
665 |
||
666 |
/** |
|
667 |
* Notification listener: handles asynchronous reception |
|
668 |
* of MBean operation results and MBean notifications. |
|
669 |
*/ |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
670 |
// Call on EDT |
2 | 671 |
public void handleNotification(Notification e, Object handback) { |
672 |
// Operation result |
|
673 |
if (e.getType().equals(XOperations.OPERATION_INVOCATION_EVENT)) { |
|
674 |
final Object message; |
|
675 |
if (handback == null) { |
|
676 |
JTextArea textArea = new JTextArea("null"); |
|
677 |
textArea.setEditable(false); |
|
678 |
textArea.setEnabled(true); |
|
679 |
textArea.setRows(textArea.getLineCount()); |
|
680 |
message = textArea; |
|
681 |
} else { |
|
682 |
Component comp = mbeansTab.getDataViewer(). |
|
683 |
createOperationViewer(handback, mbean); |
|
684 |
if (comp == null) { |
|
685 |
JTextArea textArea = new JTextArea(handback.toString()); |
|
686 |
textArea.setEditable(false); |
|
687 |
textArea.setEnabled(true); |
|
688 |
textArea.setRows(textArea.getLineCount()); |
|
689 |
JScrollPane scrollPane = new JScrollPane(textArea); |
|
690 |
Dimension d = scrollPane.getPreferredSize(); |
|
691 |
if (d.getWidth() > 400 || d.getHeight() > 250) { |
|
692 |
scrollPane.setPreferredSize(new Dimension(400, 250)); |
|
693 |
} |
|
694 |
message = scrollPane; |
|
695 |
} else { |
|
696 |
if (!(comp instanceof JScrollPane)) { |
|
697 |
comp = new JScrollPane(comp); |
|
698 |
} |
|
699 |
Dimension d = comp.getPreferredSize(); |
|
700 |
if (d.getWidth() > 400 || d.getHeight() > 250) { |
|
701 |
comp.setPreferredSize(new Dimension(400, 250)); |
|
702 |
} |
|
703 |
message = comp; |
|
704 |
} |
|
705 |
} |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
706 |
new ThreadDialog( |
2 | 707 |
(Component) e.getSource(), |
708 |
message, |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
709 |
Messages.OPERATION_RETURN_VALUE, |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
710 |
JOptionPane.INFORMATION_MESSAGE).run(); |
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
711 |
} // Got notification |
2 | 712 |
else if (e.getType().equals( |
713 |
XMBeanNotifications.NOTIFICATION_RECEIVED_EVENT)) { |
|
714 |
DefaultMutableTreeNode emitter = (DefaultMutableTreeNode) handback; |
|
715 |
Long received = (Long) e.getUserData(); |
|
716 |
updateReceivedNotifications(emitter, received.longValue(), true); |
|
717 |
} |
|
718 |
} |
|
719 |
||
720 |
/** |
|
721 |
* Action listener: handles actions in panel buttons |
|
722 |
*/ |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
723 |
// Call on EDT |
2 | 724 |
public void actionPerformed(ActionEvent e) { |
725 |
if (e.getSource() instanceof JButton) { |
|
726 |
JButton button = (JButton) e.getSource(); |
|
727 |
// Refresh button |
|
728 |
if (button == refreshButton) { |
|
1017
8d24d37ceed8
6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents:
715
diff
changeset
|
729 |
refreshAttributes(); |
2 | 730 |
return; |
731 |
} |
|
732 |
// Clear button |
|
733 |
if (button == clearButton) { |
|
734 |
clearCurrentNotifications(); |
|
735 |
return; |
|
736 |
} |
|
737 |
// Subscribe button |
|
738 |
if (button == subscribeButton) { |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
739 |
registerListener(); |
2 | 740 |
return; |
741 |
} |
|
742 |
// Unsubscribe button |
|
743 |
if (button == unsubscribeButton) { |
|
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
744 |
unregisterListener(); |
2 | 745 |
return; |
746 |
} |
|
747 |
} |
|
748 |
} |
|
749 |
} |