1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.wizards; 21 22 import java.awt.Dimension ; 23 import javax.swing.JLabel ; 24 import javax.swing.text.PlainDocument ; 25 import javax.swing.text.AttributeSet ; 26 import javax.swing.text.BadLocationException ; 27 28 33 public class CvsRootPanel extends javax.swing.JPanel { 34 35 36 public CvsRootPanel() { 37 initComponents(); 38 39 int w = accessLabel.getPreferredSize().width; 42 w = Math.max(w, userLabel.getPreferredSize().width); 43 w = Math.max(w, hostLabel.getPreferredSize().width); 44 w = Math.max(w, repositoryLabel.getPreferredSize().width); 45 46 setPreferredWidth(accessLabel, w); 47 setPreferredWidth(userLabel, w); 48 setPreferredWidth(hostLabel, w); 49 setPreferredWidth(repositoryLabel, w); 50 51 portTextField.setDocument(new PortDocument()); 52 } 53 54 private void setPreferredWidth(JLabel label, int width) { 55 Dimension dim = label.getPreferredSize(); 56 dim.width = width; 57 label.setPreferredSize(dim); 58 } 59 60 static class PortDocument extends PlainDocument { 61 62 public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { 63 64 if (str == null) return; 65 66 char[] upper = str.toCharArray(); 67 for (int i = 0; i < upper.length; i++) { 68 if ("1234567890".indexOf(upper[i]) == -1) { return; 70 } 71 } 72 super.insertString(offs, new String (upper), a); 73 } 74 } 75 80 private void initComponents() { 82 java.awt.GridBagConstraints gridBagConstraints; 83 84 setLayout(new java.awt.GridBagLayout ()); 85 86 accessLabel.setLabelFor(accessComboBox); 87 org.openide.awt.Mnemonics.setLocalizedText(accessLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1006")); 88 accessLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_AccessMethod")); 89 gridBagConstraints = new java.awt.GridBagConstraints (); 90 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 91 gridBagConstraints.insets = new java.awt.Insets (0, 0, 3, 3); 92 add(accessLabel, gridBagConstraints); 93 94 accessComboBox.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "pserver", "ext", "local", "fork" })); 95 accessComboBox.setMinimumSize(new java.awt.Dimension (120, 24)); 96 gridBagConstraints = new java.awt.GridBagConstraints (); 97 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 98 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 99 gridBagConstraints.weightx = 1.0; 100 gridBagConstraints.insets = new java.awt.Insets (0, 3, 3, 0); 101 add(accessComboBox, gridBagConstraints); 102 103 userLabel.setLabelFor(userTextField); 104 org.openide.awt.Mnemonics.setLocalizedText(userLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1007")); 105 userLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_Username")); 106 gridBagConstraints = new java.awt.GridBagConstraints (); 107 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 108 gridBagConstraints.insets = new java.awt.Insets (3, 0, 3, 3); 109 add(userLabel, gridBagConstraints); 110 111 userTextField.setColumns(12); 112 userTextField.setMinimumSize(new java.awt.Dimension (120, 19)); 113 gridBagConstraints = new java.awt.GridBagConstraints (); 114 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 115 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 116 gridBagConstraints.weightx = 10.0; 117 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 118 add(userTextField, gridBagConstraints); 119 120 hostLabel.setLabelFor(hostTextField); 121 org.openide.awt.Mnemonics.setLocalizedText(hostLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1008")); 122 hostLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_CVSHost")); 123 gridBagConstraints = new java.awt.GridBagConstraints (); 124 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 125 gridBagConstraints.insets = new java.awt.Insets (3, 0, 3, 3); 126 add(hostLabel, gridBagConstraints); 127 128 hostTextField.setColumns(30); 129 gridBagConstraints = new java.awt.GridBagConstraints (); 130 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 131 gridBagConstraints.weightx = 20.0; 132 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 133 add(hostTextField, gridBagConstraints); 134 135 portLabel.setLabelFor(portTextField); 136 org.openide.awt.Mnemonics.setLocalizedText(portLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1009")); 137 portLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_CVSPort")); 138 gridBagConstraints = new java.awt.GridBagConstraints (); 139 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 140 add(portLabel, gridBagConstraints); 141 142 portTextField.setColumns(5); 143 gridBagConstraints = new java.awt.GridBagConstraints (); 144 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 145 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 146 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 147 gridBagConstraints.weightx = 3.0; 148 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 0); 149 add(portTextField, gridBagConstraints); 150 151 repositoryLabel.setLabelFor(repositoryTextField); 152 org.openide.awt.Mnemonics.setLocalizedText(repositoryLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1005")); 153 repositoryLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_Repository")); 154 gridBagConstraints = new java.awt.GridBagConstraints (); 155 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 156 gridBagConstraints.insets = new java.awt.Insets (3, 0, 0, 3); 157 add(repositoryLabel, gridBagConstraints); 158 159 repositoryTextField.setColumns(30); 160 gridBagConstraints = new java.awt.GridBagConstraints (); 161 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 162 gridBagConstraints.weightx = 20.0; 163 gridBagConstraints.insets = new java.awt.Insets (3, 3, 0, 3); 164 add(repositoryTextField, gridBagConstraints); 165 166 gridBagConstraints = new java.awt.GridBagConstraints (); 167 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 168 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 169 gridBagConstraints.weightx = 1.0; 170 add(jPanel1, gridBagConstraints); 171 172 gridBagConstraints = new java.awt.GridBagConstraints (); 173 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 174 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 175 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 176 gridBagConstraints.weightx = 1.0; 177 gridBagConstraints.weighty = 1.0; 178 add(jPanel2, gridBagConstraints); 179 180 } 181 183 184 final javax.swing.JComboBox accessComboBox = new javax.swing.JComboBox (); 186 final javax.swing.JLabel accessLabel = new javax.swing.JLabel (); 187 final javax.swing.JLabel hostLabel = new javax.swing.JLabel (); 188 final javax.swing.JTextField hostTextField = new javax.swing.JTextField (); 189 final javax.swing.JPanel jPanel1 = new javax.swing.JPanel (); 190 final javax.swing.JPanel jPanel2 = new javax.swing.JPanel (); 191 final javax.swing.JLabel portLabel = new javax.swing.JLabel (); 192 final javax.swing.JTextField portTextField = new javax.swing.JTextField (); 193 final javax.swing.JLabel repositoryLabel = new javax.swing.JLabel (); 194 final javax.swing.JTextField repositoryTextField = new javax.swing.JTextField (); 195 final javax.swing.JLabel userLabel = new javax.swing.JLabel (); 196 final javax.swing.JTextField userTextField = new javax.swing.JTextField (); 197 199 } 200 | Popular Tags |