KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > archive > wizard > DeployablePanelVisual


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.j2ee.archive.wizard;
21
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.awt.event.ActionListener JavaDoc;
24 import java.io.File JavaDoc;
25 import java.text.MessageFormat JavaDoc;
26 import java.util.ResourceBundle JavaDoc;
27 import javax.swing.JFileChooser JavaDoc;
28 import javax.swing.JPanel JavaDoc;
29 import javax.swing.event.DocumentEvent JavaDoc;
30 import javax.swing.event.DocumentListener JavaDoc;
31 import javax.swing.filechooser.FileFilter JavaDoc;
32 import javax.swing.text.Document JavaDoc;
33 import org.netbeans.modules.j2ee.archive.project.*;
34 import org.netbeans.modules.j2ee.archive.ui.JavaEePlatformUiSupport;
35 import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerManager;
36 import org.netbeans.spi.project.ui.support.ProjectChooser;
37 import org.openide.WizardDescriptor;
38 import org.openide.WizardValidationException;
39 import org.openide.filesystems.FileUtil;
40 import org.openide.util.NbBundle;
41
42 class DeployablePanelVisual extends JPanel JavaDoc implements DocumentListener JavaDoc, ActionListener JavaDoc {
43     
44     private transient DeployableWizardPanel panel;
45     private static File JavaDoc savedArchiveLoc = null;
46     
47     /** Creates new form PanelProjectLocationVisual */
48     public DeployablePanelVisual(DeployableWizardPanel panel) {
49         initComponents();
50         this.panel = panel;
51         
52         // Register listener on the textFields to make the automatic updates
53
projectNameTextField.getDocument().addDocumentListener(this);
54         projectLocationTextField.getDocument().addDocumentListener(this);
55         archiveFileField.getDocument().addDocumentListener(this);
56         serverInstanceComboBox.addActionListener(this);
57     }
58     
59     
60     public String JavaDoc getProjectName() {
61         return this.projectNameTextField.getText();
62     }
63     
64     private String JavaDoc validFreeProjectName(final File JavaDoc parentFolder, final String JavaDoc formater, final int index) {
65         String JavaDoc name = MessageFormat.format(formater, new Object JavaDoc[]{new Integer JavaDoc(index)});
66         File JavaDoc file = new File JavaDoc(parentFolder, name);
67         return file.exists() ? null : name;
68     }
69     
70     /** This method is called from within the constructor to
71      * initialize the form.
72      * WARNING: Do NOT modify this code. The content of this method is
73      * always regenerated by the Form Editor.
74      */

75     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
76
private void initComponents() {
77         projectNameLabel = new javax.swing.JLabel JavaDoc();
78         projectNameTextField = new javax.swing.JTextField JavaDoc();
79         projectLocationLabel = new javax.swing.JLabel JavaDoc();
80         projectLocationTextField = new javax.swing.JTextField JavaDoc();
81         projectLocationButton = new javax.swing.JButton JavaDoc();
82         createdFolderLabel = new javax.swing.JLabel JavaDoc();
83         createdFolderTextField = new javax.swing.JTextField JavaDoc();
84         archiveFileLabel = new javax.swing.JLabel JavaDoc();
85         archiveFileField = new javax.swing.JTextField JavaDoc();
86         archiveLocationButton = new javax.swing.JButton JavaDoc();
87         targetServerLabel = new javax.swing.JLabel JavaDoc();
88         serverInstanceComboBox = new javax.swing.JComboBox JavaDoc();
89         manageServersButton = new javax.swing.JButton JavaDoc();
90
91         projectNameLabel.setLabelFor(projectNameTextField);
92         org.openide.awt.Mnemonics.setLocalizedText(projectNameLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("projectName_TEXT"));
93
94         projectLocationLabel.setLabelFor(projectLocationTextField);
95         org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("projectLocation_TEXT"));
96
97         org.openide.awt.Mnemonics.setLocalizedText(projectLocationButton, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("browse_TEXT"));
98         projectLocationButton.setActionCommand(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("BROWSE"));
99         projectLocationButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
100             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
101                 projectLocationButtonActionPerformed(evt);
102             }
103         });
104
105         createdFolderLabel.setLabelFor(createdFolderTextField);
106         org.openide.awt.Mnemonics.setLocalizedText(createdFolderLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("projectFolder_TEXT"));
107
108         createdFolderTextField.setEditable(false);
109
110         org.openide.awt.Mnemonics.setLocalizedText(archiveFileLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("archiveFileLabel_TEXT"));
111
112         org.openide.awt.Mnemonics.setLocalizedText(archiveLocationButton, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("browse_TEXT"));
113         archiveLocationButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
114             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
115                 archiveLocationButtonActionPerformed(evt);
116             }
117         });
118
119         org.openide.awt.Mnemonics.setLocalizedText(targetServerLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("targetServerLabel_TEXT"));
120
121         serverInstanceComboBox.setModel(JavaEePlatformUiSupport.createPlatformComboBoxModel(null));
122
123         org.openide.awt.Mnemonics.setLocalizedText(manageServersButton, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/archive/wizard/Bundle").getString("LBL_ManageServers"));
124         manageServersButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
125             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
126                 manageServersButtonActionPerformed(evt);
127             }
128         });
129
130         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
131         this.setLayout(layout);
132         layout.setHorizontalGroup(
133             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
134             .add(layout.createSequentialGroup()
135                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
136                     .add(layout.createSequentialGroup()
137                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
138                             .add(projectNameLabel)
139                             .add(projectLocationLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
140                             .add(createdFolderLabel)
141                             .add(archiveFileLabel))
142                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
143                     .add(layout.createSequentialGroup()
144                         .add(targetServerLabel)
145                         .add(33, 33, 33)))
146                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
147                     .add(serverInstanceComboBox, 0, 195, Short.MAX_VALUE)
148                     .add(createdFolderTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
149                     .add(org.jdesktop.layout.GroupLayout.TRAILING, projectNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
150                     .add(projectLocationTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
151                     .add(org.jdesktop.layout.GroupLayout.TRAILING, archiveFileField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))
152                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
153                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
154                     .add(projectLocationButton)
155                     .add(archiveLocationButton)
156                     .add(manageServersButton))
157                 .addContainerGap())
158         );
159         layout.setVerticalGroup(
160             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
161             .add(layout.createSequentialGroup()
162                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
163                     .add(projectNameLabel)
164                     .add(projectNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
165                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
166                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
167                     .add(projectLocationLabel)
168                     .add(projectLocationTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
169                     .add(projectLocationButton))
170                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
171                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
172                     .add(createdFolderLabel)
173                     .add(createdFolderTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
174                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
175                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
176                     .add(archiveFileLabel)
177                     .add(archiveFileField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
178                     .add(archiveLocationButton))
179                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
180                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
181                     .add(targetServerLabel)
182                     .add(serverInstanceComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
183                     .add(manageServersButton))
184                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
185         );
186     }// </editor-fold>//GEN-END:initComponents
187

188     private void manageServersButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_manageServersButtonActionPerformed
189
Object JavaDoc serverInstanceWrapper = serverInstanceComboBox.getSelectedItem();
190         String JavaDoc lastSelectedServerInstanceID = null;
191         if (serverInstanceWrapper != null) {
192             lastSelectedServerInstanceID = JavaEePlatformUiSupport.getServerInstanceID(serverInstanceWrapper);
193         }
194         ServerManager.showCustomizer(lastSelectedServerInstanceID);
195         serverInstanceComboBox.setModel(JavaEePlatformUiSupport.createPlatformComboBoxModel(lastSelectedServerInstanceID));
196     }//GEN-LAST:event_manageServersButtonActionPerformed
197

198     private void archiveLocationButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_archiveLocationButtonActionPerformed
199
JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
200         FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
201         chooser.setDialogTitle(NbBundle.getMessage(DeployablePanelVisual.class,
202                 "DLG_TITLE_ArchiveChooser")); // NOI18N
203
chooser.setFileFilter(new FileFilter JavaDoc() {
204             public boolean accept(File JavaDoc f) {
205                 if (f.isDirectory()) {
206                     return true;
207                 }
208                 String JavaDoc path = f.getAbsolutePath();
209                 return acceptableArchive(path);
210             }
211             public String JavaDoc getDescription() {
212                 return NbBundle.getMessage(DeployablePanelVisual.class,
213                         "ARCHIVE_CHOOSER_DESCRIPTOR"); //NOI18N
214
}
215         });
216         String JavaDoc path = this.archiveFileField.getText();
217         if (path.length() > 0) {
218             File JavaDoc f = new File JavaDoc(path);
219             if (f.exists()) {
220                 chooser.setSelectedFile(f);
221             }
222         } else if (savedArchiveLoc != null) {
223             chooser.setCurrentDirectory(savedArchiveLoc);
224         }
225         if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
226             File JavaDoc projectDir = chooser.getSelectedFile();
227             archiveFileField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
228             savedArchiveLoc = projectDir.getParentFile();
229         }
230         panel.fireChangeEvent();
231     }//GEN-LAST:event_archiveLocationButtonActionPerformed
232

233     private void projectLocationButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_projectLocationButtonActionPerformed
234
JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
235         FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
236         chooser.setDialogTitle(NbBundle.getMessage(DeployablePanelVisual.class,
237                 "DLG_TITLE_FolderChooser")); //NOI18N
238
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
239         String JavaDoc path = this.projectLocationTextField.getText();
240         if (path.length() > 0) {
241             File JavaDoc f = new File JavaDoc(path);
242             if (f.exists()) {
243                 chooser.setSelectedFile(f);
244             }
245         }
246         if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
247             File JavaDoc projectDir = chooser.getSelectedFile();
248             projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
249         }
250         panel.fireChangeEvent();
251     }//GEN-LAST:event_projectLocationButtonActionPerformed
252

253     
254     // Variables declaration - do not modify//GEN-BEGIN:variables
255
private javax.swing.JTextField JavaDoc archiveFileField;
256     private javax.swing.JLabel JavaDoc archiveFileLabel;
257     private javax.swing.JButton JavaDoc archiveLocationButton;
258     private javax.swing.JLabel JavaDoc createdFolderLabel;
259     private javax.swing.JTextField JavaDoc createdFolderTextField;
260     private javax.swing.JButton JavaDoc manageServersButton;
261     private javax.swing.JButton JavaDoc projectLocationButton;
262     private javax.swing.JLabel JavaDoc projectLocationLabel;
263     private javax.swing.JTextField JavaDoc projectLocationTextField;
264     private javax.swing.JLabel JavaDoc projectNameLabel;
265     private javax.swing.JTextField JavaDoc projectNameTextField;
266     private javax.swing.JComboBox JavaDoc serverInstanceComboBox;
267     private javax.swing.JLabel JavaDoc targetServerLabel;
268     // End of variables declaration//GEN-END:variables
269

270     public void addNotify() {
271         super.addNotify();
272         //same problem as in 31086, initial focus on Cancel button
273
projectNameTextField.requestFocus();
274     }
275     
276     private static final String JavaDoc WP_eM = "WizardPanel_errorMessage"; //NOI18N
277

278     private static final ResourceBundle JavaDoc bundle = NbBundle.getBundle(DeployablePanelVisual.class);
279     
280     boolean valid(WizardDescriptor wizardDescriptor) {
281         if (projectNameTextField.getText().length() == 0) {
282             wizardDescriptor.putProperty(WP_eM,
283                     bundle.getString("ERR_valid_folder_name")); //NOI18N
284
return false; // Display name not specified
285
}
286         File JavaDoc f = FileUtil.normalizeFile(new File JavaDoc(projectLocationTextField.getText()).getAbsoluteFile());
287         if (!f.isDirectory()) {
288             String JavaDoc message = bundle.getString("ERR_valid_path"); //NOI18N
289
wizardDescriptor.putProperty(WP_eM, message);
290             return false;
291         }
292         final File JavaDoc destFolder = FileUtil.normalizeFile(new File JavaDoc(createdFolderTextField.getText()).getAbsoluteFile());
293         
294         File JavaDoc projLoc = destFolder;
295         while (projLoc != null && !projLoc.exists()) {
296             projLoc = projLoc.getParentFile();
297         }
298         if (projLoc == null || !projLoc.canWrite()) {
299             wizardDescriptor.putProperty(WP_eM,
300                     bundle.getString("ERR_cannot_write_folder")); // NOI18N
301
return false;
302         }
303         
304         if (FileUtil.toFileObject(projLoc) == null) {
305             String JavaDoc message = bundle.getString("ERR_valid_path"); // NOI18N
306
wizardDescriptor.putProperty(WP_eM, message);
307             return false;
308         }
309         
310         File JavaDoc[] kids = destFolder.listFiles();
311         if (destFolder.exists() && kids != null && kids.length > 0) {
312             // Folder exists and is not empty
313
wizardDescriptor.putProperty(WP_eM,
314                     bundle.getString("ERR_folder_not_empty")); // NOI18N
315
return false;
316         }
317         f = FileUtil.normalizeFile(new File JavaDoc(archiveFileField.getText()).getAbsoluteFile());
318         if (!f.exists() || !f.isFile() || !f.canRead()) {
319             String JavaDoc message = bundle.getString("ERR_invalid_archive"); // NOI18N
320
wizardDescriptor.putProperty(WP_eM, message);
321             return false;
322         }
323         if (serverInstanceComboBox.getItemCount() == 0) {
324             String JavaDoc message = bundle.getString("ERR_no_possible_target"); // NOI18N
325
wizardDescriptor.putProperty(WP_eM, message);
326             return false;
327         }
328         if (serverInstanceComboBox.getSelectedItem() == null) {
329             String JavaDoc message = bundle.getString("ERR_no_target"); // NOI18N
330
wizardDescriptor.putProperty(WP_eM, message);
331             return false;
332         }
333         
334         // this may take a while to compute...
335
//
336
if (!acceptableArchive(f.getAbsoluteFile().getAbsolutePath(), wizardDescriptor)) {
337             String JavaDoc message = bundle.getString("ERR_unsupported_archive"); // NOI18N
338
wizardDescriptor.putProperty(WP_eM, message);
339             return false;
340         }
341         wizardDescriptor.putProperty(WP_eM, ""); // NOI18N
342
return true;
343     }
344     
345     boolean acceptableArchive(String JavaDoc aPath, WizardDescriptor d) {
346         // do the easy test first
347
boolean retVal = false;
348         if (aPath.endsWith("war")) { // NOI18N
349
d.putProperty(DeployableWizardIterator.PROJECT_TYPE_PROP,
350                     ArchiveProjectProperties.PROJECT_TYPE_VALUE_WAR);
351             retVal = true;
352         }
353         if (aPath.endsWith("car")) { // NOI18N
354
d.putProperty(DeployableWizardIterator.PROJECT_TYPE_PROP,
355                     ArchiveProjectProperties.PROJECT_TYPE_VALUE_CAR);
356             retVal = true;
357         }
358         if (aPath.endsWith("rar")) { // NOI18N
359
d.putProperty(DeployableWizardIterator.PROJECT_TYPE_PROP,
360                     ArchiveProjectProperties.PROJECT_TYPE_VALUE_RAR);
361             retVal = true;
362         }
363         if (aPath.endsWith("ear")) { // NOI18N
364
d.putProperty(DeployableWizardIterator.PROJECT_TYPE_PROP,
365                     ArchiveProjectProperties.PROJECT_TYPE_VALUE_EAR);
366             retVal = true;
367         }
368         if (aPath.endsWith("jar")) { // NOI18N
369
d.putProperty(DeployableWizardIterator.PROJECT_TYPE_PROP,
370                     ArchiveProjectProperties.PROJECT_TYPE_VALUE_UNKNOWN);
371             retVal = true;
372         }
373         return retVal;
374     }
375     
376     // if this is called on "next" we are golden here
377
//
378
void store(WizardDescriptor d) {
379         String JavaDoc name = projectNameTextField.getText().trim();
380         String JavaDoc folder = createdFolderTextField.getText().trim();
381         
382         d.putProperty(DeployableWizardIterator.PROJECT_DIR_PROP, new File JavaDoc(folder));
383         d.putProperty(DeployableWizardIterator.PROJECT_NAME_PROP, name);
384         d.putProperty(DeployableWizardIterator.PROJECT_TARGET_PROP, serverInstanceComboBox.getSelectedItem());
385         d.putProperty(DeployableWizardIterator.PROJECT_ARCHIVE_PROP, new File JavaDoc(archiveFileField.getText().trim()));
386     }
387     
388     void read(WizardDescriptor settings) {
389         File JavaDoc projectLocation = (File JavaDoc) settings.getProperty(DeployableWizardIterator.PROJECT_DIR_PROP);
390         if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory()) {
391             projectLocation = ProjectChooser.getProjectsFolder();
392         } else {
393             projectLocation = projectLocation.getParentFile();
394         }
395         this.projectLocationTextField.setText(projectLocation.getAbsolutePath());
396         
397         String JavaDoc projectName = (String JavaDoc) settings.getProperty(DeployableWizardIterator.PROJECT_NAME_PROP);
398         if(projectName == null) {
399             int baseCount = 0;
400             String JavaDoc formater = bundle.getString("TXT_DefaultProjectName"); // NOI18N
401
while ((projectName=validFreeProjectName(projectLocation, formater, baseCount))==null)
402                 baseCount++;
403         }
404         this.projectNameTextField.setText(projectName);
405         this.projectNameTextField.selectAll();
406     }
407     
408     void validate(WizardDescriptor d) throws WizardValidationException {
409         // nothing to validate
410
}
411     
412     // Implementation of DocumentListener --------------------------------------
413

414     public void changedUpdate(DocumentEvent JavaDoc e) {
415         updateTexts(e);
416         if (this.projectNameTextField.getDocument() == e.getDocument()) {
417             firePropertyChange(DeployableWizardIterator.PROJECT_NAME_PROP,null,this.projectNameTextField.getText());
418         }
419     }
420     
421     public void insertUpdate(DocumentEvent JavaDoc e) {
422         updateTexts(e);
423         if (this.projectNameTextField.getDocument() == e.getDocument()) {
424             firePropertyChange(DeployableWizardIterator.PROJECT_NAME_PROP,null,
425                     this.projectNameTextField.getText());
426         }
427     }
428     
429     public void removeUpdate(DocumentEvent JavaDoc e) {
430         updateTexts(e);
431         if (this.projectNameTextField.getDocument() == e.getDocument()) {
432             firePropertyChange(DeployableWizardIterator.PROJECT_NAME_PROP,null,
433                     this.projectNameTextField.getText());
434         }
435     }
436     
437     /** Handles changes in the Project name and project directory, */
438     private void updateTexts(DocumentEvent JavaDoc e) {
439         
440         Document JavaDoc doc = e.getDocument();
441         
442         if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) {
443             // Change in the project name
444

445             String JavaDoc projectName = projectNameTextField.getText();
446             String JavaDoc projectFolder = projectLocationTextField.getText();
447             
448             createdFolderTextField.setText(projectFolder + File.separatorChar + projectName);
449         }
450         panel.fireChangeEvent(); // Notify that the panel changed
451
}
452     
453     public void actionPerformed(ActionEvent JavaDoc e) {
454         panel.fireChangeEvent();
455     }
456     
457     private boolean acceptableArchive(String JavaDoc aPath) {
458         boolean retVal = false;
459         if (aPath.endsWith("war")) { // NOI18N
460
retVal = true;
461         }
462         if (aPath.endsWith("car")) { // NOI18N
463
retVal = true;
464         }
465         if (aPath.endsWith("ear")) { // NOI18N
466
retVal = true;
467         }
468         if (aPath.endsWith("jar")) { // NOI18N
469
retVal = true;
470         }
471         if (aPath.endsWith("rar")) { // NOI18N
472
retVal = true;
473         }
474         return retVal;
475     }
476 }
477
Popular Tags