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,53 **** 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 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, --- 27,48 ---- import java.util.List; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.*; import javax.swing.plaf.basic.BasicRadioButtonUI; import javax.swing.table.*; ! import sun.tools.jconsole.resources.Messages; ! import static java.awt.BorderLayout.*; import static javax.swing.ListSelectionModel.*; import static sun.tools.jconsole.Utilities.*; @SuppressWarnings("serial") public class ConnectDialog extends InternalDialog implements DocumentListener, FocusListener,
*** 64,74 **** JTextField remoteTF; JButton connectButton, cancelButton; JPanel radioButtonPanel; private Icon mastheadIcon = ! new MastheadIcon(getText("ConnectDialog.masthead.title")); private Color hintTextColor, disabledTableCellColor; // The table of managed VM (local process) JTable vmTable; ManagedVmTableModel vmModel = null; --- 59,69 ---- JTextField remoteTF; JButton connectButton, cancelButton; JPanel radioButtonPanel; private Icon mastheadIcon = ! new MastheadIcon(Messages.CONNECT_DIALOG_MASTHEAD_TITLE); private Color hintTextColor, disabledTableCellColor; // The table of managed VM (local process) JTable vmTable; ManagedVmTableModel vmModel = null;
*** 77,91 **** private Action connectAction, cancelAction; public ConnectDialog(JConsole jConsole) { ! super(jConsole, Resources.getText("ConnectDialog.title"), true); this.jConsole = jConsole; setAccessibleDescription(this, ! getText("ConnectDialog.accessibleDescription")); setDefaultCloseOperation(HIDE_ON_CLOSE); setResizable(false); Container cp = (JComponent)getContentPane(); radioButtonPanel = new JPanel(new BorderLayout(0, 12)); --- 72,86 ---- private Action connectAction, cancelAction; public ConnectDialog(JConsole jConsole) { ! super(jConsole, Messages.CONNECT_DIALOG_TITLE, true); this.jConsole = jConsole; setAccessibleDescription(this, ! Messages.CONNECT_DIALOG_ACCESSIBLE_DESCRIPTION); setDefaultCloseOperation(HIDE_ON_CLOSE); setResizable(false); Container cp = (JComponent)getContentPane(); radioButtonPanel = new JPanel(new BorderLayout(0, 12));
*** 93,111 **** ButtonGroup radioButtonGroup = new ButtonGroup(); JPanel bottomPanel = new JPanel(new BorderLayout()); statusBar = new JLabel(" ", JLabel.CENTER); setAccessibleName(statusBar, ! getText("ConnectDialog.statusBar.accessibleName")); 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")); cp.add(mastheadLabel, NORTH); cp.add(radioButtonPanel, CENTER); cp.add(bottomPanel, SOUTH); --- 88,106 ---- ButtonGroup radioButtonGroup = new ButtonGroup(); JPanel bottomPanel = new JPanel(new BorderLayout()); statusBar = new JLabel(" ", JLabel.CENTER); setAccessibleName(statusBar, ! 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, ! Messages.CONNECT_DIALOG_MASTHEAD_ACCESSIBLE_NAME); cp.add(mastheadLabel, NORTH); cp.add(radioButtonPanel, CENTER); cp.add(bottomPanel, SOUTH);
*** 115,125 **** remoteTF.addActionListener(connectAction); remoteTF.getDocument().addDocumentListener(this); remoteTF.addFocusListener(this); remoteTF.setPreferredSize(remoteTF.getPreferredSize()); setAccessibleName(remoteTF, ! getText("Remote Process.textField.accessibleName")); // // If the VM supports the local attach mechanism (is: Sun // implementation) then the Local Process panel is created. // --- 110,120 ---- remoteTF.addActionListener(connectAction); remoteTF.getDocument().addDocumentListener(this); remoteTF.addFocusListener(this); remoteTF.setPreferredSize(remoteTF.getPreferredSize()); setAccessibleName(remoteTF, ! 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,150 **** pidColumn.setResizable(false); TableColumn cmdLineColumn = columnModel.getColumn(COL_NAME); cmdLineColumn.setResizable(false); ! localRadioButton = new JRadioButton(getText("Local Process:")); ! localRadioButton.setMnemonic(getMnemonicInt("Local Process:")); localRadioButton.setFont(boldLabelFont); localRadioButton.addItemListener(this); radioButtonGroup.add(localRadioButton); JPanel localPanel = new JPanel(new BorderLayout()); --- 134,145 ---- pidColumn.setResizable(false); TableColumn cmdLineColumn = columnModel.getColumn(COL_NAME); cmdLineColumn.setResizable(false); ! 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,176 **** localMessageLabel.setFont(smallLabelFont); localMessageLabel.setForeground(hintTextColor); localTablePanel.add(localMessageLabel, SOUTH); } ! remoteRadioButton = new JRadioButton(getText("Remote Process:")); ! remoteRadioButton.setMnemonic(getMnemonicInt("Remote Process:")); remoteRadioButton.setFont(boldLabelFont); radioButtonGroup.add(remoteRadioButton); JPanel remotePanel = new JPanel(new BorderLayout()); if (localRadioButton != null) { --- 160,171 ---- localMessageLabel.setFont(smallLabelFont); localMessageLabel.setForeground(hintTextColor); localTablePanel.add(localMessageLabel, SOUTH); } ! 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,215 **** JPanel remoteTFPanel = new JPanel(new BorderLayout()); remotePanel.add(remoteTFPanel, CENTER); remoteTFPanel.add(remoteTF, NORTH); ! remoteMessageLabel = new JLabel("<html>" + getText("remoteTF.usage")); remoteMessageLabel.setFont(smallLabelFont); remoteMessageLabel.setForeground(hintTextColor); remoteTFPanel.add(remoteMessageLabel, CENTER); JPanel userPwdPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); --- 200,210 ---- JPanel remoteTFPanel = new JPanel(new BorderLayout()); remotePanel.add(remoteTFPanel, CENTER); remoteTFPanel.add(remoteTF, NORTH); ! 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,234 **** userNameTF = new JTextField(tfWidth); userNameTF.addActionListener(connectAction); userNameTF.getDocument().addDocumentListener(this); userNameTF.addFocusListener(this); setAccessibleName(userNameTF, ! getText("Username.accessibleName")); ! String labelKey = "Username: "; LabeledComponent lc; ! lc = new LabeledComponent(getText(labelKey), ! getMnemonicInt(labelKey), userNameTF); lc.label.setFont(boldLabelFont); userPwdPanel.add(lc); passwordTF = new JPasswordField(tfWidth); --- 215,229 ---- userNameTF = new JTextField(tfWidth); userNameTF.addActionListener(connectAction); userNameTF.getDocument().addDocumentListener(this); userNameTF.addFocusListener(this); setAccessibleName(userNameTF, ! Messages.USERNAME_ACCESSIBLE_NAME); ! // String labelKey = Messages.USERNAME_COLON_; LabeledComponent lc; ! lc = new LabeledComponent(Messages.USERNAME_COLON_, ! Resources.getMnemonicInt(Messages.USERNAME_COLON_), userNameTF); lc.label.setFont(boldLabelFont); userPwdPanel.add(lc); passwordTF = new JPasswordField(tfWidth);
*** 236,258 **** 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), 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"); connectButton = new JButton(connectAction); connectButton.setToolTipText(connectButtonToolTipText); cancelButton = new JButton(cancelAction); --- 231,253 ---- passwordTF.setPreferredSize(userNameTF.getPreferredSize()); passwordTF.addActionListener(connectAction); passwordTF.getDocument().addDocumentListener(this); passwordTF.addFocusListener(this); setAccessibleName(passwordTF, ! 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 = ! Messages.CONNECT_DIALOG_CONNECT_BUTTON_TOOLTIP; connectButton = new JButton(connectAction); connectButton.setToolTipText(connectButtonToolTipText); cancelButton = new JButton(cancelAction);
*** 286,296 **** remoteMessageLabel.setForeground(hintTextColor); // Update html color setting String colorStr = String.format("%06x", hintTextColor.getRGB() & 0xFFFFFF); remoteMessageLabel.setText("<html><font color=#" + colorStr + ">" + ! getText("remoteTF.usage")); } if (localMessageLabel != null) { localMessageLabel.setForeground(hintTextColor); // Update html color setting valueChanged(null); --- 281,291 ---- remoteMessageLabel.setForeground(hintTextColor); // Update html color setting String colorStr = String.format("%06x", hintTextColor.getRGB() & 0xFFFFFF); remoteMessageLabel.setText("<html><font color=#" + colorStr + ">" + ! Messages.REMOTE_TF_USAGE); } if (localMessageLabel != null) { localMessageLabel.setForeground(hintTextColor); // Update html color setting valueChanged(null);
*** 298,310 **** super.revalidate(); } private void createActions() { ! connectAction = new AbstractAction(getText("Connect")) { /* init */ { ! putValue(Action.MNEMONIC_KEY, getMnemonicInt("Connect")); } public void actionPerformed(ActionEvent ev) { if (!isEnabled() || !isVisible()) { return; --- 293,305 ---- super.revalidate(); } private void createActions() { ! connectAction = new AbstractAction(Messages.CONNECT) { /* init */ { ! putValue(Action.MNEMONIC_KEY, Resources.getMnemonicInt(Messages.CONNECT)); } public void actionPerformed(ActionEvent ev) { if (!isEnabled() || !isVisible()) { return;
*** 319,329 **** 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(); --- 314,323 ----
*** 359,369 **** refresh(); } } }; ! cancelAction = new AbstractAction(getText("Cancel")) { public void actionPerformed(ActionEvent ev) { setVisible(false); statusBar.setText(""); } }; --- 353,363 ---- refresh(); } } }; ! cancelAction = new AbstractAction(Messages.CANCEL) { public void actionPerformed(ActionEvent ev) { setVisible(false); statusBar.setText(""); } };
*** 586,598 **** int row = vmTable.getSelectedRow(); if (row >= 0) { LocalVirtualMachine lvm = vmModel.vmAt(row); if (!lvm.isManageable()) { if (lvm.isAttachable()) { ! labelText = getText("Management Will Be Enabled"); } else { ! labelText = getText("Management Not Enabled"); } } } String colorStr = String.format("%06x", hintTextColor.getRGB() & 0xFFFFFF); --- 580,592 ---- int row = vmTable.getSelectedRow(); if (row >= 0) { LocalVirtualMachine lvm = vmModel.vmAt(row); if (!lvm.isManageable()) { if (lvm.isAttachable()) { ! labelText = Messages.MANAGEMENT_WILL_BE_ENABLED; } else { ! labelText = Messages.MANAGEMENT_NOT_ENABLED; } } } String colorStr = String.format("%06x", hintTextColor.getRGB() & 0xFFFFFF);
*** 648,659 **** } // 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"), }; private List<LocalVirtualMachine> vmList; public int getColumnCount() { --- 642,653 ---- } // Represents the list of managed VMs as a tabular data model. private static class ManagedVmTableModel extends AbstractTableModel { private static String[] columnNames = { ! Messages.COLUMN_NAME, ! Messages.COLUMN_PID, }; private List<LocalVirtualMachine> vmList; public int getColumnCount() {
*** 676,686 **** case COL_PID: return vm.vmid(); default: return null; } } ! public Class getColumnClass(int column) { switch (column) { case COL_NAME: return String.class; case COL_PID: return Integer.class; default: return super.getColumnClass(column); } --- 670,680 ---- case COL_PID: return vm.vmid(); default: return null; } } ! 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,729 **** // 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")); } public Dimension getPreferredSize() { Rectangle r = getTextRectangle(radioButton); int w = (r != null && r.x > 8) ? r.x : 22; --- 698,716 ---- // data has changed fireTableDataChanged(); } } // 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, Messages.BLANK); } public Dimension getPreferredSize() { Rectangle r = getTextRectangle(radioButton); int w = (r != null && r.x > 8) ? r.x : 22;
*** 756,766 **** Graphics g = button.getGraphics(); if (g == null) { return null; } - String clippedText = SwingUtilities.layoutCompoundLabel(button, g.getFontMetrics(), text, icon, button.getVerticalAlignment(), --- 743,752 ----