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.cnd.makeproject.ui.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.JComponent;
049: import javax.swing.event.ChangeEvent;
050: import javax.swing.event.ChangeListener;
051: import org.openide.WizardDescriptor;
052: import org.openide.util.HelpCtx;
053: import org.openide.util.NbBundle;
054:
055: /**
056: * Panel just asking for basic info.
057: */
058: public class PanelConfigureProject implements WizardDescriptor.Panel,
059: NewMakeProjectWizardIterator.Name,
060: WizardDescriptor.FinishablePanel {
061:
062: private WizardDescriptor wizardDescriptor;
063: private String name;
064: private int type;
065: private PanelConfigureProjectVisual component;
066: private String title;
067: private String wizardTitle;
068: private String wizardACSD;
069: private boolean initialized = false;
070: private boolean showMakefileTextField;
071:
072: /** Create the wizard panel descriptor. */
073: public PanelConfigureProject(String name, int type,
074: String wizardTitle, String wizardACSD,
075: boolean showMakefileTextField) {
076: this .name = name;
077: this .type = type;
078: this .wizardTitle = wizardTitle;
079: this .wizardACSD = wizardACSD;
080: this .showMakefileTextField = showMakefileTextField;
081: title = NbBundle.getMessage(PanelConfigureProject.class,
082: "LAB_ConfigureProject"); // NOI18N
083: }
084:
085: public Component getComponent() {
086: if (component == null) {
087: component = new PanelConfigureProjectVisual(this ,
088: this .name, this .wizardTitle, this .wizardACSD,
089: showMakefileTextField);
090: }
091: return component;
092: }
093:
094: public String getName() {
095: return title;
096: }
097:
098: public HelpCtx getHelp() {
099: if (type == NewMakeProjectWizardIterator.TYPE_APPLICATION) {
100: return new HelpCtx("NewAppWizard"); // NOI18N
101: } else if (type == NewMakeProjectWizardIterator.TYPE_DYNAMIC_LIB) {
102: return new HelpCtx("NewDynamicLibWizard"); // NOI18N
103: } else if (type == NewMakeProjectWizardIterator.TYPE_STATIC_LIB) {
104: return new HelpCtx("NewStaticLibWizard"); // NOI18N
105: } else if (type == NewMakeProjectWizardIterator.TYPE_MAKEFILE) {
106: return new HelpCtx("NewMakeWizardP1"); // NOI18N
107: } else {
108: return new HelpCtx("CreatingCorC++Project"); // NOI18N
109: }
110: }
111:
112: public boolean isValid() {
113: getComponent();
114: return component.valid(wizardDescriptor);
115: }
116:
117: private final Set/*<ChangeListener>*/listeners = new HashSet(1);
118:
119: public final void addChangeListener(ChangeListener l) {
120: synchronized (listeners) {
121: listeners.add(l);
122: }
123: }
124:
125: public final void removeChangeListener(ChangeListener l) {
126: synchronized (listeners) {
127: listeners.remove(l);
128: }
129: }
130:
131: protected final void fireChangeEvent() {
132: Iterator it;
133: synchronized (listeners) {
134: it = new HashSet(listeners).iterator();
135: }
136: ChangeEvent ev = new ChangeEvent(this );
137: while (it.hasNext()) {
138: ((ChangeListener) it.next()).stateChanged(ev);
139: }
140: }
141:
142: public void readSettings(Object settings) {
143: if (initialized)
144: return;
145: wizardDescriptor = (WizardDescriptor) settings;
146: component.read(wizardDescriptor);
147:
148: // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
149: // this name is used in NewProjectWizard to modify the title
150: Object substitute = ((JComponent) component)
151: .getClientProperty("NewProjectWizard_Title"); // NOI18N
152: if (substitute != null) {
153: wizardDescriptor.putProperty("NewProjectWizard_Title",
154: substitute); // NOI18N
155: }
156: initialized = true;
157: }
158:
159: public void storeSettings(Object settings) {
160: WizardDescriptor d = (WizardDescriptor) settings;
161: component.store(d);
162: }
163:
164: public boolean isFinishPanel() {
165: return true;
166: }
167: }
|