KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ant > freeform > ui > BasicProjectInfoPanel


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.ant.freeform.ui;
21
22 import java.io.File JavaDoc;
23 import java.text.MessageFormat JavaDoc;
24 import javax.swing.JFileChooser JavaDoc;
25 import javax.swing.event.ChangeListener JavaDoc;
26 import javax.swing.event.DocumentEvent JavaDoc;
27 import javax.swing.event.DocumentListener JavaDoc;
28 import org.netbeans.api.project.FileOwnerQuery;
29 import org.netbeans.api.project.Project;
30 import org.netbeans.api.project.ProjectInformation;
31 import org.netbeans.modules.ant.freeform.Util;
32 import org.netbeans.spi.project.ui.support.ProjectChooser;
33 import org.openide.filesystems.FileObject;
34 import org.openide.filesystems.FileUtil;
35 import org.openide.util.HelpCtx;
36 import org.openide.util.NbBundle;
37
38 /**
39  * @author David Konecny
40  */

41 public class BasicProjectInfoPanel extends javax.swing.JPanel JavaDoc implements HelpCtx.Provider{
42     
43     private DocumentListener JavaDoc documentListener;
44     private ChangeListener JavaDoc listener;
45     /** Was antScript property edited by user? */
46     private boolean antScriptTouched = false;
47     /** Was projectFolder property edited by user? */
48     private boolean projectFolderTouched = false;
49     /** Was projectName property edited by user? */
50     private boolean projectNameTouched = false;
51     /** Is choosen Ant script a valid one? */
52     private boolean antScriptValidityChecked;
53     
54     public BasicProjectInfoPanel(String JavaDoc projectLocation, String JavaDoc antScript, String JavaDoc projectName, String JavaDoc projectFolder,
55             ChangeListener JavaDoc listener) {
56         initComponents();
57         this.projectLocation.setText(projectLocation);
58         this.antScript.setText(antScript);
59         this.projectName.setText(projectName);
60         this.projectFolder.setText(projectFolder);
61         this.listener = listener;
62         documentListener = new DocumentListener JavaDoc() {
63             public void insertUpdate(DocumentEvent JavaDoc e) {
64                 update(e);
65             }
66
67             public void removeUpdate(DocumentEvent JavaDoc e) {
68                 update(e);
69             }
70
71             public void changedUpdate(DocumentEvent JavaDoc e) {
72                 update(e);
73             }
74         };
75         this.projectLocation.getDocument().addDocumentListener(documentListener);
76         this.antScript.getDocument().addDocumentListener(documentListener);
77         this.projectName.getDocument().addDocumentListener(documentListener);
78         this.projectFolder.getDocument().addDocumentListener(documentListener);
79     }
80
81     public HelpCtx getHelpCtx() {
82         return new HelpCtx(BasicProjectInfoPanel.class);
83     }
84
85     public File JavaDoc getProjectLocation() {
86         return getAsFile(projectLocation.getText());
87     }
88
89     public File JavaDoc getAntScript() {
90         return getAsFile(antScript.getText());
91     }
92
93     public String JavaDoc getProjectName() {
94         return projectName.getText();
95     }
96
97     public File JavaDoc getProjectFolder() {
98         return getAsFile(projectFolder.getText());
99     }
100
101     public Boolean JavaDoc getMainProject() {
102         return Boolean.valueOf(mainProject.isSelected());
103     }
104
105     public String JavaDoc getError() {
106         if (projectLocation.getText().length() == 0) {
107             return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_1");
108         }
109         if (!getProjectLocation().exists()) {
110             return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_2");
111         }
112         if (antScript.getText().length() == 0) {
113             return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_3");
114         }
115         if (!getAntScript().exists()) {
116             return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_4");
117         }
118         if (!antScriptValidityChecked) {
119             FileObject fo = FileUtil.toFileObject(getAntScript());
120             if (fo != null && Util.getAntScriptTargetNames(fo) != null) {
121                 antScriptValidityChecked = true;
122             } else {
123                 return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_5");
124             }
125         }
126         if (getProjectName().length() == 0) {
127             return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_6");
128         }
129         if (projectFolder.getText().length() == 0) {
130             return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_7");
131         }
132         if (getAsFile(projectFolder.getText() + File.separatorChar + "nbproject").exists()){ // NOI18N
133
return org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_8");
134         }
135         
136         Project p;
137         File JavaDoc projectFolder = getProjectFolder();
138         
139         assert projectFolder != null;
140         
141         if ((p = FileOwnerQuery.getOwner(projectFolder.toURI())) != null && projectFolder.equals(FileUtil.toFile(p.getProjectDirectory()))) {
142             ProjectInformation pi = p.getLookup().lookup(ProjectInformation.class);
143             String JavaDoc displayName = (pi == null ? "" : pi.getDisplayName()); //NOI18N
144
return MessageFormat.format(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_9"),
145                 new Object JavaDoc[] {displayName});
146         }
147         
148         File JavaDoc projectLocation = getProjectLocation();
149         
150         assert projectLocation != null;
151         
152         if ((p = FileOwnerQuery.getOwner(projectLocation.toURI())) != null && projectLocation.equals(FileUtil.toFile(p.getProjectDirectory()))) {
153             ProjectInformation pi = p.getLookup().lookup(ProjectInformation.class);
154             String JavaDoc displayName = (pi == null ? "" : pi.getDisplayName()); //NOI18N
155
return MessageFormat.format(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_Error_10"),
156                 new Object JavaDoc[] {displayName});
157         }
158         return null;
159     }
160
161     private File JavaDoc getAsFile(String JavaDoc filename) {
162         return FileUtil.normalizeFile(new File JavaDoc(filename));
163     }
164
165     private boolean ignoreEvent = false;
166
167     private void update(DocumentEvent JavaDoc e) {
168         if (ignoreEvent) {
169             // side-effect of changes done in this handler
170
return;
171         }
172
173         // start ignoring events
174
ignoreEvent = true;
175
176         if (projectLocation.getDocument() == e.getDocument()) {
177             antScriptValidityChecked = false;
178             updateAntScriptLocation();
179             updateProjectName();
180             updateProjectFolder();
181         }
182         if (antScript.getDocument() == e.getDocument()) {
183             antScriptValidityChecked = false;
184             updateProjectName();
185         }
186
187         // stop ignoring events
188
ignoreEvent = false;
189
190         if (projectFolder.getDocument() == e.getDocument()) {
191             projectFolderTouched = !"".equals(projectFolder.getText());
192         }
193         if (antScript.getDocument() == e.getDocument()) {
194             antScriptTouched = !"".equals(antScript.getText());
195         }
196         if (projectName.getDocument() == e.getDocument()) {
197             projectNameTouched = !"".equals(projectName.getText());
198         }
199
200         listener.stateChanged(null);
201     }
202
203     private boolean isValidProjectLocation() {
204         return (getProjectLocation().exists() && getProjectLocation().isDirectory() &&
205                 projectLocation.getText().length() > 0 && (!projectLocation.getText().endsWith(":"))); // NOI18N
206
}
207
208     private void updateAntScriptLocation() {
209         if (antScriptTouched) {
210             return;
211         }
212         if (isValidProjectLocation()) {
213             File JavaDoc as = new File JavaDoc(getProjectLocation().getAbsolutePath() + File.separatorChar + "build.xml"); // NOI18N
214
if (as.exists()) {
215                 antScript.setText(as.getAbsolutePath());
216                 return;
217             }
218         }
219         antScript.setText(""); // NOI18N
220
}
221
222     private void updateProjectName() {
223         if (projectNameTouched) {
224             return;
225         }
226         if (getAntScript().exists()) {
227             File JavaDoc as = new File JavaDoc(getAntScript().getAbsolutePath());
228             if (as.exists()) {
229                 FileObject fo = FileUtil.toFileObject(as);
230                 assert fo != null : as;
231                 String JavaDoc name = Util.getAntScriptName(fo);
232                 if (name != null) {
233                     projectName.setText(name);
234                     return;
235                 }
236             }
237         }
238         projectName.setText(""); // NOI18N
239
}
240
241     private void updateProjectFolder() {
242         if (projectFolderTouched) {
243             return;
244         }
245         if (isValidProjectLocation()) {
246             projectFolder.setText(getProjectLocation().getAbsolutePath());
247         } else {
248             projectFolder.setText(""); // NOI18N
249
}
250     }
251
252     /**
253      * This method is called from within the constructor to
254      * initialize the form.
255      * WARNING: Do NOT modify this code. The content of this method is
256      * always regenerated by the Form Editor.
257      */

258     private void initComponents() {//GEN-BEGIN:initComponents
259
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
260
261         jLabel1 = new javax.swing.JLabel JavaDoc();
262         jLabel2 = new javax.swing.JLabel JavaDoc();
263         jLabel3 = new javax.swing.JLabel JavaDoc();
264         jLabel4 = new javax.swing.JLabel JavaDoc();
265         jLabel5 = new javax.swing.JLabel JavaDoc();
266         antScript = new javax.swing.JTextField JavaDoc();
267         projectName = new javax.swing.JTextField JavaDoc();
268         projectFolder = new javax.swing.JTextField JavaDoc();
269         browseAntScript = new javax.swing.JButton JavaDoc();
270         browseProjectFolder = new javax.swing.JButton JavaDoc();
271         projectLocation = new javax.swing.JTextField JavaDoc();
272         jLabel6 = new javax.swing.JLabel JavaDoc();
273         browseProjectLocation = new javax.swing.JButton JavaDoc();
274         jSeparator1 = new javax.swing.JSeparator JavaDoc();
275         mainProject = new javax.swing.JCheckBox JavaDoc();
276
277         FormListener formListener = new FormListener();
278
279         setLayout(new java.awt.GridBagLayout JavaDoc());
280
281         setPreferredSize(new java.awt.Dimension JavaDoc(323, 223));
282         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_jLabel1"));
283         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
284         gridBagConstraints.gridwidth = 3;
285         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
286         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 12, 0);
287         add(jLabel1, gridBagConstraints);
288         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_jLabel1"));
289
290         jLabel2.setLabelFor(antScript);
291         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_jLabel2"));
292         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
293         gridBagConstraints.gridx = 0;
294         gridBagConstraints.gridy = 2;
295         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
296         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
297         add(jLabel2, gridBagConstraints);
298         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_jLabel2"));
299
300         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_jLabel3"));
301         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
302         gridBagConstraints.gridx = 0;
303         gridBagConstraints.gridy = 3;
304         gridBagConstraints.gridwidth = 3;
305         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
306         gridBagConstraints.insets = new java.awt.Insets JavaDoc(24, 0, 12, 0);
307         add(jLabel3, gridBagConstraints);
308         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_jLabel3"));
309
310         jLabel4.setLabelFor(projectName);
311         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_jLabel4"));
312         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
313         gridBagConstraints.gridx = 0;
314         gridBagConstraints.gridy = 4;
315         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
316         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
317         add(jLabel4, gridBagConstraints);
318         jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_jLabel4"));
319
320         jLabel5.setLabelFor(projectFolder);
321         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_jLabel5"));
322         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
323         gridBagConstraints.gridx = 0;
324         gridBagConstraints.gridy = 5;
325         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
326         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
327         add(jLabel5, gridBagConstraints);
328         jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_jLabel5"));
329
330         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
331         gridBagConstraints.gridx = 1;
332         gridBagConstraints.gridy = 2;
333         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
334         gridBagConstraints.weightx = 1.0;
335         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
336         add(antScript, gridBagConstraints);
337
338         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
339         gridBagConstraints.gridx = 1;
340         gridBagConstraints.gridy = 4;
341         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
342         gridBagConstraints.weightx = 1.0;
343         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
344         add(projectName, gridBagConstraints);
345
346         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
347         gridBagConstraints.gridx = 1;
348         gridBagConstraints.gridy = 5;
349         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
350         gridBagConstraints.weightx = 1.0;
351         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
352         add(projectFolder, gridBagConstraints);
353
354         org.openide.awt.Mnemonics.setLocalizedText(browseAntScript, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "BTN_BasicProjectInfoPanel_browseAntScript"));
355         browseAntScript.addActionListener(formListener);
356
357         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
358         gridBagConstraints.gridx = 2;
359         gridBagConstraints.gridy = 2;
360         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
361         add(browseAntScript, gridBagConstraints);
362         browseAntScript.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_browseAntScript"));
363
364         org.openide.awt.Mnemonics.setLocalizedText(browseProjectFolder, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "BTN_BasicProjectInfoPanel_browseProjectFolder"));
365         browseProjectFolder.addActionListener(formListener);
366
367         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
368         gridBagConstraints.gridx = 2;
369         gridBagConstraints.gridy = 5;
370         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
371         add(browseProjectFolder, gridBagConstraints);
372         browseProjectFolder.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_browseProjectFolder"));
373
374         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
375         gridBagConstraints.gridx = 1;
376         gridBagConstraints.gridy = 1;
377         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
378         gridBagConstraints.weightx = 1.0;
379         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
380         add(projectLocation, gridBagConstraints);
381
382         jLabel6.setLabelFor(projectLocation);
383         org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_jLabel6"));
384         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
385         gridBagConstraints.gridx = 0;
386         gridBagConstraints.gridy = 1;
387         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
388         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
389         add(jLabel6, gridBagConstraints);
390         jLabel6.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_jLabel6"));
391
392         org.openide.awt.Mnemonics.setLocalizedText(browseProjectLocation, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "BTN_BasicProjectInfoPanel_browseProjectLocation"));
393         browseProjectLocation.addActionListener(formListener);
394
395         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
396         gridBagConstraints.gridx = 2;
397         gridBagConstraints.gridy = 1;
398         add(browseProjectLocation, gridBagConstraints);
399         browseProjectLocation.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_browseProjectLocation"));
400
401         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
402         gridBagConstraints.gridx = 0;
403         gridBagConstraints.gridy = 6;
404         gridBagConstraints.gridwidth = 3;
405         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
406         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 12, 0);
407         add(jSeparator1, gridBagConstraints);
408
409         mainProject.setSelected(true);
410         org.openide.awt.Mnemonics.setLocalizedText(mainProject, org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_BasicProjectInfoPanel_mainProject"));
411         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
412         gridBagConstraints.gridx = 0;
413         gridBagConstraints.gridy = 7;
414         gridBagConstraints.gridwidth = 3;
415         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
416         gridBagConstraints.weighty = 1.0;
417         add(mainProject, gridBagConstraints);
418         mainProject.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicProjectInfoPanel.class, "ACSD_BasicProjectInfoPanel_mainProject"));
419
420     }
421
422     // Code for dispatching events from components to event handlers.
423

424     private class FormListener implements java.awt.event.ActionListener JavaDoc {
425         public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
426             if (evt.getSource() == browseAntScript) {
427                 BasicProjectInfoPanel.this.browseAntScriptActionPerformed(evt);
428             }
429             else if (evt.getSource() == browseProjectFolder) {
430                 BasicProjectInfoPanel.this.browseProjectFolderActionPerformed(evt);
431             }
432             else if (evt.getSource() == browseProjectLocation) {
433                 BasicProjectInfoPanel.this.browseProjectLocationActionPerformed(evt);
434             }
435         }
436     }//GEN-END:initComponents
437

438     private void browseProjectLocationActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseProjectLocationActionPerformed
439
JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
440         FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
441         chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
442         if (projectLocation.getText().length() > 0 && getProjectLocation().exists()) {
443             chooser.setSelectedFile(getProjectLocation());
444         } else {
445             chooser.setSelectedFile(ProjectChooser.getProjectsFolder());
446         }
447         chooser.setDialogTitle(NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_Browse_Location"));
448         if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
449             File JavaDoc projectLoc = FileUtil.normalizeFile(chooser.getSelectedFile());
450             projectLocation.setText(projectLoc.getAbsolutePath());
451         }
452     }//GEN-LAST:event_browseProjectLocationActionPerformed
453

454     private void browseProjectFolderActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseProjectFolderActionPerformed
455
JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
456         FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
457         chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
458         if (projectFolder.getText().length() > 0 && getProjectFolder().exists()) {
459             chooser.setSelectedFile(getProjectFolder());
460         } else if (projectLocation.getText().length() > 0 && getProjectLocation().exists()) {
461             chooser.setSelectedFile(getProjectLocation());
462         } else {
463             chooser.setSelectedFile(ProjectChooser.getProjectsFolder());
464         }
465         chooser.setDialogTitle(NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_Browse_Project_Folder"));
466         if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
467             File JavaDoc projectDir = FileUtil.normalizeFile(chooser.getSelectedFile());
468             projectFolder.setText(projectDir.getAbsolutePath());
469         }
470     }//GEN-LAST:event_browseProjectFolderActionPerformed
471

472     private void browseAntScriptActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseAntScriptActionPerformed
473
JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
474         FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
475         chooser.setFileSelectionMode (JFileChooser.FILES_ONLY);
476         if (antScript.getText().length() > 0 && getAntScript().exists()) {
477             chooser.setSelectedFile(getAntScript());
478         } else if (projectLocation.getText().length() > 0 && getProjectLocation().exists()) {
479             chooser.setSelectedFile(getProjectLocation());
480         } else {
481             chooser.setSelectedFile(ProjectChooser.getProjectsFolder());
482         }
483         chooser.setDialogTitle(NbBundle.getMessage(BasicProjectInfoPanel.class, "LBL_Browse_Build_Script"));
484         if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
485             File JavaDoc script = FileUtil.normalizeFile(chooser.getSelectedFile());
486             antScript.setText(script.getAbsolutePath());
487         }
488     }//GEN-LAST:event_browseAntScriptActionPerformed
489

490     
491     // Variables declaration - do not modify//GEN-BEGIN:variables
492
private javax.swing.JTextField JavaDoc antScript;
493     private javax.swing.JButton JavaDoc browseAntScript;
494     private javax.swing.JButton JavaDoc browseProjectFolder;
495     private javax.swing.JButton JavaDoc browseProjectLocation;
496     private javax.swing.JLabel JavaDoc jLabel1;
497     private javax.swing.JLabel JavaDoc jLabel2;
498     private javax.swing.JLabel JavaDoc jLabel3;
499     private javax.swing.JLabel JavaDoc jLabel4;
500     private javax.swing.JLabel JavaDoc jLabel5;
501     private javax.swing.JLabel JavaDoc jLabel6;
502     private javax.swing.JSeparator JavaDoc jSeparator1;
503     private javax.swing.JCheckBox JavaDoc mainProject;
504     private javax.swing.JTextField JavaDoc projectFolder;
505     private javax.swing.JTextField JavaDoc projectLocation;
506     private javax.swing.JTextField JavaDoc projectName;
507     // End of variables declaration//GEN-END:variables
508

509 }
510
Popular Tags