< prev index next >
src/share/classes/sun/tools/jconsole/VMPanel.java
Print this page
rev 1501 : 7017818: NLS: JConsoleResources.java cannot be handled by translation team
Reviewed-by: mchung, mfang
rev 1505 : 8030878: JConsole issues meaningless message if SSL connection fails
Reviewed-by: mchung, sla
@@ -26,33 +26,30 @@
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 {
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;
@@ -101,11 +98,10 @@
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) {
@@ -190,13 +186,13 @@
}
public String getToolTipText(MouseEvent event) {
if (connectedIconBounds.contains(event.getPoint())) {
if (isConnected()) {
- return getText("Connected. Click to disconnect.");
+ return Messages.CONNECTED_PUNCTUATION_CLICK_TO_DISCONNECT_;
} else {
- return getText("Disconnected. Click to connect.");
+ return Messages.DISCONNECTED_PUNCTUATION_CLICK_TO_CONNECT_;
}
} else {
return super.getToolTipText(event);
}
}
@@ -223,11 +219,11 @@
super.removeTabAt(index);
}
private Tab instantiate(TabInfo tabInfo) {
try {
- Constructor con = tabInfo.tabClass.getConstructor(VMPanel.class);
+ Constructor<?> con = tabInfo.tabClass.getConstructor(VMPanel.class);
return (Tab)con.newInstance(this);
} catch (Exception ex) {
System.err.println(ex);
return null;
}
@@ -361,31 +357,31 @@
// Called on EDT
private void onConnecting() {
time0 = System.currentTimeMillis();
- final JConsole jc = (JConsole)SwingUtilities.getWindowAncestor(this);
+ 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>",
+ "<html><h3>" + Resources.format(Messages.CONNECTING_TO1, connectionName) + "</h3></html>",
progressPanel,
- "<html><b>" + getText("connectingTo2", connectionName) + "</b></html>"
+ "<html><b>" + Resources.format(Messages.CONNECTING_TO2, connectionName) + "</b></html>"
};
optionPane =
SheetDialog.showOptionDialog(this,
message,
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null,
- new String[] { getText("Cancel") },
+ new String[]{Messages.CANCEL},
0);
}
@@ -416,11 +412,11 @@
void updateFrameTitle() {
VMInternalFrame vmIF = getFrame();
if (vmIF != null) {
String displayName = getDisplayName();
if (!proxyClient.isConnected()) {
- displayName = getText("ConnectionName (disconnected)", displayName);
+ displayName = Resources.format(Messages.CONNECTION_NAME__DISCONNECTED_, displayName);
}
vmIF.setTitle(displayName);
}
}
@@ -465,53 +461,45 @@
// 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 insecureStr = getText("Insecure");
- final String cancelStr = getText("Cancel");
-
String msgTitle, msgExplanation, buttonStr;
if (wasConnected) {
wasConnected = false;
- msgTitle = getText("connectionLost1");
- msgExplanation = getText("connectionLost2", getConnectionName());
- buttonStr = reconnectStr;
+ msgTitle = Messages.CONNECTION_LOST1;
+ msgExplanation = Resources.format(Messages.CONNECTING_TO2, getConnectionName());
+ buttonStr = Messages.RECONNECT;
} else if (shouldUseSSL) {
- msgTitle = getText("connectionFailedSSL1");
- msgExplanation = getText("connectionFailedSSL2", getConnectionName());
- buttonStr = insecureStr;
+ msgTitle = Messages.CONNECTION_FAILED_SSL1;
+ msgExplanation = Resources.format(Messages.CONNECTION_FAILED_SSL2, getConnectionName());
+ buttonStr = Messages.INSECURE;
} else {
- msgTitle = getText("connectionFailed1");
- msgExplanation = getText("connectionFailed2", getConnectionName());
- buttonStr = connectStr;
+ 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, cancelStr },
+ 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 == reconnectStr || value == connectStr) {
+ if (value == Messages.RECONNECT || value == Messages.CONNECT) {
connect();
- } else if (value == insecureStr) {
+ } else if (value == Messages.INSECURE) {
shouldUseSSL = false;
connect();
} else if (!everConnected) {
try {
getFrame().setClosed(true);
@@ -654,15 +642,10 @@
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();
< prev index next >