Author: akazakov
Date: 2008-10-15 16:25:43 -0400 (Wed, 15 Oct 2008)
New Revision: 10864
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2731
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-10-15 19:42:20
UTC (rev 10863)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-10-15 20:25:43
UTC (rev 10864)
@@ -47,7 +47,8 @@
org.eclipse.wst.sse.ui,
org.eclipse.jst.jsf.common,
org.eclipse.emf.ecore,
- org.eclipse.jst.j2ee.core
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.jsf.facesconfig;bundle-version="1.1.0"
Provide-Package: org.jboss.tools.seam.core,
org.jboss.tools.seam.internal.core,
org.jboss.tools.seam.internal.core.scanner,
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java 2008-10-15
19:42:20 UTC (rev 10863)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java 2008-10-15
20:25:43 UTC (rev 10864)
@@ -11,12 +11,25 @@
package org.jboss.tools.seam.internal.core.project.facet;
import java.io.File;
+import java.util.Iterator;
+import org.apache.tools.ant.types.FilterSet;
+import org.apache.tools.ant.types.FilterSetCollection;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.jst.javaee.web.WebApp;
+import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
+import org.eclipse.jst.jsf.facesconfig.emf.DefaultLocaleType;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
+import org.eclipse.jst.jsf.facesconfig.emf.LocaleConfigType;
+import org.eclipse.jst.jsf.facesconfig.emf.SupportedLocaleType;
+import org.eclipse.jst.jsf.facesconfig.emf.ViewHandlerType;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -82,7 +95,19 @@
@Override
protected void doExecuteForEjb(final IProject project, IProjectFacetVersion fv,
IDataModel model, IProgressMonitor monitor) throws CoreException {
- // TODO
+ FilterSet jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
+ FilterSet projectFilterSet = SeamFacetFilterSetFactory.createProjectFilterSet(model);
+ ejbViewFilterSetCollection = new FilterSetCollection();
+ ejbViewFilterSetCollection.addFilterSet(jdbcFilterSet);
+ ejbViewFilterSetCollection.addFilterSet(projectFilterSet);
+
+ super.doExecuteForEjb(project, fv, model, monitor);
+
+ IResource src = getSrcFolder(project);
+ if(src!=null) {
+ File srcFile = src.getLocation().toFile();
+ AntCopyUtils.copyFileToFolder(new File(seamGenResFolder, "security.drl"),
srcFile, false); //$NON-NLS-1$
+ }
}
/*
@@ -110,6 +135,84 @@
/*
* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#configureFacesConfigXml(org.eclipse.core.resources.IProject,
org.eclipse.core.runtime.IProgressMonitor, java.lang.String)
+ */
+ @Override
+ protected void configureFacesConfigXml(final IProject project, IProgressMonitor monitor,
String webConfigName) {
+ FacesConfigArtifactEdit facesConfigEdit = null;
+ try {
+ facesConfigEdit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(project,
webConfigName);
+ 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 localeConfigExists = false;
+ for (Iterator iterator = applications.iterator(); iterator.hasNext();) {
+ ApplicationType application = (ApplicationType) iterator.next();
+ EList localeConfigs = application.getLocaleConfig();
+ if(localeConfigs.size()>0) {
+ localeConfigExists = true;
+ break;
+ }
+ }
+ if (!localeConfigExists) {
+ LocaleConfigType locale = FacesConfigFactory.eINSTANCE.createLocaleConfigType();
+ DefaultLocaleType defaultLocale =
FacesConfigFactory.eINSTANCE.createDefaultLocaleType();
+ defaultLocale.setTextContent("en");
+ locale.setDefaultLocale(defaultLocale);
+ SupportedLocaleType supportedLocale =
FacesConfigFactory.eINSTANCE.createSupportedLocaleType();
+ supportedLocale.setTextContent("bg");
+ locale.getSupportedLocale().add(supportedLocale);
+ supportedLocale = FacesConfigFactory.eINSTANCE.createSupportedLocaleType();
+ supportedLocale.setTextContent("de");
+ locale.getSupportedLocale().add(supportedLocale);
+ supportedLocale = FacesConfigFactory.eINSTANCE.createSupportedLocaleType();
+ supportedLocale.setTextContent("en");
+ locale.getSupportedLocale().add(supportedLocale);
+ supportedLocale = FacesConfigFactory.eINSTANCE.createSupportedLocaleType();
+ supportedLocale.setTextContent("fr");
+ locale.getSupportedLocale().add(supportedLocale);
+ supportedLocale = FacesConfigFactory.eINSTANCE.createSupportedLocaleType();
+ supportedLocale.setTextContent("tr");
+ locale.getSupportedLocale().add(supportedLocale);
+ applicationType.getLocaleConfig().add(locale);
+ }
+ boolean viewHandlerExists = false;
+ for (Iterator iterator = applications.iterator(); iterator.hasNext();) {
+ ApplicationType application = (ApplicationType) iterator.next();
+ EList viewHandlers = application.getViewHandler();
+ for (Iterator iterator2 = viewHandlers.iterator(); iterator2.hasNext();) {
+ ViewHandlerType viewHandlerType = (ViewHandlerType)iterator2.next();
+ if
("com.sun.facelets.FaceletViewHandler".equals(viewHandlerType.getTextContent().trim()))
{
+ viewHandlerExists = true;
+ break;
+ }
+ }
+ }
+ if (!viewHandlerExists) {
+ ViewHandlerType viewHandler = FacesConfigFactory.eINSTANCE.createViewHandlerType();
+ viewHandler.setTextContent("com.sun.facelets.FaceletViewHandler");
+ applicationType.getViewHandler().add(viewHandler);
+ }
+ if (!applicationExists) {
+ facesConfig.getApplication().add(applicationType);
+ }
+ facesConfigEdit.save(monitor);
+ } finally {
+ if (facesConfigEdit != null) {
+ facesConfigEdit.dispose();
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
* @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#configure(org.eclipse.jst.javaee.web.WebApp)
*/
@Override
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-10-15
19:42:20 UTC (rev 10863)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-10-15
20:25:43 UTC (rev 10864)
@@ -38,6 +38,9 @@
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
import org.eclipse.jst.j2ee.model.IModelProvider;
@@ -104,6 +107,11 @@
public static final String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
public static final String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
+ public static AntCopyUtils.FileSet JBOOS_EJB_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
+ .include("import\\.sql") //$NON-NLS-1$
+ .include("seam\\.properties")
+ .exclude(".*/WEB-INF"); //$NON-NLS-1$
+
public static AntCopyUtils.FileSet VIEW_FILESET = new AntCopyUtils.FileSet()
.include("home\\.xhtml") //$NON-NLS-1$
.include("error\\.xhtml") //$NON-NLS-1$
@@ -258,6 +266,7 @@
protected File seamGenResFolder;
protected File srcFolder;
protected File webContentFolder;
+ protected IPath webContentPath;
protected File webLibFolder;
protected IContainer webRootFolder;
protected File seamGenHomeFolder;
@@ -287,19 +296,8 @@
srcRootFolder = component.getRootFolder().getFolder(new
Path("/WEB-INF/classes")); //$NON-NLS-1$
webRootFolder = webRootVirtFolder.getUnderlyingFolder();
- model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
-
- Boolean dbExists = (Boolean)
model.getProperty(ISeamFacetDataModelProperties.DB_ALREADY_EXISTS);
- Boolean dbRecreate = (Boolean)
model.getProperty(ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY);
- if (!dbExists && !dbRecreate) {
- model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,
"update"); //$NON-NLS-1$
- } else if (dbExists && !dbRecreate) {
- model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,
"validate"); //$NON-NLS-1$
- } else if (dbRecreate) {
- model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,
"create-drop"); //$NON-NLS-1$
- }
-
webContentFolder = webRootFolder.getLocation().toFile();
+ webContentPath = webRootFolder.getFullPath();
webInfFolder = new File(webContentFolder, "WEB-INF"); //$NON-NLS-1$
webInfClasses = new File(webInfFolder, "classes"); //$NON-NLS-1$
webInfClassesMetaInf = new File(webInfClasses, "META-INF"); //$NON-NLS-1$
@@ -331,11 +329,6 @@
// If seam runtime is null then just modify web.xml and add seam nature.
configureWebXml(project);
}
-
- ClasspathHelper.addClasspathEntries(project, fv);
- createSeamProjectPreferenes(project, model);
- EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
- project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
/**
@@ -366,7 +359,7 @@
webContentFolder,
new AntCopyUtils.FileSetFileFilter(viewFileSet),
viewFilterSetCollection,
- true);
+ false);
// *******************************************************************
// Copy manifest and configuration resources the same way as view
@@ -378,10 +371,17 @@
AntCopyUtils.copyFileToFile(
componentsFile,
new File(webInfFolder, "components.xml"), //$NON-NLS-1$
- new FilterSetCollection(projectFilterSet), true);
+ new FilterSetCollection(projectFilterSet), false);
+ File facesConfig = new File(webContentFolder, "WEB-INF/faces-config.xml");
+ IPath webConfigPath =
webContentPath.append("WEB-INF").append("faces-config.xml");
+ String webConfigName = webConfigPath.removeFirstSegments(1).toString();
+ if(facesConfig.exists()) {
+ configureFacesConfigXml(project, monitor, webConfigName);
+ }
+
AntCopyUtils.copyFilesAndFolders(
- seamGenResFolder, webContentFolder, new AntCopyUtils.FileSetFileFilter(webInfSet),
viewFilterSetCollection, true);
+ seamGenResFolder, webContentFolder, new AntCopyUtils.FileSetFileFilter(webInfSet),
viewFilterSetCollection, false);
final FilterSetCollection hibernateDialectFilterSet = new FilterSetCollection();
hibernateDialectFilterSet.addFilterSet(jdbcFilterSet);
@@ -394,15 +394,10 @@
if (isWarConfiguration(model)) {
AntCopyUtils.FileSet webInfClassesSet = new
AntCopyUtils.FileSet(JBOOS_WAR_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
AntCopyUtils.copyFilesAndFolders(
- seamGenResFolder, srcFolder, new AntCopyUtils.FileSetFileFilter(webInfClassesSet),
viewFilterSetCollection, true);
+ seamGenResFolder, srcFolder, new AntCopyUtils.FileSetFileFilter(webInfClassesSet),
viewFilterSetCollection, false);
- createComponentsProperties(srcFolder, "", false); //$NON-NLS-1$
//$NON-NLS-2$
+ createComponentsProperties(srcFolder, "", false); //$NON-NLS-1$
- /*AntCopyUtils.copyFileToFolder(
- hibernateConsolePref,
- new File(project.getLocation().toFile(),".settings"), //$NON-NLS-1$
- new FilterSetCollection(projectFilterSet), true);*/
-
//
********************************************************************************************
// Copy seam project indicator
//
********************************************************************************************
@@ -426,33 +421,33 @@
AntCopyUtils.copyFileToFile(
new File(seamGenHomeFolder, "src/Authenticator.java"), //$NON-NLS-1$
new
File(actionsSrc,model.getProperty(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME).toString().replace('.',
'/') + "/" + "Authenticator.java"), //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
- new FilterSetCollection(filtersFilterSet), true);
+ new FilterSetCollection(filtersFilterSet), false);
AntCopyUtils.copyFileToFile(
persistenceFile,
new File(srcFolder, "META-INF/persistence.xml"), //$NON-NLS-1$
- viewFilterSetCollection, true);
+ viewFilterSetCollection, false);
File resources = new File(project.getLocation().toFile(), "resources");
AntCopyUtils.copyFileToFile(
dataSourceDsFile,
new File(resources, project.getName() + "-ds.xml"), //$NON-NLS-1$
- viewFilterSetCollection, true);
+ viewFilterSetCollection, false);
AntCopyUtils.copyFileToFile(
hibernateConsoleLaunchFile,
new File(project.getLocation().toFile(), project.getName() + ".launch"),
//$NON-NLS-1$
- viewFilterSetCollection, true);
+ viewFilterSetCollection, false);
AntCopyUtils.copyFileToFolder(
hibernateConsolePropsFile,
project.getLocation().toFile(),
- hibernateDialectFilterSet, true);
+ hibernateDialectFilterSet, false);
WtpUtils.setClasspathEntryAsExported(project, new
Path("org.eclipse.jst.j2ee.internal.web.container"), monitor); //$NON-NLS-1$
} else {
// In case of EAR configuration
- AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,
"messages_en.properties"), srcFolder, true); //$NON-NLS-1$
+ AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,
"messages_en.properties"), srcFolder, false); //$NON-NLS-1$
}
}
@@ -467,6 +462,24 @@
protected abstract void doExecuteForEar(IProject project, IProjectFacetVersion fv,
IDataModel model, IProgressMonitor monitor) throws CoreException;
+ protected IResource getSrcFolder(IProject project) throws JavaModelException {
+ IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
+
+ IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
+ IPackageFragmentRoot src = null;
+ for (int i= 0; i < roots.length; i++) {
+ if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
+ src = roots[i];
+ }
+ }
+ if(src!=null) {
+ return src.getResource();
+ }
+ return null;
+ }
+
+ protected FilterSetCollection ejbViewFilterSetCollection;
+
/**
*
* @param project
@@ -475,9 +488,71 @@
* @param monitor
* @throws CoreException
*/
- protected abstract void doExecuteForEjb(IProject project, IProjectFacetVersion fv,
- IDataModel model, IProgressMonitor monitor) throws CoreException;
+ protected void doExecuteForEjb(final IProject project, IProjectFacetVersion fv,
+ IDataModel model, IProgressMonitor monitor) throws CoreException {
+ IResource src = getSrcFolder(project);
+ if(src==null) {
+ return;
+ }
+
+ File ejbProjectFolder = project.getLocation().toFile();
+ FilterSet filtersFilterSet = SeamFacetFilterSetFactory.createFiltersFilterSet(model);
+ FilterSet jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
+ FilterSet projectFilterSet = SeamFacetFilterSetFactory.createProjectFilterSet(model);
+
+ if(ejbViewFilterSetCollection==null) {
+ ejbViewFilterSetCollection = new FilterSetCollection();
+ ejbViewFilterSetCollection.addFilterSet(jdbcFilterSet);
+ ejbViewFilterSetCollection.addFilterSet(projectFilterSet);
+ }
+
+ FilterSetCollection hibernateDialectFilterSet = new FilterSetCollection();
+ hibernateDialectFilterSet.addFilterSet(jdbcFilterSet);
+ hibernateDialectFilterSet.addFilterSet(projectFilterSet);
+ hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
+
+ File srcFile = src.getLocation().toFile();
+ // Copy sources to EJB project in case of EAR configuration
+ AntCopyUtils.copyFileToFile(
+ new File(seamGenHomeFolder, "src/Authenticator.java"), //$NON-NLS-1$
+ new File(srcFile,
model.getProperty(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME).toString().replace('.',
'/') + "/" + "Authenticator.java"), //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ new FilterSetCollection(filtersFilterSet), false);
+
+ File persistentXml = new File(srcFile, "META-INF/persistence.xml");
//$NON-NLS-1$
+ if(!persistentXml.exists()) {
+ AntCopyUtils.copyFileToFile(persistenceFile, new File(srcFile,
"META-INF/persistence.xml"), //$NON-NLS-1$
+ ejbViewFilterSetCollection, false);
+ } else {
+ // TODO modify persistence.xml
+ }
+
+ File componentProperties = new File(srcFile, "components.properties");
//$NON-NLS-1$
+ if(!componentProperties.exists()) {
+ SeamFacetAbstractInstallDelegate.createComponentsProperties(srcFile,
project.getName(), false);
+ }
+
+ AntCopyUtils.FileSet ejbSrcResourcesSet = new
AntCopyUtils.FileSet(JBOOS_EJB_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
+ AntCopyUtils.copyFilesAndFolders(seamGenResFolder, srcFile, new
AntCopyUtils.FileSetFileFilter(ejbSrcResourcesSet), ejbViewFilterSetCollection, false);
+
+ File ejbJarXml = new File(srcFile, "META-INF/ejb-jar.xml");
+ if(!ejbJarXml.exists()) {
+ AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,
"META-INF/ejb-jar.xml"), //$NON-NLS-1$
+ new File(srcFile, "META-INF"), ejbViewFilterSetCollection, false);
//$NON-NLS-1$
+ } else {
+ // TODO modify ejb-jar.xml
+ }
+ FilterSet ejbFilterSet = new FilterSet();
+ ejbFilterSet.addFilter("projectName", ejbProjectFolder.getName());
//$NON-NLS-1$
+
+ AntCopyUtils.copyFileToFile(hibernateConsoleLaunchFile, new File(
+ ejbProjectFolder, ejbProjectFolder.getName() + ".launch"), //$NON-NLS-1$
+ new FilterSetCollection(ejbFilterSet), false);
+
+ AntCopyUtils.copyFileToFolder(hibernateConsolePropsFile,
+ ejbProjectFolder, hibernateDialectFilterSet, false);
+ }
+
/**
*
* @param project
@@ -494,6 +569,19 @@
IProjectFacetVersion webVersion =
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET);
IProjectFacetVersion earVersion =
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.ENTERPRISE_APPLICATION_FACET);
initDefaultModelValues(model, webVersion!=null);
+
+ model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
+
+ Boolean dbExists = (Boolean)
model.getProperty(ISeamFacetDataModelProperties.DB_ALREADY_EXISTS);
+ Boolean dbRecreate = (Boolean)
model.getProperty(ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY);
+ if (!dbExists && !dbRecreate) {
+ model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,
"update"); //$NON-NLS-1$
+ } else if (dbExists && !dbRecreate) {
+ model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,
"validate"); //$NON-NLS-1$
+ } else if (dbRecreate) {
+ model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,
"create-drop"); //$NON-NLS-1$
+ }
+
if(ejbVersion!=null) {
doExecuteForEjb(project, fv, model, monitor);
} else if(webVersion!=null) {
@@ -501,6 +589,11 @@
} else if(earVersion!=null) {
doExecuteForEar(project, fv, model, monitor);
}
+
+ ClasspathHelper.addClasspathEntries(project, fv);
+ createSeamProjectPreferenes(project, model);
+ EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
private void initDefaultModelValues(IDataModel model, boolean warProject) {
@@ -818,7 +911,15 @@
webApp.getContextParams().add(paramValue);
}
}
-
+
+ /**
+ *
+ * @param project
+ * @param monitor
+ * @param webConfigName
+ */
+ abstract protected void configureFacesConfigXml(final IProject project, IProgressMonitor
monitor, String webConfigName);
+
protected abstract void configure(WebApp webApp);
protected void configureWebXml(final IProject project) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java 2008-10-15
19:42:20 UTC (rev 10863)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java 2008-10-15
20:25:43 UTC (rev 10864)
@@ -11,14 +11,23 @@
package org.jboss.tools.seam.internal.core.project.facet;
import java.io.File;
+import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.jst.javaee.core.DisplayName;
import org.eclipse.jst.javaee.core.JavaeeFactory;
import org.eclipse.jst.javaee.web.Filter;
import org.eclipse.jst.javaee.web.WebApp;
+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.LifecycleType;
+import org.eclipse.jst.jsf.facesconfig.emf.MessageBundleType;
+import org.eclipse.jst.jsf.facesconfig.emf.PhaseListenerType;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -106,16 +115,6 @@
/*
* (non-Javadoc)
- * @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#doExecuteForEjb(org.eclipse.core.resources.IProject,
org.eclipse.wst.common.project.facet.core.IProjectFacetVersion,
org.eclipse.wst.common.frameworks.datamodel.IDataModel,
org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected void doExecuteForEjb(final IProject project, IProjectFacetVersion fv,
- IDataModel model, IProgressMonitor monitor) throws CoreException {
- // TODO
- }
-
- /*
- * (non-Javadoc)
* @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#copyFilesToWarProject(org.eclipse.core.resources.IProject,
org.eclipse.wst.common.project.facet.core.IProjectFacetVersion,
org.eclipse.wst.common.frameworks.datamodel.IDataModel,
org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
@@ -136,6 +135,84 @@
/*
* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#configureFacesConfigXml(org.eclipse.core.resources.IProject,
org.eclipse.core.runtime.IProgressMonitor, java.lang.String)
+ */
+ @Override
+ protected void configureFacesConfigXml(final IProject project, IProgressMonitor monitor,
String webConfigName) {
+ FacesConfigArtifactEdit facesConfigEdit = null;
+ try {
+ facesConfigEdit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(project,
webConfigName);
+ 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 messageBundleExists = false;
+ for (Iterator iterator = applications.iterator(); iterator.hasNext();) {
+ ApplicationType application = (ApplicationType) iterator.next();
+ EList messageBundles = application.getMessageBundle();
+ for (Iterator iterator2 = messageBundles.iterator(); iterator2.hasNext();) {
+ MessageBundleType messageBundle = (MessageBundleType)iterator2.next();
+ if ("messages".equals(messageBundle.getTextContent().trim())) {
+ messageBundleExists = true;
+ break;
+ }
+ }
+ }
+ if (!messageBundleExists) {
+ MessageBundleType messageBundle =
FacesConfigFactory.eINSTANCE.createMessageBundleType();
+ messageBundle.setTextContent("messages");
+ applicationType.getMessageBundle().add(messageBundle);
+ }
+ if (!applicationExists) {
+ facesConfig.getApplication().add(applicationType);
+ }
+ EList lifecycles = facesConfig.getLifecycle();
+ LifecycleType lifecycleType = null;
+ boolean lifecycleExists = false;
+ if (lifecycles.size() <= 0) {
+ lifecycleType = FacesConfigFactory.eINSTANCE.createLifecycleType();
+ } else {
+ lifecycleType = (LifecycleType)lifecycles.get(0);
+ lifecycleExists = true;
+ }
+ boolean phaseListenerExists = false;
+ for (Iterator iterator = lifecycles.iterator(); iterator.hasNext();) {
+ LifecycleType lifecycle = (LifecycleType) iterator.next();
+ EList phaseListeners = lifecycle.getPhaseListener();
+ for (Iterator iterator2 = phaseListeners.iterator(); iterator2.hasNext();) {
+ PhaseListenerType messageBundle = (PhaseListenerType)iterator2.next();
+ if
("org.jboss.seam.jsf.TransactionalSeamPhaseListener".equals(messageBundle.getTextContent().trim())
||
+ "org.jboss.seam.jsf.SeamPhaseListener".equals(messageBundle.getTextContent().trim()))
{
+ phaseListenerExists = true;
+ break;
+ }
+ }
+ }
+ if (!phaseListenerExists) {
+ PhaseListenerType phaseListener =
FacesConfigFactory.eINSTANCE.createPhaseListenerType();
+ phaseListener.setTextContent("org.jboss.seam.jsf.TransactionalSeamPhaseListener");
+ lifecycleType.getPhaseListener().add(phaseListener);
+ }
+ if (!lifecycleExists) {
+ facesConfig.getLifecycle().add(lifecycleType);
+ }
+
+ facesConfigEdit.save(monitor);
+ } finally {
+ if (facesConfigEdit != null) {
+ facesConfigEdit.dispose();
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
* @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#configure(org.eclipse.jst.javaee.web.WebApp)
*/
@Override
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2008-10-15
19:42:20 UTC (rev 10863)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2008-10-15
20:25:43 UTC (rev 10864)
@@ -52,11 +52,6 @@
protected static final String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
protected static final String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
- protected static AntCopyUtils.FileSet JBOOS_EJB_WEB_INF_CLASSES_SET = new
AntCopyUtils.FileSet()
- .include("import\\.sql") //$NON-NLS-1$
- .include("seam\\.properties")
- .exclude(".*/WEB-INF"); //$NON-NLS-1$
-
private static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new AntCopyUtils.FileSet()
.include("testng-.*-jdk15\\.jar") //$NON-NLS-1$
.include("myfaces-api-.*\\.jar") //$NON-NLS-1$
@@ -382,7 +377,7 @@
SeamFacetAbstractInstallDelegate.createComponentsProperties(new File(ejbProjectFolder,
"ejbModule"), earProjectName, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- AntCopyUtils.FileSet ejbSrcResourcesSet = new
AntCopyUtils.FileSet(JBOOS_EJB_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
+ AntCopyUtils.FileSet ejbSrcResourcesSet = new
AntCopyUtils.FileSet(SeamFacetAbstractInstallDelegate.JBOOS_EJB_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
AntCopyUtils.copyFilesAndFolders(
seamGenResFolder, new File(ejbProjectFolder, "ejbModule"), new
AntCopyUtils.FileSetFileFilter(ejbSrcResourcesSet), viewFilterSetCollection, true);
//$NON-NLS-1$