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: package org.netbeans.modules.php.project.wizards;
042:
043: import java.awt.Component;
044: import java.util.Collection;
045: import java.util.LinkedList;
046:
047: import javax.swing.event.ChangeEvent;
048: import javax.swing.event.ChangeListener;
049:
050: import org.openide.WizardDescriptor;
051: import org.openide.WizardDescriptor.FinishablePanel;
052: import org.openide.WizardDescriptor.Panel;
053: import org.openide.util.HelpCtx;
054: import org.openide.util.NbBundle;
055:
056: /**
057: * @author ads
058: *
059: */
060: final class ProviderSpecificPanel implements Panel, FinishablePanel {
061:
062: ProviderSpecificPanel() {
063: init();
064: }
065:
066: /* (non-Javadoc)
067: * @see org.openide.WizardDescriptor.Panel#addChangeListener(javax.swing.event.ChangeListener)
068: */
069: public void addChangeListener(ChangeListener listener) {
070: synchronized (myListeners) {
071: myListeners.add(listener);
072: }
073: }
074:
075: /* (non-Javadoc)
076: * @see org.openide.WizardDescriptor.Panel#removeChangeListener(javax.swing.event.ChangeListener)
077: */
078: public void removeChangeListener(ChangeListener listener) {
079: synchronized (myListeners) {
080: myListeners.remove(listener);
081: }
082: }
083:
084: /* (non-Javadoc)
085: * @see org.openide.WizardDescriptor.Panel#getComponent()
086: */
087: public Component getComponent() {
088: return myComponent;
089: }
090:
091: /* (non-Javadoc)
092: * @see org.openide.WizardDescriptor.Panel#getHelp()
093: */
094: public HelpCtx getHelp() {
095: return new HelpCtx(ProviderSpecificPanel.class);
096: }
097:
098: /* (non-Javadoc)
099: * @see org.openide.WizardDescriptor.Panel#isValid()
100: */
101: public boolean isValid() {
102: return getVisual().dataIsValid(getDescriptor());
103: }
104:
105: /* (non-Javadoc)
106: * @see org.openide.WizardDescriptor.Panel#readSettings(java.lang.Object)
107: */
108: public void readSettings(Object settings) {
109: myDescriptor = (WizardDescriptor) settings;
110:
111: getVisual().read(getDescriptor());
112:
113: /*
114: * Copied from Make project configuration panel
115: */
116: // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
117: // this name is used in NewProjectWizard to modify the title
118: Object substitute = getVisual().getClientProperty(
119: PhpConfigureProjectVisual.NEW_PROJECT_WIZARD_TITLE);
120: if (substitute != null) {
121: getDescriptor().putProperty(
122: PhpConfigureProjectVisual.NEW_PROJECT_WIZARD_TITLE,
123: substitute);
124: }
125: }
126:
127: /* (non-Javadoc)
128: * @see org.openide.WizardDescriptor.Panel#storeSettings(java.lang.Object)
129: */
130: public void storeSettings(Object settings) {
131: WizardDescriptor descriptor = (WizardDescriptor) settings;
132: getVisual().store(descriptor);
133: ((WizardDescriptor) descriptor).putProperty(
134: PhpConfigureProjectVisual.NEW_PROJECT_WIZARD_TITLE,
135: null);
136: }
137:
138: /* (non-Javadoc)
139: * @see org.openide.WizardDescriptor.FinishablePanel#isFinishPanel()
140: */
141: public boolean isFinishPanel() {
142: return true;
143: }
144:
145: final void fireChangeEvent() {
146: ChangeListener[] listeners;
147: synchronized (myListeners) {
148: listeners = myListeners
149: .toArray(new ChangeListener[myListeners.size()]);
150: }
151: ChangeEvent event = new ChangeEvent(this );
152: for (ChangeListener listener : listeners) {
153: listener.stateChanged(event);
154: }
155: }
156:
157: private ProviderPanelVisual getVisual() {
158: return myComponent;
159: }
160:
161: private WizardDescriptor getDescriptor() {
162: return myDescriptor;
163: }
164:
165: private void init() {
166: myComponent = new ProviderPanelVisual(this );
167:
168: /*String[] initialSteps = getDescriptor().getInitialSteps();
169: String[] steps = new String[initialSteps.length + 1];
170: System.arraycopy(initialSteps, 0, steps, 0, initialSteps.length);
171: steps[initialSteps.length] = AddHostWizard.ELIPSIS;
172: getVisual().putClientProperty( AddHostWizard.PROP_CONTENT_DATA, steps);
173:
174: getVisual().putClientProperty(AddHostWizard.SELECTED_INDEX, 0);*/
175:
176: /*
177: * Provide a name of the step in the title bar.
178: */
179: getVisual()
180: .setName(
181: NbBundle
182: .getBundle(
183: NewPhpProjectWizardIterator.class)
184: .getString(
185: NewPhpProjectWizardIterator.STEP_WEB_SERVER));
186: }
187:
188: private ProviderPanelVisual myComponent;
189:
190: private final Collection<ChangeListener> myListeners = new LinkedList<ChangeListener>();
191:
192: private WizardDescriptor myDescriptor;
193:
194: }
|