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: package org.netbeans.modules.sql.project.ui.wizards;
020:
021: import java.awt.Component;
022: import java.util.HashSet;
023: import java.util.Iterator;
024: import java.util.Set;
025:
026: import javax.swing.JComponent;
027: import javax.swing.event.ChangeEvent;
028: import javax.swing.event.ChangeListener;
029:
030: import org.openide.WizardDescriptor;
031: import org.openide.util.HelpCtx;
032:
033: /**
034: * Panel just asking for basic info.
035: * @author Jesse Glick
036: */
037: final class PanelConfigureProject implements WizardDescriptor.Panel,
038: WizardDescriptor.FinishablePanel {
039: ///final class PanelConfigureProject implements WizardDescriptor.Panel {
040:
041: private WizardDescriptor wizardDescriptor;
042: private PanelConfigureProjectVisual component;
043: private String defaulName;
044:
045: /** Create the wizard panel descriptor. */
046: public PanelConfigureProject(String defaulName) {
047: this .defaulName = defaulName;
048: }
049:
050: public boolean isFinishPanel() {
051: return true;
052: }
053:
054: public Component getComponent() {
055: if (component == null) {
056: component = new PanelConfigureProjectVisual(this );
057: }
058: return component;
059: }
060:
061: public HelpCtx getHelp() {
062: // return HelpCtx.DEFAULT_HELP;
063: return new HelpCtx(PanelConfigureProject.class);
064: }
065:
066: public boolean isValid() {
067: getComponent();
068: return component.valid(wizardDescriptor);
069: }
070:
071: private final Set/*<ChangeListener>*/listeners = new HashSet(1);
072:
073: public final void addChangeListener(ChangeListener l) {
074: synchronized (listeners) {
075: listeners.add(l);
076: }
077: }
078:
079: public final void removeChangeListener(ChangeListener l) {
080: synchronized (listeners) {
081: listeners.remove(l);
082: }
083: }
084:
085: protected final void fireChangeEvent() {
086: Iterator it;
087: synchronized (listeners) {
088: it = new HashSet(listeners).iterator();
089: }
090: ChangeEvent ev = new ChangeEvent(this );
091: while (it.hasNext()) {
092: ((ChangeListener) it.next()).stateChanged(ev);
093: }
094: }
095:
096: public void readSettings(Object settings) {
097: wizardDescriptor = (WizardDescriptor) settings;
098: component.read(wizardDescriptor);
099:
100: // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
101: // this name is used in NewProjectWizard to modify the title
102: Object substitute = ((JComponent) component)
103: .getClientProperty("NewProjectWizard_Title"); // NOI18N
104: if (substitute != null)
105: wizardDescriptor.putProperty("NewProjectWizard_Title",
106: substitute); // NOI18N
107: }
108:
109: public void storeSettings(Object settings) {
110: WizardDescriptor d = (WizardDescriptor) settings;
111: component.store(d);
112: ((WizardDescriptor) d).putProperty("NewProjectWizard_Title",
113: null); // NOI18N
114: }
115:
116: public String getDefaulName() {
117: return defaulName;
118: }
119:
120: }
|