Source Code Cross Referenced for WebLocationsPanel.java in  » IDE-Netbeans » web.core » org » netbeans » modules » web » freeform » ui » 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 » web.core » org.netbeans.modules.web.freeform.ui 
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-2007 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.web.freeform.ui;
043:
044:        import java.awt.event.ActionEvent;
045:        import java.awt.event.ActionListener;
046:        import java.io.File;
047:        import java.util.ArrayList;
048:        import java.util.List;
049:        import javax.swing.JFileChooser;
050:        import org.netbeans.api.queries.CollocationQuery;
051:        import org.netbeans.modules.ant.freeform.spi.support.Util;
052:        import org.netbeans.modules.web.freeform.WebProjectGenerator;
053:        import org.openide.filesystems.FileUtil;
054:        import org.openide.util.HelpCtx;
055:        import org.openide.util.NbBundle;
056:        import org.netbeans.spi.project.AuxiliaryConfiguration;
057:        import org.netbeans.spi.project.support.ant.AntProjectHelper;
058:        import org.netbeans.spi.project.support.ant.PropertyUtils;
059:        import org.netbeans.spi.project.support.ant.PropertyEvaluator;
060:        import org.netbeans.spi.project.ui.support.ProjectChooser;
061:        import org.netbeans.spi.project.ui.templates.support.Templates;
062:        import org.openide.WizardDescriptor;
063:        import org.openide.filesystems.FileObject;
064:
065:        /**
066:         *
067:         * @author  Radko Najman
068:         */
069:        public class WebLocationsPanel extends javax.swing.JPanel implements 
070:                HelpCtx.Provider {
071:
072:            private static String J2EE_SPEC_5 = "1.5"; //NOI18N
073:            private static String J2EE_SPEC_1_4 = "1.4"; //NOI18N
074:            private static String J2EE_SPEC_1_3 = "1.3"; //NOI18N
075:
076:            /** Original project base folder */
077:            private File baseFolder;
078:            /** Freeform Project base folder */
079:            private File nbProjectFolder;
080:
081:            private AntProjectHelper projectHelper;
082:
083:            private File srcPackagesLocation;
084:            private String classpath;
085:
086:            private WizardDescriptor wizardDescriptor;
087:
088:            /** Creates new form WebLocations */
089:            public WebLocationsPanel(WizardDescriptor wizardDescriptor) {
090:                initComponents();
091:                this .wizardDescriptor = wizardDescriptor;
092:                jComboBoxJ2eeLevel.addItem(NbBundle.getMessage(
093:                        WebLocationsPanel.class, "TXT_J2EESpecLevel_5")); //NOI18N
094:                jComboBoxJ2eeLevel.addItem(NbBundle.getMessage(
095:                        WebLocationsPanel.class, "TXT_J2EESpecLevel_0")); //NOI18N
096:                jComboBoxJ2eeLevel.addItem(NbBundle.getMessage(
097:                        WebLocationsPanel.class, "TXT_J2EESpecLevel_1")); //NOI18N
098:                jComboBoxJ2eeLevel.setSelectedIndex(0);
099:            }
100:
101:            public WebLocationsPanel(AntProjectHelper projectHelper,
102:                    PropertyEvaluator projectEvaluator,
103:                    AuxiliaryConfiguration aux) {
104:                this (null);
105:                this .projectHelper = projectHelper;
106:                setFolders(Util.getProjectLocation(projectHelper,
107:                        projectEvaluator), FileUtil.toFile(projectHelper
108:                        .getProjectDirectory()));
109:
110:                List l = WebProjectGenerator.getWebmodules(projectHelper, aux);
111:                if (l != null) {
112:                    WebProjectGenerator.WebModule wm = (WebProjectGenerator.WebModule) l
113:                            .get(0);
114:                    String docroot = getLocationDisplayName(projectEvaluator,
115:                            nbProjectFolder, wm.docRoot);
116:                    String webInf;
117:                    if (wm.webInf != null)
118:                        webInf = getLocationDisplayName(projectEvaluator,
119:                                nbProjectFolder, wm.webInf);
120:                    else
121:                        ////NetBeans 5.x and older projects (WEB-INF is placed under Web Pages)
122:                        webInf = docroot + "/WEB-INF"; //NOI18N
123:                    classpath = wm.classpath;
124:                    jTextFieldWeb.setText(docroot);
125:                    jTextFieldWebInf.setText(webInf);
126:
127:                    jTextFieldContextPath.setText(wm.contextPath);
128:                    if (wm.j2eeSpecLevel == null
129:                            || wm.j2eeSpecLevel.equals(J2EE_SPEC_5))
130:                        jComboBoxJ2eeLevel
131:                                .setSelectedItem(NbBundle.getMessage(
132:                                        WebLocationsPanel.class,
133:                                        "TXT_J2EESpecLevel_5"));
134:                    else if (wm.j2eeSpecLevel.equals(J2EE_SPEC_1_4))
135:                        jComboBoxJ2eeLevel
136:                                .setSelectedItem(NbBundle.getMessage(
137:                                        WebLocationsPanel.class,
138:                                        "TXT_J2EESpecLevel_0"));
139:                    else
140:                        jComboBoxJ2eeLevel
141:                                .setSelectedItem(NbBundle.getMessage(
142:                                        WebLocationsPanel.class,
143:                                        "TXT_J2EESpecLevel_1"));
144:                }
145:            }
146:
147:            /**
148:             * Convert given string value (e.g. "${project.dir}/src" to a file
149:             * and try to relativize it.
150:             */
151:            // XXX: copied from java/freeform:SourceFoldersPanel.getLocationDisplayName
152:            public static String getLocationDisplayName(
153:                    PropertyEvaluator evaluator, File base, String val) {
154:                File f = Util.resolveFile(evaluator, base, val);
155:                if (f == null) {
156:                    return val;
157:                }
158:                String location = f.getAbsolutePath();
159:                if (CollocationQuery.areCollocated(base, f)) {
160:                    location = PropertyUtils.relativizeFile(base, f).replace(
161:                            '/', File.separatorChar); // NOI18N
162:                }
163:                return location;
164:            }
165:
166:            public HelpCtx getHelpCtx() {
167:                return new HelpCtx(WebLocationsPanel.class);
168:            }
169:
170:            /** This method is called from within the constructor to
171:             * initialize the form.
172:             * WARNING: Do NOT modify this code. The content of this method is
173:             * always regenerated by the Form Editor.
174:             */
175:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
176:            private void initComponents() {
177:                java.awt.GridBagConstraints gridBagConstraints;
178:
179:                jLabel1 = new javax.swing.JLabel();
180:                jLabel2 = new javax.swing.JLabel();
181:                jTextFieldWeb = new javax.swing.JTextField();
182:                jButtonWeb = new javax.swing.JButton();
183:                jLabelWebInf = new javax.swing.JLabel();
184:                jTextFieldWebInf = new javax.swing.JTextField();
185:                jButtonWebInf = new javax.swing.JButton();
186:                jLabel4 = new javax.swing.JLabel();
187:                jTextFieldContextPath = new javax.swing.JTextField();
188:                jLabel5 = new javax.swing.JLabel();
189:                jPanel1 = new javax.swing.JPanel();
190:                jLabel6 = new javax.swing.JLabel();
191:                jTextArea1 = new javax.swing.JTextArea();
192:                jComboBoxJ2eeLevel = new javax.swing.JComboBox();
193:
194:                setLayout(new java.awt.GridBagLayout());
195:
196:                jLabel1.setText(org.openide.util.NbBundle.getMessage(
197:                        WebLocationsPanel.class,
198:                        "LBL_WebPagesPanel_Description")); // NOI18N
199:                gridBagConstraints = new java.awt.GridBagConstraints();
200:                gridBagConstraints.gridwidth = 4;
201:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
202:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 8, 0);
203:                add(jLabel1, gridBagConstraints);
204:
205:                jLabel2.setLabelFor(jTextFieldWeb);
206:                org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
207:                        org.openide.util.NbBundle.getMessage(
208:                                WebLocationsPanel.class,
209:                                "LBL_WebPagesPanel_WebPagesLocation_Label")); // NOI18N
210:                gridBagConstraints = new java.awt.GridBagConstraints();
211:                gridBagConstraints.gridx = 0;
212:                gridBagConstraints.gridy = 1;
213:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
214:                add(jLabel2, gridBagConstraints);
215:                gridBagConstraints = new java.awt.GridBagConstraints();
216:                gridBagConstraints.gridx = 1;
217:                gridBagConstraints.gridy = 1;
218:                gridBagConstraints.gridwidth = 2;
219:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
220:                gridBagConstraints.weightx = 1.0;
221:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
222:                add(jTextFieldWeb, gridBagConstraints);
223:                jTextFieldWeb
224:                        .getAccessibleContext()
225:                        .setAccessibleDescription(
226:                                org.openide.util.NbBundle
227:                                        .getMessage(WebLocationsPanel.class,
228:                                                "ACS_LBL_WebPagesPanel_WebPagesLocation_A11YDesc")); // NOI18N
229:
230:                org.openide.awt.Mnemonics.setLocalizedText(jButtonWeb,
231:                        org.openide.util.NbBundle.getMessage(
232:                                WebLocationsPanel.class,
233:                                "BTN_BasicProjectInfoPanel_browseAntScript")); // NOI18N
234:                jButtonWeb
235:                        .addActionListener(new java.awt.event.ActionListener() {
236:                            public void actionPerformed(
237:                                    java.awt.event.ActionEvent evt) {
238:                                jButtonWebActionPerformed(evt);
239:                            }
240:                        });
241:                gridBagConstraints = new java.awt.GridBagConstraints();
242:                gridBagConstraints.gridx = 3;
243:                gridBagConstraints.gridy = 1;
244:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
245:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
246:                add(jButtonWeb, gridBagConstraints);
247:                jButtonWeb
248:                        .getAccessibleContext()
249:                        .setAccessibleDescription(
250:                                org.openide.util.NbBundle
251:                                        .getMessage(WebLocationsPanel.class,
252:                                                "ACS_LBL_WebPagesPanel_WebPagesLocationBrowse_A11YDesc")); // NOI18N
253:
254:                jLabelWebInf.setDisplayedMnemonic(java.util.ResourceBundle
255:                        .getBundle(
256:                                "org/netbeans/modules/web/freeform/ui/Bundle")
257:                        .getString("MNE_DeploymentDescriptorFolder").charAt(0));
258:                jLabelWebInf.setLabelFor(jTextFieldWebInf);
259:                jLabelWebInf.setText(org.openide.util.NbBundle.getMessage(
260:                        WebLocationsPanel.class,
261:                        "LBL_DeploymentDescriptorFolder_Label")); // NOI18N
262:                gridBagConstraints = new java.awt.GridBagConstraints();
263:                gridBagConstraints.gridx = 0;
264:                gridBagConstraints.gridy = 2;
265:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
266:                gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
267:                add(jLabelWebInf, gridBagConstraints);
268:                gridBagConstraints = new java.awt.GridBagConstraints();
269:                gridBagConstraints.gridx = 1;
270:                gridBagConstraints.gridy = 2;
271:                gridBagConstraints.gridwidth = 2;
272:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
273:                gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0);
274:                add(jTextFieldWebInf, gridBagConstraints);
275:                jTextFieldWebInf.getAccessibleContext()
276:                        .setAccessibleDescription(
277:                                org.openide.util.NbBundle.getMessage(
278:                                        WebLocationsPanel.class,
279:                                        "ACSD_WEBINF_TEXTFIELD")); // NOI18N
280:
281:                jButtonWebInf.setMnemonic(java.util.ResourceBundle.getBundle(
282:                        "org/netbeans/modules/web/freeform/ui/Bundle")
283:                        .getString("MNE_BrowseWebInfLocation").charAt(0));
284:                jButtonWebInf.setText(org.openide.util.NbBundle.getMessage(
285:                        WebLocationsPanel.class,
286:                        "LBL_DeploymentDescriptorBrowse_Label")); // NOI18N
287:                jButtonWebInf
288:                        .addActionListener(new java.awt.event.ActionListener() {
289:                            public void actionPerformed(
290:                                    java.awt.event.ActionEvent evt) {
291:                                jButtonWebInfActionPerformed(evt);
292:                            }
293:                        });
294:                gridBagConstraints = new java.awt.GridBagConstraints();
295:                gridBagConstraints.gridx = 3;
296:                gridBagConstraints.gridy = 2;
297:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
298:                gridBagConstraints.insets = new java.awt.Insets(5, 6, 0, 0);
299:                add(jButtonWebInf, gridBagConstraints);
300:                jButtonWebInf.getAccessibleContext().setAccessibleDescription(
301:                        org.openide.util.NbBundle.getMessage(
302:                                WebLocationsPanel.class, "ACSD_WEBINF_BROWSE")); // NOI18N
303:
304:                jLabel4.setLabelFor(jTextFieldContextPath);
305:                org.openide.awt.Mnemonics.setLocalizedText(jLabel4,
306:                        org.openide.util.NbBundle.getMessage(
307:                                WebLocationsPanel.class,
308:                                "LBL_WebPagesPanel_ContextPath_Label")); // NOI18N
309:                gridBagConstraints = new java.awt.GridBagConstraints();
310:                gridBagConstraints.gridx = 0;
311:                gridBagConstraints.gridy = 3;
312:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
313:                gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
314:                add(jLabel4, gridBagConstraints);
315:                gridBagConstraints = new java.awt.GridBagConstraints();
316:                gridBagConstraints.gridx = 1;
317:                gridBagConstraints.gridy = 3;
318:                gridBagConstraints.gridwidth = 2;
319:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
320:                gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0);
321:                add(jTextFieldContextPath, gridBagConstraints);
322:                jTextFieldContextPath
323:                        .getAccessibleContext()
324:                        .setAccessibleDescription(
325:                                org.openide.util.NbBundle
326:                                        .getMessage(WebLocationsPanel.class,
327:                                                "ACS_LBL_WebPagesPanel_ContextPath_A11YDesc")); // NOI18N
328:
329:                jLabel5.setLabelFor(jComboBoxJ2eeLevel);
330:                org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
331:                        org.openide.util.NbBundle.getMessage(
332:                                WebLocationsPanel.class,
333:                                "LBL_WebPagesPanel_J2EESpecLevel_Label")); // NOI18N
334:                gridBagConstraints = new java.awt.GridBagConstraints();
335:                gridBagConstraints.gridx = 0;
336:                gridBagConstraints.gridy = 4;
337:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
338:                gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
339:                add(jLabel5, gridBagConstraints);
340:
341:                jPanel1.setBorder(javax.swing.BorderFactory
342:                        .createLineBorder(javax.swing.UIManager.getDefaults()
343:                                .getColor("Label.disabledForeground")));
344:                jPanel1.setLayout(new java.awt.GridBagLayout());
345:
346:                jLabel6
347:                        .setIcon(new javax.swing.ImageIcon(
348:                                getClass()
349:                                        .getResource(
350:                                                "/org/netbeans/modules/web/freeform/resources/alert_32.png"))); // NOI18N
351:                gridBagConstraints = new java.awt.GridBagConstraints();
352:                gridBagConstraints.gridx = 0;
353:                gridBagConstraints.gridy = 0;
354:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
355:                gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 0);
356:                jPanel1.add(jLabel6, gridBagConstraints);
357:
358:                jTextArea1.setBackground(javax.swing.UIManager.getDefaults()
359:                        .getColor("Panel.background"));
360:                jTextArea1.setEditable(false);
361:                jTextArea1.setLineWrap(true);
362:                jTextArea1.setText(org.openide.util.NbBundle.getMessage(
363:                        WebLocationsPanel.class, "Freeform_Warning_Message")); // NOI18N
364:                jTextArea1.setWrapStyleWord(true);
365:                gridBagConstraints = new java.awt.GridBagConstraints();
366:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
367:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
368:                gridBagConstraints.weightx = 1.0;
369:                gridBagConstraints.insets = new java.awt.Insets(4, 10, 4, 4);
370:                jPanel1.add(jTextArea1, gridBagConstraints);
371:
372:                gridBagConstraints = new java.awt.GridBagConstraints();
373:                gridBagConstraints.gridx = 0;
374:                gridBagConstraints.gridy = 5;
375:                gridBagConstraints.gridwidth = 4;
376:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
377:                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
378:                gridBagConstraints.weighty = 1.0;
379:                add(jPanel1, gridBagConstraints);
380:                gridBagConstraints = new java.awt.GridBagConstraints();
381:                gridBagConstraints.gridx = 1;
382:                gridBagConstraints.gridy = 4;
383:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
384:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
385:                gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0);
386:                add(jComboBoxJ2eeLevel, gridBagConstraints);
387:                jComboBoxJ2eeLevel
388:                        .getAccessibleContext()
389:                        .setAccessibleDescription(
390:                                org.openide.util.NbBundle
391:                                        .getMessage(WebLocationsPanel.class,
392:                                                "ACS_LBL_WebPagesPanel_J2EESpecLevel_A11YDesc")); // NOI18N
393:            }// </editor-fold>//GEN-END:initComponents
394:
395:            private void jButtonWebInfActionPerformed(
396:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWebInfActionPerformed
397:                JFileChooser chooser = createChooser(getWebInfLocation(),
398:                        wizardDescriptor);
399:                if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this )) {
400:                    setWebInf(chooser.getSelectedFile());
401:                }
402:            }//GEN-LAST:event_jButtonWebInfActionPerformed
403:
404:            private void jButtonWebActionPerformed(
405:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWebActionPerformed
406:                JFileChooser chooser = createChooser(getWebPagesLocation(),
407:                        wizardDescriptor);
408:                if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this )) {
409:                    setWebPages(chooser.getSelectedFile());
410:                }
411:            }//GEN-LAST:event_jButtonWebActionPerformed
412:
413:            // Variables declaration - do not modify//GEN-BEGIN:variables
414:            private javax.swing.JButton jButtonWeb;
415:            private javax.swing.JButton jButtonWebInf;
416:            private javax.swing.JComboBox jComboBoxJ2eeLevel;
417:            private javax.swing.JLabel jLabel1;
418:            private javax.swing.JLabel jLabel2;
419:            private javax.swing.JLabel jLabel4;
420:            private javax.swing.JLabel jLabel5;
421:            private javax.swing.JLabel jLabel6;
422:            private javax.swing.JLabel jLabelWebInf;
423:            private javax.swing.JPanel jPanel1;
424:            private javax.swing.JTextArea jTextArea1;
425:            private javax.swing.JTextField jTextFieldContextPath;
426:            private javax.swing.JTextField jTextFieldWeb;
427:            private javax.swing.JTextField jTextFieldWebInf;
428:
429:            // End of variables declaration//GEN-END:variables
430:
431:            private static JFileChooser createChooser(File webPagesLoc,
432:                    WizardDescriptor wizardDescriptor) {
433:                String path = webPagesLoc.getAbsolutePath();
434:                JFileChooser chooser = new JFileChooser();
435:                FileUtil.preventFileChooserSymlinkTraversal(chooser, new File(
436:                        path));
437:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
438:                chooser.setAcceptAllFileFilterUsed(false);
439:
440:                if (path.length() > 0 && webPagesLoc.exists()) {
441:                    chooser.setSelectedFile(webPagesLoc);
442:                } else {
443:                    if (wizardDescriptor != null) {
444:                        // honor the contract in issue 58987
445:                        File currentDirectory = null;
446:                        FileObject existingSourcesFO = Templates
447:                                .getExistingSourcesFolder(wizardDescriptor);
448:                        if (existingSourcesFO != null) {
449:                            File existingSourcesFile = FileUtil
450:                                    .toFile(existingSourcesFO);
451:                            if (existingSourcesFile != null
452:                                    && existingSourcesFile.isDirectory()) {
453:                                currentDirectory = existingSourcesFile;
454:                            }
455:                        }
456:                        if (currentDirectory != null) {
457:                            chooser.setCurrentDirectory(currentDirectory);
458:                        } else {
459:                            chooser.setSelectedFile(ProjectChooser
460:                                    .getProjectsFolder());
461:                        }
462:                    } else {
463:                        chooser.setSelectedFile(ProjectChooser
464:                                .getProjectsFolder());
465:                    }
466:                }
467:
468:                return chooser;
469:            }
470:
471:            protected List<WebProjectGenerator.WebModule> getWebModules() {
472:                ArrayList<WebProjectGenerator.WebModule> l = new ArrayList<WebProjectGenerator.WebModule>();
473:
474:                WebProjectGenerator.WebModule wm = new WebProjectGenerator.WebModule();
475:                wm.docRoot = getRelativeLocation(getWebPagesLocation());
476:                wm.webInf = getRelativeLocation(getWebInfLocation());
477:                wm.contextPath = jTextFieldContextPath.getText().trim();
478:
479:                String j2eeLevel = (String) jComboBoxJ2eeLevel
480:                        .getSelectedItem();
481:                if (j2eeLevel.equals(NbBundle.getMessage(
482:                        WebLocationsPanel.class, "TXT_J2EESpecLevel_5")))
483:                    wm.j2eeSpecLevel = J2EE_SPEC_5;
484:                else if (j2eeLevel.equals(NbBundle.getMessage(
485:                        WebLocationsPanel.class, "TXT_J2EESpecLevel_0")))
486:                    wm.j2eeSpecLevel = J2EE_SPEC_1_4;
487:                else
488:                    wm.j2eeSpecLevel = J2EE_SPEC_1_3;
489:
490:                wm.classpath = classpath;
491:                l.add(wm);
492:                return l;
493:            }
494:
495:            protected List<String> getJavaSrcFolder() {
496:                ArrayList<String> l = new ArrayList<String>();
497:                File sourceLoc = getSrcPackagesLocation();
498:                l.add(getRelativeLocation(sourceLoc));
499:                l.add(sourceLoc.getName());
500:                return l;
501:            }
502:
503:            /**
504:             * @return list of pairs [relative path, display name]
505:             */
506:            protected List<String> getWebSrcFolder() {
507:                ArrayList<String> l = new ArrayList<String>();
508:                final File webLocation = getWebPagesLocation();
509:                l.add(getRelativeLocation(webLocation));
510:                l.add(webLocation.getName());
511:                return l;
512:            }
513:
514:            /**
515:             * @return list of pairs [relative path, display name]
516:             */
517:            protected List<String> getWebInfFolder() {
518:                ArrayList<String> l = new ArrayList<String>();
519:                final File webInfLocation = getWebInfLocation();
520:                l.add(getRelativeLocation(webInfLocation));
521:                l.add(webInfLocation.getName());
522:                return l;
523:            }
524:
525:            private File getAsFile(String filename) {
526:                return PropertyUtils.resolveFile(nbProjectFolder, filename);
527:            }
528:
529:            /** Called from WizardDescriptor.Panel and ProjectCustomizer.Panel
530:             * to set base folder. Panel will use this for default position of JFileChooser.
531:             * @param baseFolder original project base folder
532:             * @param nbProjectFolder Freeform Project base folder
533:             */
534:            public void setFolders(File baseFolder, File nbProjectFolder) {
535:                this .baseFolder = baseFolder;
536:                this .nbProjectFolder = nbProjectFolder;
537:            }
538:
539:            protected void setWebPages(String path) {
540:                jTextFieldWeb.setText(path);
541:            }
542:
543:            protected void setWebInf(String path) {
544:                jTextFieldWebInf.setText(path);
545:            }
546:
547:            protected void setSrcPackages(String path) {
548:                setSrcPackages(getAsFile(path));
549:            }
550:
551:            private void setWebPages(final File file) {
552:                setWebPages(relativizeFile(file));
553:            }
554:
555:            private void setWebInf(final File file) {
556:                setWebInf(relativizeFile(file));
557:            }
558:
559:            protected File getWebPagesLocation() {
560:                return getAsFile(jTextFieldWeb.getText()).getAbsoluteFile();
561:            }
562:
563:            protected File getWebInfLocation() {
564:                return getAsFile(jTextFieldWebInf.getText()).getAbsoluteFile();
565:            }
566:
567:            private void setSrcPackages(final File file) {
568:                srcPackagesLocation = file;
569:            }
570:
571:            protected File getSrcPackagesLocation() {
572:                return srcPackagesLocation;
573:            }
574:
575:            private String relativizeFile(final File file) {
576:                File normalizedFile = FileUtil.normalizeFile(file);
577:                if (CollocationQuery.areCollocated(nbProjectFolder, file)) {
578:                    return PropertyUtils.relativizeFile(nbProjectFolder,
579:                            normalizedFile);
580:                } else {
581:                    return normalizedFile.getAbsolutePath();
582:                }
583:            }
584:
585:            private String getRelativeLocation(final File location) {
586:                final File normalizedLocation = FileUtil
587:                        .normalizeFile(location);
588:                return Util.relativizeLocation(baseFolder, nbProjectFolder,
589:                        normalizedLocation);
590:            }
591:
592:            ActionListener getCustomizerOkListener() {
593:                return new ActionListener() {
594:                    public void actionPerformed(ActionEvent arg0) {
595:                        AuxiliaryConfiguration aux = Util
596:                                .getAuxiliaryConfiguration(projectHelper);
597:                        WebProjectGenerator.putWebSourceFolder(projectHelper,
598:                                getWebSrcFolder());
599:                        WebProjectGenerator.putWebInfFolder(projectHelper,
600:                                getWebInfFolder());
601:                        WebProjectGenerator.putWebModules(projectHelper, aux,
602:                                getWebModules());
603:                    }
604:                };
605:            }
606:
607:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.