001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.core.wizard;
021:
022: import java.awt.Component;
023: import java.util.ArrayList;
024: import java.util.Iterator;
025: import java.util.List;
026: import javax.swing.JTextField;
027: import javax.swing.event.ChangeEvent;
028: import javax.swing.event.ChangeListener;
029: import org.netbeans.api.project.Project;
030: import org.netbeans.api.project.SourceGroup;
031: import org.openide.WizardDescriptor;
032: import org.openide.loaders.TemplateWizard;
033: import org.openide.util.HelpCtx;
034:
035: /**
036: *
037: * from nb webservice module
038: */
039: final class NewBpelFilePanel implements
040: WizardDescriptor.Panel<WizardDescriptor> {
041:
042: NewBpelFilePanel(Project project, SourceGroup[] folders) {
043: this .folders = folders;
044: this .project = project;
045: }
046:
047: TemplateWizard getTemplateWizard() {
048: return templateWizard;
049: }
050:
051: void setNameTF(JTextField nameTF) {
052: gui.attachFileNameListener(nameTF);
053: }
054:
055: public Component getComponent() {
056: if (gui == null) {
057: gui = new BpelOptionsPanel(this );
058: }
059: return gui;
060: }
061:
062: public HelpCtx getHelp() {
063: return new HelpCtx(NewBpelFilePanel.class);
064: }
065:
066: public boolean isValid() {
067: boolean valid = true;
068:
069: if (gui.getNamespaceTextField().contains(" "))
070: valid = false;
071:
072: return valid;
073: }
074:
075: public void addChangeListener(ChangeListener l) {
076: listeners.add(l);
077: }
078:
079: public void removeChangeListener(ChangeListener l) {
080: listeners.remove(l);
081: }
082:
083: protected void fireChange() {
084: ChangeEvent e = new ChangeEvent(this );
085: Iterator it = listeners.iterator();
086: while (it.hasNext()) {
087: ((ChangeListener) it.next()).stateChanged(e);
088: }
089: }
090:
091: public void readSettings(WizardDescriptor settings) {
092: templateWizard = (TemplateWizard) settings;
093: }
094:
095: public void storeSettings(WizardDescriptor settings) {
096: if (WizardDescriptor.PREVIOUS_OPTION
097: .equals(settings.getValue())) {
098: return;
099: }
100: if (WizardDescriptor.CANCEL_OPTION.equals(settings.getValue())) {
101: return;
102: }
103:
104: settings.putProperty("NewFileWizard_Title", null); // NOI18N
105: }
106:
107: String getNS() {
108: return gui.getNamespaceTextField();
109: }
110:
111: String getWsName() {
112: return gui.getWsName();
113: }
114:
115: Project getProject() {
116: return project;
117: }
118:
119: private final List/*<ChangeListener>*/listeners = new ArrayList();
120: private BpelOptionsPanel gui;
121:
122: private Project project;
123: private SourceGroup[] folders;
124: private TemplateWizard templateWizard;
125:
126: }
|