src/share/classes/sun/tools/jconsole/VMPanel.java
Print this page
*** 26,47 ****
package sun.tools.jconsole;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
- import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.List;
import java.util.Timer;
-
import javax.swing.*;
import javax.swing.plaf.*;
import com.sun.tools.jconsole.JConsolePlugin;
import com.sun.tools.jconsole.JConsoleContext;
- import static com.sun.tools.jconsole.JConsoleContext.ConnectionState.*;
import static sun.tools.jconsole.ProxyClient.*;
@SuppressWarnings("serial")
public class VMPanel extends JTabbedPane implements PropertyChangeListener {
--- 26,46 ----
package sun.tools.jconsole;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.List;
import java.util.Timer;
import javax.swing.*;
import javax.swing.plaf.*;
+ import sun.tools.jconsole.resources.Messages;
+
import com.sun.tools.jconsole.JConsolePlugin;
import com.sun.tools.jconsole.JConsoleContext;
import static sun.tools.jconsole.ProxyClient.*;
@SuppressWarnings("serial")
public class VMPanel extends JTabbedPane implements PropertyChangeListener {
*** 49,65 ****
private ProxyClient proxyClient;
private Timer timer;
private int updateInterval;
private String hostName;
private int port;
- private int vmid;
private String userName;
private String password;
private String url;
private VMInternalFrame vmIF = null;
- private static final String windowsLaF =
- "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
private static ArrayList<TabInfo> tabInfos = new ArrayList<TabInfo>();
private boolean wasConnected = false;
// The everConnected flag keeps track of whether the window can be
// closed if the user clicks Cancel after a failed connection attempt.
--- 48,61 ----
*** 98,108 ****
VMPanel(ProxyClient proxyClient, int updateInterval) {
this.proxyClient = proxyClient;
this.updateInterval = updateInterval;
this.hostName = proxyClient.getHostName();
this.port = proxyClient.getPort();
- this.vmid = proxyClient.getVmid();
this.userName = proxyClient.getUserName();
this.password = proxyClient.getPassword();
this.url = proxyClient.getUrl();
for (TabInfo tabInfo : tabInfos) {
--- 94,103 ----
*** 184,196 ****
}
public String getToolTipText(MouseEvent event) {
if (connectedIconBounds.contains(event.getPoint())) {
if (isConnected()) {
! return getText("Connected. Click to disconnect.");
} else {
! return getText("Disconnected. Click to connect.");
}
} else {
return super.getToolTipText(event);
}
}
--- 179,191 ----
}
public String getToolTipText(MouseEvent event) {
if (connectedIconBounds.contains(event.getPoint())) {
if (isConnected()) {
! return Messages.CONNECTED_PUNCTUATION_CLICK_TO_DISCONNECT_;
} else {
! return Messages.DISCONNECTED_PUNCTUATION_CLICK_TO_CONNECT_;
}
} else {
return super.getToolTipText(event);
}
}
*** 217,227 ****
super.removeTabAt(index);
}
private Tab instantiate(TabInfo tabInfo) {
try {
! Constructor con = tabInfo.tabClass.getConstructor(VMPanel.class);
return (Tab) con.newInstance(this);
} catch (Exception ex) {
System.err.println(ex);
return null;
}
--- 212,222 ----
super.removeTabAt(index);
}
private Tab instantiate(TabInfo tabInfo) {
try {
! Constructor<?> con = tabInfo.tabClass.getConstructor(VMPanel.class);
return (Tab) con.newInstance(this);
} catch (Exception ex) {
System.err.println(ex);
return null;
}
*** 352,381 ****
// Called on EDT
private void onConnecting() {
time0 = System.currentTimeMillis();
! final JConsole jc = (JConsole) SwingUtilities.getWindowAncestor(this);
String connectionName = getConnectionName();
progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
progressPanel.add(progressBar);
Object[] message = {
! "<html><h3>" + getText("connectingTo1", connectionName) + "</h3></html>",
progressPanel,
! "<html><b>" + getText("connectingTo2", connectionName) + "</b></html>"
};
optionPane =
SheetDialog.showOptionDialog(this,
message,
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null,
! new String[]{getText("Cancel")},
0);
}
--- 347,376 ----
// Called on EDT
private void onConnecting() {
time0 = System.currentTimeMillis();
! SwingUtilities.getWindowAncestor(this);
String connectionName = getConnectionName();
progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
progressPanel.add(progressBar);
Object[] message = {
! "<html><h3>" + Resources.format(Messages.CONNECTING_TO1, connectionName) + "</h3></html>",
progressPanel,
! "<html><b>" + Resources.format(Messages.CONNECTING_TO2, connectionName) + "</b></html>"
};
optionPane =
SheetDialog.showOptionDialog(this,
message,
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null,
! new String[]{Messages.CANCEL},
0);
}
*** 407,417 ****
void updateFrameTitle() {
VMInternalFrame vmIF = getFrame();
if (vmIF != null) {
String displayName = getDisplayName();
if (!proxyClient.isConnected()) {
! displayName = getText("ConnectionName (disconnected)", displayName);
}
vmIF.setTitle(displayName);
}
}
--- 402,412 ----
void updateFrameTitle() {
VMInternalFrame vmIF = getFrame();
if (vmIF != null) {
String displayName = getDisplayName();
if (!proxyClient.isConnected()) {
! displayName = Resources.format(Messages.CONNECTION_NAME__DISCONNECTED_, displayName);
}
vmIF.setTitle(displayName);
}
}
*** 456,502 ****
// Call on EDT
private void vmPanelDied() {
disconnect();
- final JConsole jc = (JConsole) SwingUtilities.getWindowAncestor(this);
-
JOptionPane optionPane;
-
- final String connectStr = getText("Connect");
- final String reconnectStr = getText("Reconnect");
- final String cancelStr = getText("Cancel");
-
String msgTitle, msgExplanation, buttonStr;
if (wasConnected) {
wasConnected = false;
! msgTitle = getText("connectionLost1");
! msgExplanation = getText("connectionLost2", getConnectionName());
! buttonStr = reconnectStr;
} else {
! msgTitle = getText("connectionFailed1");
! msgExplanation = getText("connectionFailed2", getConnectionName());
! buttonStr = connectStr;
}
optionPane =
SheetDialog.showOptionDialog(this,
"<html><h3>" + msgTitle + "</h3>" +
"<b>" + msgExplanation + "</b>",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE, null,
! new String[]{buttonStr, cancelStr},
0);
optionPane.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
Object value = event.getNewValue();
! if (value == reconnectStr || value == connectStr) {
connect();
} else if (!everConnected) {
try {
getFrame().setClosed(true);
} catch (PropertyVetoException ex) {
--- 451,490 ----
// Call on EDT
private void vmPanelDied() {
disconnect();
JOptionPane optionPane;
String msgTitle, msgExplanation, buttonStr;
if (wasConnected) {
wasConnected = false;
! msgTitle = Messages.CONNECTION_LOST1;
! msgExplanation = Resources.format(Messages.CONNECTING_TO2, getConnectionName());
! buttonStr = Messages.RECONNECT;
} else {
! msgTitle =Messages.CONNECTION_FAILED1;
! msgExplanation = Resources.format(Messages.CONNECTION_FAILED2, getConnectionName());
! buttonStr = Messages.CONNECT;
}
optionPane =
SheetDialog.showOptionDialog(this,
"<html><h3>" + msgTitle + "</h3>" +
"<b>" + msgExplanation + "</b>",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE, null,
! new String[]{buttonStr, Messages.CANCEL},
0);
optionPane.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
Object value = event.getNewValue();
! if (value == Messages.RECONNECT || value == Messages.CONNECT) {
connect();
} else if (!everConnected) {
try {
getFrame().setClosed(true);
} catch (PropertyVetoException ex) {
*** 641,655 ****
this.name = name;
this.tabVisible = tabVisible;
}
}
- // Convenience methods
- private static String getText(String key, Object... args) {
- return Resources.getText(key, args);
- }
-
private void createPluginTabs() {
// add plugin tabs if not done
if (!pluginTabsAdded) {
for (JConsolePlugin p : plugins.keySet()) {
Map<String, JPanel> tabs = p.getTabs();
--- 629,638 ----