Source Code Cross Referenced for ImportLocationVisual.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) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         *
0026:         * The Original Software is NetBeans. The Initial Developer of the Original
0027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
0028:         * Microsystems, Inc. All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         */
0041:
0042:        package org.netbeans.modules.j2ee.clientproject.ui.wizards;
0043:
0044:        import java.awt.Dialog;
0045:        import java.awt.event.ActionEvent;
0046:        import java.awt.event.ActionListener;
0047:        import java.io.File;
0048:        import java.io.IOException;
0049:        import java.math.BigDecimal;
0050:        import java.text.MessageFormat;
0051:        import java.util.ArrayList;
0052:        import java.util.List;
0053:        import java.util.Set;
0054:        import java.util.TreeSet;
0055:        import javax.swing.DefaultComboBoxModel;
0056:        import javax.swing.JButton;
0057:        import javax.swing.JFileChooser;
0058:        import javax.swing.JPanel;
0059:        import javax.swing.event.DocumentEvent;
0060:        import javax.swing.event.DocumentListener;
0061:        import org.netbeans.api.project.Project;
0062:        import org.netbeans.api.project.ProjectInformation;
0063:        import org.netbeans.api.project.ProjectManager;
0064:        import org.netbeans.api.project.ProjectUtils;
0065:        import org.netbeans.api.project.ui.OpenProjects;
0066:        import org.netbeans.modules.j2ee.clientproject.AppClientProvider;
0067:        import org.netbeans.modules.j2ee.common.project.ui.UserProjectSettings;
0068:        import org.netbeans.modules.j2ee.dd.api.client.AppClient;
0069:        import org.netbeans.modules.j2ee.dd.api.client.DDProvider;
0070:        import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
0071:        import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
0072:        import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication;
0073:        import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
0074:        import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerManager;
0075:        import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeApplicationProvider;
0076:        import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
0077:        import org.netbeans.spi.project.ui.support.ProjectChooser;
0078:        import org.netbeans.spi.project.ui.templates.support.Templates;
0079:        import org.openide.DialogDescriptor;
0080:        import org.openide.DialogDisplayer;
0081:        import org.openide.NotifyDescriptor;
0082:        import org.openide.WizardDescriptor;
0083:        import org.openide.WizardValidationException;
0084:        import org.openide.filesystems.FileObject;
0085:        import org.openide.filesystems.FileUtil;
0086:        import org.openide.util.Exceptions;
0087:        import org.openide.util.NbBundle;
0088:
0089:        /**
0090:         *
0091:         * @author  pb97924, Martin Adamek
0092:         */
0093:        public class ImportLocationVisual extends JPanel /*implements DocumentListener */{
0094:            private static final long serialVersionUID = 1L;
0095:
0096:            private final DefaultComboBoxModel serversModel = new DefaultComboBoxModel();
0097:            private static final String J2EE_SPEC_15_LABEL = NbBundle
0098:                    .getMessage(ImportLocationVisual.class, "J2EESpecLevel_15"); //NOI18N
0099:            private static final String J2EE_SPEC_14_LABEL = NbBundle
0100:                    .getMessage(ImportLocationVisual.class, "J2EESpecLevel_14"); //NOI18N
0101:            private static final String J2EE_SPEC_13_LABEL = NbBundle
0102:                    .getMessage(ImportLocationVisual.class, "J2EESpecLevel_13"); //NOI18N
0103:            private final ImportLocation panel;
0104:            private final DocumentListener documentListener;
0105:            /** Was projectFolder property edited by user? */
0106:            private boolean projectFolderTouched;
0107:            /** Was projectName property edited by user? */
0108:            private boolean projectNameTouched;
0109:            private List<Project> earProjects;
0110:            private WizardDescriptor wizardDescriptor;
0111:            private J2eeVersionWarningPanel warningPanel;
0112:
0113:            /** Creates new form TestPanel */
0114:            public ImportLocationVisual(ImportLocation panel) {
0115:                this .panel = panel;
0116:                initComponents();
0117:                setJ2eeVersionWarningPanel();
0118:                initServers(UserProjectSettings.getDefault()
0119:                        .getLastUsedServer());
0120:                // preselect the first item in the j2ee spec combo
0121:                if (j2eeSpecComboBox.getModel().getSize() > 0) {
0122:                    j2eeSpecComboBox.setSelectedIndex(0);
0123:                }
0124:                initEnterpriseApplications();
0125:                this .getAccessibleContext().setAccessibleDescription(
0126:                        NbBundle.getMessage(ImportLocationVisual.class,
0127:                                "ACS_NWP1_NamePanel_A11YDesc")); // NOI18N
0128:                setName(NbBundle
0129:                        .getBundle(
0130:                                "org/netbeans/modules/j2ee/clientproject/ui/wizards/Bundle")
0131:                        .getString("LBL_IW_ImportTitle")); //NOI18N
0132:                putClientProperty("NewProjectWizard_Title", NbBundle
0133:                        .getMessage(ImportLocationVisual.class,
0134:                                "TXT_ImportAppClientModule")); //NOI18N
0135:                this .projectName.setText("");
0136:                documentListener = new DocumentListener() {
0137:                    public void insertUpdate(DocumentEvent e) {
0138:                        update(e);
0139:                    }
0140:
0141:                    public void removeUpdate(DocumentEvent e) {
0142:                        update(e);
0143:                    }
0144:
0145:                    public void changedUpdate(DocumentEvent e) {
0146:                        update(e);
0147:                    }
0148:                };
0149:                this .projectName.getDocument().addDocumentListener(
0150:                        documentListener);
0151:                this .projectFolder.getDocument().addDocumentListener(
0152:                        documentListener);
0153:            }
0154:
0155:            /** This method is called from within the constructor to
0156:             * initialize the form.
0157:             * WARNING: Do NOT modify this code. The content of this method is
0158:             * always regenerated by the Form Editor.
0159:             */
0160:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
0161:            private void initComponents() {
0162:                java.awt.GridBagConstraints gridBagConstraints;
0163:
0164:                jLabelSrcLocationDesc = new javax.swing.JLabel();
0165:                jLabelSrcLocation = new javax.swing.JLabel();
0166:                projectLocation = new javax.swing.JTextField();
0167:                browseProjectLocation = new javax.swing.JButton();
0168:                jLabelPrjLocationDesc = new javax.swing.JLabel();
0169:                jLabelPrjName = new javax.swing.JLabel();
0170:                projectName = new javax.swing.JTextField();
0171:                jLabelPrjLocation = new javax.swing.JLabel();
0172:                projectFolder = new javax.swing.JTextField();
0173:                browseProjectFolder = new javax.swing.JButton();
0174:                jSeparator1 = new javax.swing.JSeparator();
0175:                jPanel1 = new javax.swing.JPanel();
0176:                jCheckBox1 = new javax.swing.JCheckBox();
0177:                serverInstanceLabel = new javax.swing.JLabel();
0178:                serverInstanceComboBox = new javax.swing.JComboBox();
0179:                jLabel7 = new javax.swing.JLabel();
0180:                j2eeSpecComboBox = new javax.swing.JComboBox();
0181:                addToAppLabel = new javax.swing.JLabel();
0182:                addToAppComboBox = new javax.swing.JComboBox();
0183:                warningPlaceHolderPanel = new javax.swing.JPanel();
0184:                addServerButton = new javax.swing.JButton();
0185:
0186:                setNextFocusableComponent(projectLocation);
0187:                setLayout(new java.awt.GridBagLayout());
0188:
0189:                org.openide.awt.Mnemonics.setLocalizedText(
0190:                        jLabelSrcLocationDesc, NbBundle.getMessage(
0191:                                ImportLocationVisual.class,
0192:                                "LBL_IW_LocationSrcDesc")); // NOI18N
0193:                gridBagConstraints = new java.awt.GridBagConstraints();
0194:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0195:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0196:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
0197:                add(jLabelSrcLocationDesc, gridBagConstraints);
0198:
0199:                jLabelSrcLocation
0200:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
0201:                jLabelSrcLocation.setLabelFor(projectLocation);
0202:                org.openide.awt.Mnemonics.setLocalizedText(jLabelSrcLocation,
0203:                        NbBundle.getMessage(ImportLocationVisual.class,
0204:                                "LBL_IW_LocationSrc_Label")); // NOI18N
0205:                gridBagConstraints = new java.awt.GridBagConstraints();
0206:                gridBagConstraints.gridx = 0;
0207:                gridBagConstraints.gridy = 1;
0208:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0209:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0210:                add(jLabelSrcLocation, gridBagConstraints);
0211:                jLabelSrcLocation.getAccessibleContext()
0212:                        .setAccessibleDescription(
0213:                                org.openide.util.NbBundle.getMessage(
0214:                                        ImportLocationVisual.class,
0215:                                        "ACS_LBL_IW_Location_A11Desc")); // NOI18N
0216:
0217:                projectLocation
0218:                        .setNextFocusableComponent(browseProjectLocation);
0219:                projectLocation
0220:                        .addFocusListener(new java.awt.event.FocusAdapter() {
0221:                            public void focusLost(java.awt.event.FocusEvent evt) {
0222:                                projectLocationFocusLost(evt);
0223:                            }
0224:                        });
0225:                gridBagConstraints = new java.awt.GridBagConstraints();
0226:                gridBagConstraints.gridx = 1;
0227:                gridBagConstraints.gridy = 1;
0228:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0229:                gridBagConstraints.weightx = 1.0;
0230:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0231:                add(projectLocation, gridBagConstraints);
0232:                projectLocation.getAccessibleContext()
0233:                        .setAccessibleDescription(
0234:                                org.openide.util.NbBundle.getMessage(
0235:                                        ImportLocationVisual.class,
0236:                                        "ACS_LBL_IW_ImportLocation_A11YDesc")); // NOI18N
0237:
0238:                org.openide.awt.Mnemonics.setLocalizedText(
0239:                        browseProjectLocation, NbBundle.getMessage(
0240:                                ImportLocationVisual.class,
0241:                                "LBL_NWP1_BrowseLocation_Button_w")); // NOI18N
0242:                browseProjectLocation.setNextFocusableComponent(projectName);
0243:                browseProjectLocation
0244:                        .addActionListener(new java.awt.event.ActionListener() {
0245:                            public void actionPerformed(
0246:                                    java.awt.event.ActionEvent evt) {
0247:                                browseProjectLocationActionPerformed(evt);
0248:                            }
0249:                        });
0250:                gridBagConstraints = new java.awt.GridBagConstraints();
0251:                gridBagConstraints.gridx = 2;
0252:                gridBagConstraints.gridy = 1;
0253:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
0254:                add(browseProjectLocation, gridBagConstraints);
0255:                browseProjectLocation
0256:                        .getAccessibleContext()
0257:                        .setAccessibleDescription(
0258:                                org.openide.util.NbBundle
0259:                                        .getMessage(ImportLocationVisual.class,
0260:                                                "ACS_LBL_IW_ImportLocationBrowse_A11YDesc")); // NOI18N
0261:
0262:                org.openide.awt.Mnemonics.setLocalizedText(
0263:                        jLabelPrjLocationDesc, NbBundle.getMessage(
0264:                                ImportLocationVisual.class,
0265:                                "LBL_IW_LocationPrjDesc")); // NOI18N
0266:                gridBagConstraints = new java.awt.GridBagConstraints();
0267:                gridBagConstraints.gridx = 0;
0268:                gridBagConstraints.gridy = 2;
0269:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0270:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0271:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
0272:                add(jLabelPrjLocationDesc, gridBagConstraints);
0273:
0274:                jLabelPrjName
0275:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
0276:                jLabelPrjName.setLabelFor(projectName);
0277:                org.openide.awt.Mnemonics.setLocalizedText(jLabelPrjName,
0278:                        org.openide.util.NbBundle.getMessage(
0279:                                ImportLocationVisual.class,
0280:                                "LBL_NWP1_ProjectName_Label")); // NOI18N
0281:                gridBagConstraints = new java.awt.GridBagConstraints();
0282:                gridBagConstraints.gridx = 0;
0283:                gridBagConstraints.gridy = 3;
0284:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0285:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0286:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0287:                add(jLabelPrjName, gridBagConstraints);
0288:                java.util.ResourceBundle bundle = java.util.ResourceBundle
0289:                        .getBundle("org/netbeans/modules/j2ee/clientproject/ui/wizards/Bundle"); // NOI18N
0290:                jLabelPrjName.getAccessibleContext().setAccessibleDescription(
0291:                        bundle.getString("ACS_LBL_IW_ProjectName_A11Desc")); // NOI18N
0292:
0293:                projectName.setNextFocusableComponent(projectFolder);
0294:                gridBagConstraints = new java.awt.GridBagConstraints();
0295:                gridBagConstraints.gridx = 1;
0296:                gridBagConstraints.gridy = 3;
0297:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0298:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0299:                add(projectName, gridBagConstraints);
0300:                projectName.getAccessibleContext().setAccessibleDescription(
0301:                        org.openide.util.NbBundle.getMessage(
0302:                                ImportLocationVisual.class,
0303:                                "ACS_LBL_NWP1_ProjectName_A11YDesc")); // NOI18N
0304:
0305:                jLabelPrjLocation
0306:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
0307:                jLabelPrjLocation.setLabelFor(projectFolder);
0308:                org.openide.awt.Mnemonics.setLocalizedText(jLabelPrjLocation,
0309:                        NbBundle.getMessage(ImportLocationVisual.class,
0310:                                "LBL_NWP1_CreatedProjectFolder_Label")); // NOI18N
0311:                gridBagConstraints = new java.awt.GridBagConstraints();
0312:                gridBagConstraints.gridx = 0;
0313:                gridBagConstraints.gridy = 4;
0314:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0315:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0316:                add(jLabelPrjLocation, gridBagConstraints);
0317:                jLabelPrjLocation
0318:                        .getAccessibleContext()
0319:                        .setAccessibleDescription(
0320:                                bundle
0321:                                        .getString("ACS_LBL_IW_ProjectFolder_A11Desc")); // NOI18N
0322:
0323:                projectFolder.setNextFocusableComponent(browseProjectFolder);
0324:                gridBagConstraints = new java.awt.GridBagConstraints();
0325:                gridBagConstraints.gridx = 1;
0326:                gridBagConstraints.gridy = 4;
0327:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0328:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0329:                add(projectFolder, gridBagConstraints);
0330:                projectFolder.getAccessibleContext().setAccessibleDescription(
0331:                        org.openide.util.NbBundle.getMessage(
0332:                                ImportLocationVisual.class,
0333:                                "ACS_LBL_NPW1_ProjectLocation_A11YDesc")); // NOI18N
0334:
0335:                org.openide.awt.Mnemonics.setLocalizedText(browseProjectFolder,
0336:                        NbBundle.getMessage(ImportLocationVisual.class,
0337:                                "LBL_NWP1_BrowseLocation_Button")); // NOI18N
0338:                browseProjectFolder
0339:                        .addActionListener(new java.awt.event.ActionListener() {
0340:                            public void actionPerformed(
0341:                                    java.awt.event.ActionEvent evt) {
0342:                                browseProjectFolderActionPerformed(evt);
0343:                            }
0344:                        });
0345:                gridBagConstraints = new java.awt.GridBagConstraints();
0346:                gridBagConstraints.gridx = 2;
0347:                gridBagConstraints.gridy = 4;
0348:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
0349:                add(browseProjectFolder, gridBagConstraints);
0350:                browseProjectFolder
0351:                        .getAccessibleContext()
0352:                        .setAccessibleDescription(
0353:                                org.openide.util.NbBundle.getMessage(
0354:                                        ImportLocationVisual.class,
0355:                                        "ACS_LBL_NWP1_BrowseLocation_A11YDesc")); // NOI18N
0356:
0357:                gridBagConstraints = new java.awt.GridBagConstraints();
0358:                gridBagConstraints.gridx = 0;
0359:                gridBagConstraints.gridy = 5;
0360:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0361:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0362:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
0363:                gridBagConstraints.weightx = 1.0;
0364:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
0365:                add(jSeparator1, gridBagConstraints);
0366:
0367:                jPanel1.setLayout(new java.awt.GridBagLayout());
0368:
0369:                jCheckBox1.setSelected(true);
0370:                org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, bundle
0371:                        .getString("LBL_IW_SetAsMainProject_CheckBox")); // NOI18N
0372:                gridBagConstraints = new java.awt.GridBagConstraints();
0373:                gridBagConstraints.gridx = 0;
0374:                gridBagConstraints.gridy = 4;
0375:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0376:                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
0377:                gridBagConstraints.weightx = 1.0;
0378:                gridBagConstraints.weighty = 1.0;
0379:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
0380:                jPanel1.add(jCheckBox1, gridBagConstraints);
0381:                jCheckBox1
0382:                        .getAccessibleContext()
0383:                        .setAccessibleDescription(
0384:                                bundle
0385:                                        .getString("ACS_LBL_IW_SetAsMainProject_A11YDesc")); // NOI18N
0386:
0387:                serverInstanceLabel.setLabelFor(serverInstanceComboBox);
0388:                org.openide.awt.Mnemonics.setLocalizedText(serverInstanceLabel,
0389:                        org.openide.util.NbBundle.getMessage(
0390:                                ImportLocationVisual.class, "LBL_IW_Server")); // NOI18N
0391:                gridBagConstraints = new java.awt.GridBagConstraints();
0392:                gridBagConstraints.gridx = 0;
0393:                gridBagConstraints.gridy = 1;
0394:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0395:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 11);
0396:                jPanel1.add(serverInstanceLabel, gridBagConstraints);
0397:
0398:                serverInstanceComboBox.setModel(serversModel);
0399:                serverInstanceComboBox
0400:                        .setNextFocusableComponent(j2eeSpecComboBox);
0401:                serverInstanceComboBox
0402:                        .setPrototypeDisplayValue("The Gr8est Marvelous Nr. 1 Server");
0403:                serverInstanceComboBox
0404:                        .addActionListener(new java.awt.event.ActionListener() {
0405:                            public void actionPerformed(
0406:                                    java.awt.event.ActionEvent evt) {
0407:                                serverInstanceComboBoxActionPerformed(evt);
0408:                            }
0409:                        });
0410:                gridBagConstraints = new java.awt.GridBagConstraints();
0411:                gridBagConstraints.gridx = 1;
0412:                gridBagConstraints.gridy = 1;
0413:                gridBagConstraints.gridwidth = 2;
0414:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0415:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0416:                gridBagConstraints.weightx = 1.0;
0417:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
0418:                jPanel1.add(serverInstanceComboBox, gridBagConstraints);
0419:                serverInstanceComboBox
0420:                        .getAccessibleContext()
0421:                        .setAccessibleDescription(
0422:                                bundle
0423:                                        .getString("ACS_LBL_IW_SelectServerInstance_A11YDesc")); // NOI18N
0424:
0425:                jLabel7.setDisplayedMnemonic(org.openide.util.NbBundle
0426:                        .getMessage(ImportLocationVisual.class,
0427:                                "LBL_IW_SelectJ2EEVersion_LabelMnemonic")
0428:                        .charAt(0));
0429:                jLabel7.setLabelFor(j2eeSpecComboBox);
0430:                jLabel7.setText(org.openide.util.NbBundle.getMessage(
0431:                        ImportLocationVisual.class,
0432:                        "LBL_IW_J2EESpecLevel_Label")); // NOI18N
0433:                gridBagConstraints = new java.awt.GridBagConstraints();
0434:                gridBagConstraints.gridx = 0;
0435:                gridBagConstraints.gridy = 2;
0436:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0437:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0438:                jPanel1.add(jLabel7, gridBagConstraints);
0439:
0440:                j2eeSpecComboBox.setNextFocusableComponent(jCheckBox1);
0441:                j2eeSpecComboBox
0442:                        .setPrototypeDisplayValue("MMMMMMMMM" /* "Java EE 5" */);
0443:                j2eeSpecComboBox
0444:                        .addActionListener(new java.awt.event.ActionListener() {
0445:                            public void actionPerformed(
0446:                                    java.awt.event.ActionEvent evt) {
0447:                                j2eeSpecComboBoxActionPerformed(evt);
0448:                            }
0449:                        });
0450:                gridBagConstraints = new java.awt.GridBagConstraints();
0451:                gridBagConstraints.gridx = 1;
0452:                gridBagConstraints.gridy = 2;
0453:                gridBagConstraints.gridwidth = 2;
0454:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0455:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0456:                jPanel1.add(j2eeSpecComboBox, gridBagConstraints);
0457:                j2eeSpecComboBox
0458:                        .getAccessibleContext()
0459:                        .setAccessibleDescription(
0460:                                bundle
0461:                                        .getString("ACS_LBL_IW_SelectJ2EEVersion_A11YDesc")); // NOI18N
0462:
0463:                addToAppLabel.setLabelFor(addToAppComboBox);
0464:                org.openide.awt.Mnemonics.setLocalizedText(addToAppLabel,
0465:                        bundle.getString("LBL_NWP1_AddToEApp_CheckBox")); // NOI18N
0466:                gridBagConstraints = new java.awt.GridBagConstraints();
0467:                gridBagConstraints.gridx = 0;
0468:                gridBagConstraints.gridy = 0;
0469:                gridBagConstraints.gridwidth = 2;
0470:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0471:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
0472:                jPanel1.add(addToAppLabel, gridBagConstraints);
0473:
0474:                addToAppComboBox
0475:                        .setNextFocusableComponent(serverInstanceComboBox);
0476:                gridBagConstraints = new java.awt.GridBagConstraints();
0477:                gridBagConstraints.gridx = 2;
0478:                gridBagConstraints.gridy = 0;
0479:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0480:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0481:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0482:                gridBagConstraints.weightx = 1.0;
0483:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
0484:                jPanel1.add(addToAppComboBox, gridBagConstraints);
0485:
0486:                warningPlaceHolderPanel.setLayout(new java.awt.BorderLayout());
0487:                gridBagConstraints = new java.awt.GridBagConstraints();
0488:                gridBagConstraints.gridx = 0;
0489:                gridBagConstraints.gridy = 3;
0490:                gridBagConstraints.gridwidth = 3;
0491:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0492:                gridBagConstraints.weightx = 1.0;
0493:                jPanel1.add(warningPlaceHolderPanel, gridBagConstraints);
0494:
0495:                org.openide.awt.Mnemonics.setLocalizedText(addServerButton,
0496:                        org.openide.util.NbBundle.getMessage(
0497:                                ImportLocationVisual.class, "LBL_AddServer")); // NOI18N
0498:                addServerButton
0499:                        .addActionListener(new java.awt.event.ActionListener() {
0500:                            public void actionPerformed(
0501:                                    java.awt.event.ActionEvent evt) {
0502:                                addServerButtonActionPerformed(evt);
0503:                            }
0504:                        });
0505:                gridBagConstraints = new java.awt.GridBagConstraints();
0506:                gridBagConstraints.gridx = 3;
0507:                gridBagConstraints.gridy = 1;
0508:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0509:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
0510:                jPanel1.add(addServerButton, gridBagConstraints);
0511:                addServerButton.getAccessibleContext().setAccessibleName(
0512:                        org.openide.util.NbBundle.getMessage(
0513:                                ImportLocationVisual.class, "ASCN_AddServer")); // NOI18N
0514:                addServerButton.getAccessibleContext()
0515:                        .setAccessibleDescription(
0516:                                org.openide.util.NbBundle.getMessage(
0517:                                        ImportLocationVisual.class,
0518:                                        "ASCD_AddServer")); // NOI18N
0519:
0520:                gridBagConstraints = new java.awt.GridBagConstraints();
0521:                gridBagConstraints.gridx = 0;
0522:                gridBagConstraints.gridy = 6;
0523:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0524:                gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
0525:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0526:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0527:                gridBagConstraints.weightx = 1.0;
0528:                gridBagConstraints.weighty = 1.0;
0529:                add(jPanel1, gridBagConstraints);
0530:
0531:                getAccessibleContext().setAccessibleName("null");
0532:                getAccessibleContext().setAccessibleDescription("null");
0533:            }// </editor-fold>//GEN-END:initComponents
0534:
0535:            private void addServerButtonActionPerformed(
0536:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addServerButtonActionPerformed
0537:                ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel
0538:                        .getSelectedItem();
0539:                String selectedServerInstanceID = null;
0540:                if (serverInstanceWrapper != null) {
0541:                    selectedServerInstanceID = serverInstanceWrapper
0542:                            .getServerInstanceID();
0543:                }
0544:                String lastSelectedJ2eeSpecLevel = (String) j2eeSpecComboBox
0545:                        .getSelectedItem();
0546:                String newServerInstanceID = ServerManager
0547:                        .showAddServerInstanceWizard();
0548:                if (newServerInstanceID != null) {
0549:                    selectedServerInstanceID = newServerInstanceID;
0550:                    // clear the spec level selection
0551:                    lastSelectedJ2eeSpecLevel = null;
0552:                    j2eeSpecComboBox.setSelectedItem(null);
0553:                }
0554:                // refresh the list of servers
0555:                initServers(selectedServerInstanceID);
0556:                if (lastSelectedJ2eeSpecLevel != null) {
0557:                    j2eeSpecComboBox.setSelectedItem(lastSelectedJ2eeSpecLevel);
0558:                }
0559:            }//GEN-LAST:event_addServerButtonActionPerformed
0560:
0561:            private void j2eeSpecComboBoxActionPerformed(
0562:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j2eeSpecComboBoxActionPerformed
0563:                setJ2eeVersionWarningPanel();
0564:            }//GEN-LAST:event_j2eeSpecComboBoxActionPerformed
0565:
0566:            private void projectLocationFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_projectLocationFocusLost
0567:                if (projectLocation.getText().trim().length() > 0) {
0568:                    updateProjectName();
0569:                    updateProjectFolder();
0570:                    updateJ2EEVersion();
0571:                    panel.stateChanged(null);
0572:                }
0573:            }//GEN-LAST:event_projectLocationFocusLost
0574:
0575:            private void serverInstanceComboBoxActionPerformed(
0576:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverInstanceComboBoxActionPerformed
0577:                String prevSelectedItem = (String) j2eeSpecComboBox
0578:                        .getSelectedItem();
0579:                // update the j2ee spec list according to the selected server
0580:                ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel
0581:                        .getSelectedItem();
0582:                if (serverInstanceWrapper != null) {
0583:                    J2eePlatform j2eePlatform = Deployment
0584:                            .getDefault()
0585:                            .getJ2eePlatform(
0586:                                    serverInstanceWrapper.getServerInstanceID());
0587:                    Set supportedVersions = j2eePlatform
0588:                            .getSupportedSpecVersions(J2eeModule.CLIENT);
0589:                    j2eeSpecComboBox.removeAllItems();
0590:                    if (supportedVersions.contains(J2eeModule.JAVA_EE_5)) {
0591:                        j2eeSpecComboBox.addItem(J2EE_SPEC_15_LABEL);
0592:                    }
0593:                    if (supportedVersions.contains(J2eeModule.J2EE_14)) {
0594:                        j2eeSpecComboBox.addItem(J2EE_SPEC_14_LABEL);
0595:                    }
0596:                    if (prevSelectedItem != null) {
0597:                        j2eeSpecComboBox.setSelectedItem(prevSelectedItem);
0598:                    }
0599:                } else {
0600:                    j2eeSpecComboBox.removeAllItems();
0601:                }
0602:                // revalidate the form
0603:                panel.fireChangeEvent();
0604:            }//GEN-LAST:event_serverInstanceComboBoxActionPerformed
0605:
0606:            private void browseProjectFolderActionPerformed(
0607:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseProjectFolderActionPerformed
0608:                JFileChooser chooser = new JFileChooser();
0609:                FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
0610:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
0611:                if (projectFolder.getText().length() > 0
0612:                        && getProjectFolder().exists()) {
0613:                    chooser.setSelectedFile(getProjectFolder());
0614:                } else if (projectLocation.getText().length() > 0
0615:                        && getProjectLocation().exists()) {
0616:                    chooser.setSelectedFile(getProjectLocation());
0617:                } else {
0618:                    chooser.setSelectedFile(ProjectChooser.getProjectsFolder());
0619:                }
0620:                chooser.setDialogTitle(NbBundle.getMessage(
0621:                        ImportLocationVisual.class, "LBL_SelectNewLocation")); // NOI18N
0622:                if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this )) {
0623:                    File projectDir = FileUtil.normalizeFile(chooser
0624:                            .getSelectedFile());
0625:                    projectFolder.setText(projectDir.getAbsolutePath());
0626:                }
0627:            }//GEN-LAST:event_browseProjectFolderActionPerformed
0628:
0629:            private void browseProjectLocationActionPerformed(
0630:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseProjectLocationActionPerformed
0631:                JFileChooser chooser = new JFileChooser();
0632:                FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
0633:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
0634:                if (projectLocation.getText().length() > 0
0635:                        && getProjectLocation().exists()) {
0636:                    chooser.setSelectedFile(getProjectLocation());
0637:                } else {
0638:                    // honor the contract in issue 58987
0639:                    File currentDirectory = null;
0640:                    FileObject existingSourcesFO = Templates
0641:                            .getExistingSourcesFolder(wizardDescriptor);
0642:                    if (existingSourcesFO != null) {
0643:                        File existingSourcesFile = FileUtil
0644:                                .toFile(existingSourcesFO);
0645:                        if (existingSourcesFile != null
0646:                                && existingSourcesFile.isDirectory()) {
0647:                            currentDirectory = existingSourcesFile;
0648:                        }
0649:                    }
0650:                    if (currentDirectory != null) {
0651:                        chooser.setCurrentDirectory(currentDirectory);
0652:                    } else {
0653:                        chooser.setSelectedFile(ProjectChooser
0654:                                .getProjectsFolder());
0655:                    }
0656:                }
0657:
0658:                chooser.setDialogTitle(NbBundle.getMessage(
0659:                        ImportLocationVisual.class,
0660:                        "LBL_SelectExistingLocation")); // NOI18N
0661:                if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this )) {
0662:                    projectLocation.setText(FileUtil.normalizeFile(
0663:                            chooser.getSelectedFile()).getAbsolutePath());
0664:                    updateJ2EEVersion();
0665:                    updateProjectName();
0666:                    updateProjectFolder();
0667:                    panel.stateChanged(null);
0668:                }
0669:            }//GEN-LAST:event_browseProjectLocationActionPerformed
0670:
0671:            // Variables declaration - do not modify//GEN-BEGIN:variables
0672:            private javax.swing.JButton addServerButton;
0673:            private javax.swing.JComboBox addToAppComboBox;
0674:            private javax.swing.JLabel addToAppLabel;
0675:            private javax.swing.JButton browseProjectFolder;
0676:            private javax.swing.JButton browseProjectLocation;
0677:            private javax.swing.JComboBox j2eeSpecComboBox;
0678:            private javax.swing.JCheckBox jCheckBox1;
0679:            private javax.swing.JLabel jLabel7;
0680:            private javax.swing.JLabel jLabelPrjLocation;
0681:            private javax.swing.JLabel jLabelPrjLocationDesc;
0682:            private javax.swing.JLabel jLabelPrjName;
0683:            private javax.swing.JLabel jLabelSrcLocation;
0684:            private javax.swing.JLabel jLabelSrcLocationDesc;
0685:            private javax.swing.JPanel jPanel1;
0686:            private javax.swing.JSeparator jSeparator1;
0687:            public javax.swing.JTextField projectFolder;
0688:            public javax.swing.JTextField projectLocation;
0689:            public javax.swing.JTextField projectName;
0690:            private javax.swing.JComboBox serverInstanceComboBox;
0691:            private javax.swing.JLabel serverInstanceLabel;
0692:            private javax.swing.JPanel warningPlaceHolderPanel;
0693:            // End of variables declaration//GEN-END:variables
0694:
0695:            private boolean ignoreEvent;
0696:
0697:            private void update(DocumentEvent e) {
0698:                if (ignoreEvent) {
0699:                    // side-effect of changes done in this handler
0700:                    return;
0701:                }
0702:
0703:                // start ignoring events
0704:                ignoreEvent = true;
0705:
0706:                if (projectLocation.getDocument() == e.getDocument()) {
0707:                    updateProjectName();
0708:                    updateProjectFolder();
0709:                }
0710:
0711:                // stop ignoring events
0712:                ignoreEvent = false;
0713:
0714:                if (projectFolder.getDocument() == e.getDocument()) {
0715:                    projectFolderTouched = !"".equals(projectFolder.getText());
0716:                }
0717:                if (projectName.getDocument() == e.getDocument()) {
0718:                    projectNameTouched = !"".equals(projectName.getText());
0719:                }
0720:                panel.stateChanged(null);
0721:            }
0722:
0723:            private void updateProjectName() {
0724:                if (projectNameTouched) {
0725:                    return;
0726:                }
0727:                FileObject fo = FileUtil.toFileObject(getProjectLocation());
0728:                if (fo != null) {
0729:                    projectName.setText(fo.getName()); // NOI18N
0730:                }
0731:            }
0732:
0733:            private void updateJ2EEVersion() {
0734:                File f = new File(projectLocation.getText().trim());
0735:                FileObject fo = FileUtil
0736:                        .toFileObject(FileUtil.normalizeFile(f));
0737:                if (fo != null) {
0738:                    FileObject configFilesPath = FileSearchUtility
0739:                            .guessConfigFilesPath(fo);
0740:                    if (configFilesPath != null) {
0741:                        FileObject appClientXML = configFilesPath
0742:                                .getFileObject(AppClientProvider.FILE_DD);
0743:                        checkACXmlJ2eeVersion(appClientXML);
0744:                    } else {
0745:                        j2eeSpecComboBox.setSelectedItem(J2EE_SPEC_15_LABEL);
0746:                    }
0747:                }
0748:            }
0749:
0750:            private void updateProjectFolder() {
0751:                if (projectFolderTouched) {
0752:                    return;
0753:                }
0754:                if (isValidProjectLocation()) {
0755:                    projectFolder.setText(getProjectLocation()
0756:                            .getAbsolutePath());
0757:                } else {
0758:                    projectFolder.setText(""); // NOI18N
0759:                }
0760:            }
0761:
0762:            private boolean isValidProjectLocation() {
0763:                return (getProjectLocation().exists()
0764:                        && getProjectLocation().isDirectory()
0765:                        && projectLocation.getText().length() > 0 && (!projectLocation
0766:                        .getText().endsWith(":"))); // NOI18N
0767:            }
0768:
0769:            public boolean valid(WizardDescriptor wizardDescriptor) {
0770:                File prjDir = new File(projectLocation.getText().trim());
0771:                //        File prjFolder = new File(projectFolder.getText().trim());
0772:                String prjName = projectName.getText().trim();
0773:
0774:                if (getSelectedServerInstanceID() == null) {
0775:                    wizardDescriptor.putProperty("WizardPanel_errorMessage",
0776:                            NbBundle.getMessage(ImportLocationVisual.class,
0777:                                    "MSG_NoServer")); //NOI18N
0778:                    return false;
0779:                }
0780:
0781:                if (!prjDir.isDirectory()) {
0782:                    wizardDescriptor.putProperty("WizardPanel_errorMessage",
0783:                            NbBundle.getMessage(ImportLocationVisual.class,
0784:                                    "MSG_ProvideExistingSourcesLocation")); //NOI18N
0785:                    return false; //Existing sources location not specified
0786:                }
0787:
0788:                //Do we need this check?
0789:                //            if (!prjFolder.isDirectory()) {
0790:                //                wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(ImportLocationVisual.class,"MSG_ProjectFolderDoesNotExists")); //NOI18N
0791:                //                return false; //Project folder not specified
0792:                //            }
0793:
0794:                if (FileSearchUtility.guessJavaRoots(FileUtil
0795:                        .toFileObject(prjDir)) == null) {
0796:                    wizardDescriptor.putProperty("WizardPanel_errorMessage",
0797:                            NbBundle.getMessage(ImportLocationVisual.class,
0798:                                    "MSG_NoAppClientModule")); //NOI18N
0799:                    return false; // No java project location
0800:                }
0801:
0802:                if (prjName == null || prjName.length() == 0) {
0803:                    wizardDescriptor.putProperty("WizardPanel_errorMessage",
0804:                            NbBundle.getMessage(ImportLocationVisual.class,
0805:                                    "MSG_ProvideProjectName")); //NOI18N
0806:                    return false; //Project name not specified
0807:                }
0808:
0809:                String result = checkValidity(this .projectName.getText(),
0810:                        this .projectFolder.getText());
0811:                if (result != null) {
0812:                    wizardDescriptor.putProperty("WizardPanel_errorMessage",
0813:                            result); //NOI18N
0814:                    return false;
0815:                }
0816:
0817:                wizardDescriptor.putProperty("WizardPanel_errorMessage", ""); //NOI18N
0818:
0819:                return true;
0820:            }
0821:
0822:            static String checkValidity(final String projectName,
0823:                    final String projectLocation) {
0824:                File projLoc = new File(projectLocation).getAbsoluteFile();
0825:
0826:                if (PanelProjectLocationVisual.getCanonicalFile(projLoc) == null) {
0827:                    return NbBundle.getMessage(ImportLocationVisual.class,
0828:                            "MSG_IllegalProjectLocation");
0829:                }
0830:
0831:                while (projLoc != null && !projLoc.exists()) {
0832:                    projLoc = projLoc.getParentFile();
0833:                }
0834:                if (projLoc == null || !projLoc.canWrite()) {
0835:                    return NbBundle.getMessage(ImportLocationVisual.class,
0836:                            "MSG_ProjectFolderReadOnly");
0837:                }
0838:
0839:                File destFolder = FileUtil.normalizeFile(new File(
0840:                        projectLocation));
0841:                File[] kids = destFolder.listFiles();
0842:                if (destFolder.exists() && kids != null && kids.length > 0) {
0843:                    String file = null;
0844:                    for (int i = 0; i < kids.length; i++) {
0845:                        String childName = kids[i].getName();
0846:                        if ("nbproject".equals(childName)) { //NOI18N
0847:                            file = NbBundle.getMessage(
0848:                                    ImportLocationVisual.class,
0849:                                    "TXT_NetBeansProject");
0850:                        } else if ("build".equals(childName)) { //NOI18N
0851:                            file = NbBundle.getMessage(
0852:                                    ImportLocationVisual.class,
0853:                                    "TXT_BuildFolder");
0854:                        } else if ("dist".equals(childName)) { //NOI18N
0855:                            file = NbBundle.getMessage(
0856:                                    ImportLocationVisual.class,
0857:                                    "TXT_DistFolder");
0858:                        } else if ("build.xml".equals(childName)) { //NOI18N
0859:                            file = NbBundle.getMessage(
0860:                                    ImportLocationVisual.class, "TXT_BuildXML");
0861:                        } else if ("manifest.mf".equals(childName)) { //NOI18N
0862:                            file = NbBundle.getMessage(
0863:                                    ImportLocationVisual.class, "TXT_Manifest");
0864:                        }
0865:                        if (file != null) {
0866:                            String format = NbBundle.getMessage(
0867:                                    ImportLocationVisual.class,
0868:                                    "MSG_ProjectFolderInvalid");
0869:                            return MessageFormat.format(format,
0870:                                    new Object[] { file });
0871:                        }
0872:                    }
0873:                }
0874:
0875:                if (destFolder.isDirectory()) {
0876:                    FileObject destFO = FileUtil.toFileObject(destFolder);
0877:                    assert destFO != null : "No FileObject for " + destFolder;
0878:                    boolean clear = false;
0879:                    try {
0880:                        clear = ProjectManager.getDefault().findProject(destFO) == null;
0881:                    } catch (IOException e) {
0882:                        // need not report here; clear remains false -> error
0883:                    }
0884:                    if (!clear) {
0885:                        return NbBundle.getMessage(ImportLocationVisual.class,
0886:                                "MSG_ProjectFolderHasDeletedProject");
0887:                    }
0888:                }
0889:                return null;
0890:            }
0891:
0892:            void read(WizardDescriptor d) {
0893:                wizardDescriptor = d;
0894:            }
0895:
0896:            void store(WizardDescriptor d) {
0897:                String name = projectName.getText().trim();
0898:                String moduleLoc = projectLocation.getText().trim();
0899:
0900:                if (name.equals("") || moduleLoc.equals("")) {
0901:                    return;
0902:                }
0903:
0904:                d.putProperty(WizardProperties.PROJECT_DIR, new File(
0905:                        projectFolder.getText().trim()));
0906:                File moduleLocFile = new File(moduleLoc);
0907:                d.putProperty(WizardProperties.SOURCE_ROOT, moduleLocFile);
0908:                d.putProperty(WizardProperties.NAME, name);
0909:                d.putProperty(WizardProperties.JAVA_ROOT, FileSearchUtility
0910:                        .guessJavaRootsAsFiles(FileUtil
0911:                                .toFileObject(moduleLocFile)));
0912:                d.putProperty(WizardProperties.SERVER_INSTANCE_ID,
0913:                        getSelectedServerInstanceID());
0914:                d.putProperty(WizardProperties.J2EE_LEVEL,
0915:                        getSelectedJ2eeSpec());
0916:                d.putProperty(WizardProperties.EAR_APPLICATION,
0917:                        getSelectedEarApplication());
0918:                if (warningPanel != null && warningPanel.getDowngradeAllowed()) {
0919:                    d.putProperty(WizardProperties.JAVA_PLATFORM, warningPanel
0920:                            .getSuggestedJavaPlatformName());
0921:                    UserProjectSettings fls = UserProjectSettings.getDefault();
0922:                    d.putProperty(WizardProperties.SOURCE_LEVEL, fls
0923:                            .isAgreedSetSourceLevel14() ? "1.4" : fls
0924:                            .isAgreedSetSourceLevel15() ? "1.5" : "1.6"); // NOI18N
0925:                }
0926:
0927:                // TODO: ma154696: add also search for test roots
0928:            }
0929:
0930:            //extra finish dialog
0931:            private Dialog dialog;
0932:
0933:            void validate(WizardDescriptor d) throws WizardValidationException {
0934:                File dirF = new File(projectFolder.getText());
0935:                JButton ok = new JButton(NbBundle.getMessage(
0936:                        ImportLocationVisual.class, "LBL_IW_Buildfile_OK")); //NOI18N
0937:                ok
0938:                        .getAccessibleContext()
0939:                        .setAccessibleDescription(
0940:                                NbBundle
0941:                                        .getMessage(ImportLocationVisual.class,
0942:                                                "ACS_IW_BuildFileDialog_OKButton_LabelMnemonic")); //NOI18N
0943:                ok.setMnemonic(NbBundle.getMessage(ImportLocationVisual.class,
0944:                        "LBL_IW_BuildFileDialog_OK_LabelMnemonic").charAt(0)); //NOI18N
0945:                JButton cancel = new JButton(NbBundle.getMessage(
0946:                        ImportLocationVisual.class, "LBL_IW_Buildfile_Cancel")); //NOI18N
0947:                cancel
0948:                        .getAccessibleContext()
0949:                        .setAccessibleDescription(
0950:                                NbBundle
0951:                                        .getMessage(ImportLocationVisual.class,
0952:                                                "ACS_IW_BuildFileDialog_CancelButton_LabelMnemonic")); //NOI18N
0953:                cancel.setMnemonic(NbBundle.getMessage(
0954:                        ImportLocationVisual.class,
0955:                        "LBL_IW_BuildFileDialog_Cancel_LabelMnemonic")
0956:                        .charAt(0)); //NOI18N
0957:
0958:                final ImportBuildfile ibf = new ImportBuildfile(dirF
0959:                        .getAbsolutePath(), ok);
0960:                if ((new File(dirF, GeneratedFilesHelper.BUILD_XML_PATH))
0961:                        .exists()) {
0962:                    ActionListener actionListener = new ActionListener() {
0963:                        public void actionPerformed(ActionEvent event) {
0964:                            Object src = event.getSource();
0965:                            if (src instanceof  JButton) {
0966:                                String name = ((JButton) src).getText();
0967:                                if (name.equals(NbBundle.getMessage(
0968:                                        ImportLocationVisual.class,
0969:                                        "LBL_IW_Buildfile_OK"))) { //NOI18N
0970:                                    closeDialog();
0971:                                } else if (name.equals(NbBundle.getMessage(
0972:                                        ImportLocationVisual.class,
0973:                                        "LBL_IW_Buildfile_Cancel"))) { //NOI18N
0974:                                    NotifyDescriptor ndesc = new NotifyDescriptor.Confirmation(
0975:                                            NbBundle
0976:                                                    .getMessage(
0977:                                                            ImportLocationVisual.class,
0978:                                                            "LBL_IW_Buildfile_CancelConfirmation"),
0979:                                            NotifyDescriptor.YES_NO_OPTION); //NOI18N
0980:                                    Object ret = DialogDisplayer.getDefault()
0981:                                            .notify(ndesc);
0982:                                    if (ret == NotifyDescriptor.YES_OPTION) {
0983:                                        closeDialog();
0984:                                    }
0985:                                }
0986:                            }
0987:                        }
0988:                    };
0989:
0990:                    DialogDescriptor descriptor = new DialogDescriptor(
0991:                            ibf,
0992:                            NbBundle.getMessage(ImportLocationVisual.class,
0993:                                    "LBL_IW_BuildfileTitle"), //NOI18N
0994:                            true, new Object[] { ok, cancel },
0995:                            DialogDescriptor.OK_OPTION,
0996:                            DialogDescriptor.DEFAULT_ALIGN, null,
0997:                            actionListener);
0998:
0999:                    dialog = DialogDisplayer.getDefault().createDialog(
1000:                            descriptor);
1001:                    dialog.setVisible(true);
1002:                } else {
1003:                    return;
1004:                }
1005:            }
1006:
1007:            private void closeDialog() {
1008:                dialog.dispose();
1009:            }
1010:
1011:            //use it as a project root iff it is not sources or document root
1012:            // NOTE: the order of the searches in kind of important in this method for
1013:            //   performance reasons
1014:            public boolean isSuitableProjectRoot(FileObject dir) {
1015:                FileObject configFilesRoot = FileSearchUtility
1016:                        .guessConfigFilesPath(dir);
1017:                if (configFilesRoot != null
1018:                        && !FileUtil.isParentOf(dir, configFilesRoot)) {
1019:                    return false;
1020:                }
1021:                FileObject[] srcRoots = FileSearchUtility.guessJavaRoots(dir);
1022:                if (srcRoots != null && !isParentOf(dir, srcRoots)) {
1023:                    return false;
1024:                }
1025:                return true;
1026:            }
1027:
1028:            private boolean isParentOf(FileObject dir, FileObject[] fos) {
1029:                boolean result = true;
1030:                if (fos != null) {
1031:                    for (int i = 0; i < fos.length; i++) {
1032:                        result = FileUtil.isParentOf(dir, fos[i]);
1033:                        if (!result) {
1034:                            return result;
1035:                        }
1036:                    }
1037:                }
1038:                return result;
1039:            }
1040:
1041:            /**
1042:             * Init servers model
1043:             * @param selectedServerInstanceID preselected instance or null if non is preselected
1044:             */
1045:            private void initServers(String selectedServerInstanceID) {
1046:                // init the list of server instances
1047:                serversModel.removeAllElements();
1048:                Set<ServerInstanceWrapper> servers = new TreeSet<ServerInstanceWrapper>();
1049:                ServerInstanceWrapper selectedItem = null;
1050:                boolean sjasFound = false;
1051:                for (String serverInstanceID : Deployment.getDefault()
1052:                        .getServerInstanceIDs()) {
1053:                    String displayName = Deployment.getDefault()
1054:                            .getServerInstanceDisplayName(serverInstanceID);
1055:                    J2eePlatform j2eePlatform = Deployment.getDefault()
1056:                            .getJ2eePlatform(serverInstanceID);
1057:                    if (displayName != null
1058:                            && j2eePlatform != null
1059:                            && j2eePlatform.getSupportedModuleTypes().contains(
1060:                                    J2eeModule.CLIENT)) {
1061:                        ServerInstanceWrapper serverWrapper = new ServerInstanceWrapper(
1062:                                serverInstanceID, displayName);
1063:                        // decide whether this server should be preselected
1064:                        if (selectedItem == null || !sjasFound) {
1065:                            if (selectedServerInstanceID != null) {
1066:                                if (selectedServerInstanceID
1067:                                        .equals(serverInstanceID)) {
1068:                                    selectedItem = serverWrapper;
1069:                                }
1070:                            } else {
1071:                                // preselect the best server ;)
1072:                                String shortName = Deployment.getDefault()
1073:                                        .getServerID(serverInstanceID);
1074:                                if ("J2EE".equals(shortName)) { // NOI18N
1075:                                    selectedItem = serverWrapper;
1076:                                    sjasFound = true;
1077:                                } else if ("JBoss4".equals(shortName)) { // NOI18N
1078:                                    selectedItem = serverWrapper;
1079:                                }
1080:                            }
1081:                        }
1082:                        servers.add(serverWrapper);
1083:                    }
1084:                }
1085:                for (ServerInstanceWrapper item : servers) {
1086:                    serversModel.addElement(item);
1087:                }
1088:                if (selectedItem != null) {
1089:                    // set the preselected item
1090:                    serversModel.setSelectedItem(selectedItem);
1091:                } else if (serversModel.getSize() > 0) {
1092:                    // set the first item
1093:                    serversModel.setSelectedItem(serversModel.getElementAt(0));
1094:                }
1095:            }
1096:
1097:            public String getSelectedServerInstanceID() {
1098:                ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel
1099:                        .getSelectedItem();
1100:                if (serverInstanceWrapper == null) {
1101:                    return null;
1102:                }
1103:                return serverInstanceWrapper.getServerInstanceID();
1104:            }
1105:
1106:            public String getSelectedJ2eeSpec() {
1107:                Object item = j2eeSpecComboBox.getSelectedItem();
1108:                return item == null ? null
1109:                        : item.equals(J2EE_SPEC_14_LABEL) ? J2eeModule.J2EE_14
1110:                                : item.equals(J2EE_SPEC_15_LABEL) ? J2eeModule.JAVA_EE_5
1111:                                        : J2eeModule.J2EE_13;
1112:            }
1113:
1114:            private File getAsFile(String filename) {
1115:                return FileUtil.normalizeFile(new File(filename));
1116:            }
1117:
1118:            public File getProjectLocation() {
1119:                return getAsFile(projectLocation.getText());
1120:            }
1121:
1122:            public File getProjectFolder() {
1123:                return getAsFile(projectFolder.getText());
1124:            }
1125:
1126:            public String getProjectName() {
1127:                return projectName.getText();
1128:            }
1129:
1130:            private Project getSelectedEarApplication() {
1131:                int idx = addToAppComboBox.getSelectedIndex();
1132:                return (idx <= 0) ? null : earProjects.get(idx - 1);
1133:            }
1134:
1135:            private void initEnterpriseApplications() {
1136:                addToAppComboBox.addItem(NbBundle.getMessage(
1137:                        ImportLocationVisual.class, "LBL_NWP1_AddToEApp_None"));
1138:                addToAppComboBox.setSelectedIndex(0);
1139:
1140:                Project[] allProjects = OpenProjects.getDefault()
1141:                        .getOpenProjects();
1142:                earProjects = new ArrayList<Project>();
1143:                for (int i = 0; i < allProjects.length; i++) {
1144:                    J2eeApplicationProvider j2eeAppProvider = allProjects[i]
1145:                            .getLookup().lookup(J2eeApplicationProvider.class);
1146:                    if (j2eeAppProvider != null) {
1147:                        J2eeApplication j2eeApplication = (J2eeApplication) j2eeAppProvider
1148:                                .getJ2eeModule();
1149:                        ProjectInformation projectInfo = ProjectUtils
1150:                                .getInformation(allProjects[i]);
1151:                        if (j2eeApplication != null) {
1152:                            earProjects.add(projectInfo.getProject());
1153:                            addToAppComboBox.addItem(projectInfo
1154:                                    .getDisplayName());
1155:                        }
1156:                    }
1157:                }
1158:                if (earProjects.size() <= 0) {
1159:                    addToAppComboBox.setEnabled(false);
1160:                }
1161:            }
1162:
1163:            private BigDecimal getACXmlVersion(FileObject appClientXML)
1164:                    throws IOException {
1165:                if (appClientXML != null) {
1166:                    // TODO: possible NPE (will getEjbJar return something)?
1167:                    return DDProvider.getDefault().getDDRoot(appClientXML)
1168:                            .getVersion();
1169:                } else {
1170:                    return null;
1171:                }
1172:            }
1173:
1174:            private void checkACXmlJ2eeVersion(FileObject appClientXML) {
1175:                try {
1176:                    BigDecimal version = getACXmlVersion(appClientXML);
1177:                    if (version == null) {
1178:                        return;
1179:                    }
1180:
1181:                    if (new BigDecimal(AppClient.VERSION_1_3).equals(version)) {
1182:                        j2eeSpecComboBox.setSelectedItem(J2EE_SPEC_13_LABEL);
1183:                    } else if (new BigDecimal(AppClient.VERSION_1_4)
1184:                            .equals(version)) {
1185:                        j2eeSpecComboBox.setSelectedItem(J2EE_SPEC_14_LABEL);
1186:                    } else if (new BigDecimal(AppClient.VERSION_5_0)
1187:                            .equals(version)) {
1188:                        j2eeSpecComboBox.setSelectedItem(J2EE_SPEC_15_LABEL);
1189:                    }
1190:                } catch (IOException e) {
1191:                    String message = NbBundle.getMessage(
1192:                            ImportLocationVisual.class,
1193:                            "MSG_AppClientXmlCorrupted"); // NOI18N
1194:                    Exceptions.printStackTrace(Exceptions
1195:                            .attachLocalizedMessage(e, message));
1196:                }
1197:            }
1198:
1199:            private void setJ2eeVersionWarningPanel() {
1200:                String j2ee = getSelectedJ2eeSpec();
1201:                if (j2ee == null) {
1202:                    return;
1203:                }
1204:                String warningType = J2eeVersionWarningPanel
1205:                        .findWarningType(j2ee);
1206:                if (warningType == null && warningPanel == null) {
1207:                    return;
1208:                }
1209:                if (warningPanel == null) {
1210:                    warningPanel = new J2eeVersionWarningPanel(warningType);
1211:                    warningPlaceHolderPanel.add(warningPanel,
1212:                            java.awt.BorderLayout.CENTER);
1213:                    warningPanel.setWarningType(warningType);
1214:                } else {
1215:                    warningPanel.setWarningType(warningType);
1216:                }
1217:            }
1218:
1219:            /**
1220:             * Server instance wrapper represents server instances in the servers combobox.
1221:             * @author sherold
1222:             */
1223:            private static class ServerInstanceWrapper implements  Comparable {
1224:
1225:                private final String serverInstanceID;
1226:                private final String displayName;
1227:
1228:                ServerInstanceWrapper(String serverInstanceID,
1229:                        String displayName) {
1230:                    this .serverInstanceID = serverInstanceID;
1231:                    this .displayName = displayName;
1232:                }
1233:
1234:                public String getServerInstanceID() {
1235:                    return serverInstanceID;
1236:                }
1237:
1238:                @Override
1239:                public String toString() {
1240:                    return displayName;
1241:                }
1242:
1243:                public int compareTo(Object o) {
1244:                    return toString().compareTo(o.toString());
1245:                }
1246:            }
1247:
1248:        }
ww___w._j___a_va_2___s__.__c_om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.