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.web.jsf.wizards;
043:
044: import java.io.File;
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: import org.netbeans.api.project.libraries.Library;
051: import org.netbeans.modules.web.api.webmodule.ExtenderController;
052: import org.netbeans.modules.web.api.webmodule.WebModule;
053: import org.netbeans.modules.web.jsf.JSFFrameworkProvider;
054: import org.netbeans.modules.web.spi.webmodule.WebModuleExtender;
055: import org.openide.util.HelpCtx;
056:
057: /**
058: *
059: * @author petr
060: */
061: public class JSFConfigurationPanel extends WebModuleExtender {
062:
063: private final JSFFrameworkProvider framework;
064: private final ExtenderController controller;
065: private JSFConfigurationPanelVisual component;
066:
067: public enum LibraryType {
068: USED, NEW, NONE
069: };
070:
071: private LibraryType libraryType;
072: private Library jsfCoreLibrary;
073: private String newLibraryName;
074: private File installedFolder;
075:
076: /** Creates a new instance of JSFConfigurationPanel */
077: public JSFConfigurationPanel(JSFFrameworkProvider framework,
078: ExtenderController controller, boolean customizer) {
079: this .framework = framework;
080: this .controller = controller;
081: this .customizer = customizer;
082: getComponent();
083: }
084:
085: private boolean customizer;
086:
087: public JSFConfigurationPanelVisual getComponent() {
088: if (component == null)
089: component = new JSFConfigurationPanelVisual(this ,
090: customizer);
091:
092: return component;
093: }
094:
095: public HelpCtx getHelp() {
096: return new HelpCtx(JSFConfigurationPanel.class);
097: }
098:
099: public void update() {
100: component.update();
101: }
102:
103: public boolean isValid() {
104: getComponent();
105: return component.valid();
106: }
107:
108: public Set extend(WebModule webModule) {
109: return framework.extendImpl(webModule);
110: }
111:
112: public ExtenderController getController() {
113: return controller;
114: }
115:
116: private final Set/*<ChangeListener>*/listeners = new HashSet(1);
117:
118: public final void addChangeListener(ChangeListener l) {
119: synchronized (listeners) {
120: listeners.add(l);
121: }
122: }
123:
124: public final void removeChangeListener(ChangeListener l) {
125: synchronized (listeners) {
126: listeners.remove(l);
127: }
128: }
129:
130: protected final void fireChangeEvent() {
131: Iterator it;
132: synchronized (listeners) {
133: it = new HashSet(listeners).iterator();
134: }
135: ChangeEvent ev = new ChangeEvent(this );
136: while (it.hasNext()) {
137: ((ChangeListener) it.next()).stateChanged(ev);
138: }
139: }
140:
141: public String getServletName() {
142: return component.getServletName();
143: }
144:
145: public void setServletName(String name) {
146: component.setServletName(name);
147: }
148:
149: public String getURLPattern() {
150: return component.getURLPattern();
151: }
152:
153: public void setURLPattern(String pattern) {
154: component.setURLPattern(pattern);
155: }
156:
157: public boolean validateXML() {
158: return component.validateXML();
159: }
160:
161: public void setValidateXML(boolean ver) {
162: component.setValidateXML(ver);
163: }
164:
165: public boolean verifyObjects() {
166: return component.verifyObjects();
167: }
168:
169: public void setVerifyObjects(boolean val) {
170: component.setVerifyObjects(val);
171: }
172:
173: public boolean packageJars() {
174: return component.packageJars();
175: }
176:
177: public String getNewLibraryName() {
178: return newLibraryName;
179: }
180:
181: public void setNewLibraryName(String version) {
182: this .newLibraryName = version;
183: fireChangeEvent();
184: }
185:
186: public File getInstallFolder() {
187: return installedFolder;
188: }
189:
190: public void setInstallFolder(File folder) {
191: installedFolder = folder;
192: fireChangeEvent();
193: }
194:
195: public LibraryType getLibraryType() {
196: return libraryType;
197: }
198:
199: public void setLibraryType(LibraryType value) {
200: libraryType = value;
201: }
202:
203: public Library getLibrary() {
204: return jsfCoreLibrary;
205: }
206:
207: protected void setLibrary(Library library) {
208: this.jsfCoreLibrary = library;
209: fireChangeEvent();
210: }
211:
212: }
|