[532336] - Add support for JSF 2.3

Submitted by https://github.com/lak-proddev

Change-Id: I24e35e1c0a01940442059309f98a5e403d9e30dd
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/plugin.properties b/jsf/plugins/org.eclipse.jst.jsf.core/plugin.properties
index 82f8082..0cda30e 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/plugin.properties
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/plugin.properties
@@ -29,6 +29,9 @@
 

 JSFv22Project=JavaServer Faces v2.2 Project

 JSFv22PresetDesc=Configures a Dynamic Web application to use JSF v2.2

+

+JSFv23Project=JavaServer Faces v2.3 Project

+JSFv23PresetDesc=Configures a Dynamic Web application to use JSF v2.3

 # ====================================================================

 

 pluginName = Constraints Model

diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/plugin.xml b/jsf/plugins/org.eclipse.jst.jsf.core/plugin.xml
index 954bdfd..f205608 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/plugin.xml
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/plugin.xml
@@ -86,6 +86,13 @@
           </and>

        </constraint>

     </project-facet-version>

+	<project-facet-version facet="jst.jsf" version="2.3">

+	   <constraint>

+	      <and>

+	         <requires facet="jst.web" version="[2.5" />

+	      </and>

+	   </constraint>

+	`</project-facet-version>

 

     <action id="jst.jsf.v11.install" facet="jst.jsf" type="INSTALL" version="1.1">

       	<delegate class="org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDelegate"/>

@@ -143,6 +150,30 @@
           id="jst.jsf.v22.uninstall"

           type="UNINSTALL"

           version="2.2">

+       <config-factory

+             class="org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetUninstallConfig$Factory">

+       </config-factory>

+       <delegate

+             class="org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetUninstallDelegate">

+       </delegate>

+    </action>

+  <action

+        facet="jst.jsf"

+        id="jst.jsf.v23.install"

+        type="INSTALL"

+        version="2.3">

+     <delegate

+           class="org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDelegate">

+     </delegate>

+     <config-factory

+           class="org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider">

+     </config-factory>

+  </action>  

+    <action

+          facet="jst.jsf"

+          id="jst.jsf.v23.uninstall"

+          type="UNINSTALL"

+          version="2.3">

        <config-factory

              class="org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetUninstallConfig$Factory">

        </config-factory>

@@ -245,12 +276,21 @@
            %JSFv22PresetDesc

         </description>

      </static-preset>

+     

+	<static-preset extends="default.configuration" id="preset.jst.jsf.v2_3">

+	   <label>%JSFv23Project</label>

+	   <facet id="jst.java" version="1.8" />

+	   <facet id="jst.web" version="4.0" />

+	   <facet id="jst.jsf" version="2.3" />

+	   <description>%JSFv23PresetDesc</description>

+	</static-preset>

+	

   </extension>

 

   <extension point="org.eclipse.wst.common.project.facet.core.runtimes">

     <supported>

 		<runtime-component any="true"/>

-        	<facet id="jst.jsf" version="1.1,1.2,2.0,2.1,2.2"/> 

+        	<facet id="jst.jsf" version="1.1,1.2,2.0,2.1,2.2,2.3"/> 

     </supported>

   </extension>

     

@@ -557,6 +597,22 @@
   <extension

         point="org.eclipse.jst.common.project.facet.core.downloadableLibraries">

      <import-definitions

+           url="http://www.eclipse.org/webtools/jsf/jsf-library/jsf-2.3-downloadable-libraries.xml">

+        <enablement>

+           <with

+                 variable="requestingProjectFacet">

+              <test

+                    forcePluginActivation="true"

+                    property="org.eclipse.wst.common.project.facet.core.projectFacet"

+                    value="jst.jsf:2.3">

+              </test>

+           </with>

+        </enablement>

+     </import-definitions>

+  </extension>

+  <extension

+        point="org.eclipse.jst.common.project.facet.core.downloadableLibraries">

+     <import-definitions

            url="http://www.eclipse.org/webtools/jsf/jsf-library/jsf-2.2-downloadable-libraries.xml">

         <enablement>

            <with

diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/IJSFCoreConstants.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/IJSFCoreConstants.java
index 6dacd29..1fd0480 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/IJSFCoreConstants.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/IJSFCoreConstants.java
@@ -82,6 +82,15 @@
      */

     public static final String JSF_VERSION_2_2 = FACET_VERSION_2_2;

 

+	/**

+	 * The facet version for a JSF 2.3 project

+	 */

+	public static final String FACET_VERSION_2_3 = "2.3"; //$NON-NLS-1$

+	/**

+	 * The version string for a JSF 2.3 project

+	 */

+	public static final String JSF_VERSION_2_3 = FACET_VERSION_2_3;

+

     /**

      * @param facet

      * @return true if the facet is a jsf facet.

diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/JSFVersion.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/JSFVersion.java
index 54118a9..cf6c3e6 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/JSFVersion.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/JSFVersion.java
@@ -54,7 +54,11 @@
 	/**

 	 * Supports JSF Version 2.2

 	 */

-	V2_2;

+	V2_2,

+	/**

+	 * Supports JSF Version 2.3

+	 */

+	V2_3;

 	

 	// WARNING: you MUST add newer versions to the end; the ordinal value of

 	// of the version is used in compareTo.

@@ -74,6 +78,8 @@
             	return IJSFCoreConstants.JSF_VERSION_2_1;

             case V2_2:

             	return IJSFCoreConstants.JSF_VERSION_2_2;

+            case V2_3:

+            	return IJSFCoreConstants.JSF_VERSION_2_3;

             case UNKNOWN:

                 return "unknown"; //$NON-NLS-1$

             default:

@@ -111,6 +117,10 @@
         {

         	return V2_2;

         }

+        else if (IJSFCoreConstants.JSF_VERSION_2_3.equals(valueAsString))

+        {

+        	return V2_3;

+        }

         else if ("unknown".equals(valueAsString)) //$NON-NLS-1$

         {

             return UNKNOWN;

diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java
index fe7cb58..0200236 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java
@@ -65,6 +65,8 @@
         	return new JSFUtils21(modelProvider);

         case V2_2:

         	return new JSFUtils22(modelProvider);

+        case V2_3:

+        	return new JSFUtils23(modelProvider);

         default:

             throw new IllegalArgumentException("Unknown version: "+version); //$NON-NLS-1$

         }

diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils23.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils23.java
new file mode 100644
index 0000000..cf7b59c
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils23.java
@@ -0,0 +1,58 @@
+package org.eclipse.jst.jsf.core.internal.project.facet;

+

+import java.io.PrintWriter;

+

+import org.eclipse.jst.j2ee.model.IModelProvider;

+import org.eclipse.jst.jsf.core.JSFVersion;

+

+/**

+ * JSF Utils instance for JSF 2.3.

+ * 

+ */

+class JSFUtils23 extends JSFUtils22 {

+

+	/**

+	 * @param modelProvider

+	 */

+	protected JSFUtils23(final IModelProvider modelProvider) {

+		super(JSFVersion.V2_3, modelProvider);

+	}

+

+	/**

+	 * @param jsfVersion

+	 * @param modelProvider

+	 */

+	protected JSFUtils23(final JSFVersion jsfVersion, final IModelProvider modelProvider) {

+		super(jsfVersion, modelProvider);

+		if (jsfVersion.compareTo(JSFVersion.V2_3) < 0) {

+			throw new IllegalArgumentException("JSF Version must be at least 2.3"); //$NON-NLS-1$

+		}

+	}

+

+	@Override

+	public void doVersionSpecificConfigFile(PrintWriter pw) {

+		final String QUOTE = new String(new char[] { '"' });

+		final String schemaVersionString = getVersion().toString().replaceAll("\\.", "_"); //$NON-NLS-1$//$NON-NLS-2$

+		pw.write("<?xml version=" + //$NON-NLS-1$

+				QUOTE + "1.0" + QUOTE + //$NON-NLS-1$

+				" encoding=" + //$NON-NLS-1$

+				QUOTE + "UTF-8" + QUOTE + //$NON-NLS-1$

+				"?>\n"); //$NON-NLS-1$

+		pw.write("<faces-config\n"); //$NON-NLS-1$

+		pw.write("    xmlns=" + //$NON-NLS-1$

+				QUOTE + "http://xmlns.jcp.org/xml/ns/javaee" + QUOTE + //$NON-NLS-1$

+				"\n"); //$NON-NLS-1$

+		pw.write("    xmlns:xsi=" + //$NON-NLS-1$

+				QUOTE + "http://www.w3.org/2001/XMLSchema-instance" + QUOTE + //$NON-NLS-1$

+				"\n"); //$NON-NLS-1$

+		pw.write("    xsi:schemaLocation=" + //$NON-NLS-1$

+				QUOTE

+				+ String.format(

+						"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_%s.xsd", //$NON-NLS-1$

+						schemaVersionString)

+				+ QUOTE + "\n"); //$NON-NLS-1$

+		pw.write("    version=" + //$NON-NLS-1$

+				QUOTE + getVersion().toString() + QUOTE + ">\n\n"); //$NON-NLS-1$

+		pw.write("</faces-config>\n"); //$NON-NLS-1$

+	}

+}

diff --git a/jsf/plugins/org.eclipse.jst.jsf.ui/plugin.xml b/jsf/plugins/org.eclipse.jst.jsf.ui/plugin.xml
index 1e33adc..6048e44 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.ui/plugin.xml
+++ b/jsf/plugins/org.eclipse.jst.jsf.ui/plugin.xml
@@ -74,6 +74,12 @@
               class="org.eclipse.jst.jsf.ui.internal.project.facet.JSFFacetInstallPage">
         </page>
      </wizard-pages>
+     <wizard-pages
+           action="jst.jsf.v23.install">
+        <page
+              class="org.eclipse.jst.jsf.ui.internal.project.facet.JSFFacetInstallPage">
+        </page>
+     </wizard-pages>
   </extension>  
   
   <extension point="org.eclipse.wst.sse.ui.editorConfiguration">