KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > freeform > ui > OutputPanel


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.java.freeform.ui;
21
22 import java.awt.event.ItemEvent JavaDoc;
23 import java.io.File JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26 import javax.swing.DefaultListModel JavaDoc;
27 import javax.swing.JFileChooser JavaDoc;
28 import javax.swing.ListSelectionModel JavaDoc;
29 import javax.swing.event.ChangeEvent JavaDoc;
30 import javax.swing.event.ChangeListener JavaDoc;
31 import javax.swing.event.DocumentEvent JavaDoc;
32 import org.netbeans.modules.ant.freeform.spi.support.Util;
33 import org.netbeans.modules.java.freeform.JavaProjectGenerator;
34 import org.openide.filesystems.FileUtil;
35 import org.openide.util.HelpCtx;
36 import org.openide.util.NbBundle;
37
38 /**
39  *
40  * @author David Konecny
41  */

42 public class OutputPanel extends javax.swing.JPanel JavaDoc implements HelpCtx.Provider {
43
44     private DefaultListModel JavaDoc listModel;
45     private File JavaDoc lastChosenFile = null;
46     private boolean isSeparateClasspath = true;
47     private List JavaDoc<ProjectModel.CompilationUnitKey> compUnitsKeys;
48     private boolean ignoreEvent;
49     private ProjectModel model;
50     
51     public OutputPanel() {
52         initComponents();
53         jTextArea1.setBackground(getBackground());
54         listModel = new DefaultListModel JavaDoc();
55         output.setModel(listModel);
56         // XXX: for now only single selection
57
output.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
58         javadoc.getDocument().addDocumentListener(new javax.swing.event.DocumentListener JavaDoc () {
59             public void insertUpdate(DocumentEvent JavaDoc e) {
60                 update ();
61             }
62     
63             public void removeUpdate(DocumentEvent JavaDoc e) {
64                 update ();
65             }
66     
67             public void changedUpdate(DocumentEvent JavaDoc e) {
68                 update ();
69             }
70         });
71         jTextArea1.setDisabledTextColor(jLabel2.getForeground());
72     }
73     
74     private void update() {
75         int index = sourceFolder.getSelectedIndex();
76         assert index >= 0;
77         ProjectModel.CompilationUnitKey key = compUnitsKeys.get(index);
78         JavaProjectGenerator.JavaCompilationUnit cu = model.getCompilationUnit(key, model.isTestSourceFolder(index));
79         updateCompilationUnitJavadoc(cu);
80     }
81
82
83     public HelpCtx getHelpCtx() {
84         return new HelpCtx( OutputPanel.class );
85     }
86     
87     private void updateControls() {
88         sourceFolder.removeAllItems();
89         compUnitsKeys = model.createCompilationUnitKeys();
90         isSeparateClasspath = !ProjectModel.isSingleCompilationUnit(compUnitsKeys);
91         List JavaDoc<String JavaDoc> names = ClasspathPanel.createComboContent(compUnitsKeys, model.getEvaluator(), model.getNBProjectFolder());
92         for (String JavaDoc nm : names) {
93             sourceFolder.addItem(nm);
94         }
95         if (names.size() > 0) {
96             ignoreEvent = true;
97             sourceFolder.setSelectedIndex(0);
98             ignoreEvent = false;
99         }
100         
101         loadOutput();
102         
103         // enable/disable "Separate Classpath" checkbox
104
boolean sepClasspath = model.canHaveSeparateClasspath();
105         jLabel2.setEnabled(sepClasspath && isSeparateClasspath);
106         sourceFolder.setEnabled(sepClasspath && isSeparateClasspath);
107         
108         // disable ouput panel and Add Output button if there is
109
// no compilation unit ot be configured
110
addOutput.setEnabled(compUnitsKeys.size() > 0);
111         output.setEnabled(compUnitsKeys.size() > 0);
112         javadoc.setEnabled(compUnitsKeys.size() > 0);
113         javadocBrowse.setEnabled(compUnitsKeys.size() > 0);
114         updateButtons();
115     }
116     
117     /** This method is called from within the constructor to
118      * initialize the form.
119      * WARNING: Do NOT modify this code. The content of this method is
120      * always regenerated by the Form Editor.
121      */

122     private void initComponents() {//GEN-BEGIN:initComponents
123
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
124
125         jLabel2 = new javax.swing.JLabel JavaDoc();
126         jLabel3 = new javax.swing.JLabel JavaDoc();
127         addOutput = new javax.swing.JButton JavaDoc();
128         removeOutput = new javax.swing.JButton JavaDoc();
129         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
130         output = new javax.swing.JList JavaDoc();
131         jPanel1 = new javax.swing.JPanel JavaDoc();
132         sourceFolder = new javax.swing.JComboBox JavaDoc();
133         jTextArea1 = new javax.swing.JTextArea JavaDoc();
134         jPanel2 = new javax.swing.JPanel JavaDoc();
135         javadoc = new javax.swing.JTextField JavaDoc();
136         javadocBrowse = new javax.swing.JButton JavaDoc();
137         javadocLabel = new javax.swing.JLabel JavaDoc();
138
139         setLayout(new java.awt.GridBagLayout JavaDoc());
140
141         setPreferredSize(new java.awt.Dimension JavaDoc(275, 202));
142         jLabel2.setLabelFor(sourceFolder);
143         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(OutputPanel.class, "LBL_OutputPanel_jLabel1"));
144         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
145         gridBagConstraints.gridx = 0;
146         gridBagConstraints.gridy = 2;
147         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
148         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 6);
149         add(jLabel2, gridBagConstraints);
150
151         jLabel3.setLabelFor(output);
152         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(OutputPanel.class, "LBL_OutputPanel_jLabel3"));
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridx = 0;
155         gridBagConstraints.gridy = 3;
156         gridBagConstraints.gridwidth = 2;
157         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
158         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 0, 0, 0);
159         add(jLabel3, gridBagConstraints);
160         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_jLabel3"));
161
162         org.openide.awt.Mnemonics.setLocalizedText(addOutput, org.openide.util.NbBundle.getMessage(OutputPanel.class, "BTN_OutputPanel_addOutput"));
163         addOutput.addActionListener(new java.awt.event.ActionListener JavaDoc() {
164             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
165                 addOutputActionPerformed(evt);
166             }
167         });
168
169         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
170         gridBagConstraints.gridx = 2;
171         gridBagConstraints.gridy = 4;
172         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
173         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 6, 0);
174         add(addOutput, gridBagConstraints);
175         addOutput.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_addOutput"));
176
177         org.openide.awt.Mnemonics.setLocalizedText(removeOutput, org.openide.util.NbBundle.getMessage(OutputPanel.class, "BTN_OutputPanel_removeOutput"));
178         removeOutput.addActionListener(new java.awt.event.ActionListener JavaDoc() {
179             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
180                 removeOutputActionPerformed(evt);
181             }
182         });
183
184         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
185         gridBagConstraints.gridx = 2;
186         gridBagConstraints.gridy = 5;
187         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
188         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
189         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 6, 0);
190         add(removeOutput, gridBagConstraints);
191         removeOutput.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_removeOutput"));
192
193         output.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
194             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {
195                 outputValueChanged(evt);
196             }
197         });
198
199         jScrollPane1.setViewportView(output);
200         output.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_output"));
201
202         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
203         gridBagConstraints.gridx = 0;
204         gridBagConstraints.gridy = 4;
205         gridBagConstraints.gridwidth = 2;
206         gridBagConstraints.gridheight = 4;
207         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
208         gridBagConstraints.weightx = 1.0;
209         gridBagConstraints.weighty = 1.0;
210         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
211         add(jScrollPane1, gridBagConstraints);
212         jScrollPane1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_jScrollPanel1"));
213
214         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
215
216         sourceFolder.addItemListener(new java.awt.event.ItemListener JavaDoc() {
217             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
218                 sourceFolderItemStateChanged(evt);
219             }
220         });
221
222         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
223         gridBagConstraints.gridx = 0;
224         gridBagConstraints.gridy = 0;
225         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
226         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
227         gridBagConstraints.weightx = 1.0;
228         jPanel1.add(sourceFolder, gridBagConstraints);
229         sourceFolder.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("AD_OutputPanel_sourceFolder"));
230
231         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
232         gridBagConstraints.gridx = 1;
233         gridBagConstraints.gridy = 2;
234         gridBagConstraints.gridwidth = 2;
235         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
236         add(jPanel1, gridBagConstraints);
237
238         jTextArea1.setEditable(false);
239         jTextArea1.setLineWrap(true);
240         jTextArea1.setText(org.openide.util.NbBundle.getMessage(OutputPanel.class, "MSG_OutputPanel_jTextArea1"));
241         jTextArea1.setWrapStyleWord(true);
242         jTextArea1.setEnabled(false);
243         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
244         gridBagConstraints.gridwidth = 3;
245         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
246         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 0);
247         add(jTextArea1, gridBagConstraints);
248         jTextArea1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSN_OutputPanel_jTextArea1"));
249         jTextArea1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OutputPanel.class, "ACSD_OutputPanel_jTextArea1"));
250
251         jPanel2.setLayout(new java.awt.GridBagLayout JavaDoc());
252
253         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
254         gridBagConstraints.gridx = 1;
255         gridBagConstraints.gridy = 0;
256         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
257         gridBagConstraints.weightx = 1.0;
258         gridBagConstraints.weighty = 1.0;
259         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
260         jPanel2.add(javadoc, gridBagConstraints);
261         javadoc.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("AD_OutputPanel_javadoc"));
262
263         org.openide.awt.Mnemonics.setLocalizedText(javadocBrowse, org.openide.util.NbBundle.getMessage(OutputPanel.class, "BTN_OutputPanel_browseJavadoc"));
264         javadocBrowse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
265             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
266                 javadocBrowseActionPerformed(evt);
267             }
268         });
269
270         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
271         gridBagConstraints.gridx = 2;
272         gridBagConstraints.gridy = 0;
273         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
274         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
275         jPanel2.add(javadocBrowse, gridBagConstraints);
276         javadocBrowse.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("AD_OutputPanel_javadocBrowse"));
277
278         javadocLabel.setLabelFor(javadoc);
279         org.openide.awt.Mnemonics.setLocalizedText(javadocLabel, org.openide.util.NbBundle.getMessage(OutputPanel.class, "LBL_OutputPanel_JavadocLabel"));
280         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
281         gridBagConstraints.gridx = 0;
282         gridBagConstraints.gridy = 0;
283         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
284         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 6);
285         jPanel2.add(javadocLabel, gridBagConstraints);
286
287         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
288         gridBagConstraints.gridx = 0;
289         gridBagConstraints.gridy = 8;
290         gridBagConstraints.gridwidth = 3;
291         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
292         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
293         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 0, 0, 0);
294         add(jPanel2, gridBagConstraints);
295
296     }//GEN-END:initComponents
297

298     private void javadocBrowseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_javadocBrowseActionPerformed
299
JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
300         FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
301         chooser.setFileSelectionMode (JFileChooser.FILES_AND_DIRECTORIES);
302         chooser.setMultiSelectionEnabled(false);
303         if (lastChosenFile != null) {
304             chooser.setSelectedFile(lastChosenFile);
305         } else if (javadoc.getText().length() > 0) {
306             chooser.setSelectedFile(new File JavaDoc(javadoc.getText()));
307         } else {
308             File JavaDoc files[] = model.getBaseFolder().listFiles();
309             if (files != null && files.length > 0) {
310                 chooser.setSelectedFile(files[0]);
311             } else {
312                 chooser.setSelectedFile(model.getBaseFolder());
313             }
314         }
315         chooser.setDialogTitle(NbBundle.getMessage(OutputPanel.class, "LBL_Browse_Javadoc")); // NOI18N
316
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
317             File JavaDoc file = chooser.getSelectedFile();
318             file = FileUtil.normalizeFile(file);
319             javadoc.setText(file.getAbsolutePath());
320             lastChosenFile = file;
321         }
322     }//GEN-LAST:event_javadocBrowseActionPerformed
323

324     private void outputValueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {//GEN-FIRST:event_outputValueChanged
325
updateButtons();
326     }//GEN-LAST:event_outputValueChanged
327

328     private void sourceFolderItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_sourceFolderItemStateChanged
329
if (ignoreEvent) {
330             return;
331         }
332         if (evt.getStateChange() == ItemEvent.DESELECTED) {
333             int index = findIndex(evt.getItem());
334             // if index == -1 then item was removed and will not be saved
335
if (index != -1) {
336                 saveOutput(index);
337             }
338         } else {
339             loadOutput();
340         }
341     }//GEN-LAST:event_sourceFolderItemStateChanged
342

343     private int findIndex(Object JavaDoc o) {
344         for (int i=0; i<sourceFolder.getModel().getSize(); i++) {
345             if (sourceFolder.getModel().getElementAt(i).equals(o)) {
346                 return i;
347             }
348         }
349         return -1;
350     }
351     
352     /** Source package combo is changing - take output from the listbox and
353      * store it in compilaiton unit identified by the index.*/

354     private void saveOutput(int index) {
355         ProjectModel.CompilationUnitKey key = compUnitsKeys.get(index);
356         JavaProjectGenerator.JavaCompilationUnit cu = model.getCompilationUnit(key, model.isTestSourceFolder(index));
357         updateCompilationUnitOutput(cu);
358         updateCompilationUnitJavadoc(cu);
359     }
360
361     /** Source package has changes - find current source package and read its compilation unit and
362      * update classpath listbox with it.*/

363     private void loadOutput() {
364         int index;
365         if (isSeparateClasspath) {
366             index = sourceFolder.getSelectedIndex();
367             if (index == -1) {
368                 return;
369             }
370         } else {
371             index = 0;
372         }
373         ProjectModel.CompilationUnitKey key = compUnitsKeys.get(index);
374         JavaProjectGenerator.JavaCompilationUnit cu = model.getCompilationUnit(key, model.isTestSourceFolder(index));
375         updateJListOutput(cu.output);
376         updateJavadocField(cu.javadoc);
377     }
378     
379     private void updateJavadocField(List JavaDoc<String JavaDoc> jd) {
380         String JavaDoc value = "";
381         boolean enabled = true;
382         if (jd != null) {
383             if (jd.size() > 1) {
384                 value = getListAsString(jd);
385                 enabled = false;
386             } else if (jd.size() == 1) {
387                 File JavaDoc f = Util.resolveFile(model.getEvaluator(), model.getNBProjectFolder(), jd.get(0));
388                 if (f != null) {
389                     value = f.getAbsolutePath();
390                 }
391             }
392         }
393         javadoc.setEnabled(enabled);
394         javadocBrowse.setEnabled(enabled);
395         javadoc.setText(value);
396     }
397     
398     private String JavaDoc getListAsString(List JavaDoc<String JavaDoc> list) {
399         assert list != null;
400         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
401         for (String JavaDoc s : list) {
402             File JavaDoc f = Util.resolveFile(model.getEvaluator(), model.getNBProjectFolder(), s);
403             if (f != null) {
404                 if (sb.length()>0) {
405                     sb.append(", "); // NOI18N
406
}
407                 sb.append(f.getAbsolutePath());
408             }
409         }
410         return sb.toString();
411     }
412     
413     private void updateCompilationUnitJavadoc(JavaProjectGenerator.JavaCompilationUnit cu) {
414         if (javadoc.isEnabled()) {
415             if (javadoc.getText().length() > 0) {
416                 cu.javadoc = new ArrayList JavaDoc<String JavaDoc>();
417                 for (String JavaDoc part : javadoc.getText().split(",")) {
418                     File JavaDoc f = FileUtil.normalizeFile(new File JavaDoc(part.trim()));
419                     String JavaDoc path = Util.relativizeLocation(model.getBaseFolder(), model.getNBProjectFolder(), f);
420                     cu.javadoc.add (path);
421                 }
422             } else {
423                 cu.javadoc = null;
424             }
425         }
426     }
427
428     /** Read content of list box and update compilation unit's output.*/
429     private void updateCompilationUnitOutput(JavaProjectGenerator.JavaCompilationUnit cu) {
430         if (output.getModel().getSize() == 0) {
431             cu.output = null;
432             return;
433         }
434         List JavaDoc<String JavaDoc> l = new ArrayList JavaDoc<String JavaDoc>();
435         for (int i=0; i<output.getModel().getSize(); i++) {
436             File JavaDoc f = new File JavaDoc((String JavaDoc)output.getModel().getElementAt(i));
437             String JavaDoc path = Util.relativizeLocation(model.getBaseFolder(), model.getNBProjectFolder(), f);
438             l.add(path);
439         }
440         cu.output = l;
441     }
442
443     /** Update panel's listbox with given output list. */
444     private void updateJListOutput(List JavaDoc<String JavaDoc> l) {
445         listModel.removeAllElements();
446         if (l != null) {
447             for (String JavaDoc out : l) {
448                 File JavaDoc f = Util.resolveFile(model.getEvaluator(), model.getNBProjectFolder(), out);
449                 if (f != null) {
450                     listModel.addElement(f.getAbsolutePath());
451                 }
452             }
453         }
454         updateButtons();
455     }
456     
457     private void updateButtons() {
458         removeOutput.setEnabled(output.isEnabled() && listModel.getSize() > 0 && output.getSelectedIndex() != -1);
459     }
460     
461     private void removeOutputActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_removeOutputActionPerformed
462
int i = output.getSelectedIndex();
463         if (i != -1) {
464             listModel.remove(i);
465         }
466         applyChanges();
467         updateButtons();
468     }//GEN-LAST:event_removeOutputActionPerformed
469

470     private void addOutputActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_addOutputActionPerformed
471
JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
472         FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
473         chooser.setFileSelectionMode (JFileChooser.FILES_AND_DIRECTORIES);
474         chooser.setMultiSelectionEnabled(true);
475         if (lastChosenFile != null) {
476             chooser.setSelectedFile(lastChosenFile);
477         } else {
478             File JavaDoc files[] = model.getBaseFolder().listFiles();
479             if (files != null && files.length > 0) {
480                 chooser.setSelectedFile(files[0]);
481             } else {
482                 chooser.setSelectedFile(model.getBaseFolder());
483             }
484         }
485         chooser.setDialogTitle(NbBundle.getMessage(OutputPanel.class, "LBL_Browse_Output")); // NOI18N
486
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
487             for (File JavaDoc file : chooser.getSelectedFiles()) {
488                 file = FileUtil.normalizeFile(file);
489                 listModel.addElement(file.getAbsolutePath());
490                 lastChosenFile = file;
491             }
492             applyChanges();
493             updateButtons();
494         }
495     }//GEN-LAST:event_addOutputActionPerformed
496

497     private void applyChanges() {
498         if (isSeparateClasspath) {
499             if (sourceFolder.getSelectedIndex() != -1) {
500                 saveOutput(sourceFolder.getSelectedIndex());
501             }
502         } else {
503             saveOutput(0);
504         }
505     }
506     
507     void setModel(ProjectModel model) {
508         this.model = model;
509         updateControls();
510         model.addChangeListener(new ChangeListener JavaDoc() {
511             public void stateChanged(ChangeEvent JavaDoc arg0) {
512                 updateControls();
513             }
514         });
515     }
516
517     
518     // Variables declaration - do not modify//GEN-BEGIN:variables
519
private javax.swing.JButton JavaDoc addOutput;
520     private javax.swing.JLabel JavaDoc jLabel2;
521     private javax.swing.JLabel JavaDoc jLabel3;
522     private javax.swing.JPanel JavaDoc jPanel1;
523     private javax.swing.JPanel JavaDoc jPanel2;
524     private javax.swing.JScrollPane JavaDoc jScrollPane1;
525     private javax.swing.JTextArea JavaDoc jTextArea1;
526     private javax.swing.JTextField JavaDoc javadoc;
527     private javax.swing.JButton JavaDoc javadocBrowse;
528     private javax.swing.JLabel JavaDoc javadocLabel;
529     private javax.swing.JList JavaDoc output;
530     private javax.swing.JButton JavaDoc removeOutput;
531     private javax.swing.JComboBox JavaDoc sourceFolder;
532     // End of variables declaration//GEN-END:variables
533

534 }
535
Popular Tags