Source Code Cross Referenced for PanelSourceFolders.java in  » IDE-Netbeans » j2ee » org » netbeans » modules » j2ee » clientproject » ui » wizards » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » j2ee » org.netbeans.modules.j2ee.clientproject.ui.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.j2ee.clientproject.ui.wizards;
043:
044:        import java.beans.PropertyChangeListener;
045:        import java.beans.PropertyChangeEvent;
046:        import java.io.File;
047:        import java.io.IOException;
048:        import java.text.MessageFormat;
049:        import java.util.ArrayList;
050:        import java.util.Enumeration;
051:        import java.util.Iterator;
052:        import javax.swing.JFileChooser;
053:        import javax.swing.event.ChangeEvent;
054:        import javax.swing.event.ChangeListener;
055:        import javax.swing.event.DocumentEvent;
056:        import javax.swing.event.DocumentListener;
057:        import org.openide.DialogDisplayer;
058:        import org.openide.NotifyDescriptor;
059:        import org.openide.WizardDescriptor;
060:        import org.openide.WizardValidationException;
061:        import org.openide.filesystems.FileObject;
062:        import org.openide.filesystems.FileUtil;
063:        import org.openide.util.Exceptions;
064:        import org.openide.util.HelpCtx;
065:        import org.openide.util.NbBundle;
066:
067:        //XXX There should be a way how to add nonexistent test dir
068:
069:        /**
070:         * Sets up name and location for new Java project from existing sources.
071:         * @author Tomas Zezula et al.
072:         */
073:        public class PanelSourceFolders extends SettingsPanel implements 
074:                PropertyChangeListener {
075:            private static final long serialVersionUID = 1L;
076:
077:            private final Panel firer;
078:            private WizardDescriptor wizardDescriptor;
079:            private File oldProjectLocation;
080:
081:            private final DocumentListener configFilesDocumentListener = new DocumentListener() {
082:                public void changedUpdate(DocumentEvent e) {
083:                    configFilesChanged();
084:                }
085:
086:                public void insertUpdate(DocumentEvent e) {
087:                    configFilesChanged();
088:                }
089:
090:                public void removeUpdate(DocumentEvent e) {
091:                    configFilesChanged();
092:                }
093:            };
094:
095:            /** Creates new form PanelSourceFolders */
096:            public PanelSourceFolders(Panel panel) {
097:                this .firer = panel;
098:                initComponents();
099:                this .setName(NbBundle.getMessage(PanelSourceFolders.class,
100:                        "LAB_ConfigureSourceRoots"));
101:                this .putClientProperty("NewProjectWizard_Title", NbBundle
102:                        .getMessage(PanelSourceFolders.class,
103:                                "TXT_ImportAppClientModule")); // NOI18N
104:                this .getAccessibleContext().setAccessibleName(
105:                        NbBundle.getMessage(PanelSourceFolders.class,
106:                                "AN_PanelSourceFolders"));
107:                this .getAccessibleContext().setAccessibleDescription(
108:                        NbBundle.getMessage(PanelSourceFolders.class,
109:                                "AD_PanelSourceFolders"));
110:                this .sourcePanel.addPropertyChangeListener(this );
111:                this .testsPanel.addPropertyChangeListener(this );
112:                ((FolderList) this .sourcePanel)
113:                        .setRelatedFolderList((FolderList) this .testsPanel);
114:                ((FolderList) this .testsPanel)
115:                        .setRelatedFolderList((FolderList) this .sourcePanel);
116:                this .jTextFieldConfigFiles.getDocument().addDocumentListener(
117:                        configFilesDocumentListener);
118:            }
119:
120:            public void initValues(FileObject fo) {
121:                ((FolderList) this .sourcePanel).setLastUsedDir(FileUtil
122:                        .toFile(fo));
123:                ((FolderList) this .testsPanel).setLastUsedDir(FileUtil
124:                        .toFile(fo));
125:
126:                FileObject confFO = FileSearchUtility.guessConfigFilesPath(fo);
127:                if (confFO == null) { // without deployment descriptor
128:                    // XXX guess appropriate conf. folder
129:                } else {
130:                    String configFiles = FileUtil.toFile(confFO)
131:                            .getAbsolutePath();
132:                    jTextFieldConfigFiles.setText(configFiles);
133:                }
134:                FileObject librariesFO = FileSearchUtility
135:                        .guessLibrariesFolder(fo);
136:                if (librariesFO != null) {
137:                    String libraries = FileUtil.toFile(librariesFO)
138:                            .getAbsolutePath();
139:                    jTextFieldLibraries.setText(libraries);
140:                }
141:            }
142:
143:            public void propertyChange(PropertyChangeEvent evt) {
144:                if (FolderList.PROP_FILES.equals(evt.getPropertyName())) {
145:                    this .dataChanged();
146:                } else if (FolderList.PROP_LAST_USED_DIR.equals(evt
147:                        .getPropertyName())) {
148:                    if (evt.getSource() == this .sourcePanel) {
149:                        ((FolderList) this .testsPanel)
150:                                .setLastUsedDir((File) evt.getNewValue());
151:                    } else if (evt.getSource() == this .testsPanel) {
152:                        ((FolderList) this .sourcePanel)
153:                                .setLastUsedDir((File) evt.getNewValue());
154:                    }
155:                }
156:            }
157:
158:            private void dataChanged() {
159:                this .firer.fireChangeEvent();
160:            }
161:
162:            void read(WizardDescriptor settings) {
163:                this .wizardDescriptor = settings;
164:
165:                // #56706: only reinitialize the locations on the panel if the user changed the project location
166:                File projectLocation = (File) settings
167:                        .getProperty(WizardProperties.SOURCE_ROOT);
168:                ((FolderList) this .sourcePanel)
169:                        .setProjectFolder(projectLocation);
170:                ((FolderList) this .testsPanel)
171:                        .setProjectFolder(projectLocation);
172:                if (!projectLocation.equals(oldProjectLocation)) {
173:                    File[] srcRoot = (File[]) settings
174:                            .getProperty(WizardProperties.JAVA_ROOT); //NOI18N
175:                    if (srcRoot != null) {
176:                        ((FolderList) this .sourcePanel).setFiles(srcRoot);
177:                    }
178:                    File[] testRoot = (File[]) settings
179:                            .getProperty(WizardProperties.TEST_ROOT); //NOI18N
180:                    if (testRoot != null) {
181:                        ((FolderList) this .testsPanel).setFiles(testRoot);
182:                    }
183:                    initValues(FileUtil.toFileObject(projectLocation));
184:                    oldProjectLocation = projectLocation;
185:                }
186:            }
187:
188:            void store(WizardDescriptor settings) {
189:                File[] sourceRoots = ((FolderList) this .sourcePanel).getFiles();
190:                File[] testRoots = ((FolderList) this .testsPanel).getFiles();
191:                settings.putProperty(WizardProperties.JAVA_ROOT, sourceRoots); //NOI18N
192:                settings.putProperty(WizardProperties.TEST_ROOT, testRoots); //NOI18N
193:                String configFiles = jTextFieldConfigFiles.getText().trim();
194:                if (configFiles.length() > 0) {
195:                    settings.putProperty(WizardProperties.CONFIG_FILES_FOLDER,
196:                            new File(configFiles));
197:                } else {
198:                    settings.putProperty(WizardProperties.CONFIG_FILES_FOLDER,
199:                            null);
200:                }
201:                String libPath = jTextFieldLibraries.getText().trim();
202:                if (libPath != null && !libPath.equals("")) {
203:                    settings.putProperty(WizardProperties.LIB_FOLDER, new File(
204:                            libPath));
205:                }
206:            }
207:
208:            boolean valid(WizardDescriptor settings) {
209:                File projectLocation = (File) settings
210:                        .getProperty(WizardProperties.PROJECT_DIR); //NOI18N
211:                String confFolder = jTextFieldConfigFiles.getText().trim();
212:                if (confFolder.length() == 0) {
213:                    wizardDescriptor.putProperty("WizardPanel_errorMessage", // NOI18N
214:                            NbBundle.getMessage(PanelSourceFolders.class,
215:                                    "MSG_BlankConfigurationFilesFolder"));
216:                    return false;
217:                }
218:                File[] sourceRoots = ((FolderList) this .sourcePanel).getFiles();
219:                File[] testRoots = ((FolderList) this .testsPanel).getFiles();
220:                String result = checkValidity(projectLocation,
221:                        getConfigFiles(), sourceRoots, testRoots);
222:                if (result == null) {
223:                    wizardDescriptor.putProperty("WizardPanel_errorMessage",
224:                            " "); //NOI18N
225:                    return true;
226:                } else {
227:                    wizardDescriptor.putProperty("WizardPanel_errorMessage",
228:                            result); //NOI18N
229:                    return false;
230:                }
231:            }
232:
233:            static String checkValidity(final File projectLocation,
234:                    final File configFilesLocation, final File[] sources,
235:                    final File[] tests) {
236:                String ploc = projectLocation.getAbsolutePath();
237:                if (configFilesLocation != null) {
238:                    FileObject fo = FileUtil.toFileObject(FileUtil
239:                            .normalizeFile(configFilesLocation));
240:                    if (fo == null || !fo.isFolder()) {
241:                        return NbBundle.getMessage(PanelSourceFolders.class,
242:                                "MSG_IllegalConfigurationFilesFolder");
243:                    }
244:                }
245:                if (sources.length == 0) {
246:                    return " "; //NOI18N
247:                }
248:                for (int i = 0; i < sources.length; i++) {
249:                    if (!sources[i].isDirectory() || !sources[i].canRead()) {
250:                        return MessageFormat.format(
251:                                NbBundle.getMessage(PanelSourceFolders.class,
252:                                        "MSG_IllegalSources"),
253:                                new Object[] { sources[i].getAbsolutePath() });
254:                    }
255:                    String sloc = sources[i].getAbsolutePath();
256:                    if (ploc.equals(sloc)
257:                            || ploc.startsWith(sloc + File.separatorChar)) {
258:                        return NbBundle.getMessage(PanelSourceFolders.class,
259:                                "MSG_IllegalProjectFolder");
260:                    }
261:                }
262:                for (int i = 0; i < tests.length; i++) {
263:                    if (!tests[i].isDirectory() || !tests[i].canRead()) {
264:                        return MessageFormat.format(NbBundle.getMessage(
265:                                PanelSourceFolders.class, "MSG_IllegalTests"),
266:                                new Object[] { sources[i].getAbsolutePath() });
267:                    }
268:                    String tloc = tests[i].getAbsolutePath();
269:                    if (ploc.equals(tloc)
270:                            || ploc.startsWith(tloc + File.separatorChar)) {
271:                        return NbBundle.getMessage(PanelSourceFolders.class,
272:                                "MSG_IllegalProjectFolder");
273:                    }
274:                }
275:                return null;
276:            }
277:
278:            void validate(WizardDescriptor d) throws WizardValidationException {
279:                // sources root
280:                searchClassFiles(((FolderList) this .sourcePanel).getFiles());
281:                // test root, not asked in issue 48198
282:                //searchClassFiles (FileUtil.toFileObject (FileUtil.normalizeFile(new File (tests.getText ()))));
283:            }
284:
285:            private void searchClassFiles(File[] folders)
286:                    throws WizardValidationException {
287:                boolean found = false;
288:                for (int i = 0; i < folders.length; i++) {
289:                    FileObject folder = FileUtil.toFileObject(folders[i]);
290:                    if (folder != null) {
291:                        Enumeration en = folder.getData(true);
292:                        while (!found && en.hasMoreElements()) {
293:                            Object obj = en.nextElement();
294:                            assert obj instanceof  FileObject : "Instance of FileObject: "
295:                                    + obj; // NOI18N
296:                            FileObject fo = (FileObject) obj;
297:                            found = "class".equals(fo.getExt()); // NOI18N
298:                        }
299:                    }
300:                }
301:                if (found) {
302:                    Object DELETE_OPTION = NbBundle.getMessage(
303:                            PanelSourceFolders.class, "TXT_DeleteOption"); // NOI18N
304:                    Object KEEP_OPTION = NbBundle.getMessage(
305:                            PanelSourceFolders.class, "TXT_KeepOption"); // NOI18N
306:                    Object CANCEL_OPTION = NbBundle.getMessage(
307:                            PanelSourceFolders.class, "TXT_CancelOption"); // NOI18N
308:                    NotifyDescriptor desc = new NotifyDescriptor(
309:                            NbBundle.getMessage(PanelSourceFolders.class,
310:                                    "MSG_FoundClassFiles"), // NOI18N
311:                            NbBundle.getMessage(PanelSourceFolders.class,
312:                                    "MSG_FoundClassFiles_Title"), // NOI18N
313:                            NotifyDescriptor.YES_NO_CANCEL_OPTION,
314:                            NotifyDescriptor.QUESTION_MESSAGE,
315:                            new Object[] { DELETE_OPTION, KEEP_OPTION,
316:                                    CANCEL_OPTION }, null);
317:                    Object result = DialogDisplayer.getDefault().notify(desc);
318:                    if (DELETE_OPTION.equals(result)) {
319:                        deleteClassFiles(folders);
320:                    } else if (!KEEP_OPTION.equals(result)) {
321:                        // cancel, back to wizard
322:                        throw new WizardValidationException(this .sourcePanel,
323:                                "", ""); // NOI18N
324:                    }
325:                }
326:            }
327:
328:            private void deleteClassFiles(File[] folders) {
329:                for (int i = 0; i < folders.length; i++) {
330:                    FileObject folder = FileUtil.toFileObject(folders[i]);
331:                    Enumeration en = folder.getData(true);
332:                    while (en.hasMoreElements()) {
333:                        Object obj = en.nextElement();
334:                        assert obj instanceof  FileObject : "Instance of FileObject: "
335:                                + obj;
336:                        FileObject fo = (FileObject) obj;
337:                        try {
338:                            if ("class".equals(fo.getExt())) { // NOI18N
339:                                fo.delete();
340:                            }
341:                        } catch (IOException ioe) {
342:                            Exceptions.printStackTrace(ioe);
343:                        }
344:                    }
345:                }
346:            }
347:
348:            /** This method is called from within the constructor to
349:             * initialize the form.
350:             * WARNING: Do NOT modify this code. The content of this method is
351:             * always regenerated by the Form Editor.
352:             */
353:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
354:            private void initComponents() {
355:                java.awt.GridBagConstraints gridBagConstraints;
356:
357:                jLabel3 = new javax.swing.JLabel();
358:                sourcePanel = new FolderList(NbBundle.getMessage(
359:                        PanelSourceFolders.class, "CTL_SourceRoots"),
360:                        NbBundle.getMessage(PanelSourceFolders.class,
361:                                "MNE_SourceRoots").charAt(0), NbBundle
362:                                .getMessage(PanelSourceFolders.class,
363:                                        "AD_SourceRoots"), NbBundle.getMessage(
364:                                PanelSourceFolders.class, "CTL_AddSourceRoot"),
365:                        NbBundle.getMessage(PanelSourceFolders.class,
366:                                "MNE_AddSourceFolder").charAt(0), NbBundle
367:                                .getMessage(PanelSourceFolders.class,
368:                                        "AD_AddSourceFolder"), NbBundle
369:                                .getMessage(PanelSourceFolders.class,
370:                                        "MNE_RemoveSourceFolder").charAt(0),
371:                        NbBundle.getMessage(PanelSourceFolders.class,
372:                                "AD_RemoveSourceFolder"));
373:                testsPanel = new FolderList(NbBundle.getMessage(
374:                        PanelSourceFolders.class, "CTL_TestRoots"), NbBundle
375:                        .getMessage(PanelSourceFolders.class, "MNE_TestRoots")
376:                        .charAt(0), NbBundle.getMessage(
377:                        PanelSourceFolders.class, "AD_TestRoots"),
378:                        NbBundle.getMessage(PanelSourceFolders.class,
379:                                "CTL_AddTestRoot"), NbBundle.getMessage(
380:                                PanelSourceFolders.class, "MNE_AddTestFolder")
381:                                .charAt(0), NbBundle.getMessage(
382:                                PanelSourceFolders.class, "AD_AddTestFolder"),
383:                        NbBundle.getMessage(PanelSourceFolders.class,
384:                                "MNE_RemoveTestFolder").charAt(0), NbBundle
385:                                .getMessage(PanelSourceFolders.class,
386:                                        "AD_RemoveTestFolder"));
387:                jLabel1 = new javax.swing.JLabel();
388:                jTextFieldConfigFiles = new javax.swing.JTextField();
389:                jButtonConfigFilesLocation = new javax.swing.JButton();
390:                jLabel2 = new javax.swing.JLabel();
391:                jTextFieldLibraries = new javax.swing.JTextField();
392:                jButtonLibraries = new javax.swing.JButton();
393:
394:                setLayout(new java.awt.GridBagLayout());
395:
396:                getAccessibleContext().setAccessibleName(null);
397:                getAccessibleContext().setAccessibleDescription(null);
398:                org.openide.awt.Mnemonics.setLocalizedText(jLabel3,
399:                        org.openide.util.NbBundle.getMessage(
400:                                PanelSourceFolders.class,
401:                                "LBL_SourceDirectoriesLabel"));
402:                gridBagConstraints = new java.awt.GridBagConstraints();
403:                gridBagConstraints.gridy = 0;
404:                gridBagConstraints.gridwidth = 3;
405:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
406:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
407:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
408:                add(jLabel3, gridBagConstraints);
409:                jLabel3.getAccessibleContext().setAccessibleName(
410:                        org.openide.util.NbBundle.getBundle(
411:                                PanelSourceFolders.class).getString(
412:                                "ACSN_jLabel3"));
413:                jLabel3.getAccessibleContext().setAccessibleDescription(
414:                        org.openide.util.NbBundle.getBundle(
415:                                PanelSourceFolders.class).getString(
416:                                "ACSD_jLabel3"));
417:
418:                gridBagConstraints = new java.awt.GridBagConstraints();
419:                gridBagConstraints.gridy = 3;
420:                gridBagConstraints.gridwidth = 3;
421:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
422:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
423:                gridBagConstraints.weightx = 1.0;
424:                gridBagConstraints.weighty = 0.45;
425:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
426:                add(sourcePanel, gridBagConstraints);
427:
428:                gridBagConstraints = new java.awt.GridBagConstraints();
429:                gridBagConstraints.gridy = 4;
430:                gridBagConstraints.gridwidth = 3;
431:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
432:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
433:                gridBagConstraints.weightx = 1.0;
434:                gridBagConstraints.weighty = 0.45;
435:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
436:                add(testsPanel, gridBagConstraints);
437:
438:                jLabel1.setLabelFor(jTextFieldConfigFiles);
439:                org.openide.awt.Mnemonics
440:                        .setLocalizedText(
441:                                jLabel1,
442:                                java.util.ResourceBundle
443:                                        .getBundle(
444:                                                "org/netbeans/modules/j2ee/clientproject/ui/wizards/Bundle")
445:                                        .getString(
446:                                                "LBL_IW_ConfigFilesFolder_Label"));
447:                gridBagConstraints = new java.awt.GridBagConstraints();
448:                gridBagConstraints.gridx = 0;
449:                gridBagConstraints.gridy = 1;
450:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
451:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
452:                add(jLabel1, gridBagConstraints);
453:
454:                gridBagConstraints = new java.awt.GridBagConstraints();
455:                gridBagConstraints.gridx = 1;
456:                gridBagConstraints.gridy = 1;
457:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
458:                gridBagConstraints.weightx = 1.0;
459:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
460:                add(jTextFieldConfigFiles, gridBagConstraints);
461:
462:                org.openide.awt.Mnemonics
463:                        .setLocalizedText(
464:                                jButtonConfigFilesLocation,
465:                                java.util.ResourceBundle
466:                                        .getBundle(
467:                                                "org/netbeans/modules/j2ee/clientproject/ui/wizards/Bundle")
468:                                        .getString(
469:                                                "LBL_NWP1_BrowseLocation_Button_w"));
470:                jButtonConfigFilesLocation
471:                        .addActionListener(new java.awt.event.ActionListener() {
472:                            public void actionPerformed(
473:                                    java.awt.event.ActionEvent evt) {
474:                                jButtonConfigFilesLocationActionPerformed(evt);
475:                            }
476:                        });
477:
478:                gridBagConstraints = new java.awt.GridBagConstraints();
479:                gridBagConstraints.gridx = 2;
480:                gridBagConstraints.gridy = 1;
481:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
482:                add(jButtonConfigFilesLocation, gridBagConstraints);
483:
484:                jLabel2.setLabelFor(jTextFieldLibraries);
485:                org.openide.awt.Mnemonics
486:                        .setLocalizedText(
487:                                jLabel2,
488:                                java.util.ResourceBundle
489:                                        .getBundle(
490:                                                "org/netbeans/modules/j2ee/clientproject/ui/wizards/Bundle")
491:                                        .getString(
492:                                                "LBL_IW_LibrariesLocation_Label"));
493:                gridBagConstraints = new java.awt.GridBagConstraints();
494:                gridBagConstraints.gridx = 0;
495:                gridBagConstraints.gridy = 2;
496:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
497:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
498:                add(jLabel2, gridBagConstraints);
499:
500:                gridBagConstraints = new java.awt.GridBagConstraints();
501:                gridBagConstraints.gridx = 1;
502:                gridBagConstraints.gridy = 2;
503:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
504:                gridBagConstraints.weightx = 1.0;
505:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
506:                add(jTextFieldLibraries, gridBagConstraints);
507:
508:                org.openide.awt.Mnemonics
509:                        .setLocalizedText(
510:                                jButtonLibraries,
511:                                java.util.ResourceBundle
512:                                        .getBundle(
513:                                                "org/netbeans/modules/j2ee/clientproject/ui/wizards/Bundle")
514:                                        .getString(
515:                                                "LBL_NWP1_BrowseLocation_Button"));
516:                jButtonLibraries
517:                        .addActionListener(new java.awt.event.ActionListener() {
518:                            public void actionPerformed(
519:                                    java.awt.event.ActionEvent evt) {
520:                                jButtonLibrariesActionPerformed(evt);
521:                            }
522:                        });
523:
524:                gridBagConstraints = new java.awt.GridBagConstraints();
525:                gridBagConstraints.gridx = 2;
526:                gridBagConstraints.gridy = 2;
527:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
528:                add(jButtonLibraries, gridBagConstraints);
529:
530:            }// </editor-fold>//GEN-END:initComponents
531:
532:            private void jButtonLibrariesActionPerformed(
533:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLibrariesActionPerformed
534:                JFileChooser chooser = new JFileChooser();
535:                FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
536:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
537:                if (jTextFieldLibraries.getText().length() > 0
538:                        && getLibraries().exists()) {
539:                    chooser.setSelectedFile(getLibraries());
540:                } else {
541:                    chooser.setCurrentDirectory((File) wizardDescriptor
542:                            .getProperty(WizardProperties.PROJECT_DIR));
543:                }
544:                if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this )) {
545:                    File configFilesDir = FileUtil.normalizeFile(chooser
546:                            .getSelectedFile());
547:                    jTextFieldLibraries.setText(configFilesDir
548:                            .getAbsolutePath());
549:                }
550:            }//GEN-LAST:event_jButtonLibrariesActionPerformed
551:
552:            private void jButtonConfigFilesLocationActionPerformed(
553:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfigFilesLocationActionPerformed
554:                JFileChooser chooser = new JFileChooser();
555:                FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
556:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
557:                if (jTextFieldConfigFiles.getText().length() > 0
558:                        && getConfigFiles().exists()) {
559:                    chooser.setSelectedFile(getConfigFiles());
560:                } else {
561:                    chooser.setCurrentDirectory((File) wizardDescriptor
562:                            .getProperty(WizardProperties.PROJECT_DIR));
563:                }
564:                if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this )) {
565:                    File configFilesDir = FileUtil.normalizeFile(chooser
566:                            .getSelectedFile());
567:                    jTextFieldConfigFiles.setText(configFilesDir
568:                            .getAbsolutePath());
569:                }
570:            }//GEN-LAST:event_jButtonConfigFilesLocationActionPerformed
571:
572:            // Variables declaration - do not modify//GEN-BEGIN:variables
573:            private javax.swing.JButton jButtonConfigFilesLocation;
574:            private javax.swing.JButton jButtonLibraries;
575:            private javax.swing.JLabel jLabel1;
576:            private javax.swing.JLabel jLabel2;
577:            private javax.swing.JLabel jLabel3;
578:            private javax.swing.JTextField jTextFieldConfigFiles;
579:            private javax.swing.JTextField jTextFieldLibraries;
580:            private javax.swing.JPanel sourcePanel;
581:            private javax.swing.JPanel testsPanel;
582:
583:            // End of variables declaration//GEN-END:variables
584:
585:            static class Panel implements  WizardDescriptor.ValidatingPanel {
586:
587:                private ArrayList<ChangeListener> listeners;
588:                private PanelSourceFolders component;
589:                private WizardDescriptor settings;
590:
591:                public synchronized void removeChangeListener(ChangeListener l) {
592:                    if (this .listeners == null) {
593:                        return;
594:                    }
595:                    this .listeners.remove(l);
596:                }
597:
598:                public void addChangeListener(ChangeListener l) {
599:                    if (this .listeners == null) {
600:                        this .listeners = new ArrayList<ChangeListener>();
601:                    }
602:                    this .listeners.add(l);
603:                }
604:
605:                public void readSettings(Object settings) {
606:                    this .settings = (WizardDescriptor) settings;
607:                    this .component.read(this .settings);
608:                    // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
609:                    // this name is used in NewProjectWizard to modify the title
610:                    Object substitute = component
611:                            .getClientProperty("NewProjectWizard_Title"); // NOI18N
612:                    if (substitute != null) {
613:                        this .settings.putProperty("NewProjectWizard_Title",
614:                                substitute); // NOI18N
615:                    }
616:                }
617:
618:                public void storeSettings(Object settings) {
619:                    this .component.store(this .settings);
620:                }
621:
622:                public void validate() throws WizardValidationException {
623:                    this .component.validate(this .settings);
624:                }
625:
626:                public boolean isValid() {
627:                    return this .component.valid(this .settings);
628:                }
629:
630:                public synchronized java.awt.Component getComponent() {
631:                    if (this .component == null) {
632:                        this .component = new PanelSourceFolders(this );
633:                    }
634:                    return this .component;
635:                }
636:
637:                public HelpCtx getHelp() {
638:                    return new HelpCtx(PanelSourceFolders.class);
639:                }
640:
641:                private void fireChangeEvent() {
642:                    Iterator it = null;
643:                    synchronized (this ) {
644:                        if (this .listeners == null) {
645:                            return;
646:                        }
647:                        it = ((ArrayList) this .listeners.clone()).iterator();
648:                    }
649:                    ChangeEvent event = new ChangeEvent(this );
650:                    while (it.hasNext()) {
651:                        ((ChangeListener) it.next()).stateChanged(event);
652:                    }
653:                }
654:
655:            }
656:
657:            private File getAsFile(String filename) {
658:                return FileUtil.normalizeFile(new File(filename));
659:            }
660:
661:            public File getConfigFiles() {
662:                return getAsFile(jTextFieldConfigFiles.getText());
663:            }
664:
665:            public File getLibraries() {
666:                return getAsFile(jTextFieldLibraries.getText());
667:            }
668:
669:            private void configFilesChanged() {
670:                dataChanged();
671:            }
672:
673:        }
w___w___w__._j___av__a___2_s___._c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.