diff -r 11b2acb8a7e0 j2ee.common/nbproject/project.xml --- a/j2ee.common/nbproject/project.xml Mon Jul 25 11:29:28 2011 +0200 +++ b/j2ee.common/nbproject/project.xml Mon Jul 25 13:45:41 2011 +0200 @@ -475,7 +475,6 @@ org.netbeans.modules.glassfish.eecommon - org.netbeans.modules.javaee.beanvalidation org.netbeans.modules.j2ee.archive org.netbeans.modules.j2ee.clientproject org.netbeans.modules.j2ee.ddloaders @@ -487,6 +486,7 @@ org.netbeans.modules.j2ee.jboss4 org.netbeans.modules.j2ee.sun.appsrv81 org.netbeans.modules.j2ee.weblogic9 + org.netbeans.modules.javaee.beanvalidation org.netbeans.modules.maven.j2ee org.netbeans.modules.maven.jaxws org.netbeans.modules.mobility.end2end @@ -498,12 +498,13 @@ org.netbeans.modules.web.core org.netbeans.modules.web.freeform org.netbeans.modules.web.jsf + org.netbeans.modules.web.jsf.richfaces org.netbeans.modules.web.project org.netbeans.modules.web.struts org.netbeans.modules.websvc.core org.netbeans.modules.websvc.jaxrpc + org.netbeans.modules.websvc.manager org.netbeans.modules.websvc.restapi - org.netbeans.modules.websvc.manager org.netbeans.modules.websvc.wsitconf org.netbeans.modules.j2ee.common org.netbeans.modules.j2ee.common.dd diff -r 11b2acb8a7e0 web.jsf.richfaces/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/build.xml Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,5 @@ + + + Builds, tests, and runs the project org.netbeans.modules.web.jsf.richfaces + + diff -r 11b2acb8a7e0 web.jsf.richfaces/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/manifest.mf Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +OpenIDE-Module: org.netbeans.modules.web.jsf.richfaces +OpenIDE-Module-Layer: org/netbeans/modules/web/jsf/richfaces/resources/layer.xml +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/web/jsf/richfaces/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r 11b2acb8a7e0 web.jsf.richfaces/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/nbproject/project.properties Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,3 @@ +javac.source=1.6 +javac.compilerargs=-Xlint -Xlint:-serial +nbm.module.author=Martin Fousek diff -r 11b2acb8a7e0 web.jsf.richfaces/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/nbproject/project.xml Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,90 @@ + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.web.jsf.richfaces + + + org.netbeans.api.java.classpath + + + + 1 + 1.30 + + + + org.netbeans.api.web.webmodule + + + + 1.24 + + + + org.netbeans.modules.j2ee.common + + + + 1 + 1.65 + + + + org.netbeans.modules.j2ee.dd + + + + 1 + 1.22 + + + + org.netbeans.modules.java.project + + + + 1 + 1.39 + + + + org.netbeans.modules.project.libraries + + + + 1 + 1.30 + + + + org.netbeans.modules.web.jsf + + + + 1 + 1.27 + + + + org.openide.filesystems + + + + 7.48 + + + + org.openide.util + + + + 8.16 + + + + + + + diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/Bundle.properties Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,52 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 2011 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. +# +# Contributor(s): +# +# Portions Copyrighted 2011 Sun Microsystems, Inc. + +OpenIDE-Module-Name=RichFaces +OpenIDE-Module-Display-Category=Java Web and EE +OpenIDE-Module-Short-Description=RichFaces is an open source component suite for development with JavaServer Faces framework. +OpenIDE-Module-Long-Description=\ + RichFaces is an open source component suite for development with JavaServer Faces web framework. \ + It has extended multiple areas of JSF, including usability, performance tuning, dynamic resources, skinning, and component development. + +LBL_RichFaces4=RichFaces 4.0.0 +LBL_RichFaces4_Description=\ + RichFaces is an open source component suite for JavaServer Faces 2. It has extended multiple areas of \ + JSF, including usability, performance tuning, dynamic resources, skinning, and component development. + diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/Richfaces4Customizer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/Richfaces4Customizer.java Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,211 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.web.jsf.richfaces; + +import java.awt.Container; +import java.awt.Dialog; +import java.awt.event.WindowEvent; +import java.awt.event.WindowFocusListener; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.prefs.Preferences; +import javax.swing.JComponent; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.netbeans.api.project.libraries.Library; +import org.netbeans.api.project.libraries.LibraryManager; +import org.netbeans.modules.j2ee.common.Util; +import org.netbeans.modules.web.jsf.richfaces.ui.Richfaces4CustomizerPanelVisual; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentCustomizer; +import org.openide.util.ChangeSupport; +import org.openide.util.NbPreferences; + +/** + * + * @author Martin Fousek + */ +public class Richfaces4Customizer implements JsfComponentCustomizer { + + Richfaces4CustomizerPanelVisual panel; + private ChangeSupport changeSupport = new ChangeSupport(this); + boolean initialize = false; + + public static final Logger LOGGER = Logger.getLogger(Richfaces4Customizer.class.getName()); + + public Richfaces4Customizer() { + initialize = true; + } + + @Override + public void addChangeListener(ChangeListener listener) { + changeSupport.addChangeListener(listener); + } + + @Override + public void removeChangeListener(ChangeListener listener) { + changeSupport.removeChangeListener(listener); + } + + @Override + public JComponent getComponent() { + if (panel == null) { + panel = new Richfaces4CustomizerPanelVisual(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + changeSupport.fireChange(); + } + }); + + panel.addAncestorListener(new AncestorListener() { + + @Override + public void ancestorAdded(AncestorEvent event) { + Container component = event.getAncestor(); + if (component instanceof Dialog) { + Dialog ancestorDialog = (Dialog)component; + ancestorDialog.addWindowFocusListener(new WindowFocusListener() { + + @Override + public void windowGainedFocus(WindowEvent e) { + panel.initLibraries(initialize); + initialize = false; + changeSupport.fireChange(); + } + + @Override + public void windowLostFocus(WindowEvent e) { + } + }); + } + } + + @Override + public void ancestorRemoved(AncestorEvent event) { + } + + @Override + public void ancestorMoved(AncestorEvent event) { + } + }); + } + return panel; + } + + @Override + public boolean isValid() { + Preferences preferences = NbPreferences.forModule(Richfaces4Customizer.class).node(Richfaces4Implementation.PREF_RICHFACES_NODE); + String richfacesLibrary = preferences.get(Richfaces4Implementation.PREF_RICHFACES_LIBRARY, ""); + if (LibraryManager.getDefault().getLibrary(richfacesLibrary) != null) { + return true; + } + + for (Library library : LibraryManager.getDefault().getLibraries()) { + if (!"j2se".equals(library.getType())) { // NOI18N + continue; + } + + List content = library.getContent("classpath"); //NOI18N + if (isValidRichfacesLibrary(content)) { + return true; + } + } + + return false; + } + + @Override + public String getWarningMessage() { + return panel.getWarningMessage(); + } + + @Override + public String getErrorMessage() { + return panel.getErrorMessage(); + } + + @Override + public void saveConfiguration() { + Preferences preferences = NbPreferences.forModule(Richfaces4Customizer.class).node(Richfaces4Implementation.PREF_RICHFACES_NODE); + preferences.put(Richfaces4Implementation.PREF_RICHFACES_LIBRARY, panel.getRichFacesLibrary()); + } + + public static List getRichfacesLibraries() { + List libraries = new ArrayList(); + List content; + for (Library library : LibraryManager.getDefault().getLibraries()) { + if (!"j2se".equals(library.getType())) { // NOI18N + continue; + } + + content = library.getContent("classpath"); //NOI18N + if (Richfaces4Customizer.isValidRichfacesLibrary(content)) { + libraries.add(library); + } + } + return libraries; + } + + public static boolean isValidRichfacesLibrary(List libraryContent) { + Set> entrySet = Richfaces4Implementation.RF_LIBRARIES.entrySet(); + for (Entry entry : entrySet) { + try { + if (!Util.containsClass(libraryContent, entry.getKey())) { + return false; + } + } catch (IOException ex) { + LOGGER.log(Level.INFO, null, ex); + return false; + } + } + return true; + } + +} diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/Richfaces4Implementation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/Richfaces4Implementation.java Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,167 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.web.jsf.richfaces; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.prefs.Preferences; +import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.api.java.project.classpath.ProjectClassPathModifier; +import org.netbeans.api.project.libraries.Library; +import org.netbeans.api.project.libraries.LibraryManager; +import org.netbeans.modules.web.api.webmodule.WebModule; +import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentCustomizer; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation; +import org.openide.filesystems.FileObject; +import org.openide.util.NbBundle; +import org.openide.util.NbPreferences; + +/** + * + * @author Martin Fousek + */ +public class Richfaces4Implementation implements JsfComponentImplementation { + + private final String name; + private final String description; + + private static Richfaces4Customizer customizer; + + public static final String LIBRARY_NAME = "Richfaces 4.0.0"; //NOI18N + public static final Logger LOGGER = Logger.getLogger(Richfaces4Implementation.class.getName()); + + public static final Map RF_LIBRARIES = new HashMap(); + public static final Map RF_DEPENDENCIES = new HashMap(); + + public static final String PREF_RICHFACES_NODE = "richfaces4"; //NOI18N + public static final String PREF_RICHFACES_LIBRARY = "base-library"; //NOI18N + + + public Richfaces4Implementation() { + this.name = NbBundle.getMessage(Richfaces4Implementation.class, "LBL_RichFaces4"); //NOI18N + this.description = NbBundle.getMessage(Richfaces4Implementation.class, "LBL_RichFaces4_Description"); //NOI18N + + if (RF_LIBRARIES.isEmpty()) { + RF_LIBRARIES.put("org.richfaces.application.Module", "richfaces-core-api-4.0.0.Final.jar"); //NOI18N + RF_LIBRARIES.put("org.richfaces.application.ServiceLoader", "richfaces-core-impl-4.0.0.Final.jar"); //NOI18N + RF_LIBRARIES.put("org.richfaces.el.ValueDescriptor", "richfaces-components-api-4.0.0.Final.jar"); //NOI18N + RF_LIBRARIES.put("org.richfaces.el.ValueReference", "richfaces-components-ui-4.0.0.Final.jar"); //NOI18N + } + if (RF_DEPENDENCIES.isEmpty()) { + RF_DEPENDENCIES.put("com.google.common.base.Functions", "guava.jar"); //NOI18N + RF_DEPENDENCIES.put("org.w3c.css.sac.Parser", "sac.jar"); //NOI18N + RF_DEPENDENCIES.put("com.steadystate.css.parser.ParseException", "cssparser.jar"); //NOI18N + } + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public void remove(WebModule wm) { + } + + @Override + public Set extend(org.netbeans.modules.web.api.webmodule.WebModule webModule) { + FileObject[] javaSources = webModule.getJavaSources(); + try { + List libraries = new ArrayList(1); + Preferences preferences = NbPreferences.forModule(Richfaces4Implementation.class).node(Richfaces4Implementation.PREF_RICHFACES_NODE); + + Library rfLibrary = LibraryManager.getDefault().getLibrary(preferences.get(Richfaces4Implementation.PREF_RICHFACES_LIBRARY, "")); + if (rfLibrary == null) { + rfLibrary = Richfaces4Customizer.getRichfacesLibraries().get(0); + } + + libraries.add(rfLibrary); + ProjectClassPathModifier.addLibraries(libraries.toArray(new Library[1]), javaSources[0], ClassPath.COMPILE); + } catch (IOException ex) { + LOGGER.log(Level.WARNING, "Exception during extending an web project", ex); //NOI18N + } catch (UnsupportedOperationException ex) { + LOGGER.log(Level.WARNING, "Exception during extending an web project", ex); //NOI18N + } + + return Collections.emptySet(); + } + + @Override + public JSFVersion getJsfVersion() { + return JSFVersion.JSF_2_0; + } + + @Override + public boolean isInWebModule(org.netbeans.modules.web.api.webmodule.WebModule webModule) { + ClassPath classpath = ClassPath.getClassPath(webModule.getDocumentBase(), ClassPath.COMPILE); + Set> entrySet = RF_LIBRARIES.entrySet(); + for (Entry entry : entrySet) { + if (classpath.findResource(entry.getKey().replace('.', '/') + ".class") == null) { //NOI18N + return false; + } + } + return true; + } + + @Override + public JsfComponentCustomizer getJsfComponentCustomizer(boolean initialize, WebModule webModule) { + if (customizer == null || initialize) { + customizer = new Richfaces4Customizer(); + } + return customizer; + } + +} diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/RichfacesProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/RichfacesProvider.java Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.web.jsf.richfaces; + +import java.util.Collections; +import java.util.Set; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentProvider; + +/** + * + * @author Martin Fousek + */ +public class RichfacesProvider implements JsfComponentProvider { + + @Override + public Set getJsfComponents() { + JsfComponentImplementation implementation = new Richfaces4Implementation(); + return Collections.singleton(implementation); + } + +} diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/resources/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/resources/layer.xml Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/ui/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/ui/Bundle.properties Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,6 @@ +LBL_MissingRichFaces=No complete RichFaces library found. See list of mandatory JARs. +LBL_MissingDependency=It''s recommended to include into library also {0}. + +Richfaces4CustomizerPanelVisual.newLibraryButton.text=Create Library +Richfaces4CustomizerPanelVisual.richfacesInfoLabel.text=\nRichFaces library has to contain:
  • richfaces-components-api-4.0.0.Final.jar
  • richfaces-components-ui-4.0.0.Final.jar
  • richfaces-core-api-4.0.0.Final.jar
  • richfaces-core-impl-4.0.0.Final.jar
\nRichFaces library should contain:
  • guava.jar (Google Guava)
  • sac.jar (Simple API for CSS)
  • cssparser.jar (CSS Parser)
  • \n
\n +Richfaces4CustomizerPanelVisual.richfacesLibraryLabel.text=Valid RichFaces Library: diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/ui/Richfaces4CustomizerPanelVisual.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/ui/Richfaces4CustomizerPanelVisual.form Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,89 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r 11b2acb8a7e0 web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/ui/Richfaces4CustomizerPanelVisual.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf.richfaces/src/org/netbeans/modules/web/jsf/richfaces/ui/Richfaces4CustomizerPanelVisual.java Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,266 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ + +/* + * Richfaces4CustomizerPanelVisual.java + * + * Created on Jun 22, 2011, 1:25:30 PM + */ +package org.netbeans.modules.web.jsf.richfaces.ui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URL; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.prefs.Preferences; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeListener; +import org.netbeans.api.project.libraries.LibrariesCustomizer; +import org.netbeans.api.project.libraries.Library; +import org.netbeans.api.project.libraries.LibraryManager; +import org.netbeans.modules.j2ee.common.Util; +import org.netbeans.modules.web.jsf.richfaces.Richfaces4Implementation; +import org.netbeans.modules.web.jsf.richfaces.Richfaces4Customizer; +import org.openide.util.ChangeSupport; +import org.openide.util.NbBundle; +import org.openide.util.NbPreferences; +import org.openide.util.RequestProcessor; + +/** + * + * @author Martin Fousek + */ +public final class Richfaces4CustomizerPanelVisual extends javax.swing.JPanel { + + public static final RequestProcessor RP = new RequestProcessor("JSF Component Libraries Updater", 1); + public static final Logger LOGGER = Logger.getLogger(Richfaces4CustomizerPanelVisual.class.getName()); + + private volatile Set richfacesLibraries = new HashSet(); + + private ChangeSupport changeSupport = new ChangeSupport(this); + + /** Creates new form Richfaces4CustomizerPanelVisual */ + public Richfaces4CustomizerPanelVisual(ChangeListener listener) { + initComponents(); + addChangeListener(listener); + + initLibraries(true); + + richfacesComboBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + changeSupport.fireChange(); + } + }); + } + + public void addChangeListener(ChangeListener listener) { + changeSupport.addChangeListener(listener); + } + + public void removeChangeListener(ChangeListener listener) { + changeSupport.removeChangeListener(listener); + } + + public void initLibraries(final boolean firstInit) { + long time = System.currentTimeMillis(); + + final Vector registeredRichfaces = new Vector(); + + RequestProcessor.getDefault().post(new Runnable() { + + @Override + public void run() { + for (Library library : Richfaces4Customizer.getRichfacesLibraries()) { + registeredRichfaces.add(library.getDisplayName()); + richfacesLibraries.add(library); + } + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + setLibrariesComboBox(richfacesComboBox, registeredRichfaces); + + if (firstInit) { + setDefaultComboBoxValues(); + } + changeSupport.fireChange(); + } + }); + } + }); + + LOGGER.log(Level.FINEST, "Time spent in {0} initLibraries = {1} ms", new Object[]{this.getClass().getName(), System.currentTimeMillis() - time}); //NOI18N + } + + private void setDefaultComboBoxValues() { + Preferences preferences = NbPreferences.forModule(Richfaces4Customizer.class).node(Richfaces4Implementation.PREF_RICHFACES_NODE); + richfacesComboBox.setSelectedItem(preferences.get(Richfaces4Implementation.PREF_RICHFACES_LIBRARY, "")); + } + + private void setLibrariesComboBox(JComboBox comboBox, Vector items) { + comboBox.setModel(new DefaultComboBoxModel(items)); + comboBox.setEnabled(!items.isEmpty()); + } + + public String getErrorMessage() { + if (richfacesLibraries == null || richfacesLibraries.isEmpty()) { + return NbBundle.getMessage(Richfaces4CustomizerPanelVisual.class, "LBL_MissingRichFaces"); //NOI18N + } + return null; + } + + public String getWarningMessage() { + if (richfacesLibraries == null || !richfacesLibraries.isEmpty()) { + Library library = LibraryManager.getDefault().getLibrary(getRichFacesLibrary()); + if (library == null) { + return null; + } + + List content = library.getContent("classpath"); //NOI18N + StringBuilder recommendedJars = new StringBuilder(); + if (library != null) { + Set> entrySet = Richfaces4Implementation.RF_DEPENDENCIES.entrySet(); + for (Entry entry : entrySet) { + try { + if (!Util.containsClass(content, entry.getKey())) { + recommendedJars.append(entry.getValue()).append(", "); + } + } catch (IOException ex) { + LOGGER.log(Level.INFO, null, ex); + } + } + if (!"".equals(recommendedJars.toString())) { + return NbBundle.getMessage(Richfaces4CustomizerPanelVisual.class, + "LBL_MissingDependency", recommendedJars .toString().substring(0, + recommendedJars .toString().length() - 2)); //NOI18N + } + } + } + return null; + } + + public String getRichFacesLibrary() { + return (String)richfacesComboBox.getSelectedItem(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + richfacesLibraryLabel = new javax.swing.JLabel(); + richfacesComboBox = new javax.swing.JComboBox(); + newLibraryButton = new javax.swing.JButton(); + richfacesInfoLabel = new javax.swing.JLabel(); + + richfacesLibraryLabel.setText(org.openide.util.NbBundle.getMessage(Richfaces4CustomizerPanelVisual.class, "Richfaces4CustomizerPanelVisual.richfacesLibraryLabel.text")); // NOI18N + + richfacesComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Search RichFaces Libraries..." })); + + newLibraryButton.setText(org.openide.util.NbBundle.getMessage(Richfaces4CustomizerPanelVisual.class, "Richfaces4CustomizerPanelVisual.newLibraryButton.text")); // NOI18N + newLibraryButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + newLibraryButtonActionPerformed(evt); + } + }); + + richfacesInfoLabel.setText(org.openide.util.NbBundle.getMessage(Richfaces4CustomizerPanelVisual.class, "Richfaces4CustomizerPanelVisual.richfacesInfoLabel.text")); // NOI18N + richfacesInfoLabel.setPreferredSize(new java.awt.Dimension(100, 15)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(richfacesLibraryLabel) + .addGap(11, 11, 11) + .addComponent(richfacesComboBox, 0, 395, Short.MAX_VALUE)) + .addComponent(newLibraryButton, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(richfacesInfoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 552, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(richfacesLibraryLabel) + .addComponent(richfacesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(newLibraryButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(richfacesInfoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void newLibraryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newLibraryButtonActionPerformed + LibrariesCustomizer.showCreateNewLibraryCustomizer(LibraryManager.getDefault()); + }//GEN-LAST:event_newLibraryButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton newLibraryButton; + private javax.swing.JComboBox richfacesComboBox; + private javax.swing.JLabel richfacesInfoLabel; + private javax.swing.JLabel richfacesLibraryLabel; + // End of variables declaration//GEN-END:variables + +} diff -r 11b2acb8a7e0 web.jsf/nbproject/project.properties --- a/web.jsf/nbproject/project.properties Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/nbproject/project.properties Mon Jul 25 13:45:41 2011 +0200 @@ -41,7 +41,7 @@ # made subject to such option by the copyright holder. javac.source=1.6 -spec.version.base=1.26.0 +spec.version.base=1.27.0 test.config.stable.includes=\ **/*Test.class diff -r 11b2acb8a7e0 web.jsf/nbproject/project.xml --- a/web.jsf/nbproject/project.xml Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/nbproject/project.xml Mon Jul 25 13:45:41 2011 +0200 @@ -50,6 +50,15 @@ org.netbeans.modules.web.jsf + org.netbeans.api.annotations.common + + + + 1 + 1.10 + + + org.netbeans.api.java.classpath @@ -640,12 +649,12 @@ org.netbeans.modules.visualweb.insync org.netbeans.modules.visualweb.project.jsf + org.netbeans.modules.web.adf.complib org.netbeans.modules.web.jsf.editor org.netbeans.modules.web.jsf.navigation + org.netbeans.modules.web.jsf.richfaces org.netbeans.modules.web.primefaces - org.netbeans.modules.web.adf.complib org.netbeans.modules.web.jsf.api - org.netbeans.modules.web.jsf.api.components org.netbeans.modules.web.jsf.api.editor org.netbeans.modules.web.jsf.api.facesmodel org.netbeans.modules.web.jsf.api.metamodel diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/JSFFrameworkProvider.java --- a/web.jsf/src/org/netbeans/modules/web/jsf/JSFFrameworkProvider.java Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/JSFFrameworkProvider.java Mon Jul 25 13:45:41 2011 +0200 @@ -95,11 +95,11 @@ import org.netbeans.modules.web.spi.webmodule.WebFrameworkProvider; import org.netbeans.modules.web.api.webmodule.WebModule; import org.netbeans.modules.web.jsf.api.facesmodel.Application; -import org.netbeans.modules.web.jsf.api.facesmodel.DefaultRenderKitId; import org.netbeans.modules.web.jsf.api.facesmodel.FacesConfig; import org.netbeans.modules.web.jsf.api.facesmodel.JSFConfigModel; import org.netbeans.modules.web.jsf.api.facesmodel.ViewHandler; import org.netbeans.modules.web.jsf.palette.JSFPaletteUtilities; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation; import org.netbeans.modules.web.project.api.WebPropertyEvaluator; import org.netbeans.modules.web.spi.webmodule.WebModuleExtender; import org.openide.DialogDisplayer; @@ -214,10 +214,6 @@ } } - if (panel.getJsfComponentDescriptor() != null ) { - ProjectClassPathModifier.addLibraries(new Library[]{panel.getJsfComponentDescriptor().getLibrary()}, javaSources[0], ClassPath.COMPILE); - } - boolean isMyFaces; if (jsfLibrary != null) { // find out whether the added library is myfaces jsf implementation @@ -256,7 +252,13 @@ } FileSystem fileSystem = webInf.getFileSystem(); + fileSystem.runAtomicAction(new CreateFacesConfig(webModule, isMyFaces)); + + // extending for JSF component libraries + for (JsfComponentImplementation jsfComponentDescriptor : panel.getEnabledJsfDescriptors()) { + result.addAll(jsfComponentDescriptor.extend(webModule)); + } FileObject welcomeFile = (panel!=null && panel.isEnableFacelets()) ? webModule.getDocumentBase().getFileObject(WELCOME_XHTML): webModule.getDocumentBase().getFileObject(WELCOME_JSF); @@ -319,7 +321,7 @@ preferences.put(PREFERRED_LANGUAGE, "Facelets"); //NOI18N } } - panel = new JSFConfigurationPanel(this, controller, !defaultValue, preferences); + panel = new JSFConfigurationPanel(this, controller, !defaultValue, preferences, webModule); } else { if (webModule!=null && webModule.getDocumentBase() == null) { controller.getProperties().setProperty("NoDocBase", true); //NOI18N @@ -582,10 +584,6 @@ if (!profile.equals(Profile.JAVA_EE_6_FULL) && !profile.equals(Profile.JAVA_EE_6_WEB) && !isJSF20) { createFacesConfig = true; } - if (isJSF20 && panel.getJsfComponentDescriptor() != null) { - if (panel.getJsfComponentDescriptor().getDefaultRenderKitId() != null) - createFacesConfig = true; - } } if (createFacesConfig) { String content = readResource(Thread.currentThread().getContextClassLoader().getResourceAsStream(RESOURCE_FOLDER + facesConfigTemplate), "UTF-8"); //NOI18N @@ -634,27 +632,27 @@ viewHandler.setFullyQualifiedClassType(HANDLER); application.addViewHandler(viewHandler); } - // A component library may require a render kit - if (isJSF20 && panel.getJsfComponentDescriptor() != null) { - String drki = panel.getJsfComponentDescriptor().getDefaultRenderKitId(); - if (drki != null) { - List drkits = application.getDefaultRenderKitIds(); - boolean alreadyDefined = false; - if (drkits != null){ - for (DefaultRenderKitId drkit : drkits) { - if (drki.equals(drkit.getText().trim())){ - alreadyDefined = true; - break; - } - } - } - if (!alreadyDefined){ - DefaultRenderKitId newdrki = model.getFactory().createDefaultRenderKitId(); - newdrki.setText(drki); - application.addDefaultRenderKitId(newdrki); - } - } - } +// // A component library may require a render kit +// if (isJSF20 && panel.getJsfComponentDescriptor() != null) { +// String drki = panel.getJsfComponentDescriptor().getDefaultRenderKitId(); +// if (drki != null) { +// List drkits = application.getDefaultRenderKitIds(); +// boolean alreadyDefined = false; +// if (drkits != null){ +// for (DefaultRenderKitId drkit : drkits) { +// if (drki.equals(drkit.getText().trim())){ +// alreadyDefined = true; +// break; +// } +// } +// } +// if (!alreadyDefined){ +// DefaultRenderKitId newdrki = model.getFactory().createDefaultRenderKitId(); +// newdrki.setText(drki); +// application.addDefaultRenderKitId(newdrki); +// } +// } +// } ClassPath cp = ClassPath.getClassPath(webModule.getDocumentBase(), ClassPath.COMPILE); // FIXME icefaces on server if (panel.getLibrary()!=null && panel.getLibrary().getName().indexOf("facelets-icefaces") != -1 //NOI18N @@ -695,10 +693,6 @@ HashMap params = new HashMap(); if (isJSF20) { params.put("isJSF20", Boolean.TRUE); //NOI18N - if (panel.getJsfComponentDescriptor() != null) { - params.put("welcomeBody", panel.getJsfComponentDescriptor().getWelcomeBody()); //NOI18N - params.put("welcomeInclude", "xmlns:"+panel.getJsfComponentDescriptor().getNsPrefix()+"=\""+panel.getJsfComponentDescriptor().getNamespace()+"\""); //NOI18N - } } JSFPaletteUtilities.expandJSFTemplate(template, params, target); } diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/JSFUtils.java --- a/web.jsf/src/org/netbeans/modules/web/jsf/JSFUtils.java Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/JSFUtils.java Mon Jul 25 13:45:41 2011 +0200 @@ -44,6 +44,7 @@ package org.netbeans.modules.web.jsf; +import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; import java.io.File; import java.io.FileFilter; import java.io.IOException; @@ -60,7 +61,6 @@ import org.netbeans.modules.j2ee.dd.api.web.DDProvider; import org.netbeans.modules.j2ee.dd.api.web.WebApp; import org.netbeans.modules.web.api.webmodule.WebModule; -import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; import org.netbeans.spi.project.libraries.LibraryFactory; import org.netbeans.spi.project.libraries.LibraryImplementation; import org.netbeans.spi.project.libraries.support.LibrariesSupport; diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/api/components/JsfComponentDescriptor.java --- a/web.jsf/src/org/netbeans/modules/web/jsf/api/components/JsfComponentDescriptor.java Mon Jul 25 11:29:28 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2010 Sun Microsystems, Inc. - */ - -package org.netbeans.modules.web.jsf.api.components; - -import org.netbeans.api.project.libraries.Library; -import org.netbeans.api.project.libraries.LibraryManager; -import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; -import org.openide.util.Parameters; - -/** - * - * @author alexey butenko - */ -final public class JsfComponentDescriptor { - private final String name; - private final String libraryName; - private final String description; - private final JSFVersion jsfVersion; - private final String welcomeBody; - private final String namespace; - private final String nsPrefix; - private final String defaultRenderKitId; - - public JsfComponentDescriptor(String libraryName, String name, JSFVersion jsfVersion, String description, String welcomeBody, String namespace, String nsPrefix) { - this (libraryName, name, jsfVersion, description, welcomeBody, namespace, nsPrefix, null); - } - public JsfComponentDescriptor(String libraryName, String name, JSFVersion jsfVersion, - String description, String welcomeBody, String namespace, String nsPrefix, String defaultRenderKitId) { - Parameters.notNull("name", name); // NOI18N - Parameters.notNull("libraryName", libraryName); // NOI18N - this.libraryName = libraryName; - this.name = name; - this.jsfVersion = jsfVersion; - this.description = description; - this.welcomeBody = welcomeBody; - this.namespace = namespace; - this.nsPrefix = nsPrefix; - this.defaultRenderKitId = defaultRenderKitId; - } - - public JSFVersion getJsfVersion() { - return jsfVersion; - } - - @Override - public int hashCode() { - return getLibraryName().hashCode(); - } - - - @Override - public boolean equals(Object obj) { - if (obj instanceof JsfComponentDescriptor) { - JsfComponentDescriptor descriptor = (JsfComponentDescriptor) obj; - if (descriptor.getLibraryName().equals(getLibraryName())) { - return true; - } - } - return false; - } - - public String getName() { - return name; - } - - public String getDescription() { - if (description != null) - return description; - return getName(); - } - - public String getLibraryName() { - return libraryName; - }; - - public Library getLibrary() { - return LibraryManager.getDefault().getLibrary(getLibraryName()); - } - - @Override - public String toString() { - return getName(); - } - - public String getWelcomeBody() { - return welcomeBody; - } - - public String getNamespace() { - return namespace; - } - - public String getNsPrefix() { - return nsPrefix; - } - - /** Returns the value of default-render-kit-id element that should be placed - * in the application element in faces-config.xml. If null is - * returned, no default-render-kit-id element is written. - */ - public String getDefaultRenderKitId() { - return defaultRenderKitId; - } -} diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/api/components/JsfComponents.java --- a/web.jsf/src/org/netbeans/modules/web/jsf/api/components/JsfComponents.java Mon Jul 25 11:29:28 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2010 Sun Microsystems, Inc. - */ - -package org.netbeans.modules.web.jsf.api.components; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.netbeans.modules.web.jsf.spi.components.JsfComponentProvider; -import org.openide.util.lookup.Lookups; - -/** - * - * @author alexey butenko - */ -public final class JsfComponents { - private final static String COMPONENTS_PATH = "j2ee/jsf/components"; //NOI18N - - - public static Set findJsfComponents() { - Collection componentProvider = - Lookups.forPath(COMPONENTS_PATH).lookupAll(JsfComponentProvider.class); - Set result = new HashSet(); - for (JsfComponentProvider provider: componentProvider) { - for(JsfComponentDescriptor descriptor: provider.getComponents()) { - result.add(descriptor); - } - } - return result; - } -} diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/spi/components/JsfComponentCustomizer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/spi/components/JsfComponentCustomizer.java Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,125 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.web.jsf.spi.components; + +import javax.swing.JComponent; +import javax.swing.event.ChangeListener; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; + +/** + * Provides support for extending a JSF framework with a JSF component library. + * It allows to modify the web module to make use of the JSF suite in JSF framework. + * + * @author Martin Fousek + * + * @since 1.27 + */ +public interface JsfComponentCustomizer { + + /** + * Attaches a change listener that is to be notified of changes + * in the customizer (e.g., the result of the {@link #isValid} method + * has changed). + * + * @param listener a listener. + */ + public void addChangeListener(@NonNull ChangeListener listener); + + /** + * Removes a change listener. + * + * @param listener a listener. + */ + public void removeChangeListener(@NonNull ChangeListener listener); + + /** + * Returns a UI component used to allow the user to update this customizer. + * + * @return a component. This method might be called more than once and it is + * expected to always return the same instance. + */ + @NonNull + public JComponent getComponent(); + + /** + * Checks if this customizer is valid (e.g., if the configuration set + * using the UI component returned by {@link #getComponent} is valid). + *

+ * + * @return {@code true} if the configuration is valid, {@code false} otherwise. + * @see #getErrorMessage() + * @see #getWarningMessage() + */ + public boolean isValid(); + + /** + * Get error message or {@code null} if the {@link #getComponent component} is {@link #isValid() valid}. + * + * @return error message or {@code null} if the {@link #getComponent component} is {@link #isValid() valid} + * + * @see #isValid() + * @see #getWarningMessage() + */ + @CheckForNull + public String getErrorMessage(); + + /** + * Get warning message that can be not {@code null} even for {@link #isValid() valid} customizer. + * In other words, it is safe to extend web module even if this method returns a message. + * + * @return warning message or {@code null} + * + * @see #isValid() + * @see #getErrorMessage() + */ + @CheckForNull + public String getWarningMessage(); + + /** + * Allow to save actual configuration of UI component. + *

+ * This method is called after closing component by OK button. + */ + public void saveConfiguration(); + +} diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/spi/components/JsfComponentImplementation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/spi/components/JsfComponentImplementation.java Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,138 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.web.jsf.spi.components; + +import java.util.Set; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; +import org.netbeans.modules.web.api.webmodule.WebModule; +import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; +import org.openide.filesystems.FileObject; + +/** + * This interface allows providing support for JSF component libraries. It can be used + * to extend a web module and JSF framework with a JSF suite, to find out whether a web + * module is already extended by a JSF component library, or to retrieve a JSF suite's + * specific configuration thru the {@link JsfComponentCustomizer}. + * + *

Instances of this class are registered in the {@value + * org.netbeans.modules.web.jsfapi.spi.components.JsfComponentProvider#COMPONENTS_PATH} + * in the module layer, see {@link Registration}.

+ * + * @author Martin Fousek + * @since 1.27 + */ +public interface JsfComponentImplementation { + + /** + * Returns the name of this JSF component library. + * + * @return the name; never {@code null}. + */ + @NonNull + public String getName(); + + /** + * Returns the description of this JSF component library. + * + * @return the description. + */ + @NonNull + public String getDescription(); + + /** + * Called to extend the given web module and JSF framework with the JSF + * component library corresponding to this implementation. + * + * @param webModule the web module to be extended; never null. + * @return the set of newly created files in the web module which should be opened. + */ + @NonNull + public Set extend(@NonNull WebModule webModule); + + /** + * Returns for which version is the JSF component library designated. + *

+ * By creating new project and choosing JSF framework are JSF suites filtered + * out according to their {@link JSFVersion}. + * + * @return {@link JSFVersion} suitable for this JSF component library. + */ + @NonNull + public JSFVersion getJsfVersion(); + + + /** + * Finds out if a given web module has already been extended with this JSF component library. + *

+ * This method should be as fast as possible. + * + * @param webmodule the web module; never {@code null}. + * @return {@code true} if the web module has already been extended with this JSF suite, + * {@code false} otherwise. + */ + public boolean isInWebModule(@NonNull WebModule webModule); + + /** + * Returns a {@link JsfComponentCustomizer} for this JSF component + * library. + *

+ * For new project is called with {@code null} parameter. In project customizer is called for + * given {@link WebModule}. + * + * @param initialize says if the customizer should be initialized to IDE or project defaults + * @param webmodule the web module for which should be customizer adapted; null if the + * project doesn't exist yet + * @return a customizer; can be {@code null} if the JSF suite doesn't + * support that and no extending panel should be offered. + */ + public JsfComponentCustomizer getJsfComponentCustomizer(boolean initialize, @NullAllowed WebModule webModule); + + /** + * Performs actions needed for removal JSF component library form the web module. + * + * @param webModule the web module from which should be JSF component library removed; never null. + */ + public void remove(@NonNull WebModule webModule); + +} diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/spi/components/JsfComponentProvider.java --- a/web.jsf/src/org/netbeans/modules/web/jsf/spi/components/JsfComponentProvider.java Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/spi/components/JsfComponentProvider.java Mon Jul 25 13:45:41 2011 +0200 @@ -1,7 +1,10 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common @@ -13,9 +16,9 @@ * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this * particular file as subject to the "Classpath" exception as provided - * by Sun in the GPL Version 2 section of the License file that + * by Oracle in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: @@ -34,20 +37,38 @@ * * Contributor(s): * - * Portions Copyrighted 2010 Sun Microsystems, Inc. + * Portions Copyrighted 2011 Sun Microsystems, Inc. */ package org.netbeans.modules.web.jsf.spi.components; -import java.util.Set; -import org.netbeans.modules.web.jsf.api.components.JsfComponentDescriptor; +import java.util.Collection; +import org.netbeans.api.annotations.common.NonNull; /** - * - * @author alexeybutenko + * Provides all {@link JsfComponentImplementation}s in given {@link JsfComponentProvider}. + * JSF Support searches in registered {@link JsfComponentProvider}s for all + * {@link JsfComponentImplementation}s to offer them as JSF component libraries. + * + *

+ * Every JSF suite module should contain only one {@link JsfComponentProvider} which + * can return more {@link JsfComponentImplementation}s. + * + * + * @author Martin Fousek + * + * @since 1.27 */ public interface JsfComponentProvider { - public Set getComponents(); + public static final String COMPONENTS_PATH = "j2ee/jsf/components"; //NOI18N + + /** + * Get all registered {@link JsfComponentImplementation}s contained in the module. + * + * @return a set of registered {@link JsfComponentImplementation}s; never null. + */ + @NonNull + public Collection getJsfComponents(); } diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/wizards/Bundle.properties --- a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/Bundle.properties Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/wizards/Bundle.properties Mon Jul 25 13:45:41 2011 +0200 @@ -190,6 +190,8 @@ WARN_MissingTargetServer=The project doesn't have the target server set properly.
It is highly recommended to set it. ERR_NoJSFLibraryFound=No Facelets Libraries Found +LBL_JsfComponentNotValid=JSF library {0} not set up properly. Click more to update its configuration. + ERR_UserTransactionUnavailable=The class javax.transaction.UserTransaction is unavailable. Add an appropriate JAR file in Project Properties > Libraries. ERR_JsfTargetChooser_InvalidJsfFolder=The JSF pages folder name is invalid. ERR_JavaTargetChooser_CantUseDefaultPackage=Provide a package name. @@ -258,7 +260,7 @@ USG_PERSISTENCE_JSF=JSF Pages was created for {0} Entity Classes -LBL_Browse=Browse... +LBL_Browse=More... LBL_Browse_Mnemonic=R ACSD_Browse=Browse directories @@ -310,4 +312,5 @@ LBL_AVAILABLE_Components=Available components: LBL_NONE_Components=Do not include any components libraries LBL_JSF_Components=Components Suite: -LBL_JSF_Components_Desc=Select the JSF component suite to setup for your web application. +LBL_JSF_Components_Desc_New_Project=Select JSF component suites to setup for your web application. +LBL_JSF_Components_Desc_Customizer=JSF component suites included in your web application. diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanel.java --- a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanel.java Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanel.java Mon Jul 25 13:45:41 2011 +0200 @@ -47,6 +47,7 @@ import java.io.File; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.prefs.Preferences; import javax.swing.event.ChangeEvent; @@ -59,8 +60,7 @@ import org.netbeans.modules.web.api.webmodule.ExtenderController; import org.netbeans.modules.web.api.webmodule.WebModule; import org.netbeans.modules.web.jsf.JSFFrameworkProvider; -import org.netbeans.modules.web.jsf.api.components.JsfComponentDescriptor; -import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation; import org.netbeans.modules.web.spi.webmodule.WebModuleExtender; import org.openide.util.HelpCtx; @@ -77,9 +77,7 @@ private static final String PREFERRED_LANGUAGE="jsf.language"; //NOI18N private Preferences preferences; - -// private Library jsfComponentsLibrary; - private JsfComponentDescriptor jsfComponentDescriptor; + private WebModule webModule; public enum LibraryType {USED, NEW, SERVER}; private LibraryType libraryType; @@ -116,11 +114,12 @@ getComponent(); } - public JSFConfigurationPanel(JSFFrameworkProvider framework, ExtenderController controller, boolean customizer, Preferences preferences) { + public JSFConfigurationPanel(JSFFrameworkProvider framework, ExtenderController controller, boolean customizer, Preferences preferences, WebModule webModule) { this.framework = framework; this.controller = controller; this.customizer = customizer; this.preferences = preferences; + this.webModule = webModule; enableFacelets = preferences.get(PREFERRED_LANGUAGE, "JSP").equals(PreferredLanguage.Facelets.getName()); debugFacelets = true; @@ -339,16 +338,17 @@ return serverLibrary; } + public WebModule getWebModule() { + return webModule; + } + protected void setServerLibrary(ServerLibrary library){ this.serverLibrary = library; fireChangeEvent(); } - void setJsfComponentDescriptor(JsfComponentDescriptor jsfComponentDescriptor) { - this.jsfComponentDescriptor = jsfComponentDescriptor; - } - - public JsfComponentDescriptor getJsfComponentDescriptor() { - return jsfComponentDescriptor; + + public List getEnabledJsfDescriptors() { + return component.getActivedJsfDescriptors(); } protected static class PreferredLanguage { diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.form --- a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.form Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.form Mon Jul 25 13:45:41 2011 +0200 @@ -61,7 +61,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -78,16 +78,16 @@ - + - - + + - + @@ -121,7 +121,7 @@ - + @@ -299,7 +299,7 @@ - + @@ -396,17 +396,13 @@ - + - - - - - - + + - + @@ -414,40 +410,40 @@ - - - - - - - + + + + - - - - - - + - - - - - + + - - - - - - - + + + + + + + + + + + + +
+
+
+
+
+
diff -r 11b2acb8a7e0 web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.java --- a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.java Mon Jul 25 11:29:28 2011 +0200 +++ b/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.java Mon Jul 25 13:45:41 2011 +0200 @@ -45,6 +45,10 @@ package org.netbeans.modules.web.jsf.wizards; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.io.File; import java.io.IOException; import java.net.URL; @@ -62,9 +66,20 @@ import java.util.logging.Logger; import java.util.regex.Pattern; import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JFileChooser; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.DocumentListener; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; import org.netbeans.api.j2ee.core.Profile; import org.netbeans.api.project.libraries.Library; import org.netbeans.api.project.libraries.LibraryManager; @@ -78,14 +93,19 @@ import org.netbeans.modules.web.api.webmodule.ExtenderController; import org.netbeans.modules.web.api.webmodule.ExtenderController.Properties; import org.netbeans.modules.web.jsf.JSFUtils; -import org.netbeans.modules.web.jsf.api.components.JsfComponents; -import org.netbeans.modules.web.jsf.api.components.JsfComponentDescriptor; import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentCustomizer; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentProvider; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; import org.openide.WizardDescriptor; import org.openide.util.Exceptions; import org.openide.util.HelpCtx; +import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; +import org.openide.util.lookup.Lookups; /** * @@ -102,7 +122,7 @@ private final List jsfLibraries = new ArrayList(); // private final List componentsLibraries = new ArrayList(); - private final Map> componentsMap = new HashMap>(); + private final Map> componentsMap = new HashMap>(); /** * Do not modify it directly, use setJsfVersion method */ @@ -115,16 +135,34 @@ private String currentServerInstanceID; private final List excludeLibs = Arrays.asList("javaee-web-api-6.0", "javaee-api-6.0", "jsp-compilation"); //NOI18N private boolean isWebLogicServer = false; + + // Jsf component libraries related + private JSFComponentsTableModel jsfComponentsTableModel; + + private static final Lookup.Result jsfComponentProviders = + Lookups.forPath(JsfComponentProvider.COMPONENTS_PATH).lookupResult(JsfComponentProvider.class); + /** Creates new form JSFConfigurationPanelVisual */ public JSFConfigurationPanelVisual(JSFConfigurationPanel panel, boolean customizer) { this.panel = panel; this.customizer = customizer; + this.jsfComponentsTableModel = new JSFComponentsTableModel(customizer); initComponents(); tURLPattern.getDocument().addDocumentListener(this); cbPackageJars.setVisible(false); - cbJsfComponents.setModel(new DefaultComboBoxModel(new ComponentsLibraryItem[]{new ComponentsLibraryItem(null)})); + + // update JSF components list + jsfComponentsTable.setModel(jsfComponentsTableModel); + JsfComponentsTableCellRenderer renderer = new JsfComponentsTableCellRenderer(); + renderer.setBooleanRenderer(jsfComponentsTable.getDefaultRenderer(Boolean.class)); + renderer.setJButtonRenderer(new JTableButtonRenderer()); + jsfComponentsTable.setDefaultRenderer(JsfComponentImplementation.class, renderer); + jsfComponentsTable.setDefaultRenderer(Boolean.class, renderer); + jsfComponentsTable.setDefaultRenderer(JButton.class, renderer); + jsfComponentsTable.addMouseListener(new JTableButtonMouseListener(jsfComponentsTable)); + initJsfComponentTableVisualProperties(jsfComponentsTable); } @Override @@ -205,7 +243,7 @@ updateJsfComponents(); } }); - LOG.finest("Time spent in initLibraries in Runnable = "+(System.currentTimeMillis()-time) +" ms"); //NOI18N + LOG.log(Level.FINEST, "Time spent in initLibraries in Runnable = {0} ms", (System.currentTimeMillis()-time)); //NOI18N } } }; @@ -213,19 +251,25 @@ libsInitialized = true; // repaint(); - LOG.finest("Time spent in "+this.getClass().getName() +" initLibraries = "+(System.currentTimeMillis()-time) +" ms"); //NOI18N + LOG.log(Level.FINEST, "Time spent in {0} initLibraries = {1} ms", new Object[]{this.getClass().getName(), System.currentTimeMillis()-time}); //NOI18N } private void initJsfComponentsLibraries() { if (jsfComponentsInitialized) return; - for (JsfComponentDescriptor components : JsfComponents.findJsfComponents()) { - List list = componentsMap.get(components.getJsfVersion()); + + List jsfComponentDescriptors = new ArrayList(); + for (JsfComponentProvider provider: jsfComponentProviders.allInstances()) { + jsfComponentDescriptors.addAll(provider.getJsfComponents()); + } + + for (JsfComponentImplementation jsfDescriptor : jsfComponentDescriptors) { + List list = componentsMap.get(jsfDescriptor.getJsfVersion()); if (list == null) { - list = new ArrayList(); + list = new ArrayList(); } - list.add(components); - componentsMap.put(components.getJsfVersion(), list); + list.add(jsfDescriptor); + componentsMap.put(jsfDescriptor.getJsfVersion(), list); } jsfComponentsInitialized = true; if (currentJSFVersion !=null) { @@ -473,9 +517,9 @@ cbPreferredLang = new javax.swing.JComboBox(); jLabel1 = new javax.swing.JLabel(); componentsPanel = new javax.swing.JPanel(); - cbJsfComponents = new javax.swing.JComboBox(); - jLabel2 = new javax.swing.JLabel(); - jLabel3 = new javax.swing.JLabel(); + jsfComponentsLabel = new javax.swing.JLabel(); + jsfComponentsScrollPane = new javax.swing.JScrollPane(); + jsfComponentsTable = new javax.swing.JTable(); setLayout(new java.awt.CardLayout()); @@ -571,28 +615,28 @@ .addGroup(libPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(rbNewLibrary, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) + .addComponent(rbNewLibrary, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE) .addGroup(libPanelLayout.createSequentialGroup() .addGap(22, 22, 22) .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cbPackageJars) .addComponent(lVersion) .addComponent(lDirectory)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 202, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 245, Short.MAX_VALUE)) .addGroup(libPanelLayout.createSequentialGroup() .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(rbServerLibrary, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(rbRegisteredLibrary, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(cbLibraries, 0, 292, Short.MAX_VALUE) + .addComponent(cbLibraries, 0, 322, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, libPanelLayout.createSequentialGroup() .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jtNewLibraryName, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE) - .addComponent(jtFolder, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)) + .addComponent(jtNewLibraryName, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE) + .addComponent(jtFolder, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jbBrowse)) - .addComponent(serverLibraries, 0, 292, Short.MAX_VALUE)))) + .addComponent(serverLibraries, 0, 322, Short.MAX_VALUE)))) .addContainerGap()) ); libPanelLayout.setVerticalGroup( @@ -617,7 +661,7 @@ .addComponent(lVersion)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cbPackageJars) - .addContainerGap(28, Short.MAX_VALUE)) + .addContainerGap(22, Short.MAX_VALUE)) ); cbPackageJars.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_PackageJarToWar")); // NOI18N @@ -650,7 +694,7 @@ .addGroup(confPanelLayout.createSequentialGroup() .addComponent(lURLPattern) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(tURLPattern, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)) + .addComponent(tURLPattern, javax.swing.GroupLayout.DEFAULT_SIZE, 326, Short.MAX_VALUE)) .addGroup(confPanelLayout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -675,16 +719,20 @@ jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_TAB_Configuration"), confPanel); // NOI18N - cbJsfComponents.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cbJsfComponentsActionPerformed(evt); + jsfComponentsLabel.setText(getJsfComponentsLabelText()); + + jsfComponentsTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" } - }); - - jLabel2.setLabelFor(cbJsfComponents); - jLabel2.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_JSF_Components")); // NOI18N - - jLabel3.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_JSF_Components_Desc")); // NOI18N + )); + jsfComponentsScrollPane.setViewportView(jsfComponentsTable); javax.swing.GroupLayout componentsPanelLayout = new javax.swing.GroupLayout(componentsPanel); componentsPanel.setLayout(componentsPanelLayout); @@ -693,23 +741,18 @@ .addGroup(componentsPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(componentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(componentsPanelLayout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cbJsfComponents, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jLabel3)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(jsfComponentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE) + .addComponent(jsfComponentsLabel)) + .addContainerGap()) ); componentsPanelLayout.setVerticalGroup( componentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(componentsPanelLayout.createSequentialGroup() .addContainerGap() - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(componentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(cbJsfComponents, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(125, Short.MAX_VALUE)) + .addComponent(jsfComponentsLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jsfComponentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE) + .addContainerGap()) ); jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_TAB_Components"), componentsPanel); // NOI18N @@ -781,25 +824,20 @@ } updatePreferredLanguages(); }//GEN-LAST:event_serverLibrariesActionPerformed - -private void cbJsfComponentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbJsfComponentsActionPerformed - // TODO add your handling code here: - panel.setJsfComponentDescriptor(((ComponentsLibraryItem)cbJsfComponents.getSelectedItem()).getJsfComponentDescriptor()); -}//GEN-LAST:event_cbJsfComponentsActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup buttonGroup1; - private javax.swing.JComboBox cbJsfComponents; private javax.swing.JComboBox cbLibraries; private javax.swing.JCheckBox cbPackageJars; private javax.swing.JComboBox cbPreferredLang; private javax.swing.JPanel componentsPanel; private javax.swing.JPanel confPanel; private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; private javax.swing.JButton jbBrowse; + private javax.swing.JLabel jsfComponentsLabel; + private javax.swing.JScrollPane jsfComponentsScrollPane; + private javax.swing.JTable jsfComponentsTable; private javax.swing.JTabbedPane jsfTabbedPane; private javax.swing.JTextField jtFolder; private javax.swing.JTextField jtNewLibraryName; @@ -900,8 +938,20 @@ } } if (!isServerRegistered(serverInstanceID)) { //NOI18N - controller.getProperties().setProperty(WizardDescriptor.PROP_INFO_MESSAGE, NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ERR_MissingTargetServer")); + controller.getProperties().setProperty(WizardDescriptor.PROP_INFO_MESSAGE, + NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ERR_MissingTargetServer")); //NOI18N } + + // check all enabled JSF component libraries + for (JsfComponentImplementation jsfComponentDescriptor : getActivedJsfDescriptors()) { + if (jsfComponentDescriptor.getJsfComponentCustomizer(false, null) != null && + !jsfComponentDescriptor.getJsfComponentCustomizer(false, null).isValid()) { + controller.getProperties().setProperty(WizardDescriptor.PROP_INFO_MESSAGE, + NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_JsfComponentNotValid", jsfComponentDescriptor.getName())); // NOI18N + return false; + } + } + controller.setErrorMessage(null); return true; } @@ -1087,6 +1137,15 @@ tURLPattern.setText(pattern); } + public List getActivedJsfDescriptors() { + List activatedDescriptors = new ArrayList(); + for (int i = 0; i < jsfComponentsTableModel.getRowCount(); i++) { + if (jsfComponentsTableModel.getItem(i).isSelected()) + activatedDescriptors.add(jsfComponentsTableModel.getItem(i).getJsfComponent()); + } + return activatedDescriptors; + } + public boolean packageJars(){ return cbPackageJars.isSelected(); } @@ -1135,20 +1194,21 @@ updatePreferredLanguages(); } private void updateJsfComponentsModel(JSFVersion version) { - List componentsList = new ArrayList(); - //Add empty default component - componentsList.add(new ComponentsLibraryItem(null)); - List providers = componentsMap.get(version); - if (providers != null) { - for (JsfComponentDescriptor provider : providers) { - componentsList.add(new ComponentsLibraryItem(provider)); + List descriptors = componentsMap.get(version); + jsfComponentsTableModel.removeAllItems(); + if (descriptors != null) { + for (JsfComponentImplementation descriptor : descriptors) { + addFrameworkToModel(descriptor); } } - cbJsfComponents.setModel(new DefaultComboBoxModel(componentsList.toArray(new ComponentsLibraryItem[componentsList.size()]))); + + jsfComponentsTable.setModel(jsfComponentsTableModel); } private void updateJsfComponents() { - panel.setJsfComponentDescriptor(((ComponentsLibraryItem)cbJsfComponents.getSelectedItem()).getJsfComponentDescriptor()); + if (currentJSFVersion != null && customizer) { + initJsfComponentLibraries(currentJSFVersion); + } } private void enableDefinedLibraryComponent(boolean enabled){ @@ -1193,6 +1253,14 @@ return message; } + private String getJsfComponentsLabelText() { + if (!customizer) { + return org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_JSF_Components_Desc_New_Project"); //NOI18N + } else { + return org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_JSF_Components_Desc_Customizer"); //NOI18N + } + } + private static class LibraryItem { private Library library; @@ -1309,30 +1377,288 @@ } } + + private void initJsfComponentLibraries(JSFVersion version) { + List descriptors = componentsMap.get(version); + for (int i = 0; i < descriptors.size(); i++) { + JsfComponentImplementation jsfComponentDescriptor = descriptors.get(i); + if (jsfComponentDescriptor.isInWebModule(panel.getWebModule())) { + jsfComponentsTable.setValueAt(true, i, 0); + } + } + } - private static class ComponentsLibraryItem { - private JsfComponentDescriptor jsfComponentsProvider; - private String defaultName = "None"; + private void initJsfComponentTableVisualProperties(JTable table) { + table.setRowSelectionAllowed(true); + table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + table.setTableHeader(null); + + table.setRowHeight(jsfComponentsTable.getRowHeight() + 4); + table.setIntercellSpacing(new java.awt.Dimension(0, 0)); + // set the color of the table's JViewport + table.getParent().setBackground(table.getBackground()); + table.setShowHorizontalLines(false); + table.setShowVerticalLines(false); + + table.getColumnModel().getColumn(0).setMaxWidth(30); + table.getColumnModel().getColumn(2).setMaxWidth(100); + + if (customizer) { + table.setEnabled(false); + } + } + + private void addFrameworkToModel(JsfComponentImplementation component) { + jsfComponentsTableModel.addItem(new JSFComponentModelItem(component)); + } + + private static void fireJsfDialogUpdate(JsfComponentCustomizer jsfComponentExtender, DialogDescriptor dialogDescriptor) { + if (jsfComponentExtender.getErrorMessage() != null) { + dialogDescriptor.getNotificationLineSupport().setErrorMessage(jsfComponentExtender.getErrorMessage()); + } else if (jsfComponentExtender.getWarningMessage() != null) { + dialogDescriptor.getNotificationLineSupport().setWarningMessage(jsfComponentExtender.getWarningMessage()); + } else { + dialogDescriptor.getNotificationLineSupport().clearMessages(); + } + dialogDescriptor.setValid(jsfComponentExtender.isValid()); + } + + public static class JsfComponentsTableCellRenderer extends DefaultTableCellRenderer { + + private TableCellRenderer jbuttonRenderer; + private TableCellRenderer booleanRenderer; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (value instanceof JsfComponentImplementation) { + JsfComponentImplementation item = (JsfComponentImplementation) value; + Component comp = super.getTableCellRendererComponent(table, item.getName(), isSelected, false, row, column); + if (comp instanceof JComponent) { + ((JComponent)comp).setOpaque(isSelected); + } + return comp; + } else if (value instanceof Boolean && booleanRenderer != null) { + return booleanRenderer.getTableCellRendererComponent(table, value, isSelected, false, row, column); + + } else { + if (value instanceof JButton && jbuttonRenderer != null) { + return jbuttonRenderer.getTableCellRendererComponent(table, value, isSelected, false, row, column); + } + else { + return super.getTableCellRendererComponent(table, value, isSelected, false, row, column); + } + } + } + + public void setBooleanRenderer(TableCellRenderer booleanRenderer) { + this.booleanRenderer = booleanRenderer; + } + + public void setJButtonRenderer(TableCellRenderer jbuttonRenderer) { + this.jbuttonRenderer = jbuttonRenderer; + } + } + + private static class JTableButtonRenderer implements TableCellRenderer { + + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JButton button = (JButton)value; + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(UIManager.getColor("Button.background")); + } + return button; + } + } + + private class JTableButtonMouseListener extends MouseAdapter { + + private final JTable table; - public ComponentsLibraryItem(JsfComponentDescriptor jsfComponentsProvider) { - this.jsfComponentsProvider = jsfComponentsProvider; + public JTableButtonMouseListener(JTable table) { + this.table = table; } - public JsfComponentDescriptor getJsfComponentDescriptor() { - return jsfComponentsProvider; + public void mouseClicked(MouseEvent e) { + int column = table.getColumnModel().getColumnIndexAtX(e.getX()); + int row = e.getY()/table.getRowHeight(); + + if (row < table.getRowCount() && row >= 0 && column < table.getColumnCount() && column >= 0) { + Object value = table.getValueAt(row, column); + if (value instanceof JButton) { + ((JButton)value).doClick(); + } else if (value instanceof Boolean) { + panel.fireChangeEvent(); + } + } + } + } + + /** + * Implements a TableModel. + */ + public static final class JSFComponentsTableModel extends AbstractTableModel { + + private static final Class[] COLUMN_TYPES = new Class[] {Boolean.class, JsfComponentImplementation.class, JButton.class}; + private DefaultListModel model; + private boolean inCustomizer; + + public JSFComponentsTableModel(boolean inCustomizer) { + model = new DefaultListModel(); + this.inCustomizer = inCustomizer; + } + + public int getColumnCount() { + return COLUMN_TYPES.length; + } + + public int getRowCount() { + return model.size(); + } + + public Class getColumnClass(int columnIndex) { + return COLUMN_TYPES[columnIndex]; + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return (columnIndex == 0); + } + + public Object getValueAt(final int row, int column) { + final JSFComponentModelItem item = getItem(row); + switch (column) { + case 0: return item.isSelected(); + case 1: return item.getJsfComponent(); + case 2: + if (item.isClickable()) { + JButton button = new JButton("More..."); + if (!inCustomizer) { + button.addActionListener(new JSFComponentModelActionListener(item.getJsfComponent())); + } + return button; + } else { + return null; + } + } + return ""; + } + + public void setValueAt(Object value, int row, int column) { + JSFComponentModelItem item = getItem(row); + switch (column) { + case 0: item.setSelected((Boolean) value);break; + case 1: item.setJsfComponent((JsfComponentImplementation) value);break; + } + fireTableCellUpdated(row, column); + } + + private JSFComponentModelItem getItem(int index) { + return (JSFComponentModelItem) model.get(index); + } + + public void addItem(JSFComponentModelItem item){ + model.addElement(item); + } + + public void removeAllItems() { + if (!model.isEmpty()) { + model.removeAllElements(); + } + } + } + + private static final class JSFComponentModelActionListener implements ActionListener { + + private JsfComponentImplementation jsfDescriptor; + private JSFComponentWindowChangeListener listener; + + public JSFComponentModelActionListener(JsfComponentImplementation jsfDescriptor) { + this.jsfDescriptor = jsfDescriptor; + listener = new JSFComponentWindowChangeListener(); + } + + @Override + public void actionPerformed(ActionEvent e) { + final JsfComponentCustomizer jsfCustomizer = jsfDescriptor.getJsfComponentCustomizer(true, null); + jsfCustomizer.addChangeListener(listener); + + final DialogDescriptor dialogDescriptor = new DialogDescriptor( + jsfCustomizer.getComponent(), + jsfDescriptor.getName(), true, null); + dialogDescriptor.createNotificationLineSupport(); + + listener.setDialogDescriptor(dialogDescriptor); + listener.setJsfComponentExtender(jsfCustomizer); + + // OK button will save JSF extender configuration + ActionListener buttonsListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(DialogDescriptor.OK_OPTION)) { + jsfCustomizer.saveConfiguration(); + } + } + }; + dialogDescriptor.setButtonListener(buttonsListener); + DialogDisplayer.getDefault().notify(dialogDescriptor); + } + + } + + private static final class JSFComponentWindowChangeListener implements ChangeListener { + + private DialogDescriptor dialogDescriptor; + private JsfComponentCustomizer jsfComponentExtender; + + public void setDialogDescriptor(DialogDescriptor dialogDescriptor) { + this.dialogDescriptor = dialogDescriptor; } - public Library getLibrary() { - return jsfComponentsProvider!= null ? jsfComponentsProvider.getLibrary() : null; - } - - public String getName() { - return jsfComponentsProvider!= null ? jsfComponentsProvider.getName() : defaultName; + public void setJsfComponentExtender(JsfComponentCustomizer jsfComponentExtender) { + this.jsfComponentExtender = jsfComponentExtender; } @Override - public String toString() { - return getName(); + public void stateChanged(ChangeEvent e) { + assert dialogDescriptor != null && jsfComponentExtender != null; + fireJsfDialogUpdate(jsfComponentExtender, dialogDescriptor); + } + + } + + private final class JSFComponentModelItem { + private JsfComponentImplementation component; + private Boolean selected; + + /** Creates a new instance of BeanFormProperty */ + public JSFComponentModelItem(JsfComponentImplementation component) { + this.setJsfComponent(component); + setSelected(Boolean.FALSE); + } + + public JsfComponentImplementation getJsfComponent() { + return component; + } + + public void setJsfComponent(JsfComponentImplementation component) { + this.component = component; + } + + public Boolean isSelected() { + return selected; + } + + public void setSelected(Boolean selected) { + this.selected = selected; + } + + public Boolean isClickable() { + return component.getJsfComponentCustomizer(false, null) != null; } } } diff -r 11b2acb8a7e0 web.primefaces/nbproject/project.xml --- a/web.primefaces/nbproject/project.xml Mon Jul 25 11:29:28 2011 +0200 +++ b/web.primefaces/nbproject/project.xml Mon Jul 25 13:45:41 2011 +0200 @@ -6,12 +6,47 @@ org.netbeans.modules.web.primefaces + org.netbeans.api.java.classpath + + + + 1 + 1.30 + + + + org.netbeans.api.web.webmodule + + + + 1.24 + + + + org.netbeans.modules.java.project + + + + 1 + 1.39 + + + + org.netbeans.modules.project.libraries + + + + 1 + 1.31 + + + org.netbeans.modules.web.jsf 1 - 1.19 + 1.27 @@ -21,11 +56,19 @@ + org.openide.filesystems + + + + 7.48 + + + org.openide.util - 8.7 + 8.16 diff -r 11b2acb8a7e0 web.primefaces/src/org/netbeans/modules/web/primefaces/Primefaces2Implementation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web.primefaces/src/org/netbeans/modules/web/primefaces/Primefaces2Implementation.java Mon Jul 25 13:45:41 2011 +0200 @@ -0,0 +1,123 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.web.primefaces; + +import java.io.IOException; +import java.util.Collections; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.api.java.project.classpath.ProjectClassPathModifier; +import org.netbeans.api.project.libraries.Library; +import org.netbeans.api.project.libraries.LibraryManager; +import org.netbeans.modules.web.api.webmodule.WebModule; +import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentCustomizer; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation; +import org.openide.filesystems.FileObject; +import org.openide.util.NbBundle; + +/** + * + * @author Martin Fousek + */ +public class Primefaces2Implementation implements JsfComponentImplementation { + + private final String name; + private final String description; + + private static final Logger LOGGER = Logger.getLogger(Primefaces2Implementation.class.getName()); + private static final String PRIMEFACES_SPECIFIC_CLASS = "org.primefaces.application.PrimeResource"; //NOI18N + private static final String PRIMEFACES_LIBRARY_NAME = "primefaces"; //NOI18N + + public Primefaces2Implementation() { + this.name = NbBundle.getMessage(PrimefacesProvider.class, "LBL_PrimeFaces"); //NOI18N + this.description = NbBundle.getMessage(PrimefacesProvider.class, "LBL_PrimeFaces_Description"); //NOI18N + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public Set extend(WebModule webModule) { + try { + ProjectClassPathModifier.addLibraries( + new Library[]{ LibraryManager.getDefault().getLibrary(PRIMEFACES_LIBRARY_NAME) }, + webModule.getJavaSources()[0], + ClassPath.COMPILE); + } catch (IOException ex) { + LOGGER.log(Level.WARNING, "Exception during extending an web project", ex); //NOI18N + } catch (UnsupportedOperationException ex) { + LOGGER.log(Level.WARNING, "Exception during extending an web project", ex); //NOI18N + } + return Collections.emptySet(); + } + + @Override + public JSFVersion getJsfVersion() { + return JSFVersion.JSF_2_0; + } + + @Override + public boolean isInWebModule(WebModule webModule) { + ClassPath classpath = ClassPath.getClassPath(webModule.getDocumentBase(), ClassPath.COMPILE); + return classpath.findResource(PRIMEFACES_SPECIFIC_CLASS.replace('.', '/') + ".class") != null; //NOI18N + } + + @Override + public JsfComponentCustomizer getJsfComponentCustomizer(boolean initialize, WebModule webModule) { + return null; + } + + @Override + public void remove(WebModule wm) { + } + +} diff -r 11b2acb8a7e0 web.primefaces/src/org/netbeans/modules/web/primefaces/PrimefacesProvider.java --- a/web.primefaces/src/org/netbeans/modules/web/primefaces/PrimefacesProvider.java Mon Jul 25 11:29:28 2011 +0200 +++ b/web.primefaces/src/org/netbeans/modules/web/primefaces/PrimefacesProvider.java Mon Jul 25 13:45:41 2011 +0200 @@ -43,41 +43,20 @@ import java.util.Collections; import java.util.Set; -import org.netbeans.modules.web.jsf.api.components.JsfComponentDescriptor; -import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; +import org.netbeans.modules.web.jsf.spi.components.JsfComponentImplementation; import org.netbeans.modules.web.jsf.spi.components.JsfComponentProvider; -import org.openide.util.NbBundle; /** * - * @author alexey butenko + * @author Martin Fousek */ public class PrimefacesProvider implements JsfComponentProvider { - private final static String NS_PREFIX = "p"; //NOI18N - private final static String NAMESPACE = "http://primefaces.prime.com.tr/ui"; //NOI18N @Override - public Set getComponents() { - JsfComponentDescriptor descriptor = new JsfComponentDescriptor(NbBundle.getMessage(PrimefacesProvider.class, "LBL_Library_Name"), - NbBundle.getMessage(PrimefacesProvider.class, "LBL_PrimeFaces"), JSFVersion.JSF_2_0, - NbBundle.getMessage(PrimefacesProvider.class, "LBL_PrimeFaces_Description"), getWelcomeMessageBody(), getNamespace(), getNsPrefix()); + public Set getJsfComponents() { + JsfComponentImplementation descriptor = new Primefaces2Implementation(); return Collections.singleton(descriptor); } - private static String getWelcomeMessageBody() { - String body = "<" + NS_PREFIX +":commandButton value=\"Hello from PrimeFaces\" onclick=\"dlg1.show();\" type=\"button\" />" - + "<" + NS_PREFIX +":dialog header=\"PrimeFaces Dialog\" widgetVar=\"dlg1\" width=\"500\">" - + "For more information visit http://primefaces.org." - + ""; - return body; - } - - private static String getNamespace() { - return NAMESPACE; //NOI18N - } - - private static String getNsPrefix() { - return NS_PREFIX; - } } diff -r 11b2acb8a7e0 web.primefaces/src/org/netbeans/modules/web/primefaces/resources/Bundle.properties --- a/web.primefaces/src/org/netbeans/modules/web/primefaces/resources/Bundle.properties Mon Jul 25 11:29:28 2011 +0200 +++ b/web.primefaces/src/org/netbeans/modules/web/primefaces/resources/Bundle.properties Mon Jul 25 13:45:41 2011 +0200 @@ -1,7 +1,7 @@ OpenIDE-Module-Display-Category=Java Web and EE OpenIDE-Module-Name=PrimeFaces OpenIDE-Module-Long-Description=\ - This module bundles PrimeFaces components, that can be used with JavaServer Faces. + This module bundles PrimeFaces JSF suite, that can be used with JavaServer Faces. OpenIDE-Module-Short-Description=PrimeFaces # library display name