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.web.wizards;
043:
044: import java.awt.Component;
045: import java.util.HashSet;
046: import java.util.Iterator;
047: import java.util.Set;
048: import javax.swing.event.ChangeEvent;
049: import javax.swing.event.ChangeListener;
050:
051: import org.openide.WizardDescriptor;
052: import org.openide.util.HelpCtx;
053: import org.openide.loaders.TemplateWizard;
054:
055: /** A single panel descriptor for a wizard.
056: * You probably want to make a wizard iterator to hold it.
057: *
058: * @author Milan Kuchtiak
059: */
060: public class WrapperSelection implements WizardDescriptor.Panel {
061:
062: /** The visual component that displays this panel.
063: * If you need to access the component from this class,
064: * just use getComponent().
065: */
066: private WrapperPanel component;
067: private transient TemplateWizard wizard;
068:
069: /** Create the wizard panel descriptor. */
070: public WrapperSelection(TemplateWizard wizard) {
071: this .wizard = wizard;
072: }
073:
074: // Get the visual component for the panel. In this template, the component
075: // is kept separate. This can be more efficient: if the wizard is created
076: // but never displayed, or not all panels are displayed, it is better to
077: // create only those which really need to be visible.
078: public Component getComponent() {
079: if (component == null) {
080: component = new WrapperPanel(this );
081: }
082: return component;
083: }
084:
085: public HelpCtx getHelp() {
086: return null;
087: }
088:
089: public boolean isValid() {
090: // If it is always OK to press Next or Finish, then:
091: return true;
092: // If it depends on some condition (form filled out...), then:
093: // return someCondition ();
094: // and when this condition changes (last form field filled in...) then:
095: // fireChangeEvent ();
096: // and uncomment the complicated stuff below.
097: }
098:
099: /*
100: public boolean isValid() {
101: if(isListenerSelected()) {
102: wizard.putProperty("WizardPanel_errorMessage", ""); //NOI18N
103: return true;
104: }
105: wizard.putProperty("WizardPanel_errorMessage", //NOI18N
106: org.openide.util.NbBundle.getMessage(ListenerPanel.class,"MSG_noListenerSelected"));
107: return false;
108: }
109: */
110:
111: public final void addChangeListener(ChangeListener l) {
112: }
113:
114: public final void removeChangeListener(ChangeListener l) {
115: }
116:
117: /*
118: private final Set listeners = new HashSet (1); // Set<ChangeListener>
119: public final void addChangeListener (ChangeListener l) {
120: synchronized (listeners) {
121: listeners.add (l);
122: }
123: }
124: public final void removeChangeListener (ChangeListener l) {
125: synchronized (listeners) {
126: listeners.remove (l);
127: }
128: }
129: protected final void fireChangeEvent () {
130: Iterator it;
131: synchronized (listeners) {
132: it = new HashSet (listeners).iterator ();
133: }
134: ChangeEvent ev = new ChangeEvent (this);
135: while (it.hasNext ()) {
136: ((ChangeListener) it.next ()).stateChanged (ev);
137: }
138: }
139: */
140:
141: // You can use a settings object to keep track of state.
142: // Normally the settings object will be the WizardDescriptor,
143: // so you can use WizardDescriptor.getProperty & putProperty
144: // to store information entered by the user.
145: public void readSettings(Object settings) {
146: }
147:
148: public void storeSettings(Object settings) {
149: }
150:
151: boolean isWrapper() {
152: return component.isWrapper();
153: }
154:
155: }
|