Author: snjeza
Date: 2008-08-01 09:46:18 -0400 (Fri, 01 Aug 2008)
New Revision: 9471
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-beanutils-1.7.0.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-collections-3.2.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-digester-1.8.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-lang-2.1.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-logging-1.0.4.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/jsf-facelets-1.1.14.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-api-1.0.0-SNAPSHOT.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-impl-1.0.0-SNAPSHOT.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-api-3.2.2-20080725.050700-44.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-impl-3.2.2-20080725.050700-44.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/ui.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetUninstallDelegate.java
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF
trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/PortletCoreActivator.java
Log:
JBIDE-2574 Support for JSF portlets
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF 2008-08-01
13:41:55 UTC (rev 9470)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF 2008-08-01
13:46:18 UTC (rev 9471)
@@ -12,8 +12,14 @@
org.eclipse.jst.j2ee,
org.eclipse.jdt.core,
org.jboss.ide.eclipse.as.classpath.core,
+ org.eclipse.jst.j2ee.core,
org.eclipse.jst.j2ee.web,
- org.eclipse.jst.common.frameworks
+ org.eclipse.emf.common,
+ org.eclipse.emf.ecore,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.ui.ide,
+ org.eclipse.jem,
+ org.eclipse.jst.jsf.facesconfig
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.portlet.core,
org.jboss.tools.portlet.core.internal,
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!--
+<!DOCTYPE jboss-app PUBLIC
+ "-//JBoss Portal//DTD JBoss Web Application 2.6//EN"
+ "http://www.jboss.org/portal/dtd/jboss-app_2_6.dtd">
+-->
+
+<!ELEMENT jboss-app (app-name?)>
+
+<!--
+When a web application is deployed, the context path under wich it is deployed
+is taken as application name. The application name value in this descriptor is
+used to override it. When a component references a references a portlet, it needs to
+reference the application too and if the portlet application war file is renammed
+the reference is not valid anymore. Therefore this tag is used to have an application
+name that does not depend upon the context path under which the application is deployed.
+-->
+<!ELEMENT app-name (#PCDATA)>
\ No newline at end of file
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-08-01 13:41:55 UTC
(rev 9470)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-08-01 13:46:18 UTC
(rev 9471)
@@ -82,6 +82,70 @@
id="org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v20"/>
</extension>
+ <extension point="org.eclipse.wst.common.project.facet.core.facets">
+
+ <project-facet id="jboss.jsfportlet">
+ <label>JBoss JSF Portlet</label>
+ <description>
+ Adds support for the JSF Portlet.
+ </description>
+ <default-version version="1.0"/>
+ </project-facet>
+
+ <project-facet-version facet="jboss.jsfportlet"
version="1.0">
+ <constraint>
+ <and>
+ <requires facet="jst.java" version="[5.0"/>
+ <requires facet="jst.web" version="[2.3"/>
+ <requires facet="jboss.portlet" version="[1.0"/>
+ <requires facet="jst.jsf" version="[1.2"/>
+ </and>
+ </constraint>
+ </project-facet-version>
+
+ <action id="jboss.jsfportlet.install"
facet="jboss.jsfportlet" type="INSTALL" version="1.0">
+ <delegate
class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletFacetInstallDelegate"/>
+ <config-factory
class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletFacetInstallDataModelProvider"/>
+ </action>
+
+ <action id="jboss.jsfportlet.uninstall"
facet="jboss.jsfportlet" type="UNINSTALL" version="1.0"
>
+ <delegate
class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletFacetUninstallDelegate"/>
+ </action>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.presets">
+ <static-preset id="preset.jboss.jsfportlet.v20">
+ <label>JBoss JSF Portlet Project v2.0</label>
+ <facet id="jst.java" version="5.0" />
+ <facet id="jst.web" version="2.5"/>
+ <facet id="jst.jsf" version="1.2"/>
+ <facet id="jboss.portlet" version="2.0" />
+ <facet id="jboss.jsfportlet" version="1.0" />
+ <description>JBoss JSF Portlet Project v2.0</description>
+ </static-preset>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.presets">
+ <dynamic-preset id="preset.jboss.jsfportlet.v10">
+ <factory
class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletConfigurationPresetFactory10"/>
+ </dynamic-preset>
+ </extension>
+
+ <extension
point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <supported>
+ <runtime-component any="true"/>
+ <facet id="jboss.jsfportlet" version="1.0"/>
+ </supported>
+ </extension>
+
+ <extension
point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer
class="org.jboss.tools.portlet.core.internal.JSFPortlet10LibrariesContainerInitializer"
+
id="org.jboss.tools.portlet.core.internal.jsfportletlibrarycontainer.v10"/>
+ </extension>
+
<extension point="org.eclipse.wst.xml.core.catalogContributions">
<catalogContribution id="default">
<public
@@ -96,6 +160,11 @@
publicId="-//JBoss Portal//DTD JBoss Portlet 2.6//EN"
uri="dtdsAndSchemas/jboss-portlet_2_6.dtd"
webURL="http://www.jboss.org/portal/dtd/jboss-portlet_2_6.dtd"
/>
+
+ <public
+ publicId="-//JBoss Portal//DTD JBoss Web Application 2.6//EN"
+ uri="dtdsAndSchemas/jboss-app_2_6.dtd"
+
webURL="http://www.jboss.org/portal/dtd/jboss-app_2_6.dtd"
/>
<uri
name="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-beanutils-1.7.0.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-beanutils-1.7.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-collections-3.2.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-collections-3.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-digester-1.8.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-digester-1.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-lang-2.1.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-lang-2.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-logging-1.0.4.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-logging-1.0.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/jsf-facelets-1.1.14.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/jsf-facelets-1.1.14.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-api-1.0.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-api-1.0.0-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-impl-1.0.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-impl-1.0.0-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-api-3.2.2-20080725.050700-44.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-api-3.2.2-20080725.050700-44.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-impl-3.2.2-20080725.050700-44.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-impl-3.2.2-20080725.050700-44.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/ui.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/ui.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,26 @@
+package org.jboss.tools.portlet.core;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface IJBossWebUtil {
+
+ static final Object JSF_SERVLET_CLASS = "javax.faces.webapp.FacesServlet";
+ static final String WEB_INF_FACES_CONFIG_XML = "/WEB-INF/faces-config.xml";
+ static final String JAVAX_FACES_CONFIG_FILES = "javax.faces.CONFIG_FILES";
+
+ void configureContextParam( IProject project,
+ IProgressMonitor monitor,String name, String value,String description);
+
+ void configureFilter(IProject project,
+ IProgressMonitor monitor, String name, String className,String displayName,
+ String description);
+
+ void configureFilterMapping(IProject project,
+ IProgressMonitor monitor, String name, String servletName);
+
+ String findJsfServlet(Object modelObject);
+
+ String getFacesConfig(IProject project,
+ IProgressMonitor monitor);
+}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-08-01
13:41:55 UTC (rev 9470)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -10,8 +10,8 @@
************************************************************************************/
package org.jboss.tools.portlet.core;
-import org.eclipse.core.runtime.IPath;
+
/**
* @author snjeza
*
@@ -21,18 +21,34 @@
static final String PORTLET_FACET_ID="jboss.portlet";
+ static final String JSFPORTLET_FACET_ID="jboss.jsfportlet";
+
static final String CONFIG_PATH = "WEB-INF/portlet.xml";
static final String PORTLET_FACET_VERSION_10 = "1.0";
static final String PORTLET_FACET_VERSION_20 = "2.0";
+
+ static final String JSFPORTLET_FACET_VERSION_10 = "1.0";
static final String PORTLET_CONTAINER_10_ID =
"org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v10";
static final String PORTLET_CONTAINER_20_ID =
"org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v20";
+
+ static final String JSFPORTLET_CONTAINER_10_ID =
"org.jboss.tools.portlet.core.internal.jsfportletlibrarycontainer.v10";
static final String PORTLET_INSTANCES_FILE = "WEB-INF/portlet-instances.xml";
static final String PORTLET_OBJECT_FILE = "WEB-INF/default-object.xml";
+ static final String JBOSS_APP_FILE = "WEB-INF/jboss-app.xml";
+
+ static final String DEPLOY_JARS = "DEPLOY_JARS";
+
+ static final String JSF_SECTION = "jsfSection";
+
+ static final String WEB_INF_LIB = "WEB-INF/lib";
+
+ static final String JBOSS_PORTLET_FILE = "WEB-INF/jboss-portlet.xml";
+
}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,254 @@
+package org.jboss.tools.portlet.core;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jem.java.JavaClass;
+import org.eclipse.jst.j2ee.common.CommonFactory;
+import org.eclipse.jst.j2ee.common.Description;
+import org.eclipse.jst.j2ee.common.ParamValue;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.jst.j2ee.webapplication.ContextParam;
+import org.eclipse.jst.j2ee.webapplication.DispatcherType;
+import org.eclipse.jst.j2ee.webapplication.Filter;
+import org.eclipse.jst.j2ee.webapplication.FilterMapping;
+import org.eclipse.jst.j2ee.webapplication.Servlet;
+import org.eclipse.jst.j2ee.webapplication.WebApp;
+import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+
+public class JBossWebUtil implements IJBossWebUtil {
+
+ public void configureContextParam(IProject project,
+ IProgressMonitor monitor, String name, String value,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // handle context-param settings
+ // if contained this param
+ List list = null;
+ if (webApp.getVersionID() == 23) {
+ // for servlet 2.3
+ list = webApp.getContexts();
+ } else {
+ // for servlet 2.4
+ list = webApp.getContextParams();
+ }
+
+ int index = getContextParamIndexByName(list, name);
+ if (index >= 0) {
+ String ret = query.queryOverwrite("Context-param '" + name +
"'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+
+ // remove old item
+ list.remove(index);
+ }
+
+ if (webApp.getVersionID() == 23) {
+ // create context-param object
+ ContextParam param = WebapplicationFactory.eINSTANCE
+ .createContextParam();
+ param.setParamName(name);
+ param.setParamValue(value);
+ if (description != null)
+ param.setDescription(description);
+
+ param.setWebApp(webApp);
+ } else {
+ // create ParamValue object for servlet 2.4
+ ParamValue param = CommonFactory.eINSTANCE.createParamValue();
+ param.setName(name);
+ param.setValue(value);
+ if (description != null) {
+ Description descriptionObj = CommonFactory.eINSTANCE
+ .createDescription();
+ descriptionObj.setValue(description);
+ param.getDescriptions().add(descriptionObj);
+ param.setDescription(description);
+ }
+
+ // add into list
+ webApp.getContextParams().add(param);
+ }
+
+ }
+
+ private int getContextParamIndexByName(List list, String name) {
+ if (list == null || name == null)
+ return -1;
+ Iterator it = list.iterator();
+ int index = 0;
+ while (it.hasNext()) {
+ // get param object
+ Object paramObj = it.next();
+ // for servlet 2.3
+ if (paramObj instanceof ContextParam) {
+ ContextParam param = (ContextParam) paramObj;
+ if (name.equals(param.getParamName()))
+ return index;
+ }
+ // for servlet 2.4
+ if (paramObj instanceof ParamValue) {
+ ParamValue param = (ParamValue) paramObj;
+ if (name.equals(param.getName()))
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
+ public void configureFilter(IProject project, IProgressMonitor monitor,
+ String name, String className, String displayName,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // handle filter settings
+
+ // if contained this filter
+ Object obj = webApp.getFilterNamed(name);
+ if (obj != null) {
+ String ret = query.queryOverwrite("Filter '" + name +
"'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)
+ || IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+
+ // remove old item
+ webApp.getFilters().remove(obj);
+ }
+
+ // create filter object
+ Filter filter = WebapplicationFactory.eINSTANCE.createFilter();
+ filter.setName(name);
+ filter.setFilterClassName(className);
+ filter.setDescription(description);
+ filter.setDisplayName(displayName);
+ webApp.getFilters().add(filter);
+ }
+
+ public void configureFilterMapping(IProject project,
+ IProgressMonitor monitor, String name, String servletName) {
+ // FIXME check if filter mapping already exists
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // create FilterMapping object
+ FilterMapping mapping = WebapplicationFactory.eINSTANCE
+ .createFilterMapping();
+ // get filter by name
+ Filter filter = webApp.getFilterNamed(name);
+ if (filter != null) {
+ mapping.setFilter(filter);
+ mapping.setServletName(servletName);
+ EList dispatcherTypes = mapping.getDispatcherType();
+ dispatcherTypes.add(DispatcherType.REQUEST_LITERAL);
+ dispatcherTypes.add(DispatcherType.FORWARD_LITERAL);
+ dispatcherTypes.add(DispatcherType.INCLUDE_LITERAL);
+ // get Servlet object
+ Servlet servlet = webApp.getServletNamed(servletName);
+ mapping.setServlet(servlet);
+ // if (uri != null || servlet != null)
+ webApp.getFilterMappings().add(mapping);
+ }
+
+ }
+
+ private Object getFilterMappingByKey(List list, String key) {
+ if (list == null || key == null)
+ return null;
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ // get filter-mapping object
+ FilterMapping filterMapping = (FilterMapping) it.next();
+ if (filterMapping != null) {
+ String name = filterMapping.getFilter().getName();
+ String servletName = filterMapping.getServletName();
+ String uri = filterMapping.getUrlPattern();
+ String curKey = getFilterMappingString(name, servletName, uri);
+ if (key.equals(curKey))
+ return filterMapping;
+ }
+ }
+ return null;
+ }
+
+ private String getFilterMappingString(String name, String servletName,
+ String uri) {
+ return (name != null ? name : "") //$NON-NLS-1$
+ + (servletName != null ? servletName : "") //$NON-NLS-1$
+ + (uri != null ? uri : ""); //$NON-NLS-1$
+ }
+
+ private WebApp getWebApp(IProject project, IProgressMonitor monitor) {
+ if (monitor.isCanceled())
+ return null;
+ if (project == null) {
+ return null;
+ }
+ IModelProvider modelProvider = ModelProviderManager
+ .getModelProvider(project);
+ Object modelObject = modelProvider.getModelObject();
+ if (!(modelObject instanceof WebApp)) {
+ // TODO log
+ return null;
+ }
+ return (WebApp) modelObject;
+ }
+
+ public String findJsfServlet(Object modelObject) {
+ WebApp webApp = (WebApp) modelObject;
+ Iterator it = webApp.getServlets().iterator();
+
+ while (it.hasNext()) {
+ Servlet servlet = (Servlet) it.next();
+ JavaClass servletClass = servlet.getServletClass();
+ if (servletClass != null
+ && servletClass.getInstanceClassName().trim().equals(
+ JSF_SERVLET_CLASS)) {
+ return servlet.getServletName();
+ }
+ }
+ return null;
+ }
+
+ public String getFacesConfig(IProject project,
+ IProgressMonitor monitor) {
+ WebApp webApp = getWebApp(project, monitor);
+ EList contextParams = webApp.getContextParams();
+ for (Iterator iterator = contextParams.iterator(); iterator.hasNext();) {
+ Object paramObj = (Object) iterator.next();
+ if (paramObj instanceof ContextParam) {
+ ContextParam param = (ContextParam) paramObj;
+ if (JAVAX_FACES_CONFIG_FILES.equals(param.getParamName()))
+ return param.getParamValue();
+ }
+ }
+ return WEB_INF_FACES_CONFIG_XML;
+ }
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,268 @@
+package org.jboss.tools.portlet.core;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.jst.javaee.core.Description;
+import org.eclipse.jst.javaee.core.DisplayName;
+import org.eclipse.jst.javaee.core.JavaeeFactory;
+import org.eclipse.jst.javaee.core.ParamValue;
+import org.eclipse.jst.javaee.core.UrlPatternType;
+import org.eclipse.jst.javaee.web.DispatcherType;
+import org.eclipse.jst.javaee.web.Filter;
+import org.eclipse.jst.javaee.web.FilterMapping;
+import org.eclipse.jst.javaee.web.Servlet;
+import org.eclipse.jst.javaee.web.WebApp;
+import org.eclipse.jst.javaee.web.WebFactory;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+
+public class JBossWebUtil25 implements IJBossWebUtil {
+
+ public void configureContextParam(IProject project,
+ IProgressMonitor monitor, String name, String value,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+ List list = webApp.getContextParams();
+ int index = getContextParamIndexByName(list, name);
+ if (index >= 0) {
+ String ret = query.queryOverwrite("Context-param '" + name +
"'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+
+ // remove old item
+ list.remove(index);
+ }
+
+ ParamValue param = JavaeeFactory.eINSTANCE.createParamValue();
+ param.setParamName(name);
+ param.setParamValue(value);
+ if (description != null) {
+ Description descriptionObj = JavaeeFactory.eINSTANCE
+ .createDescription();
+ descriptionObj.setValue(description);
+ param.getDescriptions().add(descriptionObj);
+
+ }
+
+ // add into list
+ webApp.getContextParams().add(param);
+
+ }
+
+ private int getContextParamIndexByName(List list, String name) {
+ if (list == null || name == null)
+ return -1;
+ Iterator it = list.iterator();
+ int index = 0;
+ while (it.hasNext()) {
+ Object paramObj = it.next();
+ if (paramObj instanceof ParamValue) {
+ ParamValue param = (ParamValue) paramObj;
+ if (name.equals(param.getParamName()))
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
+ public void configureFilter(IProject project, IProgressMonitor monitor,
+ String name, String className, String displayName,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // if contained this filter
+ Object obj = getFilterByName(webApp, name);
+ if (obj != null) {
+ String ret = query.queryOverwrite("Filter '" + name +
"'"); //$NON-NLS-1$ //$NON-NLS-2$
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)
+ || IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ // remove old item
+ webApp.getFilters().remove(obj);
+ }
+ // create filter object
+ Filter filter = WebFactory.eINSTANCE.createFilter();
+ filter.setFilterName(name);
+ filter.setFilterClass(className);
+ DisplayName dName = JavaeeFactory.eINSTANCE.createDisplayName();
+ dName.setValue(displayName);
+ filter.getDisplayNames().add(dName);
+ Description descriptionObj = JavaeeFactory.eINSTANCE
+ .createDescription();
+ descriptionObj.setValue(description);
+ webApp.getFilters().add(filter);
+
+ }
+
+ private Object getFilterByName(WebApp webApp, String name) {
+ if (webApp == null || name == null)
+ return null;
+ List filters = webApp.getFilters();
+ for (Iterator iterator = filters.iterator(); iterator.hasNext();) {
+ Filter filter = (Filter) iterator.next();
+ if (filter != null && name.equals(filter.getFilterName()))
+ return filter;
+ }
+
+ return null;
+ }
+
+ public void configureFilterMapping(IProject project,
+ IProgressMonitor monitor, String name, String servletName) {
+ // FIXME check if filter mapping already exists
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // if contained this filter-mapping
+ Object obj = getFilterMappingByKey(webApp.getFilterMappings(), name);
+ if (obj != null) {
+ String ret = query.queryOverwrite("Filter-mapping '" + name +
"'"); //$NON-NLS-1$ //$NON-NLS-2$
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)
+ || IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ // remove old item
+ webApp.getFilterMappings().remove(obj);
+ }
+ // filter name
+ // create FilterMapping object
+ FilterMapping mapping = WebFactory.eINSTANCE.createFilterMapping();
+ // get filter by name
+ Filter filter = (Filter) getFilterByName(webApp, name);
+ if (filter != null) {
+ mapping.setFilterName(filter.getFilterName());
+ mapping.getDispatchers().add(DispatcherType.REQUEST_LITERAL);
+ mapping.getDispatchers().add(DispatcherType.FORWARD_LITERAL);
+ mapping.getDispatchers().add(DispatcherType.INCLUDE_LITERAL);
+ mapping.getServletNames().add(servletName);
+
+ // get Servlet object
+ // Servlet servlet = findServletByName(webApp, servletName);
+ // mapping.setServlet(servlet);
+ // if (servlet != null || uri != null)
+ webApp.getFilterMappings().add(mapping);
+ }
+ }
+
+ private Object getFilterMappingByKey(List list, String key) {
+ if (list == null || key == null)
+ return null;
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ // get filter-mapping object
+ FilterMapping filterMapping = (FilterMapping) it.next();
+ if (filterMapping != null) {
+ String name = filterMapping.getFilterName();
+ List servletNames = filterMapping.getServletNames();
+ for (Iterator iterator = servletNames.iterator(); iterator
+ .hasNext();) {
+ String servletName = (String) iterator.next();
+ List urlPatterns = filterMapping.getUrlPatterns();
+ for (Iterator iterator2 = urlPatterns.iterator(); iterator2
+ .hasNext();) {
+ UrlPatternType urlPattern = (UrlPatternType) iterator2
+ .next();
+ String uri = urlPattern.getValue();
+ String curKey = getFilterMappingString(name,
+ servletName, uri);
+ if (key.equals(curKey))
+ return filterMapping;
+ }
+
+ }
+
+ }
+ }
+ return null;
+ }
+
+ private String getFilterMappingString(String name, String servletName,
+ String uri) {
+ return (name != null ? name : "") //$NON-NLS-1$
+ + (servletName != null ? servletName : "") //$NON-NLS-1$
+ + (uri != null ? uri : ""); //$NON-NLS-1$
+ }
+
+ private Servlet findServletByName(WebApp webApp, String name) {
+ Iterator it = webApp.getServlets().iterator();
+ while (it.hasNext()) {
+ Servlet servlet = (Servlet) it.next();
+ if (servlet.getServletName() != null
+ && servlet.getServletName().trim().equals(name)) {
+ return servlet;
+ }
+ }
+ return null;
+ }
+
+ private WebApp getWebApp(IProject project, IProgressMonitor monitor) {
+ if (monitor.isCanceled())
+ return null;
+ if (project == null) {
+ return null;
+ }
+ IModelProvider modelProvider = ModelProviderManager
+ .getModelProvider(project);
+ Object modelObject = modelProvider.getModelObject();
+ if (!(modelObject instanceof WebApp)) {
+ return null;
+ }
+ WebApp webApp = (WebApp) modelObject;
+ return webApp;
+ }
+
+ public String findJsfServlet(Object modelObject) {
+ WebApp webApp = (WebApp) modelObject;
+ Iterator it = webApp.getServlets().iterator();
+ while (it.hasNext()) {
+ Servlet servlet = (Servlet) it.next();
+ if (servlet.getServletClass() != null
+ && servlet.getServletClass().trim().equals(
+ JSF_SERVLET_CLASS)) {
+ return servlet.getServletName();
+ }
+ }
+ return null;
+ }
+
+ public String getFacesConfig(IProject project, IProgressMonitor monitor) {
+ WebApp webApp = getWebApp(project, monitor);
+ List contextParams = webApp.getContextParams();
+ for (Iterator iterator = contextParams.iterator(); iterator.hasNext();) {
+ Object paramObj = (Object) iterator.next();
+ if (paramObj instanceof ParamValue) {
+ ParamValue param = (ParamValue) paramObj;
+ if (JAVAX_FACES_CONFIG_FILES.equals(param.getParamName()))
+ return param.getParamValue();
+ }
+ }
+ return WEB_INF_FACES_CONFIG_XML;
+ }
+
+}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/PortletCoreActivator.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/PortletCoreActivator.java 2008-08-01
13:41:55 UTC (rev 9470)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/PortletCoreActivator.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -4,7 +4,6 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
@@ -21,6 +20,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.osgi.framework.BundleContext;
@@ -31,10 +31,18 @@
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.portlet.core";
+ public static final String RESOURCES_FOLDER = "resources";
+ public static final String JSFPORTLET_FOLDER = "jsfportlet";
+ public static final IOverwriteQuery OVERWRITE_ALL_QUERY = new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return IOverwriteQuery.ALL;
+ }
+ };
+
// The shared instance
private static PortletCoreActivator plugin;
-
+
/**
* The constructor
*/
@@ -43,7 +51,9 @@
/*
* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -52,7 +62,9 @@
/*
* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -61,7 +73,7 @@
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static PortletCoreActivator getDefault() {
@@ -73,42 +85,50 @@
* @return IModelProvider
*/
public static IModelProvider getModelProvider(IProject webProject) {
- IModelProvider provider = ModelProviderManager.getModelProvider(webProject);
+ IModelProvider provider = ModelProviderManager
+ .getModelProvider(webProject);
Object webAppObj = provider.getModelObject();
- if (webAppObj == null){
+ if (webAppObj == null) {
return null;
- }
+ }
return provider;
}
-
+
public static IStatus getStatus(String message) {
- return new Status(IStatus.ERROR,PLUGIN_ID,message);
-
+ return new Status(IStatus.ERROR, PLUGIN_ID, message);
+
}
- public static void createPortletXml(String versionString,IProject project,
IProgressMonitor monitor) {
+ public static void createPortletXml(String versionString, IProject project,
+ IProgressMonitor monitor) {
IPath portletXmlPath = ComponentCore.createComponent(project)
- .getRootFolder().getUnderlyingFolder().getRawLocation().append(
- new Path(IPortletConstants.CONFIG_PATH));
+ .getRootFolder().getUnderlyingFolder().getRawLocation().append(
+ new Path(IPortletConstants.CONFIG_PATH));
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>");
-
+
if (IPortletConstants.PORTLET_FACET_VERSION_20.equals(versionString)) {
- buffer.append("<portlet-app
xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\"...);
+ buffer
+ .append("<portlet-app
xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\"...);
buffer.append("\n\t");
-
buffer.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-ins...
");
- buffer.append("\n\t");
-
buffer.append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\" ");
- buffer.append("\n\t");
- buffer.append("version=\"2.0\">");
+ buffer
+ .append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
");
+ buffer.append("\n\t");
+ buffer
+ .append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\" ");
+ buffer.append("\n\t");
+ buffer.append("version=\"2.0\">");
} else {
- buffer.append("<portlet-app
xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"...);
+ buffer
+ .append("<portlet-app
xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"...);
buffer.append("\n\t");
-
buffer.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-ins...;
- buffer.append("\n\t");
-
buffer.append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/...
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"");
- buffer.append("\n\t");
- buffer.append("version=\"1.0\">");
+ buffer
+ .append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
+ buffer.append("\n\t");
+ buffer
+ .append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"");
+ buffer.append("\n\t");
+ buffer.append("version=\"1.0\">");
}
buffer.append("\n\n");
buffer.append("</portlet-app>");
@@ -133,44 +153,85 @@
}
}
}
-
+
}
public static void log(Exception e, String message) {
- IStatus status = new Status(IStatus.ERROR,PLUGIN_ID,message,e);
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
PortletCoreActivator.getDefault().getLog().log(status);
}
-
+
public static void log(Throwable e) {
- IStatus status = new Status(IStatus.ERROR,PLUGIN_ID,e.getLocalizedMessage(),e);
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e
+ .getLocalizedMessage(), e);
PortletCoreActivator.getDefault().getLog().log(status);
}
- public static void createPortletInstances(IProject project, IFile file) throws
CoreException, UnsupportedEncodingException {
-
+ public static void createPortletInstances(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>");
buffer.append("<!DOCTYPE deployments PUBLIC \n");
- buffer.append("\"-//JBoss Portal//DTD Portlet Instances
2.6//EN\"\n");
-
buffer.append("\"http://www.jboss.org/portal/dtd/portlet-instan...;
- buffer.append("<deployments>");
- buffer.append("</deployments>");
-
- ByteArrayInputStream source = new
ByteArrayInputStream(buffer.toString().getBytes("UTF8"));
- file.create(source, true, new NullProgressMonitor());
+ buffer.append("\"-//JBoss Portal//DTD Portlet Instances
2.6//EN\"\n");
+ buffer
+ .append("\"http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd\">");
+ buffer.append("<deployments>");
+ buffer.append("</deployments>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
}
-
-public static void createPortletObject(IProject project, IFile file) throws
CoreException, UnsupportedEncodingException {
-
+
+ public static void createPortletObject(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>");
buffer.append("<!DOCTYPE deployments PUBLIC \n");
- buffer.append("\"-//JBoss Portal//DTD Portal Object
2.6//EN\"\n");
-
buffer.append("\"http://www.jboss.org/portal/dtd/portal-object_...;
- buffer.append("<deployments>");
- buffer.append("</deployments>");
-
- ByteArrayInputStream source = new
ByteArrayInputStream(buffer.toString().getBytes("UTF8"));
- file.create(source, true, new NullProgressMonitor());
+ buffer.append("\"-//JBoss Portal//DTD Portal Object 2.6//EN\"\n");
+ buffer
+ .append("\"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd\">");
+ buffer.append("<deployments>");
+ buffer.append("</deployments>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
}
+
+ public static void createJBossApp(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>");
+ buffer.append("<!DOCTYPE jboss-app PUBLIC \n");
+ buffer.append("\"-//JBoss Portal//DTD JBoss Web Application
2.6//EN\"\n");
+
buffer.append("\"http://www.jboss.org/portal/dtd/jboss-app_2_6....;
+ buffer.append("<jboss-app>");
+ buffer.append("</jboss-app>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
+ }
+
+ public static void createJBossPortlet(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>");
+ buffer.append("<!DOCTYPE portlet-app PUBLIC \n");
+ buffer
+ .append("\"-//JBoss Portal//DTD JBoss Portlet 2.6//EN\"\n");
+
buffer.append("\"http://www.jboss.org/portal/dtd/jboss-portlet_...;
+ buffer.append("<portlet-app>");
+ buffer.append("</portlet-app>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
+ }
+
}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,126 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer;
+import
org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainerInitializer;
+import org.jboss.ide.eclipse.as.classpath.core.xpl.ClasspathDecorations;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortlet10LibrariesContainerInitializer extends
+ AbstractClasspathContainerInitializer {
+
+ public String getDescription(IPath containerPath, IJavaProject project) {
+ return "JBoss JSF Portlet Classpath Container Initializer v1.0";
+ }
+
+ @Override
+ protected AbstractClasspathContainer createClasspathContainer(IPath path) {
+ return new JSFPortlet10ClasspathContainer(path);
+ }
+
+ @Override
+ protected String getClasspathContainerID() {
+ return IPortletConstants.JSFPORTLET_CONTAINER_10_ID;
+ }
+
+ private class JSFPortlet10ClasspathContainer extends AbstractClasspathContainer {
+
+ public final static String SUFFIX =
PortletCoreActivator.JSFPORTLET_FOLDER;//$NON-NLS-1$
+ public final static String PREFIX = "org.jboss.tools.portlet.core";
+ public final static String DESCRIPTION = "JBoss JSF Portlet Libraries v1.0";
+
+ public JSFPortlet10ClasspathContainer(IPath path) {
+ super(path, DESCRIPTION, SUFFIX);
+ }
+
+ @Override
+ protected String getBaseDir() {
+ try {
+ URL installURL = FileLocator.toFileURL(PortletCoreActivator
+ .getDefault().getBundle().getEntry("/"));
+ return installURL.getFile().toString();
+ } catch (IOException e) {
+ PortletCoreActivator
+ .log(e, "Error loading classpath container");
+ }
+ return null;
+ }
+
+ @Override
+ protected IClasspathEntry[] computeEntries() {
+ ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+
+ String baseDir = getBaseDir();
+ if (baseDir == null)
+ return new IClasspathEntry[0];
+
+ File libDir = new File(baseDir
+ + "/" + PortletCoreActivator.RESOURCES_FOLDER + "/" +
PortletCoreActivator.JSFPORTLET_FOLDER);//$NON-NLS-1$ //$NON-NLS-2$
+
+ File[] jars = libDir.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return (file.toString().endsWith(".jar"));//$NON-NLS-1$
+ }
+ });
+
+ if (jars != null) {
+ for (int i = 0; i < jars.length; i++) {
+ File jarFile = jars[i];
+
+ IPath entryPath = new Path(jarFile.toString());
+
+ IPath sourceAttachementPath = null;
+ IPath sourceAttachementRootPath = null;
+
+ final ClasspathDecorations dec = decorations
+ .getDecorations(getDecorationManagerKey(getPath()
+ .toString()), entryPath.toString());
+
+ IClasspathAttribute[] attrs = {};
+ if (dec != null) {
+ sourceAttachementPath = dec.getSourceAttachmentPath();
+ sourceAttachementRootPath = dec
+ .getSourceAttachmentRootPath();
+ attrs = dec.getExtraAttributes();
+ }
+
+ IAccessRule[] access = {};
+ IClasspathEntry entry = JavaCore.newLibraryEntry(entryPath,
+ sourceAttachementPath, sourceAttachementRootPath,
+ access, attrs, false);
+ entries.add(entry);
+ }
+ }
+
+ return entries.toArray(new IClasspathEntry[entries.size()]);
+ }
+ }
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * Copyright (c) 2008 BEA Systems, Inc. and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik
+ ******************************************************************************/
+
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jst.common.project.facet.JavaFacetUtils;
+import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
+import org.eclipse.wst.common.project.facet.core.IDynamicPreset;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
+import org.eclipse.wst.common.project.facet.core.IPresetFactory;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.PresetDefinition;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.portlet.core.IPortletConstants;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin
Komissarchik</a>
+ * @author snjeza
+ */
+
+public final class JSFPortletConfigurationPresetFactory10
+
+implements IPresetFactory {
+ public PresetDefinition createPreset(final String presetId,
+ final Map<String, Object> context)
+
+ throws CoreException {
+ final IFacetedProjectBase fproj = (IFacetedProjectBase) context
+ .get(IDynamicPreset.CONTEXT_KEY_FACETED_PROJECT);
+ final IProjectFacetVersion webFacetVersion = fproj
+ .getProjectFacetVersion(WebFacetUtils.WEB_FACET);
+ final IProjectFacet PORTLET_FACET =
ProjectFacetsManager.getProjectFacet(IPortletConstants.PORTLET_FACET_ID);
+ final IProjectFacetVersion portletFacetVersion =
PORTLET_FACET.getVersion(IPortletConstants.PORTLET_FACET_VERSION_10);
+ final IProjectFacet JSF_FACET =
ProjectFacetsManager.getProjectFacet("jst.jsf");
+ final IProjectFacetVersion jsfFacetVersion = JSF_FACET.getVersion("1.2");
+ if (webFacetVersion != null
+ && webFacetVersion.compareTo(WebFacetUtils.WEB_23) >= 0 &&
+ portletFacetVersion != null) {
+ final Set<IProjectFacetVersion> facets = new
HashSet<IProjectFacetVersion>();
+ final IProjectFacet jsfPortletFacet = ProjectFacetsManager
+ .getProjectFacet(IPortletConstants.JSFPORTLET_FACET_ID);
+ final IProjectFacetVersion jsfPortletVersion = jsfPortletFacet
+ .getVersion(IPortletConstants.JSFPORTLET_FACET_VERSION_10);
+ facets.add(jsfPortletVersion);
+ facets.add(webFacetVersion);
+ facets.add(JavaFacetUtils.JAVA_50);
+ facets.add(portletFacetVersion);
+ facets.add(jsfFacetVersion);
+ return new PresetDefinition("JBoss JSF Portlet Project v1.0",
+ "JBoss JSF Portlet Project v1.0", facets);
+ }
+ return null;
+ }
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,42 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.util.Set;
+
+import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
+import org.jboss.tools.portlet.core.IPortletConstants;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortletFacetInstallDataModelProvider extends
+ FacetInstallDataModelProvider implements IPortletConstants {
+
+ @Override
+ public Object getDefaultProperty(String propertyName) {
+ if(propertyName.equals(FACET_ID)){
+ return IPortletConstants.JSFPORTLET_FACET_ID;
+ }
+ if (propertyName.equals(IPortletConstants.DEPLOY_JARS)) {
+ return Boolean.TRUE;
+ }
+ return super.getDefaultProperty(propertyName);
+ }
+
+ @Override
+ public Set<String> getPropertyNames() {
+ Set<String> propertyNames = super.getPropertyNames();
+ propertyNames.add(IPortletConstants.DEPLOY_JARS);
+ return propertyNames;
+ }
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,326 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.javaee.web.WebApp;
+import org.eclipse.jst.javaee.web.WebAppVersionType;
+import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
+import org.eclipse.jst.jsf.facesconfig.emf.StateManagerType;
+import org.eclipse.jst.jsf.facesconfig.emf.ViewHandlerType;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.portlet.core.IJBossWebUtil;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.JBossWebUtil;
+import org.jboss.tools.portlet.core.JBossWebUtil25;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortletFacetInstallDelegate implements IDelegate {
+
+ private static final String ORG_JBOSS_PORTLET_STATE_MANAGER =
"org.jboss.portletbridge.application.PortletStateManager";
+ private static final String ORG_JBOSS_PORTLET_VIEW_HANDLER =
"org.jboss.portletbridge.application.PortletViewHandler";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse
+ * .core.resources.IProject,
+ * org.eclipse.wst.common.project.facet.core.IProjectFacetVersion,
+ * java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(final IProject project, final IProjectFacetVersion fv,
+ final Object cfg, final IProgressMonitor monitor)
+ throws CoreException {
+
+ if (monitor != null) {
+ monitor.beginTask("", 1);
+ }
+ try {
+ IDataModel config = null;
+
+ if (cfg != null) {
+ config = (IDataModel) cfg;
+ } else {
+ throw new CoreException(
+ PortletCoreActivator
+ .getStatus("Internal Error creating JBoss JSF Portlet Facet. Missing
configuration."));
+ }
+
+ // check whether web.xml is available for update
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ if (provider == null) {
+ throw new CoreException(
+ PortletCoreActivator
+ .getStatus("Cannot configure web module for JBoss JSF Portlet
Facet"));
+ } else if (!(provider.validateEdit(null, null).isOK())) {
+ if (!(provider.validateEdit(null, null).isOK())) {
+ throw new CoreException(PortletCoreActivator
+ .getStatus("The web.xml file is not updateable"));
+ }
+ }
+
+ configureFacesConfig(project, monitor, config);
+
+ configureClassPath(project, monitor, config);
+
+ configureWebApp(project, monitor, config);
+
+ if (monitor != null) {
+ monitor.worked(1);
+ }
+
+ } finally {
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
+ }
+
+ private void configureFacesConfig(IProject project,
+ IProgressMonitor monitor, IDataModel config) {
+
+ String facesConfigString = getFacesConfigFile(project, monitor);
+ FacesConfigArtifactEdit facesConfigEdit = null;
+ try {
+ facesConfigEdit = FacesConfigArtifactEdit
+ .getFacesConfigArtifactEditForWrite(project,
+ facesConfigString);
+ FacesConfigType facesConfig = facesConfigEdit.getFacesConfig();
+ EList applications = facesConfig.getApplication();
+ ApplicationType applicationType = null;
+ boolean applicationExists = false;
+ if (applications.size() <= 0) {
+ applicationType = FacesConfigFactory.eINSTANCE
+ .createApplicationType();
+ } else {
+ applicationType = (ApplicationType) applications.get(0);
+ applicationExists = true;
+ }
+ boolean viewHandlerExists = false;
+ for (Iterator iterator = applications.iterator(); iterator
+ .hasNext();) {
+ ApplicationType application = (ApplicationType) iterator.next();
+ EList viewHandlers = applicationType.getViewHandler();
+ for (Iterator iterator2 = viewHandlers.iterator(); iterator2
+ .hasNext();) {
+ ViewHandlerType viewHandler = (ViewHandlerType) iterator2
+ .next();
+ if (ORG_JBOSS_PORTLET_VIEW_HANDLER.equals(viewHandler
+ .getTextContent())) {
+ viewHandlerExists = true;
+ }
+ }
+ }
+ if (!viewHandlerExists) {
+ ViewHandlerType viewHandler = FacesConfigFactory.eINSTANCE
+ .createViewHandlerType();
+ viewHandler.setTextContent(ORG_JBOSS_PORTLET_VIEW_HANDLER);
+ applicationType.getViewHandler().add(viewHandler);
+ }
+ boolean stateManagerExists = false;
+ for (Iterator iterator = applications.iterator(); iterator
+ .hasNext();) {
+ ApplicationType application = (ApplicationType) iterator.next();
+ EList stateManagers = applicationType.getStateManager();
+ for (Iterator iterator2 = stateManagers.iterator(); iterator2
+ .hasNext();) {
+ StateManagerType stateManager = (StateManagerType) iterator2
+ .next();
+ if (ORG_JBOSS_PORTLET_STATE_MANAGER.equals(stateManager
+ .getTextContent())) {
+ stateManagerExists = true;
+ }
+ }
+ }
+ if (!stateManagerExists) {
+ StateManagerType stateManager = FacesConfigFactory.eINSTANCE
+ .createStateManagerType();
+ stateManager.setTextContent(ORG_JBOSS_PORTLET_STATE_MANAGER);
+ applicationType.getStateManager().add(stateManager);
+ }
+ if (!applicationExists) {
+ facesConfig.getApplication().add(applicationType);
+ }
+ facesConfigEdit.save(monitor);
+
+ } finally {
+ if (facesConfigEdit != null) {
+ facesConfigEdit.dispose();
+ }
+ }
+ }
+
+ private String getFacesConfigFile(IProject project, IProgressMonitor monitor) {
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ if (isWebApp25(provider.getModelObject())) {
+ return new JBossWebUtil25().getFacesConfig(project, monitor);
+ }
+ return new JBossWebUtil().getFacesConfig(project, monitor);
+ }
+
+ private void configureWebApp(final IProject project,
+ final IProgressMonitor monitor, IDataModel config) {
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ IPath modelPath = new Path("WEB-INF").append("web.xml");
//$NON-NLS-1$ //$NON-NLS-2$
+ boolean exists = project.getProjectRelativePath().append(modelPath)
+ .toFile().exists();
+ if (isWebApp25(provider.getModelObject()) && !exists) {
+ modelPath = IModelProvider.FORCESAVE;
+ }
+ provider.modify(new Runnable() {
+ public void run() {
+ IJBossWebUtil util = null;
+
+ if (isWebApp25(provider.getModelObject())) {
+ util = new JBossWebUtil25();
+ } else {
+ util = new JBossWebUtil();
+ }
+ String name = "org.ajax4jsf.VIEW_HANDLERS";
+ String value =
"org.jboss.portletbridge.application.FaceletPortletViewHandler";
+ String description = null;
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ name = "javax.portlet.faces.renderPolicy";
+ value = "ALWAYS_DELEGATE";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ // RichFaces settings
+
+ name = "org.richfaces.LoadStyleStrategy";
+ value = "NONE";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ name = "org.richfaces.LoadScriptStrategy";
+ value = "NONE";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ name = "org.ajax4jsf.RESOURCE_URI_PREFIX";
+ value = "rfRes";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ String displayName = "Ajax4jsf Filter";
+ String filterName = "ajax4jsf";
+ String className = "org.ajax4jsf.Filter";
+ util.configureFilter(project, monitor, filterName, className,
+ displayName, description);
+
+ String servletName = util.findJsfServlet(provider
+ .getModelObject());
+ if (servletName == null) {
+ RuntimeException e = new RuntimeException(
+ "Cannot find the JSF servlet");
+ PortletCoreActivator.log(e);
+ throw e;
+ }
+ util.configureFilterMapping(project, monitor, filterName,
+ servletName);
+
+ // FIXME add Seam settings
+ }
+ }, modelPath);
+ }
+
+ private void configureClassPath(final IProject project,
+ final IProgressMonitor monitor, IDataModel config)
+ throws JavaModelException {
+ IJavaProject javaProject = JavaCore.create(project);
+
+ boolean deployJars = config
+ .getBooleanProperty(IPortletConstants.DEPLOY_JARS);
+ if (deployJars) {
+ try {
+ URL installURL = FileLocator.toFileURL(PortletCoreActivator
+ .getDefault().getBundle().getEntry("/"));
+ String baseDir = installURL.getFile().toString();
+ File libDir = new File(baseDir + "/"
+ + PortletCoreActivator.RESOURCES_FOLDER + "/"
+ + PortletCoreActivator.JSFPORTLET_FOLDER);
+ List<File> filesToImport = Arrays.asList(libDir.listFiles());
+ IVirtualComponent component = ComponentCore
+ .createComponent(project);
+ IVirtualFile libVirtualFile = component.getRootFolder()
+ .getFile(IPortletConstants.WEB_INF_LIB);
+
+ IFile folder = libVirtualFile.getUnderlyingFile();
+
+ ImportOperation importOperation = new ImportOperation(folder
+ .getFullPath(), libDir,
+ FileSystemStructureProvider.INSTANCE,
+ PortletCoreActivator.OVERWRITE_ALL_QUERY, filesToImport);
+ importOperation.setCreateContainerStructure(false);
+ importOperation.run(monitor);
+ } catch (Exception e) {
+ PortletCoreActivator
+ .log(e, "Error loading classpath container");
+ }
+ } else {
+ IPath containerPath = new Path(
+ IPortletConstants.JSFPORTLET_CONTAINER_10_ID);
+
+ IClasspathEntry entry = JavaCore.newContainerEntry(containerPath,
+ true);
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
+ System.arraycopy(entries, 0, newEntries, 0, entries.length);
+ newEntries[entries.length] = entry;
+ javaProject.setRawClasspath(newEntries, monitor);
+ }
+ }
+
+ private boolean isWebApp25(final Object webApp) {
+ if (webApp instanceof WebApp
+ && ((WebApp) webApp).getVersion() == WebAppVersionType._25_LITERAL)
+ return true;
+ return false;
+ }
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetUninstallDelegate.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetUninstallDelegate.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetUninstallDelegate.java 2008-08-01
13:46:18 UTC (rev 9471)
@@ -0,0 +1,34 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortletFacetUninstallDelegate implements IDelegate {
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject,
org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object,
org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+}