src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XSheet.java
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--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1017
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1017
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1017
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1017
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1017
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.tools.jconsole.inspector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import sun.tools.jconsole.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import sun.tools.jconsole.inspector.XNodeInfo.Type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
@SuppressWarnings("serial")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
public class XSheet extends JPanel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        implements ActionListener, NotificationListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private JPanel mainPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private JPanel southPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // XMBeanAttributes container
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private XMBeanAttributes mbeanAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // XMBeanOperations container
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private XMBeanOperations mbeanOperations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    // XMBeanNotifications container
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private XMBeanNotifications mbeanNotifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // XMBeanInfo container
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private XMBeanInfo mbeanInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // Refresh JButton (mbean attributes case)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private JButton refreshButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    // Reference to MBeans tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private MBeansTab mbeansTab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public XSheet(MBeansTab mbeansTab) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        this.mbeansTab = mbeansTab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        setupScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        XDataViewer.dispose(mbeansTab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        mbeanNotifications.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private void setupScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        // add main panel to XSheet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        mainPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        mainPanel.setLayout(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        add(mainPanel, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        // add south panel to XSheet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        southPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        add(southPanel, BorderLayout.SOUTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        refreshButton.addActionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        clearButton.addActionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        subscribeButton.addActionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        unsubscribeButton.addActionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        // create XMBeanAttributes container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        mbeanAttributes = new XMBeanAttributes(mbeansTab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        // create XMBeanOperations container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        mbeanOperations = new XMBeanOperations(mbeansTab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        mbeanOperations.addOperationsListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        // create XMBeanNotifications container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        mbeanNotifications = new XMBeanNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        mbeanNotifications.addNotificationsListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        // create XMBeanInfo container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        mbeanInfo = new XMBeanInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        clear();
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   159
        displayEmptyNode();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (node == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   163
        currentNode = node;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        Object userObject = node.getUserObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (userObject instanceof XNodeInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            XNodeInfo uo = (XNodeInfo) userObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            switch (uo.getType()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                case MBEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    displayMBeanNode(node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                case NONMBEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                    displayEmptyNode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                case ATTRIBUTES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    displayMBeanAttributesNode(node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                case OPERATIONS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    displayMBeanOperationsNode(node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                case NOTIFICATIONS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                    displayMBeanNotificationsNode(node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                case ATTRIBUTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                case OPERATION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                case NOTIFICATION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    displayMetadataNode(node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    displayEmptyNode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            displayEmptyNode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    private void displayMBeanNode(final DefaultMutableTreeNode node) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        final XNodeInfo uo = (XNodeInfo) node.getUserObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        if (!uo.getType().equals(Type.MBEAN)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                        mainPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                        mainPanel.add(mbeanInfo, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                        southPanel.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                        southPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                        validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    // Call on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    private void displayMetadataNode(final DefaultMutableTreeNode node) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        final XNodeInfo uo = (XNodeInfo) node.getUserObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        final XMBeanInfo mbi = mbeanInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        switch (uo.getType()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            case OPERATION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                MBeanOperationInfo mboi =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                mainPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                JPanel operationPanel = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                JPanel operationBorderPanel = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                operationPanel.add(operationBorderPanel, BorderLayout.NORTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                mbi.addMBeanOperationInfo(mboi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                operationPanel.add(mbi, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                mainPanel.add(operationPanel, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                southPanel.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                southPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            case NOTIFICATION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                Object notifData = uo.getData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                mainPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                mbi.addMBeanNotificationInfo((MBeanNotificationInfo) notifData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                mainPanel.add(mbi, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                southPanel.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                southPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    private void displayMBeanAttributesNode(final DefaultMutableTreeNode node) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        final XNodeInfo uo = (XNodeInfo) node.getUserObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        if (!uo.getType().equals(Type.ATTRIBUTES)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    private void displayMBeanOperationsNode(final DefaultMutableTreeNode node) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        final XNodeInfo uo = (XNodeInfo) node.getUserObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        if (!uo.getType().equals(Type.OPERATIONS)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                        mainPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                        JPanel borderPanel = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                        mainPanel.add(borderPanel, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                        southPanel.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                        southPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        final XNodeInfo uo = (XNodeInfo) node.getUserObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        if (!uo.getType().equals(Type.NOTIFICATIONS)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    // Call on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    private void displayEmptyNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        mainPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        southPanel.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * Subscribe button action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * Unsubscribe button action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * Refresh button action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    private void refreshAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        mbeanAttributes.refreshAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            clearNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * Update notification node label in MBean tree: "Notifications[received]".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    private void updateReceivedNotifications(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        if (bold && emitter != selectedNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            text = "<html><b>" + text + "</b></html>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        updateNotificationsNodeLabel(emitter, text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * Update notification node label in MBean tree: "Notifications".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * Update notification node label in MBean tree: "Notifications[0]".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * Update the label of the supplied MBean tree node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * Clear button action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    // Call on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    private void clearCurrentNotifications() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        mbeanNotifications.clearCurrentNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        if (mbeanNotifications.isListenerRegistered(mbean)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            // Update notifs in MBean tree "Notifications[0]".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            // Notification buffer has been cleared with a listener been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            // registered so add "[0]" at the end of the node label.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            clearNotifications0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            // Update notifs in MBean tree "Notifications".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            // Notification buffer has been cleared without a listener been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            // registered so don't add "[0]" at the end of the node label.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            clearNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    private void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        mbeanAttributes.stopCellEditing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        mbeanAttributes.emptyTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        mbeanAttributes.removeAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        mbeanOperations.removeOperations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        mbeanNotifications.stopCellEditing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        mbeanNotifications.emptyTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        mbeanNotifications.disableNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * Notification listener: handles asynchronous reception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * of MBean operation results and MBean notifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public void handleNotification(Notification e, Object handback) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        // Operation result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        if (e.getType().equals(XOperations.OPERATION_INVOCATION_EVENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            final Object message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            if (handback == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                JTextArea textArea = new JTextArea("null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                textArea.setEditable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                textArea.setEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                textArea.setRows(textArea.getLineCount());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                message = textArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                Component comp = mbeansTab.getDataViewer().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                        createOperationViewer(handback, mbean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                if (comp == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                    JTextArea textArea = new JTextArea(handback.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                    textArea.setEditable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                    textArea.setEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                    textArea.setRows(textArea.getLineCount());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                    JScrollPane scrollPane = new JScrollPane(textArea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                    Dimension d = scrollPane.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                    if (d.getWidth() > 400 || d.getHeight() > 250) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                        scrollPane.setPreferredSize(new Dimension(400, 250));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                    message = scrollPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                    if (!(comp instanceof JScrollPane)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                        comp = new JScrollPane(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                    Dimension d = comp.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                    if (d.getWidth() > 400 || d.getHeight() > 250) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                        comp.setPreferredSize(new Dimension(400, 250));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                    message = comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            }
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   706
            new ThreadDialog(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                    (Component) e.getSource(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        else if (e.getType().equals(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                XMBeanNotifications.NOTIFICATION_RECEIVED_EVENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            DefaultMutableTreeNode emitter = (DefaultMutableTreeNode) handback;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            Long received = (Long) e.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            updateReceivedNotifications(emitter, received.longValue(), true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * Action listener: handles actions in panel buttons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        if (e.getSource() instanceof JButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            JButton button = (JButton) e.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            // Refresh button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            if (button == refreshButton) {
1017
8d24d37ceed8 6733294: MBeans tab - UI issues with writable attributes
dfuchs
parents: 715
diff changeset
   729
                refreshAttributes();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            // Clear button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            if (button == clearButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                clearCurrentNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            // Subscribe button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            // Unsubscribe button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
}