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