Author: akazakov
Date: 2008-09-29 12:00:28 -0400 (Mon, 29 Sep 2008)
New Revision: 10543
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
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.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2731 Moved seam test project creation from facet
to wizard.
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java 2008-09-29
15:29:53 UTC (rev 10542)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/ResourcesUtils.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -67,12 +67,18 @@
}
public static IProject importExistingProject(IProject project, String location, String
name) throws CoreException {
+ return importExistingProject(project, location, name, new NullProgressMonitor(),
true);
+ }
+
+ public static IProject importExistingProject(IProject project, String location, String
name, IProgressMonitor monitor, boolean refreshWorkspace) throws CoreException {
IPath path = new Path(location).append(".project");
IProjectDescription description =
ResourcesPlugin.getWorkspace().loadProjectDescription(path);
description.setName(name);
- project.create(description, new NullProgressMonitor());
- project.open(IResource.NONE, new NullProgressMonitor());
- ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, new
NullProgressMonitor());
+ project.create(description, monitor);
+ project.open(IResource.NONE, monitor);
+ if(refreshWorkspace) {
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, new
NullProgressMonitor());
+ }
return project;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2008-09-29 15:29:53 UTC (rev
10542)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2008-09-29 16:00:28 UTC (rev
10543)
@@ -49,40 +49,52 @@
facet="jst.seam"
version="1.2">
<constraint>
- <and>
- <requires
- facet="jst.web"
- version="[2.5">
- </requires>
- <requires
- facet="jst.jsf"
- version="[1.2">
- </requires>
- <requires
- facet="jst.java"
- version="5.0">
- </requires>
- </and>
+ <or>
+ <requires
+ facet="jst.ejb"
+ version="[3.0">
+ </requires>
+ <and>
+ <requires
+ facet="jst.web"
+ version="[2.5">
+ </requires>
+ <requires
+ facet="jst.jsf"
+ version="[1.2">
+ </requires>
+ <requires
+ facet="jst.java"
+ version="5.0">
+ </requires>
+ </and>
+ </or>
</constraint>
</project-facet-version>
<project-facet-version
facet="jst.seam"
version="2.0">
<constraint>
- <and>
- <requires
- facet="jst.web"
- version="[2.5">
- </requires>
- <requires
- facet="jst.jsf"
- version="[1.2">
- </requires>
- <requires
- facet="jst.java"
- version="[5.0">
- </requires>
- </and>
+ <or>
+ <requires
+ facet="jst.ejb"
+ version="[3.0">
+ </requires>
+ <and>
+ <requires
+ facet="jst.web"
+ version="[2.5">
+ </requires>
+ <requires
+ facet="jst.jsf"
+ version="[1.2">
+ </requires>
+ <requires
+ facet="jst.java"
+ version="5.0">
+ </requires>
+ </and>
+ </or>
</constraint>
</project-facet-version>
<action
@@ -176,10 +188,10 @@
<static-preset
id="jst.seam.preset">
<label>Dynamic Web Project with Seam 1.2</label>
- <facet id="jst.java" version="5.0" />
+ <facet id="jst.java" version="5.0"/>
<facet id="jst.web" version="2.5"/>
- <facet id="jst.jsf" version="1.2" />
- <facet id="jst.seam" version="1.2" />
+ <facet id="jst.jsf" version="1.2"/>
+ <facet id="jst.seam" version="1.2"/>
<description>
Configures a Dynamic Web application to use Seam v1.2
</description>
@@ -187,10 +199,10 @@
<static-preset
id="jst.seam2.preset">
<label>Dynamic Web Project with Seam 2.0</label>
- <facet id="jst.java" version="5.0" />
+ <facet id="jst.java" version="5.0"/>
<facet id="jst.web" version="2.5"/>
- <facet id="jst.jsf" version="1.2" />
- <facet id="jst.seam" version="2.0" />
+ <facet id="jst.jsf" version="1.2"/>
+ <facet id="jst.seam" version="2.0"/>
<description>
Configures a Dynamic Web application to use Seam v2.0
</description>
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -0,0 +1,115 @@
+ /*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.project.facet;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.tools.ant.types.FilterSet;
+import org.apache.tools.ant.types.FilterSetCollection;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+/**
+ * @author Alexey Kazakov
+ * This class helps New Seam Wizard Page to create EJB, EAR and test projects for seam
1.2 WAR project.
+ */
+public class Seam1ProjectCreator extends SeamProjectCreator {
+
+ protected static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new
AntCopyUtils.FileSet()
+ .include("testng-.*-jdk15\\.jar") //$NON-NLS-1$
+ .include("myfaces-api-.*\\.jar") //$NON-NLS-1$
+ .include("myfaces-impl-.*\\.jar") //$NON-NLS-1$
+ .include("servlet-api\\.jar") //$NON-NLS-1$
+ .include("hibernate-all\\.jar") //$NON-NLS-1$
+ .include("jboss-ejb3-all\\.jar") //$NON-NLS-1$
+ .include("thirdparty-all\\.jar") //$NON-NLS-1$
+ .exclude(".*/CVS") //$NON-NLS-1$
+ .exclude(".*/\\.svn"); //$NON-NLS-1$
+
+ /**
+ * @param model Seam facet data model
+ * @param seamWebProject Seam web project
+ */
+ public Seam1ProjectCreator(IDataModel model, IProject seamWebProject) {
+ super(model, seamWebProject);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.project.facet.SeamProjectCreator#createTestProject()
+ */
+ @Override
+ protected void createTestProject() {
+ File testProjectDir = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(), testProjectName);
//$NON-NLS-1$
+ testProjectDir.mkdir();
+
+ IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
+
+ File testLibDir = new File(testProjectDir, "lib"); //$NON-NLS-1$
+ File embededEjbDir = new File(testProjectDir, "embedded-ejb"); //$NON-NLS-1$
+ File testSrcDir = new File(testProjectDir, "test-src"); //$NON-NLS-1$
+ FilterSet filterSet = new FilterSet();
+ filterSet.addFilter("projectName", seamWebProject.getName()); //$NON-NLS-1$
+ filterSet.addFilter("runtimeName",
WtpUtils.getServerRuntimeName(seamWebProject)); //$NON-NLS-1$
+ filterSet.addFilter("webRootFolder",
webRootVirtFolder.getUnderlyingFolder().getFullPath().removeFirstSegments(1).toString());
//$NON-NLS-1$
+
+ AntCopyUtils.FileSet includeLibs = new
AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET).dir(new File(seamRuntime.getHomeDir(),
"lib")); //$NON-NLS-1$
+ File[] libs = includeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(includeLibs));
+ StringBuffer testLibraries = new StringBuffer();
+
+ for (File file : libs) {
+ testLibraries.append("\t<classpathentry kind=\"lib\"
path=\"lib/" + file.getName() + "\"/>\n"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ StringBuffer requiredProjects = new StringBuffer();
+ requiredProjects.append("\t<classpathentry
combineaccessrules=\"false\" kind=\"src\" path=\"/" +
seamWebProject.getName() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!SeamFacetAbstractInstallDelegate.isWarConfiguration(model)) {
+ requiredProjects.append("\n\t<classpathentry
combineaccessrules=\"false\" kind=\"src\" path=\"/" +
ejbProjectName + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ filterSet.addFilter("testLibraries", testLibraries.toString());
//$NON-NLS-1$
+ filterSet.addFilter("requiredProjects", requiredProjects.toString());
//$NON-NLS-1$
+ File testTemplateDir = null;
+ try {
+ testTemplateDir = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"test"); //$NON-NLS-1$
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return;
+ }
+ AntCopyUtils.FileSet excludeCvsSvn
+ = new
AntCopyUtils.FileSet(SeamFacetAbstractInstallDelegate.CVS_SVN).dir(testTemplateDir);
+
+ AntCopyUtils.copyFilesAndFolders(
+ testTemplateDir,
+ testProjectDir,
+ new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
+ new FilterSetCollection(filterSet), true);
+
+ excludeCvsSvn.dir(new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"));
//$NON-NLS-1$
+ AntCopyUtils.copyFiles(
+ new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"), //$NON-NLS-1$
+ embededEjbDir,
+ new AntCopyUtils.FileSetFileFilter(excludeCvsSvn));
+
+ AntCopyUtils.copyFiles(
+ new File(seamRuntime.getHomeDir(), "lib"), //$NON-NLS-1$
+ testLibDir,
+ new AntCopyUtils.FileSetFileFilter(includeLibs));
+
+ SeamFacetAbstractInstallDelegate.createComponentsProperties(testSrcDir, "",
Boolean.TRUE); //$NON-NLS-1$
+ }
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam1ProjectCreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-09-29
15:29:53 UTC (rev 10542)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -11,36 +11,29 @@
package org.jboss.tools.seam.internal.core.project.facet;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.util.HashSet;
-import java.util.Properties;
import java.util.Set;
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.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jdt.internal.ui.jarpackagerfat.FatJarAntExporter;
import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
import org.eclipse.jst.javaee.web.WebApp;
import org.eclipse.wst.common.componentcore.ComponentCore;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
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.ProjectFacetsManager;
@@ -50,16 +43,12 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
// TODO: why not just *one* global filter set to avoid any missing names ? (assert for it
in our unittests!
public class Seam2FacetInstallDelegate extends SeamFacetAbstractInstallDelegate{
public static String DEV_WAR_PROFILE = "dev-war"; //$NON-NLS-1$
public static String DEV_EAR_PROFILE = "dev"; //$NON-NLS-1$
- public static String TEST_WAR_PROFILE = "test-war"; //$NON-NLS-1$
- public static String TEST_EAR_PROFILE = "test"; //$NON-NLS-1$
public static AntCopyUtils.FileSet JBOSS_WAR_LIB_FILESET_WAR_CONFIG = new
AntCopyUtils.FileSet()
.include("ajax4jsf.*\\.jar") //$NON-NLS-1$
@@ -88,23 +77,6 @@
.include("mvel14.jar") //$NON-NLS-1$
.include("jboss-el.jar"); //$NON-NLS-1$
- // test/*.jar are duplicated here since the filtering seem to be assymetric when
matching
- public static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new AntCopyUtils.FileSet()
- .include("testng\\.jar") //$NON-NLS-1$
- .include("test/hibernate-all\\.jar") //$NON-NLS-1$
- .include("hibernate-all\\.jar") //$NON-NLS-1$
- .include("test/jboss-embedded-all.jar") //$NON-NLS-1$
- .include("jboss-embedded-all.jar") //$NON-NLS-1$
- .include("test/jboss-embedded-api.jar") //$NON-NLS-1$
- .include("jboss-embedded-api.jar") //$NON-NLS-1$
- .include("test/jboss-deployers.jar") //$NON-NLS-1$
- .include("jboss-deployers.jar") //$NON-NLS-1$
- .include("test/thirdparty-all\\.jar") //$NON-NLS-1$
- .include("thirdparty-all\\.jar") //$NON-NLS-1$
- .include("core.jar") //$NON-NLS-1$
- .exclude(".*/CVS") //$NON-NLS-1$
- .exclude(".*/\\.svn"); //$NON-NLS-1$
-
public static AntCopyUtils.FileSet JBOSS_WAR_LIB_FILESET_EAR_CONFIG = new
AntCopyUtils.FileSet()
.include("richfaces-impl\\.jar") //$NON-NLS-1$
.include("richfaces-ui\\.jar") //$NON-NLS-1$
@@ -149,13 +121,6 @@
.exclude(".*/CVS") //$NON-NLS-1$
.exclude(".*/\\.svn"); //$NON-NLS-1$
- public static AntCopyUtils.FileSet CVS_SVN = new AntCopyUtils.FileSet()
- .include(".*") //$NON-NLS-1$
- .exclude(".*/CVS") //$NON-NLS-1$
- .exclude("CVS") //$NON-NLS-1$
- .exclude(".*\\.svn") //$NON-NLS-1$
- .exclude(".*/\\.svn"); //$NON-NLS-1$
-
public static AntCopyUtils.FileSet JBOOS_WAR_WEBINF_SET = new AntCopyUtils.FileSet()
.include("WEB-INF") //$NON-NLS-1$
//.include("WEB-INF/web\\.xml") //$NON-NLS-1$
@@ -184,6 +149,8 @@
public void doExecute(final IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
final IDataModel model = (IDataModel)config;
+ IFacetedProjectWorkingCopy fc =
(IFacetedProjectWorkingCopy)model.getProperty(IFacetDataModelProperties.FACETED_PROJECT_WORKING_COPY);
+ Set<IProjectFacetVersion> fvd = fc.getProjectFacets();
// get WebContents folder path from DWP model
IVirtualComponent component = ComponentCore.createComponent(project);
@@ -192,7 +159,6 @@
IContainer webRootFolder = webRootVirtFolder.getUnderlyingFolder();
model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
- model.setProperty(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT,
project.getName()+"-test"); //$NON-NLS-1$
Boolean dbExists =
(Boolean)model.getProperty(ISeamFacetDataModelProperties.DB_ALREADY_EXISTS);
Boolean dbRecreate =
(Boolean)model.getProperty(ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY);
@@ -276,7 +242,7 @@
hibernateDialectFilterSet.addFilterSet(projectFilterSet);
hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
- createTestProject(model,project,selectedRuntime);
+// createTestProject(model,project,selectedRuntime);
//
********************************************************************************************
// Handle WAR/EAR configurations
@@ -502,157 +468,22 @@
if(!isWarConfiguration(model)) {
IProject ejbProjectToBeImported =
wsRoot.getProject(project.getName()+"-ejb");
- ResourcesUtils.importExistingProject(ejbProjectToBeImported,
wsPath+"/"+project.getName()+"-ejb",
project.getName()+"-ejb");
+ ResourcesUtils.importExistingProject(ejbProjectToBeImported,
wsPath+"/"+project.getName()+"-ejb",
project.getName()+"-ejb", monitor, false);
toggleHibernateOnProject(ejbProjectToBeImported, consoleName);
IProjectFacet sf = ProjectFacetsManager.getProjectFacet("jst.ejb");
IProjectFacetVersion pfv =
ProjectFacetsManager.create(ejbProjectToBeImported).getInstalledVersion(sf);
ClasspathHelper.addClasspathEntries(ejbProjectToBeImported, pfv);
IProject earProjectToBeImported =
wsRoot.getProject(project.getName()+"-ear");
- ResourcesUtils.importExistingProject(earProjectToBeImported,
wsPath+"/"+project.getName()+"-ear",
project.getName()+"-ear");
+ ResourcesUtils.importExistingProject(earProjectToBeImported,
wsPath+"/"+project.getName()+"-ear",
project.getName()+"-ear", monitor, false);
}
-
- IProject testProjectToBeImported =
wsRoot.getProject(project.getName()+"-test");
- ResourcesUtils.importExistingProject(testProjectToBeImported,
wsPath+"/"+project.getName()+"-test",
project.getName()+"-test");
- toggleHibernateOnProject(testProjectToBeImported, consoleName);
}
- public static boolean isWarConfiguration(IDataModel model) {
- return
"war".equals(model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
//$NON-NLS-1$
- }
-
- private void createTestProject(IDataModel model, IProject seamWebProject, SeamRuntime
seamRuntime) {
- String projectName =
model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME).toString();
- File testProjectDir = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(),projectName+"-test");
//$NON-NLS-1$
- testProjectDir.mkdir();
-
- IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
- IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
-
- File testLibDir = new File(testProjectDir,"lib"); //$NON-NLS-1$
- File embededEjbDir = new File(testProjectDir,"bootstrap"); //$NON-NLS-1$
- File testSrcDir = new File(testProjectDir,"test-src"); //$NON-NLS-1$
- String seamGenResFolder = seamRuntime.getResourceTemplatesDir();
- File persistenceFile = new File(seamGenResFolder ,"META-INF/persistence-" +
(isWarConfiguration(model)?TEST_WAR_PROFILE:TEST_EAR_PROFILE) + ".xml");
//$NON-NLS-1$ //$NON-NLS-2$
- File dataSourceFile = new File(seamGenResFolder, "datasource-ds.xml");
- File seamPropertiesFile = new File(seamGenResFolder, "seam.properties");
- //File jbossBeansFile = new File(seamGenResFolder
,"META-INF/jboss-beans.xml"); //$NON-NLS-1$
- FilterSet filterSet = new FilterSet();
- filterSet.addFilter("projectName", projectName); //$NON-NLS-1$
- filterSet.addFilter("runtimeName",
WtpUtils.getServerRuntimeName(seamWebProject)); //$NON-NLS-1$
- filterSet.addFilter("webRootFolder",webRootVirtFolder.getUnderlyingFolder().getFullPath().removeFirstSegments(1).toString());
//$NON-NLS-1$
-
- FilterSet jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
- // TODO: why are these filters not shared!?
- filterSet.addConfiguredFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
-
- final SeamRuntime selectedRuntime =
SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
- final String seamHomePath = selectedRuntime.getHomeDir();
-
- AntCopyUtils.FileSet includeLibs
- = new AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET)
- .dir(new File(seamRuntime.getHomeDir(),"lib")); //$NON-NLS-1$
- AntCopyUtils.FileSet secondSetincludeLibs
- = new AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET)
- .dir(new File(seamRuntime.getHomeDir(),"lib/test")); //$NON-NLS-1$
-
- File[] firstlibs = includeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(includeLibs));
- File[] secondLibs = secondSetincludeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(secondSetincludeLibs));
- Set<String> allLibs = new HashSet<String>(); // HACK: needed to be unique
because some jboss-*.jars are duplicated
- for(File f : firstlibs) {
- allLibs.add(f.getName());
- }
- for(File f : secondLibs) {
- allLibs.add(f.getName());
- }
-
- StringBuffer testLibraries = new StringBuffer();
-
- for (String file : allLibs) {
- testLibraries.append("\t<classpathentry kind=\"lib\"
path=\"lib/" + file + "\"/>\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- StringBuffer requiredProjects = new StringBuffer();
- requiredProjects.append(
- "\t<classpathentry combineaccessrules=\"false\"
kind=\"src\" path=\"/" + seamWebProject.getName() +
"\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- if(!isWarConfiguration(model)) {
- requiredProjects.append(
- "\n\t<classpathentry combineaccessrules=\"false\"
kind=\"src\" path=\"/" + seamWebProject.getName() +
"-ejb\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- filterSet.addFilter("testLibraries",testLibraries.toString());
//$NON-NLS-1$
- filterSet.addFilter("requiredProjects",requiredProjects.toString());
//$NON-NLS-1$
- File testTemplateDir = null;
- try {
- testTemplateDir = new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"test-seam2");
//$NON-NLS-1$
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- return;
- }
- AntCopyUtils.FileSet excludeCvsSvn
- = new AntCopyUtils.FileSet(CVS_SVN).dir(testTemplateDir);
-
- AntCopyUtils.copyFilesAndFolders(
- testTemplateDir,
- testProjectDir,
- new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
- new FilterSetCollection(filterSet), true);
-
- excludeCvsSvn.dir(new File(seamRuntime.getHomeDir(),"bootstrap"));
//$NON-NLS-1$
- AntCopyUtils.copyFilesAndFolders(
- new File(seamRuntime.getHomeDir(),"bootstrap"), //$NON-NLS-1$
- embededEjbDir,
- new AntCopyUtils.FileSetFileFilter(excludeCvsSvn), new FilterSetCollection(),
true);
-
-// AntCopyUtils.copyFileToFile(
-// persistenceFile,
-// new File(testProjectDir,"test-src/META-INF/persistence.xml"),
//$NON-NLS-1$
-// new FilterSetCollection(filterSet), true);
-
- FilterSetCollection f = new FilterSetCollection();
- f.addFilterSet(filterSet);
- f.addFilterSet(jdbcFilterSet);
-
- AntCopyUtils.copyFileToFile(
- dataSourceFile,
- new
File(testProjectDir,"test-src/META-INF/"+seamWebProject.getName()+"-test-ds.xml"),
//$NON-NLS-1$
- f, true);
-
- AntCopyUtils.copyFileToFolder(
- seamPropertiesFile,
- testSrcDir, //$NON-NLS-1$
- new FilterSetCollection(filterSet), true);
-
- AntCopyUtils.copyFiles(
- new File(seamRuntime.getHomeDir(),"lib"), //$NON-NLS-1$
- testLibDir,
- new AntCopyUtils.FileSetFileFilter(includeLibs));
-
- //seam2 has a lib/test
- AntCopyUtils.copyFiles(
- new File(seamRuntime.getHomeDir(),"lib/test"), //$NON-NLS-1$
- testLibDir,
- new AntCopyUtils.FileSetFileFilter(includeLibs));
-
- createComponentsProperties(testSrcDir, "", true); //$NON-NLS-1$
- }
-
- /**
- * @param seamGenResFolder
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#configure(org.eclipse.jst.javaee.web.WebApp)
*/
- private void createComponentsProperties(final File seamGenResFolder, String projectName,
boolean embedded) {
- Properties components = new Properties();
- String prefix =
"".equals(projectName)?"":projectName+"/"; //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
- components.setProperty("embeddedEjb", ""+embedded); //$NON-NLS-1$
- components.setProperty("jndiPattern", prefix+"#{ejbName}/local");
//$NON-NLS-1$ //$NON-NLS-2$
- File componentsProps = new File(seamGenResFolder,"components.properties");
//$NON-NLS-1$
- try {
- componentsProps.createNewFile();
- components.store(new FileOutputStream(componentsProps), ""); //$NON-NLS-1$
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
- }
-
+ @Override
protected void configure(WebApp webApp) {
// Ajax4jsf
createOrUpdateContextParam(webApp, ORG_RICHFACES_SKIN,
@@ -682,56 +513,4 @@
// Security
addSecurityConstraint(webApp);
}
-
- public static boolean toggleHibernateOnProject(IProject project, String
defaultConsoleName) {
- IScopeContext scope = new ProjectScope(project);
-
- Preferences node = scope.getNode("org.hibernate.eclipse.console");
-
- if(node!=null) {
- node.putBoolean("hibernate3.enabled", true );
- node.put("default.configuration", defaultConsoleName );
- try {
- node.flush();
- } catch (BackingStoreException e) {
- SeamCorePlugin.getDefault().logError("Could not save changes to
preferences", e);
- return false;
- }
- } else {
- return false;
- }
-
- try {
- addProjectNature(project, "org.hibernate.eclipse.console.hibernateNature",
new NullProgressMonitor() );
- return true;
- } catch(CoreException ce) {
- SeamCorePlugin.getDefault().logError("Could not activate Hibernate nature on
project " + project.getName(), ce);
- return false;
- }
- }
-
- /**
- * Add the given project nature to the given project (if it isn't already added).
- * @return true if nature where added, false if not
- * @throws OperationCanceledException if job were cancelled or CoreException if
something went wrong.
- */
- public static boolean addProjectNature(IProject project, String nature, IProgressMonitor
monitor) throws CoreException {
- if (monitor != null && monitor.isCanceled() ) {
- throw new OperationCanceledException();
- }
-
- if (!project.hasNature(nature) ) {
- IProjectDescription description = project.getDescription();
- String[] prevNatures= description.getNatureIds();
- String[] newNatures= new String[prevNatures.length + 1];
- System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
- newNatures[prevNatures.length]= nature;
- description.setNatureIds(newNatures);
- project.setDescription(description, monitor);
- return true;
- } else {
- monitor.worked(1);
- return false;
- }
- }
}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -0,0 +1,164 @@
+ /*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.project.facet;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.tools.ant.types.FilterSet;
+import org.apache.tools.ant.types.FilterSetCollection;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+/**
+ * @author Alexey Kazakov
+ * This class helps New Seam Wizard Page to create EJB, EAR and test projects for seam
2.* WAR project.
+ */
+public class Seam2ProjectCreator extends SeamProjectCreator {
+
+ // test/*.jar are duplicated here since the filtering seem to be assymetric when
matching
+ protected static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new
AntCopyUtils.FileSet()
+ .include("testng\\.jar") //$NON-NLS-1$
+ .include("test/hibernate-all\\.jar") //$NON-NLS-1$
+ .include("hibernate-all\\.jar") //$NON-NLS-1$
+ .include("test/jboss-embedded-all.jar") //$NON-NLS-1$
+ .include("jboss-embedded-all.jar") //$NON-NLS-1$
+ .include("test/jboss-embedded-api.jar") //$NON-NLS-1$
+ .include("jboss-embedded-api.jar") //$NON-NLS-1$
+ .include("test/jboss-deployers.jar") //$NON-NLS-1$
+ .include("jboss-deployers.jar") //$NON-NLS-1$
+ .include("test/thirdparty-all\\.jar") //$NON-NLS-1$
+ .include("thirdparty-all\\.jar") //$NON-NLS-1$
+ .include("core.jar") //$NON-NLS-1$
+ .exclude(".*/CVS") //$NON-NLS-1$
+ .exclude(".*/\\.svn"); //$NON-NLS-1$
+
+ /**
+ * @param model Seam facet data model
+ * @param seamWebProject Seam web project
+ */
+ public Seam2ProjectCreator(IDataModel model, IProject seamWebProject) {
+ super(model, seamWebProject);
+ }
+
+ @Override
+ protected void createTestProject() {
+ File testProjectDir = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(), testProjectName);
//$NON-NLS-1$
+ testProjectDir.mkdir();
+
+ IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
+
+ File testLibDir = new File(testProjectDir,"lib"); //$NON-NLS-1$
+ File embededEjbDir = new File(testProjectDir,"bootstrap"); //$NON-NLS-1$
+ File testSrcDir = new File(testProjectDir,"test-src"); //$NON-NLS-1$
+ String seamGenResFolder = seamRuntime.getResourceTemplatesDir();
+ File dataSourceFile = new File(seamGenResFolder, "datasource-ds.xml");
+ File seamPropertiesFile = new File(seamGenResFolder, "seam.properties");
+ //File jbossBeansFile = new File(seamGenResFolder
,"META-INF/jboss-beans.xml"); //$NON-NLS-1$
+ FilterSet filterSet = new FilterSet();
+ filterSet.addFilter("projectName", seamWebProject.getName()); //$NON-NLS-1$
+ filterSet.addFilter("runtimeName",
WtpUtils.getServerRuntimeName(seamWebProject)); //$NON-NLS-1$
+ filterSet.addFilter("webRootFolder",webRootVirtFolder.getUnderlyingFolder().getFullPath().removeFirstSegments(1).toString());
//$NON-NLS-1$
+
+ FilterSet jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
+ // TODO: why are these filters not shared!?
+ filterSet.addConfiguredFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
+
+ AntCopyUtils.FileSet includeLibs = new
AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET).dir(new
File(seamRuntime.getHomeDir(),"lib")); //$NON-NLS-1$
+ AntCopyUtils.FileSet secondSetincludeLibs = new
AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET).dir(new
File(seamRuntime.getHomeDir(),"lib/test")); //$NON-NLS-1$
+
+ File[] firstlibs = includeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(includeLibs));
+ File[] secondLibs = secondSetincludeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(secondSetincludeLibs));
+ Set<String> allLibs = new HashSet<String>(); // HACK: needed to be unique
because some jboss-*.jars are duplicated
+ for(File f : firstlibs) {
+ allLibs.add(f.getName());
+ }
+ for(File f : secondLibs) {
+ allLibs.add(f.getName());
+ }
+
+ StringBuffer testLibraries = new StringBuffer();
+
+ for (String file : allLibs) {
+ testLibraries.append("\t<classpathentry kind=\"lib\"
path=\"lib/" + file + "\"/>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ StringBuffer requiredProjects = new StringBuffer();
+ requiredProjects.append(
+ "\t<classpathentry combineaccessrules=\"false\"
kind=\"src\" path=\"/" + seamWebProject.getName() +
"\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
+ if(!SeamFacetAbstractInstallDelegate.isWarConfiguration(model)) {
+ requiredProjects.append("\n\t<classpathentry
combineaccessrules=\"false\" kind=\"src\" path=\"/" +
ejbProjectName + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ filterSet.addFilter("testLibraries",testLibraries.toString()); //$NON-NLS-1$
+ filterSet.addFilter("requiredProjects",requiredProjects.toString());
//$NON-NLS-1$
+ File testTemplateDir = null;
+ try {
+ testTemplateDir = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"test-seam2"); //$NON-NLS-1$
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return;
+ }
+ AntCopyUtils.FileSet excludeCvsSvn
+ = new
AntCopyUtils.FileSet(SeamFacetAbstractInstallDelegate.CVS_SVN).dir(testTemplateDir);
+
+ AntCopyUtils.copyFilesAndFolders(
+ testTemplateDir,
+ testProjectDir,
+ new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
+ new FilterSetCollection(filterSet), true);
+
+ excludeCvsSvn.dir(new File(seamRuntime.getHomeDir(), "bootstrap"));
//$NON-NLS-1$
+ AntCopyUtils.copyFilesAndFolders(
+ new File(seamRuntime.getHomeDir(), "bootstrap"), //$NON-NLS-1$
+ embededEjbDir,
+ new AntCopyUtils.FileSetFileFilter(excludeCvsSvn), new FilterSetCollection(), true);
+
+// AntCopyUtils.copyFileToFile(
+// persistenceFile,
+// new File(testProjectDir,"test-src/META-INF/persistence.xml"),
//$NON-NLS-1$
+// new FilterSetCollection(filterSet), true);
+
+ FilterSetCollection f = new FilterSetCollection();
+ f.addFilterSet(filterSet);
+ f.addFilterSet(jdbcFilterSet);
+
+ AntCopyUtils.copyFileToFile(
+ dataSourceFile,
+ new File(testProjectDir, "test-src/META-INF/"+seamWebProject.getName() +
"-test-ds.xml"), //$NON-NLS-1$
+ f, true);
+
+ AntCopyUtils.copyFileToFolder(
+ seamPropertiesFile,
+ testSrcDir, //$NON-NLS-1$
+ new FilterSetCollection(filterSet), true);
+
+ AntCopyUtils.copyFiles(
+ new File(seamRuntime.getHomeDir(), "lib"), //$NON-NLS-1$
+ testLibDir,
+ new AntCopyUtils.FileSetFileFilter(includeLibs));
+
+ //seam2 has a lib/test
+ AntCopyUtils.copyFiles(
+ new File(seamRuntime.getHomeDir(), "lib/test"), //$NON-NLS-1$
+ testLibDir,
+ new AntCopyUtils.FileSetFileFilter(includeLibs));
+
+ SeamFacetAbstractInstallDelegate.createComponentsProperties(testSrcDir, "",
true); //$NON-NLS-1$
+ }
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-09-29
15:29:53 UTC (rev 10542)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -10,17 +10,24 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.project.facet;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -52,6 +59,7 @@
import org.jboss.tools.seam.core.SeamCoreMessages;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
/**
*
@@ -77,6 +85,13 @@
public static String XHTML = "XHTML";
public static String WEB_RESOURCE_COLLECTION_PATTERN = "*.xhtml";
+ static AntCopyUtils.FileSet CVS_SVN = new AntCopyUtils.FileSet()
+ .include(".*") //$NON-NLS-1$
+ .exclude(".*/CVS") //$NON-NLS-1$
+ .exclude("CVS") //$NON-NLS-1$
+ .exclude(".*\\.svn") //$NON-NLS-1$
+ .exclude(".*/\\.svn"); //$NON-NLS-1$
+
/* (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)
*/
@@ -106,9 +121,88 @@
}
}
+ public static boolean toggleHibernateOnProject(IProject project, String
defaultConsoleName) {
+ IScopeContext scope = new ProjectScope(project);
+
+ Preferences node = scope.getNode("org.hibernate.eclipse.console");
+
+ if(node!=null) {
+ node.putBoolean("hibernate3.enabled", true );
+ node.put("default.configuration", defaultConsoleName );
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getDefault().logError("Could not save changes to
preferences", e);
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ try {
+ addProjectNature(project, "org.hibernate.eclipse.console.hibernateNature",
new NullProgressMonitor() );
+ return true;
+ } catch(CoreException ce) {
+ SeamCorePlugin.getDefault().logError("Could not activate Hibernate nature on
project " + project.getName(), ce);
+ return false;
+ }
+ }
+
/**
+ * Add the given project nature to the given project (if it isn't already added).
*
* @param project
+ * @param nature
+ * @param monitor
+ * @return true if nature where added, false if not
+ * @throws OperationCanceledException if job were canceled or CoreException if something
went wrong.
+ */
+ public static boolean addProjectNature(IProject project, String nature, IProgressMonitor
monitor) throws CoreException {
+ if (monitor != null && monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
+ if (!project.hasNature(nature)) {
+ IProjectDescription description = project.getDescription();
+ String[] prevNatures = description.getNatureIds();
+ String[] newNatures = new String[prevNatures.length + 1];
+ System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+ newNatures[prevNatures.length] = nature;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, monitor);
+ return true;
+ } else {
+ monitor.worked(1);
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @param model
+ * @return
+ */
+ static boolean isWarConfiguration(IDataModel model) {
+ return
"war".equals(model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
//$NON-NLS-1$
+ }
+
+ static void createComponentsProperties(final File seamGenResFolder, String projectName,
Boolean embedded) {
+ Properties components = new Properties();
+ String prefix = "".equals(projectName) ? "" : projectName +
"/"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ components.put("embeddedEjb", embedded.toString()); //$NON-NLS-1$
+ components.put("jndiPattern", prefix + "#{ejbName}/local");
//$NON-NLS-1$ //$NON-NLS-2$
+ File componentsProps = new File(seamGenResFolder, "components.properties");
//$NON-NLS-1$
+ try {
+ componentsProps.createNewFile();
+ components.store(new FileOutputStream(componentsProps), ""); //$NON-NLS-1$
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+
+ /**
+ *
+ * @param project
* @param fv
* @param config
* @param monitor
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-09-29
15:29:53 UTC (rev 10542)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegate.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -14,31 +14,24 @@
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.util.List;
import java.util.Properties;
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.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
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.javaee.web.WebFactory;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
@@ -52,8 +45,6 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
/**
* Install delegate for seam faset version 1.2
@@ -85,16 +76,6 @@
/**
*
*/
- public static final String TEST_WAR_PROFILE = "test-war"; //$NON-NLS-1$
-
- /**
- *
- */
- public static final String TEST_EAR_PROFILE = "test"; //$NON-NLS-1$
-
- /**
- *
- */
public static final AntCopyUtils.FileSet JBOSS_WAR_LIB_FILESET_WAR_CONFIG = new
AntCopyUtils.FileSet()
.include("ajax4jsf.*\\.jar") //$NON-NLS-1$
.include("richfaces.*\\.jar") //$NON-NLS-1$
@@ -136,20 +117,6 @@
/**
*
*/
- public static AntCopyUtils.FileSet JBOSS_TEST_LIB_FILESET = new AntCopyUtils.FileSet()
- .include("testng-.*-jdk15\\.jar") //$NON-NLS-1$
- .include("myfaces-api-.*\\.jar") //$NON-NLS-1$
- .include("myfaces-impl-.*\\.jar") //$NON-NLS-1$
- .include("servlet-api\\.jar") //$NON-NLS-1$
- .include("hibernate-all\\.jar") //$NON-NLS-1$
- .include("jboss-ejb3-all\\.jar") //$NON-NLS-1$
- .include("thirdparty-all\\.jar") //$NON-NLS-1$
- .exclude(".*/CVS") //$NON-NLS-1$
- .exclude(".*/\\.svn"); //$NON-NLS-1$
-
- /**
- *
- */
public static AntCopyUtils.FileSet JBOSS_WAR_LIB_FILESET_EAR_CONFIG = new
AntCopyUtils.FileSet()
.include("ajax4jsf.*\\.jar") //$NON-NLS-1$
.include("richfaces.*\\.jar") //$NON-NLS-1$
@@ -211,16 +178,6 @@
/**
*
*/
- public static AntCopyUtils.FileSet CVS_SVN = new AntCopyUtils.FileSet()
- .include(".*") //$NON-NLS-1$
- .exclude(".*/CVS") //$NON-NLS-1$
- .exclude("CVS") //$NON-NLS-1$
- .exclude(".*\\.svn") //$NON-NLS-1$
- .exclude(".*/\\.svn"); //$NON-NLS-1$
-
- /**
- *
- */
public static AntCopyUtils.FileSet JBOOS_WAR_WEBINF_SET = new AntCopyUtils.FileSet()
.include("WEB-INF") //$NON-NLS-1$
//.include("WEB-INF/web\\.xml") //$NON-NLS-1$
@@ -267,12 +224,8 @@
*/
public static String WEB_LIBRARIES_RELATED_PATH = "WEB-INF/lib";
//$NON-NLS-1$
- /**
- *
- */
- public void doExecute(final IProject project, IProjectFacetVersion fv,
- Object config, IProgressMonitor monitor) throws CoreException {
- final IDataModel model = (IDataModel)config;
+ private void doExecuteForWar(final IProject project, IProjectFacetVersion fv,
+ IDataModel model, IProgressMonitor monitor) throws CoreException {
// get WebContents folder path from DWP model
IVirtualComponent component = ComponentCore.createComponent(project);
@@ -281,7 +234,6 @@
IContainer webRootFolder = webRootVirtFolder.getUnderlyingFolder();
model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
- model.setProperty(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT, project.getName() +
"-test"); //$NON-NLS-1$
Boolean dbExists = (Boolean)
model.getProperty(ISeamFacetDataModelProperties.DB_ALREADY_EXISTS);
Boolean dbRecreate = (Boolean)
model.getProperty(ISeamFacetDataModelProperties.RECREATE_TABLES_AND_DATA_ON_DEPLOY);
@@ -310,7 +262,6 @@
final File seamHomeFolder = new File(seamHomePath);
final File seamLibFolder = new File(seamHomePath, SEAM_LIB_RELATED_PATH);
final File seamGenResFolder = new File(seamHomePath, "seam-gen/resources");
//$NON-NLS-1$
- final File seamGenResMetainfFolder = new File(seamGenResFolder, "META-INF");
//$NON-NLS-1$
final File droolsLibFolder = new File(seamHomePath, DROOLS_LIB_SEAM_RELATED_PATH);
final File seamGenHomeFolder = new File(seamHomePath, "seam-gen");
//$NON-NLS-1$
@@ -323,8 +274,6 @@
//final File hibernateConsolePref = new File(seamGenHomeFolder,
"hibernatetools/.settings/org.hibernate.eclipse.console.prefs"); //$NON-NLS-1$
final File persistenceFile = new File(seamGenResFolder,
"META-INF/persistence-" + (isWarConfiguration(model) ? DEV_WAR_PROFILE :
DEV_EAR_PROFILE) + ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
- final File applicationFile = new File(seamGenResFolder,
"META-INF/application.xml"); //$NON-NLS-1$
-
final FilterSet jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
final FilterSet projectFilterSet =
SeamFacetFilterSetFactory.createProjectFilterSet(model);
final FilterSet filtersFilterSet =
SeamFacetFilterSetFactory.createFiltersFilterSet(model);
@@ -350,7 +299,7 @@
AntCopyUtils.FileSet webInfSet = new
AntCopyUtils.FileSet(JBOOS_WAR_WEBINF_SET).dir(seamGenResFolder);
configureWebXml(project);
-
+
AntCopyUtils.copyFileToFile(
componentsFile,
new File(webInfFolder, "components.xml"), //$NON-NLS-1$
@@ -364,7 +313,7 @@
hibernateDialectFilterSet.addFilterSet(projectFilterSet);
hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
- createTestProject(model, project, selectedRuntime);
+// createTestProject(model, project, selectedRuntime);
//
********************************************************************************************
// Handle WAR/EAR configurations
@@ -389,7 +338,7 @@
//
********************************************************************************************
// Copy seam project indicator
//
********************************************************************************************
-
+
final IContainer source = srcRootFolder.getUnderlyingFolder();
IPath actionSrcPath = new Path(source.getFullPath().removeFirstSegments(1) +
"/action"); //$NON-NLS-1$
@@ -403,9 +352,9 @@
srcRootFolder.createLink(modelSrcPath, 0, null);
File actionsSrc = new File(project.getLocation().toFile(),
source.getFullPath().removeFirstSegments(1) + "/action/");
-
+
//AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,
"seam.properties"), actionsSrc, true); //$NON-NLS-1$
-
+
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$
@@ -458,7 +407,7 @@
} else {
filterSet.addFilter("driverJar", ""); //$NON-NLS-1$
//$NON-NLS-2$
}
-
+
File ejbTemplateDir = new
File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ejb");
AntCopyUtils.FileSet excludeCvsSvn = new
AntCopyUtils.FileSet(CVS_SVN).dir(ejbTemplateDir);
@@ -582,183 +531,32 @@
if (!isWarConfiguration(model)) {
IProject ejbProjectToBeImported = wsRoot.getProject(project.getName() +
"-ejb");
- ResourcesUtils.importExistingProject(ejbProjectToBeImported, wsPath + "/" +
project.getName() + "-ejb", project.getName() + "-ejb");
+ ResourcesUtils.importExistingProject(ejbProjectToBeImported, wsPath + "/" +
project.getName() + "-ejb", project.getName() + "-ejb", monitor,
false);
toggleHibernateOnProject(ejbProjectToBeImported, consoleName);
IProjectFacet sf = ProjectFacetsManager.getProjectFacet("jst.ejb");
IProjectFacetVersion pfv =
ProjectFacetsManager.create(ejbProjectToBeImported).getInstalledVersion(sf);
ClasspathHelper.addClasspathEntries(ejbProjectToBeImported, pfv);
IProject earProjectToBeImported = wsRoot.getProject(project.getName() +
"-ear");
- ResourcesUtils.importExistingProject(earProjectToBeImported, wsPath + "/" +
project.getName() + "-ear", project.getName() + "-ear");
+ ResourcesUtils.importExistingProject(earProjectToBeImported, wsPath + "/" +
project.getName() + "-ear", project.getName() + "-ear", monitor,
false);
}
-
- IProject testProjectToBeImported = wsRoot.getProject(project.getName() +
"-test");
- ResourcesUtils.importExistingProject(testProjectToBeImported, wsPath + "/" +
project.getName() + "-test", project.getName() + "-test");
- toggleHibernateOnProject(testProjectToBeImported, consoleName);
}
- /**
- *
- * @param model
- * @return
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#doExecute(org.eclipse.core.resources.IProject,
org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object,
org.eclipse.core.runtime.IProgressMonitor)
*/
- public static boolean isWarConfiguration(IDataModel model) {
- return
"war".equals(model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
//$NON-NLS-1$
- }
+ public void doExecute(final IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ final IDataModel model = (IDataModel)config;
- private void createTestProject(IDataModel model, IProject seamWebProject, SeamRuntime
seamRuntime) {
- String projectName =
model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME).toString();
- File testProjectDir = new
File(seamWebProject.getLocation().removeLastSegments(1).toFile(), projectName +
"-test"); //$NON-NLS-1$
- testProjectDir.mkdir();
-
- IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
- IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
-
- File testLibDir = new File(testProjectDir, "lib"); //$NON-NLS-1$
- File embededEjbDir = new File(testProjectDir, "embedded-ejb"); //$NON-NLS-1$
- File testSrcDir = new File(testProjectDir, "test-src"); //$NON-NLS-1$
- String seamGenResFolder = seamRuntime.getResourceTemplatesDir();
- File persistenceFile = new File(seamGenResFolder , "META-INF/persistence-" +
(isWarConfiguration(model) ? TEST_WAR_PROFILE:TEST_EAR_PROFILE) + ".xml");
//$NON-NLS-1$ //$NON-NLS-2$
- File jbossBeansFile = new File(seamGenResFolder ,
"META-INF/jboss-beans.xml"); //$NON-NLS-1$
- FilterSet filterSet = new FilterSet();
- filterSet.addFilter("projectName", projectName); //$NON-NLS-1$
- filterSet.addFilter("runtimeName",
WtpUtils.getServerRuntimeName(seamWebProject)); //$NON-NLS-1$
- filterSet.addFilter("webRootFolder",
webRootVirtFolder.getUnderlyingFolder().getFullPath().removeFirstSegments(1).toString());
//$NON-NLS-1$
-
- final SeamRuntime selectedRuntime =
SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
- final String seamHomePath = selectedRuntime.getHomeDir();
-
- AntCopyUtils.FileSet includeLibs
- = new AntCopyUtils.FileSet(JBOSS_TEST_LIB_FILESET)
- .dir(new File(seamRuntime.getHomeDir(), "lib")); //$NON-NLS-1$
- File[] libs = includeLibs.getDir().listFiles(new
AntCopyUtils.FileSetFileFilter(includeLibs));
- StringBuffer testLibraries = new StringBuffer();
-
- for (File file : libs) {
- testLibraries.append("\t<classpathentry kind=\"lib\"
path=\"lib/" + file.getName() + "\"/>\n"); //$NON-NLS-1$
//$NON-NLS-2$
- }
-
- StringBuffer requiredProjects = new StringBuffer();
- requiredProjects.append(
- "\t<classpathentry combineaccessrules=\"false\"
kind=\"src\" path=\"/" + seamWebProject.getName() +
"\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- if (!isWarConfiguration(model)) {
- requiredProjects.append(
- "\n\t<classpathentry combineaccessrules=\"false\"
kind=\"src\" path=\"/" + seamWebProject.getName() +
"-ejb\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- filterSet.addFilter("testLibraries", testLibraries.toString());
//$NON-NLS-1$
- filterSet.addFilter("requiredProjects", requiredProjects.toString());
//$NON-NLS-1$
- File testTemplateDir = null;
- try {
- testTemplateDir = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),
"test"); //$NON-NLS-1$
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- return;
- }
- AntCopyUtils.FileSet excludeCvsSvn
- = new AntCopyUtils.FileSet(CVS_SVN).dir(testTemplateDir);
-
- AntCopyUtils.copyFilesAndFolders(
- testTemplateDir,
- testProjectDir,
- new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
- new FilterSetCollection(filterSet), true);
-
- excludeCvsSvn.dir(new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"));
//$NON-NLS-1$
- AntCopyUtils.copyFiles(
- new File(seamRuntime.getHomeDir(), "embedded-ejb/conf"), //$NON-NLS-1$
- embededEjbDir,
- new AntCopyUtils.FileSetFileFilter(excludeCvsSvn));
-
- AntCopyUtils.copyFiles(
- new File(seamRuntime.getHomeDir(), "lib"), //$NON-NLS-1$
- testLibDir,
- new AntCopyUtils.FileSetFileFilter(includeLibs));
-
- createComponentsProperties(testSrcDir, "", Boolean.TRUE); //$NON-NLS-1$
+ doExecuteForWar(project, fv, model, monitor);
}
- /**
- *
- * @param seamGenResFolder
- * @param projectName
- * @param embedded
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.project.facet.SeamFacetAbstractInstallDelegate#configure(org.eclipse.jst.javaee.web.WebApp)
*/
- private void createComponentsProperties(final File seamGenResFolder, String projectName,
Boolean embedded) {
- Properties components = new Properties();
- String prefix = "".equals(projectName) ? "" : projectName +
"/"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- components.put("embeddedEjb", embedded.toString()); //$NON-NLS-1$
- components.put("jndiPattern", prefix + "#{ejbName}/local");
//$NON-NLS-1$ //$NON-NLS-2$
- File componentsProps = new File(seamGenResFolder, "components.properties");
//$NON-NLS-1$
- try {
- componentsProps.createNewFile();
- components.store(new FileOutputStream(componentsProps), ""); //$NON-NLS-1$
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
- }
-
- /**
- *
- * @param project
- * @param defaultConsoleName
- * @return
- */
- public static boolean toggleHibernateOnProject(IProject project, String
defaultConsoleName) {
- IScopeContext scope = new ProjectScope(project);
-
- Preferences node = scope.getNode("org.hibernate.eclipse.console");
-
- if (node != null) {
- node.putBoolean("hibernate3.enabled", true);
- node.put("default.configuration", defaultConsoleName);
- try {
- node.flush();
- } catch (BackingStoreException e) {
- SeamCorePlugin.getDefault().logError("Could not save changes to
preferences", e);
- return false;
- }
- } else {
- return false;
- }
-
- try {
- addProjectNature(project, "org.hibernate.eclipse.console.hibernateNature",
new NullProgressMonitor());
- return true;
- } catch (CoreException ce) {
- SeamCorePlugin.getDefault().logError("Could not activate Hibernate nature on
project " + project.getName(), ce);
- return false;
- }
- }
-
- /**
- * Add the given project nature to the given project (if it isn't already added).
- *
- * @param project
- * @param nature
- * @param monitor
- * @return true if nature where added, false if not
- * @throws OperationCanceledException if job were canceled or CoreException if something
went wrong.
- */
- public static boolean addProjectNature(IProject project, String nature, IProgressMonitor
monitor) throws CoreException {
- if (monitor != null && monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
-
- if (!project.hasNature(nature)) {
- IProjectDescription description = project.getDescription();
- String[] prevNatures = description.getNatureIds();
- String[] newNatures = new String[prevNatures.length + 1];
- System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
- newNatures[prevNatures.length] = nature;
- description.setNatureIds(newNatures);
- project.setDescription(description, monitor);
- return true;
- } else {
- monitor.worked(1);
- return false;
- }
- }
-
@Override
protected void configure(WebApp webApp) {
// Ajax4jsf (must come first!)
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -0,0 +1,99 @@
+ /*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.project.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.common.util.ResourcesUtils;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+
+/**
+ * @author Alexey Kazakov
+ * This is basic class that helps New Seam Wizard Page to create EJB, EAR and test
projects for seam WAR project.
+ */
+abstract public class SeamProjectCreator {
+
+ protected static final String TEST_WAR_PROFILE = "test-war"; //$NON-NLS-1$
+ protected static final String TEST_EAR_PROFILE = "test"; //$NON-NLS-1$
+
+ protected IDataModel model;
+ protected IProject seamWebProject;
+ protected SeamRuntime seamRuntime;
+ protected String earProjectName;
+ protected String ejbProjectName;
+ protected String testProjectName;
+
+ /**
+ * @param model Seam facet data model
+ * @param seamWebProject Seam web project
+ */
+ public SeamProjectCreator(IDataModel model, IProject seamWebProject) {
+ this.model = model;
+ this.seamWebProject = seamWebProject;
+
+ seamRuntime =
SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
+ if(seamRuntime==null) {
+ throw new RuntimeException("Can't get seam runtime " +
model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
+ }
+
+ // Set default project names
+ earProjectName = seamWebProject.getName() + "-ear";
+ ejbProjectName = seamWebProject.getName() + "-ejb";
+ testProjectName = seamWebProject.getName() + "-test";
+ }
+
+ public IDataModel getModel() {
+ return model;
+ }
+
+ public void setModel(IDataModel model) {
+ this.model = model;
+ }
+
+ /**
+ * Creates test project for seam web project in case of WAR deployment and test, EAR and
EJB projects in case of EAR deployment.
+ * @param monitor
+ * @throws CoreException
+ */
+ public void execute(IProgressMonitor monitor) throws CoreException {
+ createTestProject();
+ final String consoleName = SeamFacetAbstractInstallDelegate.isWarConfiguration(model) ?
seamWebProject.getName() : ejbProjectName;
+
+ String wsPath =
seamWebProject.getLocation().removeLastSegments(1).toFile().getAbsoluteFile().getPath();
+ IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject testProjectToBeImported = wsRoot.getProject(testProjectName);
+
+ ResourcesUtils.importExistingProject(testProjectToBeImported, wsPath + "/" +
testProjectName, testProjectName, monitor, true);
+ SeamFacetAbstractInstallDelegate.toggleHibernateOnProject(testProjectToBeImported,
consoleName);
+ }
+
+ /**
+ * Creates test project for given seam web project.
+ */
+ abstract protected void createTestProject();
+
+ /**
+ * Creates test project for given seam web project.
+ * @param testProjectName
+ */
+ protected void createTestProject(String testProjectName) {
+ if(testProjectName==null) {
+ throw new IllegalArgumentException("Test project name must not be null");
+ }
+ this.testProjectName = testProjectName;
+ createTestProject();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-09-29
15:29:53 UTC (rev 10542)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -219,6 +219,14 @@
}
/**
+ *
+ * @return
+ */
+ public IDataModel getConfig() {
+ return model;
+ }
+
+ /**
* Finish has been pressed.
*/
public void transferStateToConfig() {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2008-09-29
15:29:53 UTC (rev 10542)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2008-09-29
16:00:28 UTC (rev 10543)
@@ -15,6 +15,9 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jst.servlet.ui.project.facet.WebProjectFirstPage;
@@ -48,8 +51,12 @@
import org.eclipse.wst.server.ui.ServerUIUtil;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
+import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.internal.core.project.facet.Seam1ProjectCreator;
+import org.jboss.tools.seam.internal.core.project.facet.Seam2ProjectCreator;
import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetProjectCreationDataModelProvider;
+import org.jboss.tools.seam.internal.core.project.facet.SeamProjectCreator;
import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.SeamInstallWizardPage;
@@ -188,6 +195,31 @@
return super.performFinish();
}
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard#performFinish(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void performFinish(final IProgressMonitor monitor) throws CoreException {
+ super.performFinish(monitor);
+ IProject project = this.getFacetedProject().getProject();
+
+ SeamInstallWizardPage page =
(SeamInstallWizardPage)getPage(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_FACET);
+ IDataModel model = page.getConfig();
+
+ String seamVersionString =
model.getProperty(IFacetDataModelProperties.FACET_VERSION_STR).toString();
+ SeamVersion seamVersion = SeamVersion.parseFromString(seamVersionString);
+ SeamProjectCreator creator = null;
+ if(seamVersion == SeamVersion.SEAM_1_2) {
+ creator = new Seam1ProjectCreator(model, project);
+ } else if(seamVersion == SeamVersion.SEAM_2_0) {
+ creator = new Seam2ProjectCreator(model, project);
+ } else {
+ throw new RuntimeException("Can't get seam version from seam facet
model");
+ }
+
+ creator.execute(monitor);
+ }
+
class SeamWebProjectFirstPage extends WebProjectFirstPage {
@Override
protected String getInfopopID() {