001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.j2me.cdc.project.ui.wizards;
043:
044: import javax.swing.JPanel;
045:
046: import org.openide.WizardDescriptor;
047: import org.openide.WizardValidationException;
048: import org.openide.util.NbBundle;
049:
050: /** First panel in the NewProject wizard. Used for filling in
051: * name, and directory of the project.
052: *
053: * @author Petr Hrebejk
054: */
055: public class PanelConfigureProjectVisual extends JPanel {
056:
057: private PanelConfigureProject panel;
058:
059: private SettingsPanel projectLocationPanel;
060:
061: private PanelOptionsVisual optionsPanel;
062:
063: private int type;
064:
065: final static private String WIZARD_TYPE = "cdc-wizard-type";
066:
067: /** Creates new form PanelInitProject */
068: public PanelConfigureProjectVisual(PanelConfigureProject panel,
069: int type, String preferredName) {
070: this .panel = panel;
071: initComponents();
072: this .type = type;
073: setName(NbBundle.getMessage(PanelConfigureProjectVisual.class,
074: "TXT_NameAndLoc")); // NOI18N
075: if (type == NewCDCProjectWizardIterator.TYPE_APP
076: || type == NewCDCProjectWizardIterator.TYPE_EXT
077: || type == NewCDCProjectWizardIterator.TYPE_SAMPLE) {
078: projectLocationPanel = new PanelProjectLocationVisual(
079: panel, type, preferredName);
080: putClientProperty("NewProjectWizard_Title", NbBundle
081: .getMessage(PanelConfigureProjectVisual.class,
082: "TXT_NewJavaApp")); // NOI18N
083: jSeparator1.setVisible(true);
084: getAccessibleContext().setAccessibleName(
085: NbBundle.getMessage(
086: PanelConfigureProjectVisual.class,
087: "TXT_NewJavaApp")); // NOI18N
088: getAccessibleContext().setAccessibleDescription(
089: NbBundle.getMessage(
090: PanelConfigureProjectVisual.class,
091: "ACSD_NewJavaApp")); // NOI18N
092: } else if (type == NewCDCProjectWizardIterator.TYPE_LIB) {
093: projectLocationPanel = new PanelProjectLocationVisual(
094: panel, type, preferredName);
095: jSeparator1.setVisible(false);
096: putClientProperty("NewProjectWizard_Title", NbBundle
097: .getMessage(PanelConfigureProjectVisual.class,
098: "TXT_NewJavaLib")); // NOI18N
099: getAccessibleContext().setAccessibleName(
100: NbBundle.getMessage(
101: PanelConfigureProjectVisual.class,
102: "TXT_NewJavaLib")); // NOI18N
103: getAccessibleContext().setAccessibleDescription(
104: NbBundle.getMessage(
105: PanelConfigureProjectVisual.class,
106: "ACSD_NewJavaLib")); // NOI18N
107: }
108: locationContainer.add(projectLocationPanel,
109: java.awt.BorderLayout.CENTER);
110: optionsPanel = new PanelOptionsVisual(panel, type);
111: projectLocationPanel.addPropertyChangeListener(optionsPanel);
112: optionsContainer
113: .add(optionsPanel, java.awt.BorderLayout.CENTER);
114: }
115:
116: boolean valid(WizardDescriptor wizardDescriptor) {
117: wizardDescriptor.putProperty("WizardPanel_errorMessage", " "); //NOI18N
118: return projectLocationPanel.valid(wizardDescriptor)
119: && optionsPanel.valid(wizardDescriptor);
120: }
121:
122: void read(WizardDescriptor d) {
123: Integer lastType = (Integer) d.getProperty(WIZARD_TYPE); //NOI18N
124: if (lastType == null || lastType.intValue() != this .type) {
125: //bugfix #46387 The type of project changed, reset values to defaults
126: d.putProperty("name", null);
127: d.putProperty("projdir", null);
128: }
129: projectLocationPanel.read(d);
130: projectLocationPanel.store(d); //read back the properties
131: optionsPanel.read(d);
132: }
133:
134: void store(WizardDescriptor d) {
135: d.putProperty(WIZARD_TYPE, new Integer(this .type)); //NOI18N
136: projectLocationPanel.store(d);
137: optionsPanel.store(d);
138: }
139:
140: void validate(WizardDescriptor d) throws WizardValidationException {
141: projectLocationPanel.validate(d);
142: }
143:
144: /** This method is called from within the constructor to
145: * initialize the form.
146: * WARNING: Do NOT modify this code. The content of this method is
147: * always regenerated by the Form Editor.
148: */
149: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
150: private void initComponents() {
151: java.awt.GridBagConstraints gridBagConstraints;
152:
153: locationContainer = new javax.swing.JPanel();
154: jSeparator1 = new javax.swing.JSeparator();
155: optionsContainer = new javax.swing.JPanel();
156:
157: setLayout(new java.awt.GridBagLayout());
158:
159: locationContainer.setLayout(new java.awt.BorderLayout());
160:
161: gridBagConstraints = new java.awt.GridBagConstraints();
162: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
163: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
164: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
165: gridBagConstraints.weightx = 1.0;
166: add(locationContainer, gridBagConstraints);
167: locationContainer.getAccessibleContext().setAccessibleName(
168: org.openide.util.NbBundle.getBundle(
169: PanelConfigureProjectVisual.class).getString(
170: "ACSN_locationContainer"));
171: locationContainer.getAccessibleContext()
172: .setAccessibleDescription(
173: org.openide.util.NbBundle.getBundle(
174: PanelConfigureProjectVisual.class)
175: .getString("ACSD_locationContainer"));
176:
177: gridBagConstraints = new java.awt.GridBagConstraints();
178: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
179: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
180: gridBagConstraints.weightx = 1.0;
181: gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 0);
182: add(jSeparator1, gridBagConstraints);
183:
184: optionsContainer.setLayout(new java.awt.BorderLayout());
185:
186: gridBagConstraints = new java.awt.GridBagConstraints();
187: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
188: gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
189: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
191: gridBagConstraints.weightx = 1.0;
192: gridBagConstraints.weighty = 1.0;
193: add(optionsContainer, gridBagConstraints);
194: optionsContainer.getAccessibleContext().setAccessibleName(
195: org.openide.util.NbBundle.getBundle(
196: PanelConfigureProjectVisual.class).getString(
197: "ACSN_optionsContainer"));
198: optionsContainer.getAccessibleContext()
199: .setAccessibleDescription(
200: org.openide.util.NbBundle.getBundle(
201: PanelConfigureProjectVisual.class)
202: .getString("ACSD_optionsContainer"));
203:
204: }// </editor-fold>//GEN-END:initComponents
205:
206: /** Currently only handles the "Browse..." button
207: */
208:
209: // Variables declaration - do not modify//GEN-BEGIN:variables
210: private javax.swing.JSeparator jSeparator1;
211: private javax.swing.JPanel locationContainer;
212: private javax.swing.JPanel optionsContainer;
213: // End of variables declaration//GEN-END:variables
214:
215: }
|