001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.sql.project.ui.wizards;
043:
044: import java.awt.event.ItemEvent;
045: import java.beans.PropertyChangeEvent;
046: import java.beans.PropertyChangeListener;
047: import java.io.File;
048: import java.io.IOException;
049: import java.text.MessageFormat;
050: import javax.swing.event.DocumentEvent;
051: import javax.swing.event.DocumentListener; //import org.netbeans.modules.sql.project.ui.customizer.IcanproProjectProperties;
052: import org.netbeans.modules.compapp.projects.base.ui.customizer.IcanproProjectProperties;
053: import org.openide.WizardDescriptor;
054: import org.openide.util.NbBundle;
055:
056: public class PanelOptionsVisual extends SettingsPanel implements
057: PropertyChangeListener {
058:
059: // private static boolean lastMainClassCheck = false; // XXX Store somewhere
060:
061: private PanelConfigureProject panel;
062: private String j2eeLevel = IcanproProjectProperties.J2EE_1_4;
063:
064: // private boolean valid;
065:
066: /** Creates new form PanelOptionsVisual */
067: public PanelOptionsVisual(PanelConfigureProject panel) {
068: initComponents();
069: this .panel = panel;
070: //B initJ2EESpecLevels();
071: }
072:
073: public void propertyChange(PropertyChangeEvent event) {
074: if (PanelProjectLocationVisual.PROP_PROJECT_NAME.equals(event
075: .getPropertyName())) {
076: String newProjectName = ((String) event.getNewValue())
077: .trim();
078: }
079: }
080:
081: /** This method is called from within the constructor to
082: * initialize the form.
083: * WARNING: Do NOT modify this code. The content of this method is
084: * always regenerated by the Form Editor.
085: */
086: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
087: private void initComponents() {
088: setAsMainCheckBox = new javax.swing.JCheckBox();
089: jLabel1 = new javax.swing.JLabel();
090:
091: setLayout(new java.awt.BorderLayout());
092:
093: setAsMainCheckBox.setSelected(true);
094: org.openide.awt.Mnemonics
095: .setLocalizedText(
096: setAsMainCheckBox,
097: java.util.ResourceBundle
098: .getBundle(
099: "org/netbeans/modules/sql/project/ui/wizards/Bundle")
100: .getString(
101: "LBL_NWP1_SetAsMain_CheckBox"));
102: setAsMainCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
103: add(setAsMainCheckBox, java.awt.BorderLayout.CENTER);
104: setAsMainCheckBox.getAccessibleContext()
105: .setAccessibleDescription(
106: org.openide.util.NbBundle.getMessage(
107: PanelOptionsVisual.class,
108: "ACS_LBL_NWP1_SetAsMain_A11YDesc"));
109:
110: jLabel1.setText(" ");
111: add(jLabel1, java.awt.BorderLayout.NORTH);
112:
113: }// </editor-fold>//GEN-END:initComponents
114:
115: boolean valid(WizardDescriptor settings) {
116: settings.putProperty("WizardPanel_errorMessage", null); // NOI18N
117: return true;
118: }
119:
120: boolean validateFileName(WizardDescriptor wizardDescriptor,
121: String fileName, String errMsgKey) {
122: if (fileName.length() == 0 || fileName.indexOf('/') > 0 //NOI18N
123: // || fileName.indexOf('/') > 0 //NOI18N
124: || fileName.indexOf('\\') > 0 //NOI18N
125: || fileName.indexOf(':') > 0) { //NOI18N
126: wizardDescriptor.putProperty("WizardPanel_errorMessage", // NOI18N
127: NbBundle
128: .getMessage(
129: PanelProjectLocationVisual.class,
130: errMsgKey));
131: return false;
132: }
133:
134: final File tmpFile = new File(fileName).getAbsoluteFile();
135: if (getCanonicalFile(tmpFile) == null) {
136: String message = NbBundle.getMessage(
137: PanelProjectLocationVisual.class, errMsgKey);
138: wizardDescriptor.putProperty("WizardPanel_errorMessage",
139: message); // NOI18N
140: return false;
141: }
142:
143: return true;
144: }
145:
146: void store(WizardDescriptor d) {
147: d.putProperty(WizardProperties.SET_AS_MAIN, setAsMainCheckBox
148: .isSelected() ? Boolean.TRUE : Boolean.FALSE);
149: d.putProperty(WizardProperties.J2EE_LEVEL, j2eeLevel);
150: }
151:
152: void read(WizardDescriptor d) {
153: }
154:
155: // Variables declaration - do not modify//GEN-BEGIN:variables
156: private javax.swing.JLabel jLabel1;
157: private javax.swing.JCheckBox setAsMainCheckBox;
158:
159: // End of variables declaration//GEN-END:variables
160:
161: private void bpelNameChanged() {
162: // String bpelName = this.bpelNameTextField.getText();
163: // this.valid = bpelName.endsWith(".bpel");
164: this .panel.fireChangeEvent();
165: }
166:
167: private void wsdlNameChanged() {
168: // String wsdlName = this.wsdlNameTextField.getText();
169: // this.valid = wsdlName.endsWith(".wsdl");
170: this .panel.fireChangeEvent();
171: }
172:
173: static File getCanonicalFile(File file) {
174: try {
175: return file.getCanonicalFile();
176: } catch (IOException e) {
177: return null;
178: }
179: }
180: }
|