src/share/classes/sun/tools/jconsole/ConnectDialog.java

Print this page
rev 5340 : 7017818: NLS: JConsoleResources.java cannot be handled by translation team
Reviewed-by: duke

@@ -27,27 +27,22 @@
 
 import java.util.List;
 import java.awt.*;
 import java.awt.event.*;
 import java.util.*;
-import java.net.MalformedURLException;
-import java.io.IOException;
 
-import javax.accessibility.*;
 import javax.swing.*;
-import javax.swing.Timer;
 import javax.swing.border.*;
 import javax.swing.event.*;
 import javax.swing.plaf.basic.BasicRadioButtonUI;
 import javax.swing.table.*;
 
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.JMXConnector;
+import sun.tools.jconsole.resources.Messages;
+
 
 import static java.awt.BorderLayout.*;
 import static javax.swing.ListSelectionModel.*;
-import static sun.tools.jconsole.Resources.*;
 import static sun.tools.jconsole.Utilities.*;
 
 @SuppressWarnings("serial")
 public class ConnectDialog extends InternalDialog
                 implements DocumentListener, FocusListener,

@@ -64,11 +59,11 @@
     JTextField remoteTF;
     JButton connectButton, cancelButton;
     JPanel radioButtonPanel;
 
     private Icon mastheadIcon =
-        new MastheadIcon(getText("ConnectDialog.masthead.title"));
+        new MastheadIcon(Messages.CONNECT_DIALOG_MASTHEAD_TITLE);
     private Color hintTextColor, disabledTableCellColor;
 
     // The table of managed VM (local process)
     JTable vmTable;
     ManagedVmTableModel vmModel = null;

@@ -77,15 +72,15 @@
 
     private Action connectAction, cancelAction;
 
 
     public ConnectDialog(JConsole jConsole) {
-        super(jConsole, Resources.getText("ConnectDialog.title"), true);
+        super(jConsole, Messages.CONNECT_DIALOG_TITLE, true);
 
         this.jConsole = jConsole;
         setAccessibleDescription(this,
-                                 getText("ConnectDialog.accessibleDescription"));
+                Messages.CONNECT_DIALOG_ACCESSIBLE_DESCRIPTION);
         setDefaultCloseOperation(HIDE_ON_CLOSE);
         setResizable(false);
         Container cp = (JComponent)getContentPane();
 
         radioButtonPanel = new JPanel(new BorderLayout(0, 12));

@@ -93,19 +88,19 @@
         ButtonGroup radioButtonGroup = new ButtonGroup();
         JPanel bottomPanel = new JPanel(new BorderLayout());
 
         statusBar = new JLabel(" ", JLabel.CENTER);
         setAccessibleName(statusBar,
-                          getText("ConnectDialog.statusBar.accessibleName"));
+                Messages.CONNECT_DIALOG_STATUS_BAR_ACCESSIBLE_NAME);
 
         Font normalLabelFont = statusBar.getFont();
         Font boldLabelFont = normalLabelFont.deriveFont(Font.BOLD);
         Font smallLabelFont = normalLabelFont.deriveFont(normalLabelFont.getSize2D() - 1);
 
         JLabel mastheadLabel = new JLabel(mastheadIcon);
         setAccessibleName(mastheadLabel,
-                          getText("ConnectDialog.masthead.accessibleName"));
+                Messages.CONNECT_DIALOG_MASTHEAD_ACCESSIBLE_NAME);
 
         cp.add(mastheadLabel, NORTH);
         cp.add(radioButtonPanel, CENTER);
         cp.add(bottomPanel, SOUTH);
 

@@ -115,11 +110,11 @@
         remoteTF.addActionListener(connectAction);
         remoteTF.getDocument().addDocumentListener(this);
         remoteTF.addFocusListener(this);
         remoteTF.setPreferredSize(remoteTF.getPreferredSize());
         setAccessibleName(remoteTF,
-                          getText("Remote Process.textField.accessibleName"));
+                Messages.REMOTE_PROCESS_TEXT_FIELD_ACCESSIBLE_NAME);
 
         //
         // If the VM supports the local attach mechanism (is: Sun
         // implementation) then the Local Process panel is created.
         //

@@ -139,12 +134,12 @@
             pidColumn.setResizable(false);
 
             TableColumn cmdLineColumn = columnModel.getColumn(COL_NAME);
             cmdLineColumn.setResizable(false);
 
-            localRadioButton = new JRadioButton(getText("Local Process:"));
-            localRadioButton.setMnemonic(getMnemonicInt("Local Process:"));
+            localRadioButton = new JRadioButton(Messages.LOCAL_PROCESS_COLON);
+            localRadioButton.setMnemonic(Resources.getMnemonicInt(Messages.LOCAL_PROCESS_COLON));
             localRadioButton.setFont(boldLabelFont);
             localRadioButton.addItemListener(this);
             radioButtonGroup.add(localRadioButton);
 
             JPanel localPanel = new JPanel(new BorderLayout());

@@ -165,12 +160,12 @@
             localMessageLabel.setFont(smallLabelFont);
             localMessageLabel.setForeground(hintTextColor);
             localTablePanel.add(localMessageLabel, SOUTH);
         }
 
-        remoteRadioButton = new JRadioButton(getText("Remote Process:"));
-        remoteRadioButton.setMnemonic(getMnemonicInt("Remote Process:"));
+        remoteRadioButton = new JRadioButton(Messages.REMOTE_PROCESS_COLON);
+        remoteRadioButton.setMnemonic(Resources.getMnemonicInt(Messages.REMOTE_PROCESS_COLON));
         remoteRadioButton.setFont(boldLabelFont);
         radioButtonGroup.add(remoteRadioButton);
 
         JPanel remotePanel = new JPanel(new BorderLayout());
         if (localRadioButton != null) {

@@ -205,11 +200,11 @@
         JPanel remoteTFPanel = new JPanel(new BorderLayout());
         remotePanel.add(remoteTFPanel, CENTER);
 
         remoteTFPanel.add(remoteTF, NORTH);
 
-        remoteMessageLabel = new JLabel("<html>" + getText("remoteTF.usage"));
+        remoteMessageLabel = new JLabel("<html>" + Messages.REMOTE_TF_USAGE + "</html>");
         remoteMessageLabel.setFont(smallLabelFont);
         remoteMessageLabel.setForeground(hintTextColor);
         remoteTFPanel.add(remoteMessageLabel, CENTER);
 
         JPanel userPwdPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));

@@ -220,15 +215,15 @@
         userNameTF = new JTextField(tfWidth);
         userNameTF.addActionListener(connectAction);
         userNameTF.getDocument().addDocumentListener(this);
         userNameTF.addFocusListener(this);
         setAccessibleName(userNameTF,
-                          getText("Username.accessibleName"));
-        String labelKey = "Username: ";
+                Messages.USERNAME_ACCESSIBLE_NAME);
+     //   String labelKey = Messages.USERNAME_COLON_;
         LabeledComponent lc;
-        lc = new LabeledComponent(getText(labelKey),
-                                  getMnemonicInt(labelKey),
+        lc = new LabeledComponent(Messages.USERNAME_COLON_,
+                                  Resources.getMnemonicInt(Messages.USERNAME_COLON_),
                                   userNameTF);
         lc.label.setFont(boldLabelFont);
         userPwdPanel.add(lc);
 
         passwordTF = new JPasswordField(tfWidth);

@@ -236,23 +231,23 @@
         passwordTF.setPreferredSize(userNameTF.getPreferredSize());
         passwordTF.addActionListener(connectAction);
         passwordTF.getDocument().addDocumentListener(this);
         passwordTF.addFocusListener(this);
         setAccessibleName(passwordTF,
-                          getText("Password.accessibleName"));
-        labelKey = "Password: ";
-        lc = new LabeledComponent(getText(labelKey),
-                                  getMnemonicInt(labelKey),
+                Messages.PASSWORD_ACCESSIBLE_NAME);
+
+        lc = new LabeledComponent(Messages.PASSWORD_COLON_,
+                                  Resources.getMnemonicInt(Messages.PASSWORD_COLON_),
                                   passwordTF);
         lc.setBorder(new EmptyBorder(0, 12, 0, 0)); // Left padding
         lc.label.setFont(boldLabelFont);
         userPwdPanel.add(lc);
 
         remoteTFPanel.add(userPwdPanel, SOUTH);
 
         String connectButtonToolTipText =
-            getText("ConnectDialog.connectButton.toolTip");
+                Messages.CONNECT_DIALOG_CONNECT_BUTTON_TOOLTIP;
         connectButton = new JButton(connectAction);
         connectButton.setToolTipText(connectButtonToolTipText);
 
         cancelButton = new JButton(cancelAction);
 

@@ -286,11 +281,11 @@
             remoteMessageLabel.setForeground(hintTextColor);
             // Update html color setting
             String colorStr =
                 String.format("%06x", hintTextColor.getRGB() & 0xFFFFFF);
             remoteMessageLabel.setText("<html><font color=#" + colorStr + ">" +
-                                       getText("remoteTF.usage"));
+                    Messages.REMOTE_TF_USAGE);
         }
         if (localMessageLabel != null) {
             localMessageLabel.setForeground(hintTextColor);
             // Update html color setting
             valueChanged(null);

@@ -298,13 +293,13 @@
 
         super.revalidate();
     }
 
     private void createActions() {
-        connectAction = new AbstractAction(getText("Connect")) {
+        connectAction = new AbstractAction(Messages.CONNECT) {
             /* init */ {
-                putValue(Action.MNEMONIC_KEY, getMnemonicInt("Connect"));
+                putValue(Action.MNEMONIC_KEY, Resources.getMnemonicInt(Messages.CONNECT));
             }
 
             public void actionPerformed(ActionEvent ev) {
                 if (!isEnabled() || !isVisible()) {
                     return;

@@ -319,11 +314,10 @@
                     String password = passwordTF.getText();
                     password = password.equals("") ? null : password;
                     try {
                         if (txt.startsWith(JConsole.ROOT_URL)) {
                             String url = txt;
-                            String msg = null;
                             jConsole.addUrl(url, userName, password, false);
                             remoteTF.setText(JConsole.ROOT_URL);
                             return;
                         } else {
                             String host = remoteTF.getText().trim();

@@ -359,11 +353,11 @@
                     refresh();
                 }
             }
         };
 
-        cancelAction = new AbstractAction(getText("Cancel")) {
+        cancelAction = new AbstractAction(Messages.CANCEL) {
             public void actionPerformed(ActionEvent ev) {
                 setVisible(false);
                 statusBar.setText("");
             }
         };

@@ -586,13 +580,13 @@
         int row = vmTable.getSelectedRow();
         if (row >= 0) {
             LocalVirtualMachine lvm = vmModel.vmAt(row);
             if (!lvm.isManageable()) {
                 if (lvm.isAttachable()) {
-                    labelText = getText("Management Will Be Enabled");
+                    labelText = Messages.MANAGEMENT_WILL_BE_ENABLED;
                 } else {
-                    labelText = getText("Management Not Enabled");
+                    labelText = Messages.MANAGEMENT_NOT_ENABLED;
                 }
             }
         }
         String colorStr =
             String.format("%06x", hintTextColor.getRGB() & 0xFFFFFF);

@@ -648,12 +642,12 @@
     }
 
     // Represents the list of managed VMs as a tabular data model.
     private static class ManagedVmTableModel extends AbstractTableModel {
         private static String[] columnNames = {
-            Resources.getText("Column.Name"),
-            Resources.getText("Column.PID"),
+            Messages.COLUMN_NAME,
+            Messages.COLUMN_PID,
         };
 
         private List<LocalVirtualMachine> vmList;
 
         public int getColumnCount() {

@@ -676,11 +670,11 @@
                 case COL_PID:  return vm.vmid();
                 default: return null;
             }
         }
 
-        public Class getColumnClass(int column) {
+        public Class<?> getColumnClass(int column) {
             switch (column) {
                 case COL_NAME: return String.class;
                 case COL_PID:  return Integer.class;
                 default: return super.getColumnClass(column);
             }

@@ -704,26 +698,19 @@
             // data has changed
             fireTableDataChanged();
         }
     }
 
-
-    // Convenience method
-    private static String getText(String key) {
-        return Resources.getText(key);
-    }
-
-
     // A blank component that takes up as much space as the
     // button part of a JRadioButton.
     private static class Padder extends JPanel {
         JRadioButton radioButton;
 
         Padder(JRadioButton radioButton) {
             this.radioButton = radioButton;
 
-            setAccessibleName(this, getText("Blank"));
+            setAccessibleName(this, Messages.BLANK);
         }
 
         public Dimension getPreferredSize() {
             Rectangle r = getTextRectangle(radioButton);
             int w = (r != null && r.x > 8) ? r.x : 22;

@@ -756,11 +743,10 @@
 
             Graphics g = button.getGraphics();
             if (g == null) {
                 return null;
             }
-            String clippedText =
                 SwingUtilities.layoutCompoundLabel(button,
                                                    g.getFontMetrics(),
                                                    text,
                                                    icon,
                                                    button.getVerticalAlignment(),