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-2007 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.visualweb.project.jsf.framework;
0043:
0044: // <RAVE>
0045: import org.netbeans.modules.visualweb.project.jsf.api.JsfProjectUtils; // </RAVE>
0046:
0047: import java.awt.Component;
0048: import java.io.File;
0049: import java.io.IOException;
0050: import java.util.ArrayList;
0051: import java.util.Arrays;
0052: import java.util.Vector;
0053: import javax.swing.DefaultComboBoxModel;
0054: import javax.swing.JFileChooser;
0055: import javax.swing.event.DocumentListener;
0056: import org.netbeans.api.project.Project;
0057: import org.netbeans.api.project.libraries.Library;
0058: import org.netbeans.api.project.libraries.LibraryManager;
0059: import org.netbeans.modules.j2ee.common.Util;
0060: import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
0061: import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; // import org.netbeans.modules.web.jsf.JSFUtils;
0062: import org.netbeans.modules.web.api.webmodule.ExtenderController;
0063: import org.netbeans.modules.web.api.webmodule.ExtenderController.Properties;
0064: import org.openide.WizardDescriptor;
0065: import org.openide.filesystems.FileObject;
0066: import org.openide.filesystems.FileUtil;
0067: import org.openide.util.HelpCtx;
0068: import org.openide.util.NbBundle;
0069:
0070: /**
0071: *
0072: * @author Po-Ting Wu
0073: */
0074: public class JSFConfigurationPanelVisual extends javax.swing.JPanel
0075: implements HelpCtx.Provider, DocumentListener {
0076:
0077: private Project project;
0078: private JSFConfigurationPanel panel;
0079: private boolean customizer;
0080:
0081: private ArrayList<Library> jsfLibraries;
0082: private boolean webModule25Version;
0083: private String serverInstanceID;
0084: private boolean addJSF = false;
0085:
0086: // <RAVE> Visual Web JSF Backwards Compatibility Kit & Default Bean Package
0087: private boolean addJAXRPC = false;
0088: private boolean addRowset = false;
0089: private boolean beanPackageModified = false;
0090:
0091: // </RAVE>
0092:
0093: /** Creates new form JSFConfigurationPanelVisual */
0094: public JSFConfigurationPanelVisual(JSFConfigurationPanel panel,
0095: Project project, boolean customizer) {
0096: this .project = project;
0097: this .panel = panel;
0098: this .customizer = customizer;
0099:
0100: initComponents();
0101:
0102: // <RAVE>
0103: remove(jsfTabbedPane);
0104: add(confPanel, "card10");
0105: // </RAVE>
0106: initLibraries();
0107:
0108: tURLPattern.getDocument().addDocumentListener(this );
0109: cbPackageJars.setVisible(false);
0110:
0111: if (customizer) {
0112: enableComponents(false);
0113: } else {
0114: updateLibrary();
0115: }
0116: }
0117:
0118: private void initLibraries() {
0119: Library libraries[] = LibraryManager.getDefault()
0120: .getLibraries();
0121: Vector<String> items = new Vector();
0122: jsfLibraries = new ArrayList();
0123:
0124: for (int i = 0; i < libraries.length; i++) {
0125: if (libraries[i].getName().startsWith("JSF-")
0126: || libraries[i].getName().equals("jsf12")) { //NOI18N
0127: String displayName = libraries[i].getDisplayName();
0128: items.add(displayName);
0129: jsfLibraries.add(libraries[i]);
0130: }
0131: }
0132:
0133: cbLibraries.setModel(new DefaultComboBoxModel(items));
0134: if (items.size() == 0) {
0135: rbRegisteredLibrary.setEnabled(false);
0136: cbLibraries.setEnabled(false);
0137: rbNewLibrary.setSelected(true);
0138: panel.setLibrary(null);
0139: } else {
0140: rbRegisteredLibrary.setEnabled(true);
0141: rbRegisteredLibrary.setSelected(true);
0142: cbLibraries.setEnabled(true);
0143: }
0144: repaint();
0145: }
0146:
0147: /** This method is called from within the constructor to
0148: * initialize the form.
0149: * WARNING: Do NOT modify this code. The content of this method is
0150: * always regenerated by the Form Editor.
0151: */
0152: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
0153: private void initComponents() {
0154:
0155: buttonGroup1 = new javax.swing.ButtonGroup();
0156: jsfTabbedPane = new javax.swing.JTabbedPane();
0157: confPanel = new javax.swing.JPanel();
0158: beanPackageLabel = new javax.swing.JLabel();
0159: beanPackageTextField = new javax.swing.JTextField();
0160: lServletName = new javax.swing.JLabel();
0161: tServletName = new javax.swing.JTextField();
0162: lURLPattern = new javax.swing.JLabel();
0163: tURLPattern = new javax.swing.JTextField();
0164: cbValidate = new javax.swing.JCheckBox();
0165: cbVerify = new javax.swing.JCheckBox();
0166: cbPackageJars = new javax.swing.JCheckBox();
0167: jPanel1 = new javax.swing.JPanel();
0168: libPanel = new javax.swing.JPanel();
0169: rbRegisteredLibrary = new javax.swing.JRadioButton();
0170: cbLibraries = new javax.swing.JComboBox();
0171: rbNewLibrary = new javax.swing.JRadioButton();
0172: lDirectory = new javax.swing.JLabel();
0173: jtFolder = new javax.swing.JTextField();
0174: jbBrowse = new javax.swing.JButton();
0175: lVersion = new javax.swing.JLabel();
0176: jtVersion = new javax.swing.JTextField();
0177: rbNoneLibrary = new javax.swing.JRadioButton();
0178:
0179: setLayout(new java.awt.CardLayout());
0180:
0181: beanPackageLabel
0182: .setDisplayedMnemonic(java.util.ResourceBundle
0183: .getBundle(
0184: "org/netbeans/modules/visualweb/project/jsf/framework/Bundle")
0185: .getString(
0186: "MNE_DefaultBackingPackageLabelMnemonic")
0187: .charAt(0));
0188: beanPackageLabel.setLabelFor(beanPackageTextField);
0189: beanPackageLabel.setText(NbBundle.getMessage(
0190: JSFConfigurationPanelVisual.class,
0191: "LBL_DefaultBackingPackageLabel")); // NOI18N
0192:
0193: beanPackageTextField
0194: .addKeyListener(new java.awt.event.KeyAdapter() {
0195: public void keyReleased(java.awt.event.KeyEvent evt) {
0196: beanPackageTextFieldKeyReleased(evt);
0197: }
0198: });
0199:
0200: lServletName
0201: .setDisplayedMnemonic(java.util.ResourceBundle
0202: .getBundle(
0203: "org/netbeans/modules/visualweb/project/jsf/framework/Bundle")
0204: .getString("MNE_lServletName").charAt(0));
0205: lServletName.setLabelFor(tServletName);
0206: lServletName.setText(org.openide.util.NbBundle.getMessage(
0207: JSFConfigurationPanelVisual.class, "LBL_Servlet_Name")); // NOI18N
0208:
0209: tServletName.setEditable(false);
0210: tServletName.setText("Faces Servlet");
0211:
0212: lURLPattern
0213: .setDisplayedMnemonic(java.util.ResourceBundle
0214: .getBundle(
0215: "org/netbeans/modules/visualweb/project/jsf/framework/Bundle")
0216: .getString("MNE_lURLPattern").charAt(0));
0217: lURLPattern.setLabelFor(tURLPattern);
0218: lURLPattern.setText(org.openide.util.NbBundle.getMessage(
0219: JSFConfigurationPanelVisual.class, "LBL_URL_Pattern")); // NOI18N
0220:
0221: tURLPattern.setText("/faces/*");
0222:
0223: cbValidate
0224: .setMnemonic(java.util.ResourceBundle
0225: .getBundle(
0226: "org/netbeans/modules/visualweb/project/jsf/framework/Bundle")
0227: .getString("MNE_cbValidate").charAt(0));
0228: cbValidate.setSelected(true);
0229: cbValidate.setText(org.openide.util.NbBundle.getMessage(
0230: JSFConfigurationPanelVisual.class, "CB_Validate_XML")); // NOI18N
0231: cbValidate.setBorder(javax.swing.BorderFactory
0232: .createEmptyBorder(0, 0, 0, 0));
0233: cbValidate.setMargin(new java.awt.Insets(0, 0, 0, 0));
0234:
0235: cbVerify
0236: .setMnemonic(java.util.ResourceBundle
0237: .getBundle(
0238: "org/netbeans/modules/visualweb/project/jsf/framework/Bundle")
0239: .getString("MNE_cbVerify").charAt(0));
0240: cbVerify
0241: .setText(org.openide.util.NbBundle.getMessage(
0242: JSFConfigurationPanelVisual.class,
0243: "CB_Verify_Objects")); // NOI18N
0244: cbVerify.setBorder(javax.swing.BorderFactory.createEmptyBorder(
0245: 0, 0, 0, 0));
0246: cbVerify.setMargin(new java.awt.Insets(0, 0, 0, 0));
0247:
0248: cbPackageJars.setSelected(true);
0249: cbPackageJars.setText(org.openide.util.NbBundle.getMessage(
0250: JSFConfigurationPanelVisual.class, "CB_Package_JARs")); // NOI18N
0251: cbPackageJars.setBorder(javax.swing.BorderFactory
0252: .createEmptyBorder(0, 0, 0, 0));
0253: cbPackageJars.setMargin(new java.awt.Insets(0, 0, 0, 0));
0254:
0255: jPanel1.setEnabled(false);
0256: jPanel1.setFocusable(false);
0257: jPanel1.setRequestFocusEnabled(false);
0258:
0259: org.jdesktop.layout.GroupLayout confPanelLayout = new org.jdesktop.layout.GroupLayout(
0260: confPanel);
0261: confPanel.setLayout(confPanelLayout);
0262: confPanelLayout
0263: .setHorizontalGroup(confPanelLayout
0264: .createParallelGroup(
0265: org.jdesktop.layout.GroupLayout.LEADING)
0266: .add(
0267: confPanelLayout
0268: .createSequentialGroup()
0269: .add(
0270: confPanelLayout
0271: .createParallelGroup(
0272: org.jdesktop.layout.GroupLayout.LEADING)
0273: .add(
0274: jPanel1,
0275: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0276: 395,
0277: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
0278: .add(
0279: org.jdesktop.layout.GroupLayout.TRAILING,
0280: confPanelLayout
0281: .createSequentialGroup()
0282: .add(
0283: 11,
0284: 11,
0285: 11)
0286: .add(
0287: confPanelLayout
0288: .createParallelGroup(
0289: org.jdesktop.layout.GroupLayout.LEADING)
0290: .add(
0291: confPanelLayout
0292: .createSequentialGroup()
0293: .addPreferredGap(
0294: org.jdesktop.layout.LayoutStyle.RELATED,
0295: 1,
0296: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
0297: .add(
0298: cbPackageJars))
0299: .add(
0300: confPanelLayout
0301: .createSequentialGroup()
0302: .add(
0303: confPanelLayout
0304: .createParallelGroup(
0305: org.jdesktop.layout.GroupLayout.LEADING)
0306: .add(
0307: beanPackageLabel)
0308: .add(
0309: lServletName)
0310: .add(
0311: confPanelLayout
0312: .createSequentialGroup()
0313: .addPreferredGap(
0314: org.jdesktop.layout.LayoutStyle.RELATED,
0315: 1,
0316: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
0317: .add(
0318: confPanelLayout
0319: .createParallelGroup(
0320: org.jdesktop.layout.GroupLayout.LEADING)
0321: .add(
0322: lURLPattern)
0323: .add(
0324: cbValidate))))
0325: .addPreferredGap(
0326: org.jdesktop.layout.LayoutStyle.RELATED)
0327: .add(
0328: confPanelLayout
0329: .createParallelGroup(
0330: org.jdesktop.layout.GroupLayout.LEADING)
0331: .add(
0332: confPanelLayout
0333: .createSequentialGroup()
0334: .addPreferredGap(
0335: org.jdesktop.layout.LayoutStyle.RELATED)
0336: .add(
0337: cbVerify))
0338: .add(
0339: tServletName,
0340: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0341: 345,
0342: Short.MAX_VALUE)
0343: .add(
0344: tURLPattern,
0345: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0346: 345,
0347: Short.MAX_VALUE)
0348: .add(
0349: beanPackageTextField,
0350: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0351: 345,
0352: Short.MAX_VALUE))))))
0353: .add(12, 12, 12)));
0354: confPanelLayout
0355: .setVerticalGroup(confPanelLayout
0356: .createParallelGroup(
0357: org.jdesktop.layout.GroupLayout.LEADING)
0358: .add(
0359: confPanelLayout
0360: .createSequentialGroup()
0361: .addContainerGap()
0362: .add(
0363: confPanelLayout
0364: .createParallelGroup(
0365: org.jdesktop.layout.GroupLayout.BASELINE)
0366: .add(
0367: beanPackageLabel)
0368: .add(
0369: beanPackageTextField,
0370: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0371: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0372: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
0373: .addPreferredGap(
0374: org.jdesktop.layout.LayoutStyle.RELATED)
0375: .add(
0376: confPanelLayout
0377: .createParallelGroup(
0378: org.jdesktop.layout.GroupLayout.BASELINE)
0379: .add(
0380: lServletName)
0381: .add(
0382: tServletName,
0383: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0384: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0385: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
0386: .addPreferredGap(
0387: org.jdesktop.layout.LayoutStyle.RELATED)
0388: .add(
0389: confPanelLayout
0390: .createParallelGroup(
0391: org.jdesktop.layout.GroupLayout.BASELINE)
0392: .add(
0393: lURLPattern)
0394: .add(
0395: tURLPattern,
0396: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0397: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0398: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
0399: .add(17, 17, 17)
0400: .add(
0401: confPanelLayout
0402: .createParallelGroup(
0403: org.jdesktop.layout.GroupLayout.BASELINE)
0404: .add(cbValidate)
0405: .add(cbVerify))
0406: .addPreferredGap(
0407: org.jdesktop.layout.LayoutStyle.RELATED)
0408: .add(cbPackageJars)
0409: .add(51, 51, 51)
0410: .add(
0411: jPanel1,
0412: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0413: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0414: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));
0415:
0416: beanPackageTextField.getAccessibleContext()
0417: .setAccessibleDescription(
0418: org.openide.util.NbBundle.getMessage(
0419: JSFConfigurationPanelVisual.class,
0420: "ACSD_DefaultBackingPackageDesc")); // NOI18N
0421: tServletName.getAccessibleContext().setAccessibleDescription(
0422: org.openide.util.NbBundle.getMessage(
0423: JSFConfigurationPanelVisual.class,
0424: "ACSD_ServletName")); // NOI18N
0425: tURLPattern.getAccessibleContext().setAccessibleDescription(
0426: org.openide.util.NbBundle.getMessage(
0427: JSFConfigurationPanelVisual.class,
0428: "ACSD_Mapping")); // NOI18N
0429: cbValidate.getAccessibleContext().setAccessibleDescription(
0430: org.openide.util.NbBundle.getMessage(
0431: JSFConfigurationPanelVisual.class,
0432: "ACSD_ValidateXML")); // NOI18N
0433: cbVerify.getAccessibleContext().setAccessibleDescription(
0434: org.openide.util.NbBundle.getMessage(
0435: JSFConfigurationPanelVisual.class,
0436: "ACSD_VerifyObjects")); // NOI18N
0437: cbPackageJars.getAccessibleContext().setAccessibleDescription(
0438: org.openide.util.NbBundle.getMessage(
0439: JSFConfigurationPanelVisual.class,
0440: "ACSD_PackageJarToWar")); // NOI18N
0441:
0442: jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(
0443: JSFConfigurationPanelVisual.class,
0444: "LBL_TAB_Configuration"), confPanel); // NOI18N
0445:
0446: libPanel.setAlignmentX(0.2F);
0447: libPanel.setAlignmentY(0.2F);
0448:
0449: buttonGroup1.add(rbRegisteredLibrary);
0450: java.util.ResourceBundle bundle = java.util.ResourceBundle
0451: .getBundle("org/netbeans/modules/visualweb/project/jsf/framework/Bundle"); // NOI18N
0452: rbRegisteredLibrary.setText(bundle
0453: .getString("LBL_REGISTERED_LIBRARIES")); // NOI18N
0454: rbRegisteredLibrary.setBorder(javax.swing.BorderFactory
0455: .createEmptyBorder(0, 0, 0, 0));
0456: rbRegisteredLibrary.setMargin(new java.awt.Insets(0, 0, 0, 0));
0457: rbRegisteredLibrary
0458: .addItemListener(new java.awt.event.ItemListener() {
0459: public void itemStateChanged(
0460: java.awt.event.ItemEvent evt) {
0461: rbRegisteredLibraryItemStateChanged(evt);
0462: }
0463: });
0464:
0465: cbLibraries
0466: .setModel(new javax.swing.DefaultComboBoxModel(
0467: new String[] { "Item 1", "Item 2", "Item 3",
0468: "Item 4" }));
0469: cbLibraries
0470: .addActionListener(new java.awt.event.ActionListener() {
0471: public void actionPerformed(
0472: java.awt.event.ActionEvent evt) {
0473: cbLibrariesActionPerformed(evt);
0474: }
0475: });
0476:
0477: buttonGroup1.add(rbNewLibrary);
0478: rbNewLibrary
0479: .setText(bundle.getString("LBL_CREATE_NEW_LIBRARY")); // NOI18N
0480: rbNewLibrary.setToolTipText(bundle
0481: .getString("MSG_CreatingLibraries")); // NOI18N
0482: rbNewLibrary.setBorder(javax.swing.BorderFactory
0483: .createEmptyBorder(0, 0, 0, 0));
0484: rbNewLibrary.setMargin(new java.awt.Insets(0, 0, 0, 0));
0485: rbNewLibrary.addItemListener(new java.awt.event.ItemListener() {
0486: public void itemStateChanged(java.awt.event.ItemEvent evt) {
0487: rbNewLibraryItemStateChanged(evt);
0488: }
0489: });
0490:
0491: lDirectory.setText(bundle.getString("LBL_INSTALL_DIR")); // NOI18N
0492: lDirectory.setToolTipText(bundle
0493: .getString("HINT_JSF_Directory")); // NOI18N
0494:
0495: jtFolder.setToolTipText(bundle.getString("HINT_JSF_Directory")); // NOI18N
0496: jtFolder.addKeyListener(new java.awt.event.KeyAdapter() {
0497: public void keyPressed(java.awt.event.KeyEvent evt) {
0498: jtFolderKeyPressed(evt);
0499: }
0500: });
0501:
0502: jbBrowse.setText(bundle.getString("LBL_Browse")); // NOI18N
0503: jbBrowse.addActionListener(new java.awt.event.ActionListener() {
0504: public void actionPerformed(java.awt.event.ActionEvent evt) {
0505: jbBrowseActionPerformed(evt);
0506: }
0507: });
0508:
0509: lVersion.setText(bundle.getString("LBL_VERSION")); // NOI18N
0510: lVersion.setToolTipText(bundle.getString("HINT_Version")); // NOI18N
0511:
0512: jtVersion.setToolTipText(bundle.getString("HINT_Version")); // NOI18N
0513: jtVersion.addKeyListener(new java.awt.event.KeyAdapter() {
0514: public void keyReleased(java.awt.event.KeyEvent evt) {
0515: jtVersionKeyReleased(evt);
0516: }
0517: });
0518:
0519: buttonGroup1.add(rbNoneLibrary);
0520: rbNoneLibrary.setText(bundle.getString("LBL_Any_Library")); // NOI18N
0521: rbNoneLibrary.setBorder(javax.swing.BorderFactory
0522: .createEmptyBorder(0, 0, 0, 0));
0523: rbNoneLibrary.setMargin(new java.awt.Insets(0, 0, 0, 0));
0524: rbNoneLibrary
0525: .addItemListener(new java.awt.event.ItemListener() {
0526: public void itemStateChanged(
0527: java.awt.event.ItemEvent evt) {
0528: rbNoneLibraryItemStateChanged(evt);
0529: }
0530: });
0531:
0532: org.jdesktop.layout.GroupLayout libPanelLayout = new org.jdesktop.layout.GroupLayout(
0533: libPanel);
0534: libPanel.setLayout(libPanelLayout);
0535: libPanelLayout
0536: .setHorizontalGroup(libPanelLayout
0537: .createParallelGroup(
0538: org.jdesktop.layout.GroupLayout.LEADING)
0539: .add(
0540: libPanelLayout
0541: .createSequentialGroup()
0542: .addContainerGap()
0543: .add(
0544: libPanelLayout
0545: .createParallelGroup(
0546: org.jdesktop.layout.GroupLayout.LEADING)
0547: .add(
0548: libPanelLayout
0549: .createSequentialGroup()
0550: .add(
0551: rbRegisteredLibrary)
0552: .addPreferredGap(
0553: org.jdesktop.layout.LayoutStyle.RELATED)
0554: .add(
0555: cbLibraries,
0556: 0,
0557: 332,
0558: Short.MAX_VALUE))
0559: .add(
0560: rbNewLibrary,
0561: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0562: 478,
0563: Short.MAX_VALUE)
0564: .add(
0565: libPanelLayout
0566: .createSequentialGroup()
0567: .add(
0568: 17,
0569: 17,
0570: 17)
0571: .add(
0572: libPanelLayout
0573: .createParallelGroup(
0574: org.jdesktop.layout.GroupLayout.LEADING)
0575: .add(
0576: lDirectory)
0577: .add(
0578: lVersion))
0579: .addPreferredGap(
0580: org.jdesktop.layout.LayoutStyle.RELATED)
0581: .add(
0582: libPanelLayout
0583: .createParallelGroup(
0584: org.jdesktop.layout.GroupLayout.TRAILING)
0585: .add(
0586: jtVersion,
0587: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0588: 282,
0589: Short.MAX_VALUE)
0590: .add(
0591: jtFolder,
0592: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0593: 282,
0594: Short.MAX_VALUE))
0595: .addPreferredGap(
0596: org.jdesktop.layout.LayoutStyle.RELATED)
0597: .add(
0598: jbBrowse))
0599: .add(
0600: rbNoneLibrary,
0601: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0602: 478,
0603: Short.MAX_VALUE))
0604: .addContainerGap()));
0605: libPanelLayout
0606: .setVerticalGroup(libPanelLayout
0607: .createParallelGroup(
0608: org.jdesktop.layout.GroupLayout.LEADING)
0609: .add(
0610: libPanelLayout
0611: .createSequentialGroup()
0612: .addContainerGap()
0613: .add(
0614: libPanelLayout
0615: .createParallelGroup(
0616: org.jdesktop.layout.GroupLayout.BASELINE)
0617: .add(
0618: rbRegisteredLibrary)
0619: .add(
0620: cbLibraries,
0621: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0622: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0623: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
0624: .addPreferredGap(
0625: org.jdesktop.layout.LayoutStyle.RELATED)
0626: .add(rbNewLibrary)
0627: .add(7, 7, 7)
0628: .add(
0629: libPanelLayout
0630: .createParallelGroup(
0631: org.jdesktop.layout.GroupLayout.BASELINE)
0632: .add(jbBrowse)
0633: .add(lDirectory)
0634: .add(
0635: jtFolder,
0636: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0637: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0638: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
0639: .addPreferredGap(
0640: org.jdesktop.layout.LayoutStyle.RELATED)
0641: .add(
0642: libPanelLayout
0643: .createParallelGroup(
0644: org.jdesktop.layout.GroupLayout.BASELINE)
0645: .add(lVersion)
0646: .add(
0647: jtVersion,
0648: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
0649: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
0650: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
0651: .addPreferredGap(
0652: org.jdesktop.layout.LayoutStyle.RELATED)
0653: .add(rbNoneLibrary)
0654: .addContainerGap(125,
0655: Short.MAX_VALUE)));
0656:
0657: jsfTabbedPane.addTab(
0658: org.openide.util.NbBundle.getMessage(
0659: JSFConfigurationPanelVisual.class,
0660: "LBL_TAB_Libraries"), libPanel); // NOI18N
0661:
0662: add(jsfTabbedPane, "card10");
0663: }// </editor-fold>//GEN-END:initComponents
0664:
0665: private void beanPackageTextField1KeyReleased(
0666: java.awt.event.KeyEvent evt) {//GEN-FIRST:event_beanPackageTextField1KeyReleased
0667: // TODO add your handling code here:
0668: }//GEN-LAST:event_beanPackageTextField1KeyReleased
0669:
0670: private void beanPackageTextFieldKeyReleased(
0671: java.awt.event.KeyEvent evt) {//GEN-FIRST:event_beanPackageTextFieldKeyReleased
0672: if (beanPackageTextField.getText().length() == 0)
0673: beanPackageModified = false;
0674: else
0675: beanPackageModified = true;
0676: panel.fireChangeEvent();
0677: }//GEN-LAST:event_beanPackageTextFieldKeyReleased
0678:
0679: private void rbNoneLibraryItemStateChanged(
0680: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbNoneLibraryItemStateChanged
0681: updateLibrary();
0682: }//GEN-LAST:event_rbNoneLibraryItemStateChanged
0683:
0684: private void jtVersionKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtVersionKeyReleased
0685: checkNewLibrarySetting();
0686: }//GEN-LAST:event_jtVersionKeyReleased
0687:
0688: private void rbNewLibraryItemStateChanged(
0689: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbNewLibraryItemStateChanged
0690: updateLibrary();
0691: }//GEN-LAST:event_rbNewLibraryItemStateChanged
0692:
0693: private void cbLibrariesActionPerformed(
0694: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbLibrariesActionPerformed
0695: panel.setLibrary(jsfLibraries.get(cbLibraries
0696: .getSelectedIndex()));
0697: }//GEN-LAST:event_cbLibrariesActionPerformed
0698:
0699: private void rbRegisteredLibraryItemStateChanged(
0700: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbRegisteredLibraryItemStateChanged
0701: updateLibrary();
0702: }//GEN-LAST:event_rbRegisteredLibraryItemStateChanged
0703:
0704: private void jbBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBrowseActionPerformed
0705: JFileChooser chooser = new JFileChooser();
0706: chooser.setDialogTitle(NbBundle.getMessage(
0707: JSFConfigurationPanelVisual.class,
0708: "LBL_SelectLibraryLocation")); //NOI18N
0709: chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
0710:
0711: if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this )) {
0712: File projectDir = chooser.getSelectedFile();
0713: jtFolder.setText(projectDir.getAbsolutePath());
0714: checkNewLibrarySetting();
0715: }
0716: }//GEN-LAST:event_jbBrowseActionPerformed
0717:
0718: private void jtFolderKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtFolderKeyPressed
0719: checkNewLibrarySetting();
0720: }//GEN-LAST:event_jtFolderKeyPressed
0721:
0722: // Variables declaration - do not modify//GEN-BEGIN:variables
0723: private javax.swing.JLabel beanPackageLabel;
0724: protected javax.swing.JTextField beanPackageTextField;
0725: private javax.swing.ButtonGroup buttonGroup1;
0726: private javax.swing.JComboBox cbLibraries;
0727: private javax.swing.JCheckBox cbPackageJars;
0728: private javax.swing.JCheckBox cbValidate;
0729: private javax.swing.JCheckBox cbVerify;
0730: private javax.swing.JPanel confPanel;
0731: private javax.swing.JPanel jPanel1;
0732: private javax.swing.JButton jbBrowse;
0733: private javax.swing.JTabbedPane jsfTabbedPane;
0734: private javax.swing.JTextField jtFolder;
0735: private javax.swing.JTextField jtVersion;
0736: private javax.swing.JLabel lDirectory;
0737: private javax.swing.JLabel lServletName;
0738: private javax.swing.JLabel lURLPattern;
0739: private javax.swing.JLabel lVersion;
0740: private javax.swing.JPanel libPanel;
0741: private javax.swing.JRadioButton rbNewLibrary;
0742: private javax.swing.JRadioButton rbNoneLibrary;
0743: private javax.swing.JRadioButton rbRegisteredLibrary;
0744: private javax.swing.JTextField tServletName;
0745: private javax.swing.JTextField tURLPattern;
0746:
0747: // End of variables declaration//GEN-END:variables
0748:
0749: void enableComponents(boolean enable) {
0750: Component[] components;
0751:
0752: components = confPanel.getComponents();
0753: for (int i = 0; i < components.length; i++) {
0754: components[i].setEnabled(enable);
0755: }
0756:
0757: components = libPanel.getComponents();
0758: for (int i = 0; i < components.length; i++) {
0759: components[i].setEnabled(enable);
0760: }
0761: }
0762:
0763: boolean valid() {
0764: ExtenderController controller = panel.getController();
0765: // <RAVE> Checking default Bean Package
0766: String beanPkg = beanPackageTextField.getText();
0767: if (!customizer
0768: && !JsfProjectUtils.isValidJavaPackageName(beanPkg)) {
0769: String errMsg = NbBundle.getMessage(
0770: JSFConfigurationPanelVisual.class,
0771: "MSG_InvalidPackage");
0772: controller.setErrorMessage(errMsg); // NOI18N
0773: return false;
0774: }
0775: // </RAVE>
0776:
0777: String urlPattern = tURLPattern.getText();
0778: if (urlPattern == null || urlPattern.trim().equals("")) {
0779: controller.setErrorMessage(NbBundle.getMessage(
0780: JSFConfigurationPanelVisual.class,
0781: "MSG_URLPatternIsEmpty"));
0782: return false;
0783: }
0784: if (!isPatternValid(urlPattern)) {
0785: controller.setErrorMessage(NbBundle.getMessage(
0786: JSFConfigurationPanelVisual.class,
0787: "MSG_URLPatternIsNotValid"));
0788: return false;
0789: }
0790:
0791: if (!customizer) {
0792: Properties properties = controller.getProperties();
0793: String j2eeLevel = (String) properties
0794: .getProperty("j2eeLevel"); //NOI18N
0795: String currentServerInstanceID = (String) properties
0796: .getProperty("serverInstanceID"); //NOI18N
0797: if (j2eeLevel != null && currentServerInstanceID != null) {
0798: boolean currentWebModule25Version;
0799: if (j2eeLevel.equals("1.5")) //NOI81N
0800: currentWebModule25Version = true;
0801: else
0802: currentWebModule25Version = false;
0803: if (!currentServerInstanceID.equals(serverInstanceID)
0804: || currentWebModule25Version != webModule25Version) {
0805: webModule25Version = currentWebModule25Version;
0806: serverInstanceID = currentServerInstanceID;
0807: initLibSettings(webModule25Version,
0808: serverInstanceID);
0809: }
0810: }
0811:
0812: // <RAVE>
0813: initBackwardsKitSettings("1.5".equals(j2eeLevel),
0814: currentServerInstanceID); // NOI18N
0815: // </RAVE>
0816: }
0817:
0818: // <RAVE>
0819: boolean addJSF11 = false;
0820: if (addJSF) {
0821: if ((rbNewLibrary.isSelected() && (jtFolder.getText()
0822: .trim().length() <= 0 || jtVersion.getText().trim()
0823: .length() <= 0))
0824: || (rbRegisteredLibrary.isSelected() && cbLibraries
0825: .getItemCount() <= 0)) {
0826: addJSF11 = true;
0827: }
0828: }
0829:
0830: if (addJSF11 || addJAXRPC || addRowset) {
0831: controller
0832: .setErrorMessage(JsfProjectUtils
0833: .getBackwardsKitMesg(addJSF11, addJAXRPC,
0834: addRowset)); //NOI18N
0835: return false;
0836: }
0837: // </RAVE>
0838:
0839: if (rbNewLibrary.isSelected()) {
0840: String folder = jtFolder.getText().trim();
0841: String version = jtVersion.getText().trim();
0842: if (folder.length() <= 0) {
0843: controller.setErrorMessage(NbBundle.getMessage(
0844: JSFConfigurationPanelVisual.class,
0845: "LBL_EmptyJSFFolder")); //NOI18N
0846: return false;
0847: }
0848: File jsfFolder = new File(folder);
0849: if (!jsfFolder.exists()) {
0850: controller.setErrorMessage(NbBundle.getMessage(
0851: JSFConfigurationPanelVisual.class,
0852: "LBL_NonExistingJSFFolder")); //NOI18N
0853: return false;
0854: }
0855: if (!jsfFolder.isDirectory()) {
0856: controller.setErrorMessage(NbBundle.getMessage(
0857: JSFConfigurationPanelVisual.class,
0858: "LBL_NotJSFFolder")); //NOI18N
0859: return false;
0860: }
0861: FileObject fo = FileUtil.toFileObject(jsfFolder);
0862: FileObject[] ch = fo.getChildren();
0863: int counter = 0;
0864: for (int i = 0; i < ch.length; i++) {
0865: FileObject child = ch[i];
0866: if (child.getName().equalsIgnoreCase("jsf-api")
0867: || child.getName().equalsIgnoreCase("jsf-impl")) //NOI18N
0868: counter++;
0869: }
0870: if (counter != 2) {
0871: controller.setErrorMessage(NbBundle.getMessage(
0872: JSFConfigurationPanelVisual.class,
0873: "LBL_NotValidJSFFolder")); //NOI18N
0874: return false;
0875: }
0876: if (version.length() <= 0) {
0877: controller.setErrorMessage(NbBundle.getMessage(
0878: JSFConfigurationPanelVisual.class,
0879: "LBL_EmptyJSFVersion")); //NOI18N
0880: return false;
0881: }
0882: Library lib = JSFUtils.getJSFLibrary(version);
0883: if (lib != null) {
0884: controller.setErrorMessage(NbBundle.getMessage(
0885: JSFConfigurationPanelVisual.class,
0886: "LBL_AlreadyExists")); //NOI18N
0887: return false;
0888: }
0889: }
0890:
0891: controller.setErrorMessage(null);
0892: return true;
0893: }
0894:
0895: // <RAVE> Default Bean Package
0896: protected boolean isBeanPackageModified() {
0897: return beanPackageModified;
0898: }
0899:
0900: // </RAVE>
0901:
0902: private boolean isPatternValid(String pattern) {
0903: if (pattern.startsWith("*.")) {
0904: String p = pattern.substring(2);
0905: if (p.indexOf('.') == -1 && p.indexOf('*') == -1
0906: && p.indexOf('/') == -1 && !p.trim().equals(""))
0907: return true;
0908: }
0909: // pattern = "/.../*", where ... can't be empty.
0910: if ((pattern.length() > 3) && pattern.endsWith("/*")
0911: && pattern.startsWith("/"))
0912: return true;
0913: return false;
0914: }
0915:
0916: void update() {
0917: Properties properties = panel.getController().getProperties();
0918: if ("1.5".equals((String) properties.getProperty("j2eeLevel"))) //NOI81N
0919: webModule25Version = true;
0920: else
0921: webModule25Version = false;
0922:
0923: serverInstanceID = (String) properties
0924: .getProperty("serverInstanceID"); //NOI18N
0925: initLibSettings(webModule25Version, serverInstanceID);
0926:
0927: // <RAVE>
0928: initBackwardsKitSettings(webModule25Version, serverInstanceID);
0929: // </RAVE>
0930: }
0931:
0932: private void initLibSettings(boolean webModule25Version,
0933: String serverInstanceID) {
0934: try {
0935: addJSF = false;
0936: File[] cp;
0937: J2eePlatform platform = Deployment.getDefault()
0938: .getJ2eePlatform(serverInstanceID);
0939: // j2eeplatform can be null, when the target server is not accessible.
0940: if (platform != null) {
0941: cp = platform.getClasspathEntries();
0942: } else {
0943: cp = new File[0];
0944: }
0945: boolean isJSF = Util.containsClass(Arrays.asList(cp),
0946: JSFUtils.FACES_EXCEPTION);
0947: if (isJSF)
0948: rbNoneLibrary.setSelected(true);
0949: else if (webModule25Version) {
0950: Library jsf12 = LibraryManager.getDefault().getLibrary(
0951: "jsf12");
0952: if (jsf12 != null) {
0953: rbRegisteredLibrary.setSelected(true);
0954: cbLibraries.setSelectedItem(jsf12.getDisplayName());
0955: } else
0956: rbNewLibrary.setSelected(true);
0957: } else {
0958: // <RAVE>
0959: Library lib = LibraryManager.getDefault().getLibrary(
0960: "jsf1102");
0961: /*
0962: Library[] libs = LibraryManager.getDefault().getLibraries();
0963: Library lib = null;
0964: for (int i = 0; i < libs.length; i++) {
0965: if (libs[i].getDisplayName().startsWith("JSF-")) {
0966: lib = libs[i];
0967: break;
0968: }
0969: }
0970: </RAVE> */
0971: if (lib != null) {
0972: rbRegisteredLibrary.setSelected(true);
0973: cbLibraries.setSelectedItem(lib.getDisplayName());
0974: } else
0975: rbNewLibrary.setSelected(true);
0976: addJSF = true;
0977: }
0978: } catch (IOException exc) {
0979: }
0980: }
0981:
0982: // <RAVE>
0983: private void initBackwardsKitSettings(boolean webModule25Version,
0984: String serverInstanceID) {
0985: // It's a J2EE 1.4 project
0986: addJAXRPC = false;
0987: if (!webModule25Version) {
0988: Library libJAXRPC = LibraryManager.getDefault().getLibrary(
0989: "jaxrpc16"); // NOI18N
0990:
0991: // IDE does not have the JAXRPC support
0992: if (libJAXRPC == null) {
0993: // Server does not have the JAXRPC support
0994: try {
0995: File[] cp;
0996: J2eePlatform platform = Deployment.getDefault()
0997: .getJ2eePlatform(serverInstanceID);
0998: // j2eeplatform can be null, when the target server is not accessible.
0999: if (platform != null) {
1000: cp = platform.getClasspathEntries();
1001: } else {
1002: cp = new File[0];
1003: }
1004: addJAXRPC = !Util.containsClass(Arrays.asList(cp),
1005: "javax.xml.rpc.Service"); // NOI18N
1006: } catch (IOException exc) {
1007: }
1008: }
1009: }
1010:
1011: String setSrcLevel = (project == null) ? null : JsfProjectUtils
1012: .getSourceLevel(project);
1013: if (setSrcLevel == null) {
1014: Properties properties = panel.getController()
1015: .getProperties();
1016: setSrcLevel = (String) properties
1017: .getProperty("setSourceLevel"); //NOI18N
1018: }
1019:
1020: // It's a J2SE 1.4 project
1021: addRowset = false;
1022: if ("1.4".equals(setSrcLevel)) { // NOI18N
1023: Library libRowset = LibraryManager.getDefault().getLibrary(
1024: "rowset-ri"); // NOI18N
1025: // IDE doesn't have the Rowset RI support
1026: if (libRowset == null) {
1027: addRowset = true;
1028: }
1029: }
1030: }
1031:
1032: // </RAVE>
1033:
1034: void store(WizardDescriptor d) {
1035: // projectLocationPanel.store(d);
1036: // optionsPanel.store(d);
1037: }
1038:
1039: /** Help context where to find more about the paste type action.
1040: * @return the help context for this action
1041: */
1042: public HelpCtx getHelpCtx() {
1043: return new HelpCtx(JSFConfigurationPanelVisual.class);
1044: }
1045:
1046: public void removeUpdate(javax.swing.event.DocumentEvent e) {
1047: panel.fireChangeEvent();
1048: }
1049:
1050: public void insertUpdate(javax.swing.event.DocumentEvent e) {
1051: panel.fireChangeEvent();
1052: }
1053:
1054: public void changedUpdate(javax.swing.event.DocumentEvent e) {
1055: panel.fireChangeEvent();
1056: }
1057:
1058: // <RAVE> Default Bean Package
1059: public String getBeanPackage() {
1060: return beanPackageTextField.getText();
1061: }
1062:
1063: public void setBeanPackage(String pkg_name) {
1064: beanPackageTextField.setText(pkg_name);
1065: }
1066:
1067: // </RAVE>
1068:
1069: public String getServletName() {
1070: return tServletName.getText();
1071: }
1072:
1073: public void setServletName(String name) {
1074: tServletName.setText(name);
1075: }
1076:
1077: public String getURLPattern() {
1078: return tURLPattern.getText();
1079: }
1080:
1081: public void setURLPattern(String pattern) {
1082: tURLPattern.setText(pattern);
1083: }
1084:
1085: public boolean validateXML() {
1086: return cbValidate.isSelected();
1087: }
1088:
1089: public void setValidateXML(boolean ver) {
1090: cbValidate.setSelected(ver);
1091: }
1092:
1093: public boolean verifyObjects() {
1094: return cbVerify.isSelected();
1095: }
1096:
1097: public void setVerifyObjects(boolean val) {
1098: cbVerify.setSelected(val);
1099: }
1100:
1101: public boolean packageJars() {
1102: return cbPackageJars.isSelected();
1103: }
1104:
1105: private void updateLibrary() {
1106: if (cbLibraries.getItemCount() == 0)
1107: rbRegisteredLibrary.setEnabled(false);
1108:
1109: if (rbNoneLibrary.isSelected()) {
1110: enableNewLibraryComponent(false);
1111: enableDefinedLibraryComponent(false);
1112: panel
1113: .setLibraryType(JSFConfigurationPanel.LibraryType.NONE);
1114: panel.getController().setErrorMessage(null);
1115: } else if (rbRegisteredLibrary.isSelected()) {
1116: enableNewLibraryComponent(false);
1117: enableDefinedLibraryComponent(true);
1118: panel
1119: .setLibraryType(JSFConfigurationPanel.LibraryType.USED);
1120: if (jsfLibraries.size() > 0) {
1121: panel.setLibrary(jsfLibraries.get(cbLibraries
1122: .getSelectedIndex()));
1123: }
1124: panel.getController().setErrorMessage(null);
1125: } else if (rbNewLibrary.isSelected()) {
1126: enableNewLibraryComponent(true);
1127: enableDefinedLibraryComponent(false);
1128: panel.setLibraryType(JSFConfigurationPanel.LibraryType.NEW);
1129: checkNewLibrarySetting();
1130: }
1131: }
1132:
1133: private void enableDefinedLibraryComponent(boolean enabled) {
1134: cbLibraries.setEnabled(enabled);
1135: }
1136:
1137: private void enableNewLibraryComponent(boolean enabled) {
1138: lDirectory.setEnabled(enabled);
1139: jtFolder.setEnabled(enabled);
1140: jbBrowse.setEnabled(enabled);
1141: lVersion.setEnabled(enabled);
1142: jtVersion.setEnabled(enabled);
1143: }
1144:
1145: private void checkNewLibrarySetting() {
1146: String message = null;
1147: String fileName = jtFolder.getText();
1148: if (fileName == null || "".equals(fileName)) {
1149: message = NbBundle.getMessage(
1150: JSFConfigurationPanelVisual.class,
1151: "MSG_PathIsNotFaceletsFolder");
1152: } else {
1153: File folder = new File(fileName);
1154: if (!JSFUtils.isJSFInstallFolder(folder)) {
1155: message = NbBundle.getMessage(
1156: JSFConfigurationPanelVisual.class,
1157: "MSG_PathIsNotFaceletsFolder");
1158: } else {
1159: panel.setInstallFolder(folder);
1160:
1161: String version = jtVersion.getText().trim();
1162: if (version == null || "".equals(version)) {
1163: message = NbBundle.getMessage(
1164: JSFConfigurationPanelVisual.class,
1165: "MSG_VersionHasToBeDefined");
1166: } else {
1167: String name = "jsf-"
1168: + JSFUtils.convertLibraryVersion(version); //NOI18N
1169: int length = jsfLibraries.size();
1170: for (int i = 0; i < length; i++) {
1171: if (jsfLibraries.get(i).getName().equals(name)) {
1172: message = NbBundle.getMessage(
1173: JSFConfigurationPanelVisual.class,
1174: "MSG_VersionAlreadyExist");
1175: }
1176: }
1177: }
1178: if (message == null) {
1179: panel.setNewLibraryVersion(jtVersion.getText()
1180: .trim());
1181: }
1182: }
1183: }
1184: panel.getController().setErrorMessage(message);
1185: }
1186:
1187: }
|