src/jdk.jconsole/share/classes/sun/tools/jconsole/VMPanel.java
author mgronlun
Wed, 23 May 2018 15:21:54 +0200
changeset 50234 6ba3e32a9882
parent 47216 71c04702a3d5
permissions -rw-r--r--
8203457: Add back missing full buffer notification Reviewed-by: redestad, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
19432
ce3b6c1ab8a6 6696970: Jconsole becomes unusable if a plugin throws an exception
egahlin
parents: 18253
diff changeset
     2
 * Copyright (c) 2004, 2013, 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: 715
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: 715
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: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.reflect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Timer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
    38
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.jconsole.JConsolePlugin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import com.sun.tools.jconsole.JConsoleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import static sun.tools.jconsole.ProxyClient.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
@SuppressWarnings("serial")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class VMPanel extends JTabbedPane implements PropertyChangeListener {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    46
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private ProxyClient proxyClient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private Timer timer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private int updateInterval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private String hostName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private int port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private String userName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private String password;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private String url;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private VMInternalFrame vmIF = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static ArrayList<TabInfo> tabInfos = new ArrayList<TabInfo>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private boolean wasConnected = false;
17719
ba3677303a76 6470730: Disconnect button leads to wrong popup message
nloodin
parents: 14342
diff changeset
    58
    private boolean userDisconnected = false;
18197
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
    59
    private boolean shouldUseSSL = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // The everConnected flag keeps track of whether the window can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    // closed if the user clicks Cancel after a failed connection attempt.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private boolean everConnected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    // The initialUpdate flag is used to enable/disable tabs each time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // a connect or reconnect takes place. This flag avoids having to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // enable/disable tabs on each update call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private boolean initialUpdate = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // Each VMPanel has its own instance of the JConsolePlugin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // A map of JConsolePlugin to the previous SwingWorker
19432
ce3b6c1ab8a6 6696970: Jconsole becomes unusable if a plugin throws an exception
egahlin
parents: 18253
diff changeset
    74
    private Map<ExceptionSafePlugin, SwingWorker<?, ?>> plugins = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private boolean pluginTabsAdded = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    // Update these only on the EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private JOptionPane optionPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private JProgressBar progressBar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private long time0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        tabInfos.add(new TabInfo(OverviewTab.class, OverviewTab.getTabName(), true));
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    84
        tabInfos.add(new TabInfo(MemoryTab.class, MemoryTab.getTabName(), true));
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    85
        tabInfos.add(new TabInfo(ThreadTab.class, ThreadTab.getTabName(), true));
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    86
        tabInfos.add(new TabInfo(ClassTab.class, ClassTab.getTabName(), true));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        tabInfos.add(new TabInfo(SummaryTab.class, SummaryTab.getTabName(), true));
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    88
        tabInfos.add(new TabInfo(MBeansTab.class, MBeansTab.getTabName(), true));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public static TabInfo[] getTabInfos() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        return tabInfos.toArray(new TabInfo[tabInfos.size()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    VMPanel(ProxyClient proxyClient, int updateInterval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        this.proxyClient = proxyClient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this.updateInterval = updateInterval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this.hostName = proxyClient.getHostName();
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    99
        this.port = proxyClient.getPort();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this.userName = proxyClient.getUserName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        this.password = proxyClient.getPassword();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this.url = proxyClient.getUrl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        for (TabInfo tabInfo : tabInfos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            if (tabInfo.tabVisible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                addTab(tabInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
19432
ce3b6c1ab8a6 6696970: Jconsole becomes unusable if a plugin throws an exception
egahlin
parents: 18253
diff changeset
   110
        plugins = new LinkedHashMap<ExceptionSafePlugin, SwingWorker<?, ?>>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        for (JConsolePlugin p : JConsole.getPlugins()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            p.setContext(proxyClient);
19432
ce3b6c1ab8a6 6696970: Jconsole becomes unusable if a plugin throws an exception
egahlin
parents: 18253
diff changeset
   113
            plugins.put(new ExceptionSafePlugin(p), null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        Utilities.updateTransparency(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        ToolTipManager.sharedInstance().registerComponent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        // Start listening to connection state events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        proxyClient.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        addMouseListener(new MouseAdapter() {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   125
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            public void mouseClicked(MouseEvent e) {
43722
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 25859
diff changeset
   127
                if (connectedIconBounds != null
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 25859
diff changeset
   128
                        && (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 25859
diff changeset
   129
                        && connectedIconBounds.contains(e.getPoint())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    if (isConnected()) {
17719
ba3677303a76 6470730: Disconnect button leads to wrong popup message
nloodin
parents: 14342
diff changeset
   132
                        userDisconnected = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                        disconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                        wasConnected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                        connect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                    repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private static Icon connectedIcon16 =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   145
            new ImageIcon(VMPanel.class.getResource("resources/connected16.png"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    private static Icon connectedIcon24 =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   147
            new ImageIcon(VMPanel.class.getResource("resources/connected24.png"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    private static Icon disconnectedIcon16 =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   149
            new ImageIcon(VMPanel.class.getResource("resources/disconnected16.png"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private static Icon disconnectedIcon24 =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   151
            new ImageIcon(VMPanel.class.getResource("resources/disconnected24.png"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    private Rectangle connectedIconBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    // Override to increase right inset for tab area,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    // in order to reserve space for the connect toggle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public void setUI(TabbedPaneUI ui) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   157
        Insets insets = (Insets) UIManager.getLookAndFeelDefaults().get("TabbedPane.tabAreaInsets");
19568
873477c7e278 6800801: NPE in JConsole when using Nimbus L&F
egahlin
parents: 19432
diff changeset
   158
        if (insets != null) {
873477c7e278 6800801: NPE in JConsole when using Nimbus L&F
egahlin
parents: 19432
diff changeset
   159
            insets = (Insets) insets.clone();
873477c7e278 6800801: NPE in JConsole when using Nimbus L&F
egahlin
parents: 19432
diff changeset
   160
            insets.right += connectedIcon24.getIconWidth() + 8;
873477c7e278 6800801: NPE in JConsole when using Nimbus L&F
egahlin
parents: 19432
diff changeset
   161
            UIManager.put("TabbedPane.tabAreaInsets", insets);
873477c7e278 6800801: NPE in JConsole when using Nimbus L&F
egahlin
parents: 19432
diff changeset
   162
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    // Override to paint the connect toggle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    protected void paintComponent(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        super.paintComponent(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        Icon icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        Component c0 = getComponent(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (c0 != null && c0.getY() > 24) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            icon = isConnected() ? connectedIcon24 : disconnectedIcon24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            icon = isConnected() ? connectedIcon16 : disconnectedIcon16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        Insets insets = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        int x = getWidth() - insets.right - icon.getIconWidth() - 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        int y = insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (c0 != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            y = (c0.getY() - icon.getIconHeight()) / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        icon.paintIcon(this, g, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        connectedIconBounds = new Rectangle(x, y, icon.getIconWidth(), icon.getIconHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    public String getToolTipText(MouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        if (connectedIconBounds.contains(event.getPoint())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            if (isConnected()) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   190
                return Messages.CONNECTED_PUNCTUATION_CLICK_TO_DISCONNECT_;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            } else {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   192
                return Messages.DISCONNECTED_PUNCTUATION_CLICK_TO_CONNECT_;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            return super.getToolTipText(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    private synchronized void addTab(TabInfo tabInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        Tab tab = instantiate(tabInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        if (tab != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            addTab(tabInfo.name, tab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            tabInfo.tabVisible = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    private synchronized void insertTab(TabInfo tabInfo, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        Tab tab = instantiate(tabInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        if (tab != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            insertTab(tabInfo.name, null, tab, null, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            tabInfo.tabVisible = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public synchronized void removeTabAt(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        super.removeTabAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    private Tab instantiate(TabInfo tabInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        try {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   223
            Constructor<?> con = tabInfo.tabClass.getConstructor(VMPanel.class);
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   224
            return (Tab) con.newInstance(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        } catch (Exception ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            System.err.println(ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    boolean isConnected() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return proxyClient.isConnected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    public int getUpdateInterval() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        return updateInterval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * WARNING NEVER CALL THIS METHOD TO MAKE JMX REQUEST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * IF  assertThread == false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * DISPATCHER THREAD IS NOT ASSERTED.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * IT IS USED TO MAKE SOME LOCAL MANIPULATIONS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    ProxyClient getProxyClient(boolean assertThread) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   246
        if (assertThread) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return getProxyClient();
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   248
        } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            return proxyClient;
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   250
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public ProxyClient getProxyClient() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        String threadClass = Thread.currentThread().getClass().getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        if (threadClass.equals("java.awt.EventDispatchThread")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            String msg = "Calling VMPanel.getProxyClient() from the Event Dispatch Thread!";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            new RuntimeException(msg).printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return proxyClient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public void cleanUp() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        //proxyClient.disconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        for (Tab tab : getTabs()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            tab.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        for (JConsolePlugin p : plugins.keySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            p.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        // Cancel pending update tasks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        if (timer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            timer.cancel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        // Stop listening to connection state events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        proxyClient.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    // Call on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    public void connect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (isConnected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            // create plugin tabs if not done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            createPluginTabs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            // Notify tabs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            fireConnectedChange(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            // Enable/disable tabs on initial update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            initialUpdate = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            // Start/Restart update timer on connect/reconnect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            startUpdateTimer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            new Thread("VMPanel.connect") {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   294
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                public void run() {
18197
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   296
                    proxyClient.connect(shouldUseSSL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            }.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    // Call on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public void disconnect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        proxyClient.disconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        updateFrameTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    // Called on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    public void propertyChange(PropertyChangeEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        String prop = ev.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        if (prop == CONNECTION_STATE_PROPERTY) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   313
            ConnectionState oldState = (ConnectionState) ev.getOldValue();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   314
            ConnectionState newState = (ConnectionState) ev.getNewValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            switch (newState) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   316
                case CONNECTING:
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   317
                    onConnecting();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   318
                    break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   320
                case CONNECTED:
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   321
                    if (progressBar != null) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   322
                        progressBar.setIndeterminate(false);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   323
                        progressBar.setValue(100);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   324
                    }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   325
                    closeOptionPane();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   326
                    updateFrameTitle();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   327
                    // create tabs if not done
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   328
                    createPluginTabs();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   329
                    repaint();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   330
                    // Notify tabs
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   331
                    fireConnectedChange(true);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   332
                    // Enable/disable tabs on initial update
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   333
                    initialUpdate = true;
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   334
                    // Start/Restart update timer on connect/reconnect
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   335
                    startUpdateTimer();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   336
                    break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   338
                case DISCONNECTED:
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   339
                    if (progressBar != null) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   340
                        progressBar.setIndeterminate(false);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   341
                        progressBar.setValue(0);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   342
                        closeOptionPane();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   343
                    }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   344
                    vmPanelDied();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   345
                    if (oldState == ConnectionState.CONNECTED) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   346
                        // Notify tabs
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   347
                        fireConnectedChange(false);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   348
                    }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   349
                    break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    // Called on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    private void onConnecting() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        time0 = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   358
        SwingUtilities.getWindowAncestor(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        String connectionName = getConnectionName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        progressBar = new JProgressBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        progressBar.setIndeterminate(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        progressPanel.add(progressBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        Object[] message = {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   367
            "<html><h3>" + Resources.format(Messages.CONNECTING_TO1, connectionName) + "</h3></html>",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            progressPanel,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   369
            "<html><b>" + Resources.format(Messages.CONNECTING_TO2, connectionName) + "</b></html>"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        optionPane =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   373
                SheetDialog.showOptionDialog(this,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   374
                message,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   375
                JOptionPane.DEFAULT_OPTION,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   376
                JOptionPane.INFORMATION_MESSAGE, null,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   377
                new String[]{Messages.CANCEL},
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   378
                0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    // Called on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    private void closeOptionPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (optionPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            new Thread("VMPanel.sleeper") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    long elapsed = System.currentTimeMillis() - time0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                    if (elapsed < 2000) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                            sleep(2000 - elapsed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                        } catch (InterruptedException ex) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   393
                        // Ignore
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                    SwingUtilities.invokeLater(new Runnable() {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   397
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                            optionPane.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                            progressBar = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            }.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    void updateFrameTitle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        VMInternalFrame vmIF = getFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        if (vmIF != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            String displayName = getDisplayName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            if (!proxyClient.isConnected()) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   413
                displayName = Resources.format(Messages.CONNECTION_NAME__DISCONNECTED_, displayName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            vmIF.setTitle(displayName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    private VMInternalFrame getFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        if (vmIF == null) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   421
            vmIF = (VMInternalFrame) SwingUtilities.getAncestorOfClass(VMInternalFrame.class,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   422
                    this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        return vmIF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    // TODO: this method is not needed when all JConsole tabs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    // are migrated to use the new JConsolePlugin API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    // A thread safe clone of all JConsole tabs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    synchronized List<Tab> getTabs() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        ArrayList<Tab> list = new ArrayList<Tab>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        int n = getTabCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            Component c = getComponentAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            if (c instanceof Tab) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                list.add((Tab) c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        return list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    private void startUpdateTimer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        if (timer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            timer.cancel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        TimerTask timerTask = new TimerTask() {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   448
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                update();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        };
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   453
        String timerName = "Timer-" + getConnectionName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        timer = new Timer(timerName, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        timer.schedule(timerTask, 0, updateInterval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    // Call on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    private void vmPanelDied() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        disconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
17719
ba3677303a76 6470730: Disconnect button leads to wrong popup message
nloodin
parents: 14342
diff changeset
   462
        if (userDisconnected) {
ba3677303a76 6470730: Disconnect button leads to wrong popup message
nloodin
parents: 14342
diff changeset
   463
            userDisconnected = false;
ba3677303a76 6470730: Disconnect button leads to wrong popup message
nloodin
parents: 14342
diff changeset
   464
            return;
ba3677303a76 6470730: Disconnect button leads to wrong popup message
nloodin
parents: 14342
diff changeset
   465
        }
ba3677303a76 6470730: Disconnect button leads to wrong popup message
nloodin
parents: 14342
diff changeset
   466
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        JOptionPane optionPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        String msgTitle, msgExplanation, buttonStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        if (wasConnected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            wasConnected = false;
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   472
            msgTitle = Messages.CONNECTION_LOST1;
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   473
            msgExplanation = Resources.format(Messages.CONNECTING_TO2, getConnectionName());
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   474
            buttonStr = Messages.RECONNECT;
18197
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   475
        } else if (shouldUseSSL) {
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   476
            msgTitle = Messages.CONNECTION_FAILED_SSL1;
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   477
            msgExplanation = Resources.format(Messages.CONNECTION_FAILED_SSL2, getConnectionName());
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   478
            buttonStr = Messages.INSECURE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        } else {
18197
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   480
            msgTitle = Messages.CONNECTION_FAILED1;
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   481
            msgExplanation = Resources.format(Messages.CONNECTION_FAILED2, getConnectionName());
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   482
            buttonStr = Messages.CONNECT;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        optionPane =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   486
                SheetDialog.showOptionDialog(this,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   487
                "<html><h3>" + msgTitle + "</h3>" +
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   488
                "<b>" + msgExplanation + "</b>",
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   489
                JOptionPane.DEFAULT_OPTION,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   490
                JOptionPane.WARNING_MESSAGE, null,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   491
                new String[]{buttonStr, Messages.CANCEL},
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   492
                0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        optionPane.addPropertyChangeListener(new PropertyChangeListener() {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   495
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            public void propertyChange(PropertyChangeEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                    Object value = event.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   500
                    if (value == Messages.RECONNECT || value == Messages.CONNECT) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                        connect();
18197
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   502
                    } else if (value == Messages.INSECURE) {
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   503
                        shouldUseSSL = false;
ae73e4f50e08 8003703: Update RMI connection dialog box
sla
parents: 14342
diff changeset
   504
                        connect();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                    } else if (!everConnected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                            getFrame().setClosed(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                        } catch (PropertyVetoException ex) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   509
                        // Should not happen, but can be ignored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    // Note: This method is called on a TimerTask thread. Any GUI manipulation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    // must be performed with invokeLater() or invokeAndWait().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    private Object lockObject = new Object();
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   520
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    private void update() {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   522
        synchronized (lockObject) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            if (!isConnected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                if (wasConnected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                    EventQueue.invokeLater(new Runnable() {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   526
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                            vmPanelDied();
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
                wasConnected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                wasConnected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                everConnected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            proxyClient.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            List<Tab> tabs = getTabs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            final int n = tabs.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                final int index = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                    if (!proxyClient.isDead()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                        // Update tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                        tabs.get(index).update();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                        // Enable tab on initial update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                        if (initialUpdate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                            EventQueue.invokeLater(new Runnable() {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   552
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                                    setEnabledAt(index, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                    // Disable tab on initial update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                    if (initialUpdate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                        EventQueue.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                                setEnabledAt(index, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            // plugin GUI update
19432
ce3b6c1ab8a6 6696970: Jconsole becomes unusable if a plugin throws an exception
egahlin
parents: 18253
diff changeset
   573
            for (ExceptionSafePlugin p : plugins.keySet()) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   574
                SwingWorker<?, ?> sw = p.newSwingWorker();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   575
                SwingWorker<?, ?> prevSW = plugins.get(p);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                // schedule SwingWorker to run only if the previous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                // SwingWorker has finished its task and it hasn't started.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                if (prevSW == null || prevSW.isDone()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                    if (sw == null || sw.getState() == SwingWorker.StateValue.PENDING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                        plugins.put(p, sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                        if (sw != null) {
19432
ce3b6c1ab8a6 6696970: Jconsole becomes unusable if a plugin throws an exception
egahlin
parents: 18253
diff changeset
   582
                            p.executeSwingWorker(sw);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   588
            // Set the first enabled tab in the tab's list
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            // as the selected tab on initial update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            if (initialUpdate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                EventQueue.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                        // Select first enabled tab if current tab isn't.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                        int index = getSelectedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                        if (index < 0 || !isEnabledAt(index)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                            for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                                if (isEnabledAt(i)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                                    setSelectedIndex(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                initialUpdate = false;
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    public String getHostName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        return hostName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    public int getPort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        return port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    public String getUserName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        return userName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    public String getUrl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        return url;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    public String getPassword() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        return password;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    public String getConnectionName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        return proxyClient.connectionName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    public String getDisplayName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        return proxyClient.getDisplayName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    static class TabInfo {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   640
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        Class<? extends Tab> tabClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        boolean tabVisible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        TabInfo(Class<? extends Tab> tabClass, String name, boolean tabVisible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            this.tabClass = tabClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            this.tabVisible = tabVisible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    private void createPluginTabs() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        // add plugin tabs if not done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        if (!pluginTabsAdded) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            for (JConsolePlugin p : plugins.keySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                Map<String, JPanel> tabs = p.getTabs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                for (Map.Entry<String, JPanel> e : tabs.entrySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                    addTab(e.getKey(), e.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            pluginTabsAdded = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    private void fireConnectedChange(boolean connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        for (Tab tab : getTabs()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            tab.firePropertyChange(JConsoleContext.CONNECTION_STATE_PROPERTY, !connected, connected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
}