1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.wizards; 21 22 import org.netbeans.modules.versioning.util.AccessibleJFileChooser; 23 import org.netbeans.modules.versioning.util.Utils; 24 import org.netbeans.modules.versioning.system.cvss.CvsModuleConfig; 25 import org.netbeans.spi.project.ui.support.ProjectChooser; 26 import org.openide.util.NbBundle; 27 28 import javax.swing.*; 29 import javax.swing.filechooser.FileFilter ; 30 import java.awt.event.ActionListener ; 31 import java.io.File ; 32 import java.util.*; 33 34 40 final class RepositoryPanel extends javax.swing.JPanel implements ActionListener { 41 42 43 public RepositoryPanel() { 44 initComponents(); 45 } 46 47 52 private void initComponents() { 54 55 setName(org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK0006")); 57 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle"); org.openide.awt.Mnemonics.setLocalizedText(headerLabel, bundle.getString("BK0001")); 60 rootsLabel.setLabelFor(rootComboBox); 61 org.openide.awt.Mnemonics.setLocalizedText(rootsLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK0002")); 63 org.openide.awt.Mnemonics.setLocalizedText(descLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK2018")); 65 pPaswordLabel.setLabelFor(passwordTextField); 66 org.openide.awt.Mnemonics.setLocalizedText(pPaswordLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK0003")); pPaswordLabel.setToolTipText(bundle.getString("TT_PserverPassword")); 69 passwordTextField.setColumns(12); 70 71 sshButtonGroup.add(internalSshRadioButton); 72 internalSshRadioButton.setSelected(true); 73 org.openide.awt.Mnemonics.setLocalizedText(internalSshRadioButton, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1100")); internalSshRadioButton.setToolTipText(bundle.getString("TT_UseInternalSSH")); internalSshRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 76 internalSshRadioButton.setMargin(new java.awt.Insets (0, 0, 0, 0)); 77 78 extPasswordLabel5.setLabelFor(extPasswordField); 79 org.openide.awt.Mnemonics.setLocalizedText(extPasswordLabel5, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1011")); extPasswordLabel5.setToolTipText(bundle.getString("TT_SSHPassword")); 82 extPasswordField.setColumns(12); 83 84 org.openide.awt.Mnemonics.setLocalizedText(extREmemberPasswordCheckBox, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1012")); extREmemberPasswordCheckBox.setToolTipText(bundle.getString("TT_RememberPassword")); 87 org.openide.awt.Mnemonics.setLocalizedText(proxyConfigurationButton, bundle.getString("BK0005")); proxyConfigurationButton.setToolTipText(bundle.getString("TT_ProxyConfig")); 90 sshButtonGroup.add(extSshRadioButton); 91 org.openide.awt.Mnemonics.setLocalizedText(extSshRadioButton, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1101")); extSshRadioButton.setToolTipText(bundle.getString("TT_UseExternal")); extSshRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 94 extSshRadioButton.setMargin(new java.awt.Insets (0, 0, 0, 0)); 95 96 extCommandLabel.setLabelFor(extCommandTextField); 97 org.openide.awt.Mnemonics.setLocalizedText(extCommandLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1013")); extCommandLabel.setToolTipText(bundle.getString("TT_ExternalCommand")); 100 extCommandTextField.setMinimumSize(new java.awt.Dimension (80, 20)); 101 102 org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "LBL_RepositoryPanel_Command_Browse")); browseButton.addActionListener(this); 104 105 rootComboBox.setEditable(true); 106 rootComboBox.setMinimumSize(new java.awt.Dimension (80, 20)); 107 108 org.openide.awt.Mnemonics.setLocalizedText(editButton, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1105")); editButton.setToolTipText(bundle.getString("TT_EditFields")); 111 org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); 112 jPanel1.setLayout(jPanel1Layout); 113 jPanel1Layout.setHorizontalGroup( 114 jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 115 .add(0, 415, Short.MAX_VALUE) 116 ); 117 jPanel1Layout.setVerticalGroup( 118 jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 119 .add(0, 111, Short.MAX_VALUE) 120 ); 121 122 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 123 this.setLayout(layout); 124 layout.setHorizontalGroup( 125 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 126 .add(layout.createSequentialGroup() 127 .add(rootsLabel) 128 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 129 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 130 .add(layout.createSequentialGroup() 131 .add(0, 0, 0) 132 .add(rootComboBox, 0, 275, Short.MAX_VALUE) 133 .add(4, 4, 4) 134 .add(editButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 81, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 135 .add(descLabel))) 136 .add(layout.createSequentialGroup() 137 .add(pPaswordLabel) 138 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 139 .add(passwordTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 210, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 140 .add(internalSshRadioButton) 141 .add(extSshRadioButton) 142 .add(headerLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 308, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 143 .add(layout.createSequentialGroup() 144 .add(17, 17, 17) 145 .add(extCommandLabel) 146 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 147 .add(extCommandTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE) 148 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 149 .add(browseButton)) 150 .add(layout.createSequentialGroup() 151 .add(17, 17, 17) 152 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 153 .add(proxyConfigurationButton) 154 .add(layout.createSequentialGroup() 155 .add(extPasswordLabel5) 156 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 157 .add(extPasswordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 193, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 158 .add(2, 2, 2) 159 .add(extREmemberPasswordCheckBox)))) 160 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 161 ); 162 layout.setVerticalGroup( 163 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 164 .add(layout.createSequentialGroup() 165 .add(headerLabel) 166 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 167 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 168 .add(rootsLabel) 169 .add(editButton) 170 .add(rootComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 171 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 172 .add(descLabel) 173 .add(15, 15, 15) 174 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 175 .add(pPaswordLabel) 176 .add(passwordTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 177 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 178 .add(internalSshRadioButton) 179 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 180 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 181 .add(extPasswordLabel5) 182 .add(extPasswordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 183 .add(extREmemberPasswordCheckBox)) 184 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 185 .add(proxyConfigurationButton) 186 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 187 .add(extSshRadioButton) 188 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 189 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 190 .add(extCommandLabel) 191 .add(browseButton) 192 .add(extCommandTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 193 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 194 .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 195 ); 196 197 getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RepositoryStep")); } 199 200 202 public void actionPerformed(java.awt.event.ActionEvent evt) { 203 if (evt.getSource() == browseButton) { 204 RepositoryPanel.this.browseButtonActionPerformed(evt); 205 } 206 } 208 private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) { File defaultDir = defaultWorkingDirectory(); 210 JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(RepositoryPanel.class, "ACSD_BrowseCommand"), defaultDir); 211 fileChooser.setDialogTitle(NbBundle.getMessage(RepositoryPanel.class, "LBL_BrowseCommand_Title")); 212 fileChooser.setMultiSelectionEnabled(false); 213 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 214 fileChooser.showDialog(this, NbBundle.getMessage(RepositoryPanel.class, "LBL_BrowseCommand_Approve")); 215 File f = fileChooser.getSelectedFile(); 216 if (f != null) { 217 extCommandTextField.setText(f.getAbsolutePath()); 218 } 219 } 221 private File defaultWorkingDirectory() { 222 File defaultDir = null; 223 String current = extCommandTextField.getText(); 224 if (current != null && !(current.trim().equals(""))) { File currentFile = new File (current); 226 while (currentFile != null && currentFile.exists() == false) { 227 currentFile = currentFile.getParentFile(); 228 } 229 if (currentFile != null) { 230 if (currentFile.isFile()) { 231 defaultDir = currentFile.getParentFile(); 232 } else { 233 defaultDir = currentFile; 234 } 235 } 236 } 237 238 if (defaultDir == null) { 239 defaultDir = new File (System.getProperty("user.home")); } 241 242 return defaultDir; 243 } 244 245 final javax.swing.JButton browseButton = new javax.swing.JButton (); 247 final javax.swing.JLabel descLabel = new javax.swing.JLabel (); 248 final javax.swing.JButton editButton = new javax.swing.JButton (); 249 final javax.swing.JLabel extCommandLabel = new javax.swing.JLabel (); 250 final javax.swing.JTextField extCommandTextField = new javax.swing.JTextField (); 251 final javax.swing.JPasswordField extPasswordField = new javax.swing.JPasswordField (); 252 final javax.swing.JLabel extPasswordLabel5 = new javax.swing.JLabel (); 253 final javax.swing.JCheckBox extREmemberPasswordCheckBox = new javax.swing.JCheckBox (); 254 final javax.swing.JRadioButton extSshRadioButton = new javax.swing.JRadioButton (); 255 final javax.swing.JLabel headerLabel = new javax.swing.JLabel (); 256 final javax.swing.JRadioButton internalSshRadioButton = new javax.swing.JRadioButton (); 257 final javax.swing.JPanel jPanel1 = new javax.swing.JPanel (); 258 final javax.swing.JLabel pPaswordLabel = new javax.swing.JLabel (); 259 final javax.swing.JPasswordField passwordTextField = new javax.swing.JPasswordField (); 260 final javax.swing.JButton proxyConfigurationButton = new javax.swing.JButton (); 261 final javax.swing.JComboBox rootComboBox = new javax.swing.JComboBox (); 262 final javax.swing.JLabel rootsLabel = new javax.swing.JLabel (); 263 final javax.swing.ButtonGroup sshButtonGroup = new javax.swing.ButtonGroup (); 264 266 } 267 | Popular Tags |