KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > ui > wizards > RepositoryPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 JavaDoc;
30 import java.awt.event.ActionListener JavaDoc;
31 import java.io.File JavaDoc;
32 import java.util.*;
33
34 /**
35  * UI for remote CVS repository selection. Components
36  * are dynamically hidden.
37  *
38  * @author Petr Kuzel
39  */

40 final class RepositoryPanel extends javax.swing.JPanel JavaDoc implements ActionListener JavaDoc {
41
42     /** Creates new form ProxyPanel */
43     public RepositoryPanel() {
44         initComponents();
45     }
46
47     /** This method is called from within the constructor to
48      * initialize the form.
49      * WARNING: Do NOT modify this code. The content of this method is
50      * always regenerated by the Form Editor.
51      */

52     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
53
private void initComponents() {
54
55         setName(org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK0006")); // NOI18N
56

57         java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle"); // NOI18N
58
org.openide.awt.Mnemonics.setLocalizedText(headerLabel, bundle.getString("BK0001")); // NOI18N
59

60         rootsLabel.setLabelFor(rootComboBox);
61         org.openide.awt.Mnemonics.setLocalizedText(rootsLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK0002")); // NOI18N
62

63         org.openide.awt.Mnemonics.setLocalizedText(descLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK2018")); // NOI18N
64

65         pPaswordLabel.setLabelFor(passwordTextField);
66         org.openide.awt.Mnemonics.setLocalizedText(pPaswordLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK0003")); // NOI18N
67
pPaswordLabel.setToolTipText(bundle.getString("TT_PserverPassword")); // NOI18N
68

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")); // NOI18N
74
internalSshRadioButton.setToolTipText(bundle.getString("TT_UseInternalSSH")); // NOI18N
75
internalSshRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
76         internalSshRadioButton.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
77
78         extPasswordLabel5.setLabelFor(extPasswordField);
79         org.openide.awt.Mnemonics.setLocalizedText(extPasswordLabel5, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1011")); // NOI18N
80
extPasswordLabel5.setToolTipText(bundle.getString("TT_SSHPassword")); // NOI18N
81

82         extPasswordField.setColumns(12);
83
84         org.openide.awt.Mnemonics.setLocalizedText(extREmemberPasswordCheckBox, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1012")); // NOI18N
85
extREmemberPasswordCheckBox.setToolTipText(bundle.getString("TT_RememberPassword")); // NOI18N
86

87         org.openide.awt.Mnemonics.setLocalizedText(proxyConfigurationButton, bundle.getString("BK0005")); // NOI18N
88
proxyConfigurationButton.setToolTipText(bundle.getString("TT_ProxyConfig")); // NOI18N
89

90         sshButtonGroup.add(extSshRadioButton);
91         org.openide.awt.Mnemonics.setLocalizedText(extSshRadioButton, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1101")); // NOI18N
92
extSshRadioButton.setToolTipText(bundle.getString("TT_UseExternal")); // NOI18N
93
extSshRadioButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
94         extSshRadioButton.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
95
96         extCommandLabel.setLabelFor(extCommandTextField);
97         org.openide.awt.Mnemonics.setLocalizedText(extCommandLabel, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1013")); // NOI18N
98
extCommandLabel.setToolTipText(bundle.getString("TT_ExternalCommand")); // NOI18N
99

100         extCommandTextField.setMinimumSize(new java.awt.Dimension JavaDoc(80, 20));
101
102         org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "LBL_RepositoryPanel_Command_Browse")); // NOI18N
103
browseButton.addActionListener(this);
104
105         rootComboBox.setEditable(true);
106         rootComboBox.setMinimumSize(new java.awt.Dimension JavaDoc(80, 20));
107
108         org.openide.awt.Mnemonics.setLocalizedText(editButton, org.openide.util.NbBundle.getMessage(RepositoryPanel.class, "BK1105")); // NOI18N
109
editButton.setToolTipText(bundle.getString("TT_EditFields")); // NOI18N
110

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")); // NOI18N
198
}
199
200     // Code for dispatching events from components to event handlers.
201

202     public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
203         if (evt.getSource() == browseButton) {
204             RepositoryPanel.this.browseButtonActionPerformed(evt);
205         }
206     }// </editor-fold>//GEN-END:initComponents
207

208     private void browseButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseButtonActionPerformed
209
File JavaDoc 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 JavaDoc f = fileChooser.getSelectedFile();
216         if (f != null) {
217             extCommandTextField.setText(f.getAbsolutePath());
218         }
219     }//GEN-LAST:event_browseButtonActionPerformed
220

221     private File JavaDoc defaultWorkingDirectory() {
222         File JavaDoc defaultDir = null;
223         String JavaDoc current = extCommandTextField.getText();
224         if (current != null && !(current.trim().equals(""))) { // NOI18N
225
File JavaDoc currentFile = new File JavaDoc(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 JavaDoc(System.getProperty("user.home")); // NOI18N
240
}
241
242         return defaultDir;
243     }
244     
245     // Variables declaration - do not modify//GEN-BEGIN:variables
246
final javax.swing.JButton JavaDoc browseButton = new javax.swing.JButton JavaDoc();
247     final javax.swing.JLabel JavaDoc descLabel = new javax.swing.JLabel JavaDoc();
248     final javax.swing.JButton JavaDoc editButton = new javax.swing.JButton JavaDoc();
249     final javax.swing.JLabel JavaDoc extCommandLabel = new javax.swing.JLabel JavaDoc();
250     final javax.swing.JTextField JavaDoc extCommandTextField = new javax.swing.JTextField JavaDoc();
251     final javax.swing.JPasswordField JavaDoc extPasswordField = new javax.swing.JPasswordField JavaDoc();
252     final javax.swing.JLabel JavaDoc extPasswordLabel5 = new javax.swing.JLabel JavaDoc();
253     final javax.swing.JCheckBox JavaDoc extREmemberPasswordCheckBox = new javax.swing.JCheckBox JavaDoc();
254     final javax.swing.JRadioButton JavaDoc extSshRadioButton = new javax.swing.JRadioButton JavaDoc();
255     final javax.swing.JLabel JavaDoc headerLabel = new javax.swing.JLabel JavaDoc();
256     final javax.swing.JRadioButton JavaDoc internalSshRadioButton = new javax.swing.JRadioButton JavaDoc();
257     final javax.swing.JPanel JavaDoc jPanel1 = new javax.swing.JPanel JavaDoc();
258     final javax.swing.JLabel JavaDoc pPaswordLabel = new javax.swing.JLabel JavaDoc();
259     final javax.swing.JPasswordField JavaDoc passwordTextField = new javax.swing.JPasswordField JavaDoc();
260     final javax.swing.JButton JavaDoc proxyConfigurationButton = new javax.swing.JButton JavaDoc();
261     final javax.swing.JComboBox JavaDoc rootComboBox = new javax.swing.JComboBox JavaDoc();
262     final javax.swing.JLabel JavaDoc rootsLabel = new javax.swing.JLabel JavaDoc();
263     final javax.swing.ButtonGroup JavaDoc sshButtonGroup = new javax.swing.ButtonGroup JavaDoc();
264     // End of variables declaration//GEN-END:variables
265

266 }
267
Popular Tags