KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > projectimport > jbuilder > ui > JBWizardPanel


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.projectimport.jbuilder.ui;
21 import java.awt.Color JavaDoc;
22 import java.io.File JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import javax.swing.JFileChooser JavaDoc;
26 import javax.swing.JTextField JavaDoc;
27 import javax.swing.SwingUtilities JavaDoc;
28 import javax.swing.UIManager JavaDoc;
29 import javax.swing.event.DocumentEvent JavaDoc;
30 import javax.swing.event.DocumentListener JavaDoc;
31 import javax.swing.filechooser.FileFilter JavaDoc;
32 import org.netbeans.api.project.ProjectManager;
33 import org.netbeans.modules.projectimport.j2seimport.AbstractProject;
34 import org.netbeans.modules.projectimport.j2seimport.ui.BasicWizardIterator;
35 import org.netbeans.modules.projectimport.jbuilder.parsing.ProjectBuilder;
36 import org.netbeans.modules.projectimport.jbuilder.parsing.UserLibrarySupport;
37 import org.openide.WizardDescriptor;
38 import org.openide.filesystems.FileUtil;
39 import org.openide.util.HelpCtx;
40 import org.openide.util.NbBundle;
41 import org.openide.util.RequestProcessor;
42
43
44 /**
45  * Represent "Selection" step(panel) in the JBuilder importer wizard.
46  *
47  * @author Radek Matous
48  */

49 public final class JBWizardPanel extends BasicWizardIterator.Panel {
50     private JBWizardData data = null;
51     
52     private boolean projectFileValid = false;
53     private Collection JavaDoc allPrjDefs = null;
54     private DocumentListener JavaDoc documentListener;
55     
56     /** Creates new form ProjectSelectionPanel */
57     JBWizardPanel(WizardDescriptor wiz, JBWizardData data) {
58         super(wiz);
59         this.data = data;
60         initComponents();
61         initAccessibility();
62     }
63     
64     private static String JavaDoc getMessage(String JavaDoc key) {
65         return NbBundle.getMessage(JBWizardPanel.class, key);
66     }
67     
68     private void initAccessibility() {
69         prjFileBrowse.getAccessibleContext().setAccessibleDescription(getMessage("ACS_BrowseProjectFile"));
70         prjFileTextField.getAccessibleContext().setAccessibleDescription(getMessage("ACS_Project"));
71         destDirTextField.getAccessibleContext().setAccessibleDescription(getMessage("ACS_ProjectDestination"));
72         userHomeTextField.getAccessibleContext().setAccessibleDescription(getMessage("ACS_UserHome"));
73         userHomeBrowse.getAccessibleContext().setAccessibleDescription(getMessage("ACS_BrowseUserHome"));
74         destDirBrowse.getAccessibleContext().setAccessibleDescription(getMessage("ACS_BrowseDestDir"));
75         jbDirBrowse.getAccessibleContext().setAccessibleDescription(getMessage("ACS_BrowseInstallDir"));
76         jbDirTextField.getAccessibleContext().setAccessibleDescription(getMessage("ACS_InstallDir"));
77     }
78         
79     private void addListeners() {
80         if (documentListener == null) {
81             documentListener = new DocumentListener JavaDoc() {
82                 public void removeUpdate(DocumentEvent JavaDoc e) { insertUpdate(null); }
83                 public void changedUpdate(DocumentEvent JavaDoc e) { insertUpdate(null); }
84                 public void insertUpdate(DocumentEvent JavaDoc e) { fieldUpdate(); }
85             };
86             
87             prjFileTextField.getDocument().addDocumentListener(documentListener);
88             destDirTextField.getDocument().addDocumentListener(documentListener);
89             jbDirTextField.getDocument().addDocumentListener(documentListener);
90             userHomeTextField.getDocument().addDocumentListener(documentListener);
91         }
92     }
93     
94     private void removeListeners() {
95         if (documentListener != null) {
96             prjFileTextField.getDocument().removeDocumentListener(documentListener);
97             destDirTextField.getDocument().removeDocumentListener(documentListener);
98             jbDirTextField.getDocument().removeDocumentListener(documentListener);
99             userHomeTextField.getDocument().removeDocumentListener(documentListener);
100         }
101     }
102     
103     public void addNotify() {
104         super.addNotify();
105         addListeners();
106         fieldUpdate();
107         Color JavaDoc lblBgr = UIManager.getColor("Label.background"); // NOI18N
108
prjFileTextArea.setBackground(lblBgr);
109         jSpanTextArea.setBackground(lblBgr);
110     }
111     
112     public void removeNotify() {
113         super.removeNotify();
114         removeListeners();
115     }
116             
117     private void changedInstallDir() {
118         File JavaDoc libFolder = null;
119         if (UserLibrarySupport.getInstallDirLib() == null) {
120             File JavaDoc installDir = getInstallationDir();
121             if (installDir.exists()) {
122                 if (!installDir.getName().equals("lib")) { //NOI18N
123
libFolder = new File JavaDoc(installDir,"lib");//NOI18N
124
libFolder = (libFolder.exists()) ? libFolder : null;
125                 }
126             }
127         }
128         
129         if (libFolder != null) {
130             Iterator JavaDoc it = Utils.getInvalidUserLibraries(allPrjDefs).iterator();
131             while (it.hasNext()) {
132                 AbstractProject.UserLibrary uLib = (AbstractProject.UserLibrary)it.next();
133                 UserLibrarySupport usInstance;
134                 
135                 if (UserLibrarySupport.getInstance(uLib.getName(), libFolder) != null) {
136                     UserLibrarySupport.setInstallDirLib(libFolder);
137                     if (projectFileValid) {
138                         parseProjectFile(getProjectFile());
139                     }
140                     break;
141                 }
142             }
143         }
144     }
145     
146     private void fieldUpdate() {
147         String JavaDoc errorMessage = null;
148         boolean isUserHomeInvalid = false;
149         File JavaDoc destFolder = (isEmpty(destDirTextField)) ? null : getFile(destDirTextField);
150         boolean isDesttDirValid = false;
151         for(File JavaDoc tempFolder = destFolder; tempFolder != null ; tempFolder = tempFolder.getParentFile()) {
152             if (tempFolder == null || tempFolder.isFile()) {
153                 break;
154             }
155             if (tempFolder.canWrite()) {
156                 isDesttDirValid = true;
157                 break;
158             }
159         }
160         if (!isDesttDirValid) {
161             errorMessage = NbBundle.getMessage(JBWizardPanel.class, "MSG_NotRegularDestinationDir",destDirTextField.getText()); // NOI18N;
162
}
163         File JavaDoc projectFile = (isEmpty(prjFileTextField)) ? null : getFile(prjFileTextField);
164         boolean unresolvedReferences = Utils.checkNotFoundUserLibraries(allPrjDefs);
165         if (projectFile != null && ProjectBuilder.isProjectFile(projectFile)) {
166             if (!projectFileValid) {
167                 projectFileValid = true;
168                 parseProjectFile(projectFile);
169                 return;
170             } else {
171                 if (unresolvedReferences) {
172                     File JavaDoc userHomeDir = UserLibrarySupport.getUserHomeLib();
173                     File JavaDoc f = getFile(userHomeTextField);
174                     if (isDesttDirValid) {
175                         if (!isEmpty(userHomeTextField) && f.exists() && !f.equals(userHomeDir)) {
176                             UserLibrarySupport.setUserHomeLib(f);
177                             parseProjectFile(projectFile);
178                             return;
179                         } else if (isEmpty(userHomeTextField) || !f.exists() || f.getName().indexOf("jbuilder") == -1 ) {
180                             //errorMessage = NbBundle.getMessage(JBWizardPanel.class, "MSG_NotRegularUserHome", userHomeTextField.getText()); // NOI18N
181
isUserHomeInvalid = true;
182                         } else if (jbDirTextField.isEnabled()) {
183                             changedInstallDir();
184                         }
185                     }
186                 }
187             }
188             enableAdditionalComponents(unresolvedReferences);
189         } else {
190             projectFileValid = false;
191             enableAdditionalComponents(false);
192             errorMessage = NbBundle.getMessage(JBWizardPanel.class, "MSG_NotRegularProject",prjFileTextField.getText()); // NOI18N;
193
}
194         
195         if (errorMessage == null) {
196             markValid();
197             if (jbDirTextField.isEnabled() || isUserHomeInvalid) {
198                 setWarning(getMessage("LBL_Warning"));
199             }
200         } else {
201             setError(errorMessage);
202         }
203     }
204     
205     protected String JavaDoc getPanelName() {
206         return NbBundle.getMessage(JBWizardPanel.class, "CTL_FirstStep");
207     }
208     
209     protected void storeToDataModel() {
210         removeListeners();
211         fieldUpdate();
212         
213         this.data.setDestinationDir(getFile(destDirTextField));
214         this.data.setProjectFile(getFile(prjFileTextField));
215         this.data.setProjectDefinition(this.allPrjDefs);
216         this.data.setIncludeDependencies((Utils.getDependencyErrors(allPrjDefs,getDestinationDir()) == null));
217     }
218     
219     protected void readFromDataModel() {
220         addListeners();
221         enableAdditionalComponents(false);
222         if (data.getDestinationDir() != null) {
223             destDirTextField.setText(data.getDestinationDir().getAbsolutePath());
224         } else {
225             destDirTextField.setText("");//NOPI18N
226
}
227         if (data.getProjectFile() != null) {
228             prjFileTextField.setText(data.getProjectFile().getAbsolutePath());
229         } else {
230             prjFileTextField.setText("");//NOPI18N
231
}
232         File JavaDoc uLib = UserLibrarySupport.getUserHomeLib();
233         if (uLib != null && uLib.exists()) {
234             userHomeTextField.setText(uLib.getAbsolutePath());
235         }
236         
237         File JavaDoc iLib = UserLibrarySupport.getInstallDirLib();
238         if (iLib != null && iLib.exists()) {
239             if (iLib.getName().equals("lib") && iLib.getParentFile() != null) {//NOI18N
240
iLib = iLib.getParentFile();
241             }
242             jbDirTextField.setText(iLib.getAbsolutePath());
243         }
244         
245         this.allPrjDefs = data.getProjectDefinition();
246     }
247     
248     protected HelpCtx getHelp() {
249         return new HelpCtx(JBWizardPanel.class);
250     }
251     
252     private void parseProjectFile(final File JavaDoc projectFile) {
253         RequestProcessor.getDefault().post(new Runnable JavaDoc() {
254             public void run() {
255                 ProjectManager.mutex().writeAccess(new Runnable JavaDoc() {
256                     public void run() {
257                         Collection JavaDoc result = ProjectBuilder.buildProjectModels(projectFile);
258                         if (result != null && result.size() > 0 && projectFileValid &&
259                                 projectFile.equals(getFile(prjFileTextField))) {
260                             allPrjDefs = result;
261                             SwingUtilities.invokeLater(new Runnable JavaDoc() {
262                                 public void run() {
263                                     fieldUpdate();
264                                 }
265                             });
266                         }
267                     }
268                 });
269             }
270         });
271     }
272                     
273     private void enableAdditionalComponents(boolean enable) {
274         jbDirTextField.setEnabled(enable);
275         jbDirBrowse.setEnabled(enable);
276         jbDirLabel.setEnabled(enable);
277     }
278     
279     public static File JavaDoc getFile(JTextField JavaDoc textField) {
280         return new File JavaDoc(textField.getText().trim());
281     }
282     
283     public static boolean isEmpty(JTextField JavaDoc textField) {
284         return textField.getText().trim().length() == 0;
285     }
286     
287     public File JavaDoc getDestinationDir() {
288         return getFile(destDirTextField);
289     }
290     
291     
292     public File JavaDoc getProjectFile() {
293         return getFile(prjFileTextField);
294     }
295     
296     public File JavaDoc getInstallationDir() {
297         return getFile(jbDirTextField);
298     }
299     
300     private void browseActionPerformed(JTextField JavaDoc field, boolean fileHidingEnabled) {
301         String JavaDoc initValue = field.getText().trim();
302         JFileChooser JavaDoc chooser = new JFileChooser JavaDoc(initValue);
303         FileUtil.preventFileChooserSymlinkTraversal(chooser, chooser.getCurrentDirectory());
304         chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
305         chooser.setFileHidingEnabled(fileHidingEnabled);
306         int ret = chooser.showOpenDialog(this);
307         if (ret == JFileChooser.APPROVE_OPTION) {
308             field.setText(chooser.getSelectedFile().getAbsolutePath());
309         }
310     }
311     
312     /** This method is called from within the constructor to
313      * initialize the form.
314      * WARNING: Do NOT modify this code. The content of this method is
315      * always regenerated by the Form Editor.
316      */

317     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
318
private void initComponents() {
319         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
320
321         buttonGroup = new javax.swing.ButtonGroup JavaDoc();
322         prjFileTextField = new javax.swing.JTextField JavaDoc();
323         prjFileBrowse = new javax.swing.JButton JavaDoc();
324         prjFileLabel = new javax.swing.JLabel JavaDoc();
325         destDirLabel = new javax.swing.JLabel JavaDoc();
326         destDirTextField = new javax.swing.JTextField JavaDoc();
327         destDirBrowse = new javax.swing.JButton JavaDoc();
328         prjFileTextArea = new javax.swing.JTextArea JavaDoc();
329         jbDirTextField = new javax.swing.JTextField JavaDoc();
330         jbDirBrowse = new javax.swing.JButton JavaDoc();
331         jSpanTextArea = new javax.swing.JTextArea JavaDoc();
332         jbDirLabel = new javax.swing.JLabel JavaDoc();
333         userHomeLabel = new javax.swing.JLabel JavaDoc();
334         userHomeTextField = new javax.swing.JTextField JavaDoc();
335         userHomeBrowse = new javax.swing.JButton JavaDoc();
336
337         setLayout(new java.awt.GridBagLayout JavaDoc());
338
339         setPreferredSize(new java.awt.Dimension JavaDoc(500, 380));
340         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
341         gridBagConstraints.gridx = 1;
342         gridBagConstraints.gridy = 1;
343         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
344         gridBagConstraints.weightx = 1.0;
345         add(prjFileTextField, gridBagConstraints);
346
347         org.openide.awt.Mnemonics.setLocalizedText(prjFileBrowse, java.util.ResourceBundle.getBundle("org/netbeans/modules/projectimport/jbuilder/ui/Bundle").getString("CTL_BrowseProjectFile"));
348         prjFileBrowse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
349             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
350                 prjFileBrowseActionPerformed(evt);
351             }
352         });
353
354         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
355         gridBagConstraints.gridx = 2;
356         gridBagConstraints.gridy = 1;
357         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 0, 10);
358         add(prjFileBrowse, gridBagConstraints);
359
360         prjFileLabel.setLabelFor(prjFileTextField);
361         org.openide.awt.Mnemonics.setLocalizedText(prjFileLabel, org.openide.util.NbBundle.getMessage(JBWizardPanel.class, "LBL_Project"));
362         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
363         gridBagConstraints.gridx = 0;
364         gridBagConstraints.gridy = 1;
365         gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
366         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
367         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
368         add(prjFileLabel, gridBagConstraints);
369
370         destDirLabel.setLabelFor(destDirTextField);
371         org.openide.awt.Mnemonics.setLocalizedText(destDirLabel, org.openide.util.NbBundle.getMessage(JBWizardPanel.class, "LBL_ProjectDestination"));
372         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
373         gridBagConstraints.gridx = 0;
374         gridBagConstraints.gridy = 2;
375         gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
376         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
377         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
378         add(destDirLabel, gridBagConstraints);
379
380         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
381         gridBagConstraints.gridx = 1;
382         gridBagConstraints.gridy = 2;
383         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
384         gridBagConstraints.weightx = 1.0;
385         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
386         add(destDirTextField, gridBagConstraints);
387
388         org.openide.awt.Mnemonics.setLocalizedText(destDirBrowse, java.util.ResourceBundle.getBundle("org/netbeans/modules/projectimport/jbuilder/ui/Bundle").getString("CTL_BrowseDestDir"));
389         destDirBrowse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
390             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
391                 destDirBrowseActionPerformed(evt);
392             }
393         });
394
395         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
396         gridBagConstraints.gridx = 2;
397         gridBagConstraints.gridy = 2;
398         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 11, 0, 10);
399         add(destDirBrowse, gridBagConstraints);
400
401         prjFileTextArea.setEditable(false);
402         prjFileTextArea.setLineWrap(true);
403         prjFileTextArea.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/projectimport/jbuilder/ui/Bundle").getString("LBL_SpecifyProjectDescription"));
404         prjFileTextArea.setWrapStyleWord(true);
405         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
406         gridBagConstraints.gridx = 0;
407         gridBagConstraints.gridy = 0;
408         gridBagConstraints.gridwidth = 3;
409         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
410         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 24, 0);
411         add(prjFileTextArea, gridBagConstraints);
412
413         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
414         gridBagConstraints.gridx = 1;
415         gridBagConstraints.gridy = 4;
416         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
417         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
418         gridBagConstraints.weightx = 1.0;
419         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
420         add(jbDirTextField, gridBagConstraints);
421
422         org.openide.awt.Mnemonics.setLocalizedText(jbDirBrowse, java.util.ResourceBundle.getBundle("org/netbeans/modules/projectimport/jbuilder/ui/Bundle").getString("CTL_BrowseInstallDir"));
423         jbDirBrowse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
424             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
425                 jbDirBrowseActionPerformed(evt);
426             }
427         });
428
429         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
430         gridBagConstraints.gridx = 2;
431         gridBagConstraints.gridy = 4;
432         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 11, 0, 10);
433         add(jbDirBrowse, gridBagConstraints);
434
435         jSpanTextArea.setEditable(false);
436         jSpanTextArea.setLineWrap(true);
437         jSpanTextArea.setWrapStyleWord(true);
438         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
439         gridBagConstraints.gridx = 0;
440         gridBagConstraints.gridy = 5;
441         gridBagConstraints.gridwidth = 3;
442         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
443         gridBagConstraints.weighty = 1.0;
444         gridBagConstraints.insets = new java.awt.Insets JavaDoc(24, 0, 10, 0);
445         add(jSpanTextArea, gridBagConstraints);
446
447         jbDirLabel.setLabelFor(jbDirTextField);
448         org.openide.awt.Mnemonics.setLocalizedText(jbDirLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/projectimport/jbuilder/ui/Bundle").getString("LBL_InstallDir"));
449         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
450         gridBagConstraints.gridx = 0;
451         gridBagConstraints.gridy = 4;
452         gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
453         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
454         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
455         add(jbDirLabel, gridBagConstraints);
456
457         userHomeLabel.setLabelFor(userHomeTextField);
458         org.openide.awt.Mnemonics.setLocalizedText(userHomeLabel, org.openide.util.NbBundle.getMessage(JBWizardPanel.class, "LBL_UserHome"));
459         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
460         gridBagConstraints.gridx = 0;
461         gridBagConstraints.gridy = 3;
462         gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
463         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
464         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
465         add(userHomeLabel, gridBagConstraints);
466
467         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
468         gridBagConstraints.gridx = 1;
469         gridBagConstraints.gridy = 3;
470         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
471         gridBagConstraints.weightx = 1.0;
472         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
473         add(userHomeTextField, gridBagConstraints);
474
475         org.openide.awt.Mnemonics.setLocalizedText(userHomeBrowse, java.util.ResourceBundle.getBundle("org/netbeans/modules/projectimport/jbuilder/ui/Bundle").getString("CTL_BrowseUserHome"));
476         userHomeBrowse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
477             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
478                 userHomeBrowseActionPerformed(evt);
479             }
480         });
481
482         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
483         gridBagConstraints.gridx = 2;
484         gridBagConstraints.gridy = 3;
485         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 11, 0, 10);
486         add(userHomeBrowse, gridBagConstraints);
487
488     }// </editor-fold>//GEN-END:initComponents
489

490     private void userHomeBrowseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_userHomeBrowseActionPerformed
491
browseActionPerformed(userHomeTextField, false);
492     }//GEN-LAST:event_userHomeBrowseActionPerformed
493

494     private void jbDirBrowseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jbDirBrowseActionPerformed
495
browseActionPerformed(jbDirTextField, true);
496     }//GEN-LAST:event_jbDirBrowseActionPerformed
497

498     private void destDirBrowseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_destDirBrowseActionPerformed
499
browseActionPerformed(destDirTextField, true);
500     }//GEN-LAST:event_destDirBrowseActionPerformed
501

502     
503     private void prjFileBrowseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_prjFileBrowseActionPerformed
504
String JavaDoc initValue = prjFileTextField.getText().trim();
505         JFileChooser JavaDoc chooser = new JFileChooser JavaDoc(initValue);
506         chooser.setFileFilter(new FileFilter JavaDoc(){
507             public boolean accept(File JavaDoc f) {
508                 return f.isDirectory() || ProjectBuilder.isProjectFile(f);
509             }
510             
511             public String JavaDoc getDescription() {
512                 return NbBundle.getMessage(JBWizardPanel.class, "ProjectFileDescription"); // NOI18N
513
}
514             
515         });
516         FileUtil.preventFileChooserSymlinkTraversal(chooser, chooser.getCurrentDirectory());
517         chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
518         int ret = chooser.showOpenDialog(this);
519         if (ret == JFileChooser.APPROVE_OPTION) {
520             prjFileTextField.setText(chooser.getSelectedFile().getAbsolutePath());
521         }
522     }//GEN-LAST:event_prjFileBrowseActionPerformed
523

524     
525     
526     // Variables declaration - do not modify//GEN-BEGIN:variables
527
private javax.swing.ButtonGroup JavaDoc buttonGroup;
528     private javax.swing.JButton JavaDoc destDirBrowse;
529     private javax.swing.JLabel JavaDoc destDirLabel;
530     private javax.swing.JTextField JavaDoc destDirTextField;
531     private javax.swing.JTextArea JavaDoc jSpanTextArea;
532     private javax.swing.JButton JavaDoc jbDirBrowse;
533     private javax.swing.JLabel JavaDoc jbDirLabel;
534     private javax.swing.JTextField JavaDoc jbDirTextField;
535     private javax.swing.JButton JavaDoc prjFileBrowse;
536     private javax.swing.JLabel JavaDoc prjFileLabel;
537     private javax.swing.JTextArea JavaDoc prjFileTextArea;
538     private javax.swing.JTextField JavaDoc prjFileTextField;
539     private javax.swing.JButton JavaDoc userHomeBrowse;
540     private javax.swing.JLabel JavaDoc userHomeLabel;
541     private javax.swing.JTextField JavaDoc userHomeTextField;
542     // End of variables declaration//GEN-END:variables
543
}
544
Popular Tags