[jbosstools-commits] JBoss Tools SVN: r6688 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Mar 5 05:25:32 EST 2008


Author: akazakov
Date: 2008-03-05 05:25:31 -0500 (Wed, 05 Mar 2008)
New Revision: 6688

Modified:
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1322

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-03-05 09:43:42 UTC (rev 6687)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2FacetInstallDelegate.java	2008-03-05 10:25:31 UTC (rev 6688)
@@ -33,7 +33,6 @@
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.core.runtime.preferences.IScopeContext;
 import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
 import org.eclipse.wst.common.componentcore.ComponentCore;
@@ -59,8 +58,7 @@
 	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$
 		.include("richfaces.*\\.jar")
@@ -87,7 +85,7 @@
 		.include("stringtemplate.*\\.jar") //$NON-NLS-1$
 	    .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$
@@ -104,7 +102,7 @@
 		.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$
@@ -117,8 +115,7 @@
 		.include("jboss-seam-remoting\\.jar") //$NON-NLS-1$
 		.include("jboss-seam-ui\\.jar") //$NON-NLS-1$
 		.include("jsf-facelets\\.jar"); //$NON-NLS-1$
-		
-	
+
 	public static AntCopyUtils.FileSet JBOSS_EAR_CONTENT  = new AntCopyUtils.FileSet()
 		.include("antlr-runtime.jar") //$NON-NLS-1$
 		.include("drools-compiler.*\\.jar") //$NON-NLS-1$
@@ -133,7 +130,7 @@
 		.include("META-INF/application\\.xml") //$NON-NLS-1$
 		.include("META-INF/jboss-app\\.xml"); //$NON-NLS-1$
 		*/
-	
+
 	public static AntCopyUtils.FileSet VIEW_FILESET = new AntCopyUtils.FileSet()
 		.include("home\\.xhtml") //$NON-NLS-1$
 		.include("error\\.xhtml") //$NON-NLS-1$
@@ -149,14 +146,14 @@
 		.exclude(".*/.*\\.ftl") //$NON-NLS-1$
 		.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$
@@ -164,24 +161,24 @@
 		.include("WEB-INF/jboss-web\\.xml") //$NON-NLS-1$
 		.include("WEB-INF/faces-config\\.xml") //$NON-NLS-1$
 		.include("WEB-INF/componets\\.xml"); //$NON-NLS-1$
-	
+
 	public static AntCopyUtils.FileSet JBOOS_WAR_WEB_INF_CLASSES_SET = new AntCopyUtils.FileSet()
 		.include("import\\.sql") //$NON-NLS-1$
 		.include("security\\.drl") //$NON-NLS-1$
 		.include("seam\\.properties") //$NON-NLS-1$
 		.include("messages_en\\.properties"); //$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 String DROOLS_LIB_SEAM_RELATED_PATH = "lib"; //$NON-NLS-1$
-	
+
 	public static String SEAM_LIB_RELATED_PATH = "lib"; //$NON-NLS-1$
-	
+
 	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;
@@ -191,10 +188,10 @@
 		IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new Path("/")); //$NON-NLS-1$
 		final IVirtualFolder srcRootFolder = component.getRootFolder().getFolder(new Path("/WEB-INF/classes")); //$NON-NLS-1$
 		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);
 		if(!dbExists && !dbRecreate) {
@@ -204,11 +201,9 @@
 		} else if(dbRecreate) {
 			model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,"create-drop"); //$NON-NLS-1$
 		}
-		
-		
+
 		final String consoleName = isWarConfiguration(model)?project.getName():project.getName()+"-ejb";
-		
-		
+
 		final File webContentFolder = webRootFolder.getLocation().toFile();
 		final File webInfFolder = new File(webContentFolder,"WEB-INF"); //$NON-NLS-1$
 		final File webInfClasses = new File(webInfFolder,"classes"); //$NON-NLS-1$
@@ -220,29 +215,29 @@
 		final SeamRuntime selectedRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
 
 		final String seamHomePath = selectedRuntime.getHomeDir();
-		
+
 		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$
 		final File seamGenViewSource = new File(seamGenHomeFolder,"view"); //$NON-NLS-1$
 		final File dataSourceDsFile = new File(seamGenResFolder, "datasource-ds.xml"); //$NON-NLS-1$
 		final File componentsFile = new File(seamGenResFolder,"WEB-INF/components"+(isWarConfiguration(model)?"-war":"")+".xml"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-		
+
 		final File hibernateConsoleLaunchFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.launch"); //$NON-NLS-1$
 		final File hibernateConsolePropsFile = new File(seamGenHomeFolder, "hibernatetools/hibernate-console.properties"); //$NON-NLS-1$
 		//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);
-		
+
 		// ****************************************************************
 		// Copy view folder from seam-gen installation to WebContent folder
 		// ****************************************************************
@@ -251,52 +246,49 @@
 		viewFilterSetCollection.addFilterSet(jdbcFilterSet);
 		viewFilterSetCollection.addFilterSet(projectFilterSet);
 		viewFilterSetCollection.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
-		
+
 		AntCopyUtils.copyFilesAndFolders(
 				seamGenViewSource, 
 				webContentFolder, 
 				new AntCopyUtils.FileSetFileFilter(viewFileSet), 
 				viewFilterSetCollection, 
 				true);
-		
+
 		// *******************************************************************
 		// Copy manifest and configuration resources the same way as view
 		// *******************************************************************
 		AntCopyUtils.FileSet webInfSet = new AntCopyUtils.FileSet(JBOOS_WAR_WEBINF_SET).dir(seamGenResFolder);
-		
+
 		AntCopyUtils.copyFileToFile(
 				componentsFile,
 				new File(webInfFolder,"components.xml"), //$NON-NLS-1$
 				new FilterSetCollection(projectFilterSet), true);
-		
+
 		AntCopyUtils.copyFilesAndFolders(
 				seamGenResFolder,webContentFolder,new AntCopyUtils.FileSetFileFilter(webInfSet), viewFilterSetCollection, true);
-		
 
 		final FilterSetCollection hibernateDialectFilterSet = new FilterSetCollection();
 		hibernateDialectFilterSet.addFilterSet(jdbcFilterSet);
 		hibernateDialectFilterSet.addFilterSet(projectFilterSet);
 		hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
-		
-	
+
 		createTestProject(model,project,selectedRuntime);
 
 		// ********************************************************************************************
 		// Handle WAR/EAR configurations
 		// ********************************************************************************************
 		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);
-			
+
 			createComponentsProperties(srcFolder, isWarConfiguration(model)?"":project.getName()+"-ear", false); //$NON-NLS-1$ //$NON-NLS-2$
-			
+
 			/*AntCopyUtils.copyFileToFolder(
 					hibernateConsolePref,
 					new File(project.getLocation().toFile(),".settings"),	 //$NON-NLS-1$
 					new FilterSetCollection(projectFilterSet), true);*/
-			
+
 			// In case of WAR configuration
 			AntCopyUtils.copyFiles(seamHomeFolder,webLibFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_WAR_CONFIG).dir(seamHomeFolder)));
 			AntCopyUtils.copyFiles(seamLibFolder,webLibFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_WAR_CONFIG).dir(seamLibFolder)));
@@ -307,17 +299,17 @@
 			// ********************************************************************************************
 			AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"seam.properties"), srcFolder, true); //$NON-NLS-1$
 			final IContainer source = srcRootFolder.getUnderlyingFolder();
-			
+
 			IPath actionSrcPath = new Path(source.getFullPath().removeFirstSegments(1)+"/action"); //$NON-NLS-1$
 			IPath modelSrcPath = new Path(source.getFullPath().removeFirstSegments(1)+"/model"); //$NON-NLS-1$
 
 			srcRootFolder.delete(IVirtualFolder.FORCE, monitor);
 			WtpUtils.createSourceFolder(project, actionSrcPath, source.getFullPath().removeFirstSegments(1), new Path(webRootFolder.getLocation().lastSegment()+"/WEB-INF/dev")); //$NON-NLS-1$
 			WtpUtils.createSourceFolder(project, modelSrcPath, source.getFullPath().removeFirstSegments(1), null);			
-		
+
 			srcRootFolder.createLink(actionSrcPath, 0, null);
 			srcRootFolder.createLink(modelSrcPath, 0, null);					
-			
+
 			AntCopyUtils.copyFileToFile(
 					new File(seamGenHomeFolder,"src/Authenticator.java"), //$NON-NLS-1$
 					new File(project.getLocation().toFile(),source.getFullPath().removeFirstSegments(1)+"/action/" + model.getProperty(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME).toString().replace('.', '/')+"/"+"Authenticator.java"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -325,7 +317,7 @@
 
 			// Needed to make sure /dev is picked up by test, so need seam.properties.
 			AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"seam.properties"), new File(project.getLocation().toFile(),source.getFullPath().lastSegment()+"/action"), true); //$NON-NLS-1$
-			
+
 			AntCopyUtils.copyFileToFile(
 					persistenceFile,
 					new File(srcFolder,"META-INF/persistence.xml"), //$NON-NLS-1$
@@ -336,30 +328,29 @@
 					dataSourceDsFile, 
 					new File(resources,project.getName()+"-ds.xml"),  //$NON-NLS-1$
 					viewFilterSetCollection, true);
-			
+
 			// to fix seam2 tests for war deployment 
 //			File srcModelMetaInf = new File(project.getLocation().append(modelSrcPath).toFile(),"META-INF");
 //			AntCopyUtils.copyFileToFile(
 //					dataSourceDsFile, 
 //					new File(srcModelMetaInf,project.getName()+"-ds.xml"),  //$NON-NLS-1$
 //					viewFilterSetCollection, true);
-			
+
 			AntCopyUtils.copyFileToFile(
 					hibernateConsoleLaunchFile, 
 					new File(project.getLocation().toFile(),project.getName()+".launch"),  //$NON-NLS-1$
 					viewFilterSetCollection, true);
-			
+
 			AntCopyUtils.copyFileToFolder(
 					hibernateConsolePropsFile, 
 					project.getLocation().toFile(),
 					hibernateDialectFilterSet, true);
-			
-			WtpUtils.setClasspathEntryAsExported(project, new Path("org.eclipse.jst.j2ee.internal.web.container"), monitor); //$NON-NLS-1$
 
+			WtpUtils.setClasspathEntryAsExported(project, new Path("org.eclipse.jst.j2ee.internal.web.container"), monitor); //$NON-NLS-1$
 		} else {
 			model.setProperty(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, project.getName()+"-ejb"); //$NON-NLS-1$
 			model.setProperty(ISeamFacetDataModelProperties.SEAM_EAR_PROJECT, project.getName()+"-ear"); //$NON-NLS-1$
-			
+
 			// In case of EAR configuration
 			AntCopyUtils.copyFiles(seamHomeFolder,webLibFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamHomeFolder)));
 			AntCopyUtils.copyFiles(seamLibFolder,webLibFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamLibFolder)));
@@ -370,7 +361,7 @@
 			File ejb = new File(project.getLocation().removeLastSegments(1).toFile(),model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ejb"); //$NON-NLS-1$
 			ear.mkdir();
 			ejb.mkdir();
-			
+
 			try {
 				FilterSet filterSet = new FilterSet();
 				filterSet.addFilter("projectName", project.getName()); //$NON-NLS-1$
@@ -382,12 +373,12 @@
 					filterSet.addFilter("driverJar",""); //$NON-NLS-1$ //$NON-NLS-2$
 				}
 				AntCopyUtils.FileSet excludeCvsSvn = new AntCopyUtils.FileSet(CVS_SVN).dir(seamGenResFolder);
-				
+
 				AntCopyUtils.copyFilesAndFolders(
 						new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ejb"),  //$NON-NLS-1$
 						ejb, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
 						new FilterSetCollection(filterSet), true);
-				
+
 				// *******************************************************************************************
 				// Copy sources to ejb project in case of EAR configuration
 				// *******************************************************************************************
@@ -399,14 +390,13 @@
 						persistenceFile,
 						new File(ejb,"ejbModule/META-INF/persistence.xml"), //$NON-NLS-1$
 						viewFilterSetCollection, true);
-				
+
 				createComponentsProperties(new File(ejb,"ejbModule"), isWarConfiguration(model)?"":project.getName()+"-ear", 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.copyFilesAndFolders(
 						seamGenResFolder,new File(ejb,"ejbModule"),new AntCopyUtils.FileSetFileFilter(ejbSrcResourcesSet), viewFilterSetCollection, true); //$NON-NLS-1$
-		
-				
+
 				// ********************************************************************************************
 				// Copy seam project indicator
 				// ********************************************************************************************
@@ -416,41 +406,41 @@
 				// Copy security.drl to source folder
 				// ********************************************************************************************
 				AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"security.drl"), new File(ejb,"ejbModule/"), true); //$NON-NLS-1$ //$NON-NLS-2$
-				
+
 				File resources = new File(ear,"resources");
 				AntCopyUtils.copyFileToFile(
 						dataSourceDsFile, 
 						new File(resources,project.getName()+"-ds.xml"),  //$NON-NLS-1$ //$NON-NLS-2$
 						viewFilterSetCollection, true);
-				
+
 				AntCopyUtils.copyFileToFolder(
 						new File(seamGenResFolder,"META-INF/ejb-jar.xml"),  //$NON-NLS-1$
 						new File(ejb,"ejbModule/META-INF/"),  //$NON-NLS-1$
 						viewFilterSetCollection, true);
-				
+
 				/*AntCopyUtils.copyFileToFolder(
 						hibernateConsolePref,
 						new File(ejb,".settings"), //$NON-NLS-1$
 						new FilterSetCollection(projectFilterSet), true);*/
-				
+
 				FilterSet ejbFilterSet =  new FilterSet();
 				ejbFilterSet.addFilter("projectName",ejb.getName()); //$NON-NLS-1$
-				
+
 				AntCopyUtils.copyFileToFile(
 						hibernateConsoleLaunchFile, 
 						new File(ejb,ejb.getName()+".launch"),  //$NON-NLS-1$
 						new FilterSetCollection(ejbFilterSet), true);
-				
+
 				AntCopyUtils.copyFileToFolder(
 						hibernateConsolePropsFile, 
 						ejb,
 						hibernateDialectFilterSet, true);
-				
+
 				File earContentsFolder = new File(ear,"EarContent"); //$NON-NLS-1$
 
 				FilterSet earFilterSet =  new FilterSet();
 				earFilterSet.addFilter("projectName",ear.getName()+".ear"); //$NON-NLS-1$ //$NON-NLS-2$
-				
+
 			    AntCopyUtils.copyFileToFolder(
 						new File(seamGenResFolder,"META-INF/jboss-app.xml"), //$NON-NLS-1$
 						new File(earContentsFolder,"META-INF"), //$NON-NLS-1$
@@ -461,54 +451,47 @@
 						new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ear-seam2"),  //$NON-NLS-1$
 						ear, new AntCopyUtils.FileSetFileFilter(excludeCvsSvn),
 						new FilterSetCollection(filterSet), true);
-				
+
 				// Fill ear contents
 				AntCopyUtils.copyFiles(seamHomeFolder,earContentsFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamHomeFolder)));
 				AntCopyUtils.copyFiles(seamLibFolder,earContentsFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamLibFolder)));
 				AntCopyUtils.copyFiles(droolsLibFolder,earContentsFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(droolsLibFolder)));
 				AntCopyUtils.copyFiles(seamLibFolder,earContentsFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamLibFolder)));
 				AntCopyUtils.copyFiles(seamGenResFolder,earContentsFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_EAR_CONTENT).dir(seamGenResFolder)));						
-				
-				try {
-					
-					File[] earJars = earContentsFolder.listFiles(new FilenameFilter() {
-						/* (non-Javadoc)
-						 * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
-						 */
-						public boolean accept(File dir, String name) {
-							if(name.lastIndexOf(".jar")>0) return true; //$NON-NLS-1$
-							return false;
-						}
-					});
-					String earJarsStr = ""; //$NON-NLS-1$
-					for (File file : earJars) {
-						earJarsStr +=" " + file.getName() +" \n"; //$NON-NLS-1$ //$NON-NLS-2$
+
+				File[] earJars = earContentsFolder.listFiles(new FilenameFilter() {
+					/* (non-Javadoc)
+					 * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
+					 */
+					public boolean accept(File dir, String name) {
+						if(name.lastIndexOf(".jar")>0) return true; //$NON-NLS-1$
+						return false;
 					}
-					
-					FilterSetCollection manifestFilterCol = new FilterSetCollection(projectFilterSet);
-					FilterSet manifestFilter = new FilterSet();
-					manifestFilter.addFilter("earLibs",earJarsStr); //$NON-NLS-1$
-					manifestFilterCol.addFilterSet(manifestFilter);
-					AntCopyUtils.copyFileToFolder(new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"war/META-INF/MANIFEST.MF"), webMetaInf, manifestFilterCol, true); //$NON-NLS-1$
-					File ejbMetaInf = new File(ejb,"ejbModule/META-INF"); //$NON-NLS-1$
-					AntCopyUtils.copyFileToFolder(new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ejb/ejbModule/META-INF/MANIFEST.MF"), ejbMetaInf, manifestFilterCol, true); //$NON-NLS-1$
-				} catch (IOException e) {
-					SeamCorePlugin.getPluginLog().logError(e);
+				});
+				String earJarsStr = ""; //$NON-NLS-1$
+				for (File file : earJars) {
+					earJarsStr +=" " + file.getName() +" \n"; //$NON-NLS-1$ //$NON-NLS-2$
 				}
-				
+
+				FilterSetCollection manifestFilterCol = new FilterSetCollection(projectFilterSet);
+				FilterSet manifestFilter = new FilterSet();
+				manifestFilter.addFilter("earLibs",earJarsStr); //$NON-NLS-1$
+				manifestFilterCol.addFilterSet(manifestFilter);
+				AntCopyUtils.copyFileToFolder(new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"war/META-INF/MANIFEST.MF"), webMetaInf, manifestFilterCol, true); //$NON-NLS-1$
+				File ejbMetaInf = new File(ejb,"ejbModule/META-INF"); //$NON-NLS-1$
+				AntCopyUtils.copyFileToFolder(new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ejb/ejbModule/META-INF/MANIFEST.MF"), ejbMetaInf, manifestFilterCol, true); //$NON-NLS-1$
 			} catch (IOException e) {
 				SeamCorePlugin.getPluginLog().logError(e);
 			}
 		}
 
 		ClasspathHelper.addClasspathEntries(project, fv);
-		
+
 		createSeamProjectPreferenes(project, model);
-		
 
 		EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
 		toggleHibernateOnProject(project, consoleName);
-		
+
 		project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
 		String wsPath = project.getLocation().removeLastSegments(1)
 		                             .toFile().getAbsoluteFile().getPath();
@@ -516,81 +499,34 @@
 		IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
 
 		if(!isWarConfiguration(model)) {
-			
 			IProject ejbProjectToBeImported = wsRoot.getProject(project.getName()+"-ejb");
 			ResourcesUtils.importExistingProject(ejbProjectToBeImported, wsPath+"/"+project.getName()+"-ejb", project.getName()+"-ejb");
 			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");
 		}
-		
+
 		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$
 	}
-	
-	
-	/**
-	 * @param project
-	 * @param model
-	 */
-	protected void createSeamProjectPreferenes(final IProject project,
-			final IDataModel model) {
-		IScopeContext projectScope = new ProjectScope(project);
-		IEclipsePreferences prefs = projectScope.getNode(SeamCorePlugin.PLUGIN_ID);
-		
-		prefs.put(JBOSS_AS_DEPLOY_AS, model.getProperty(JBOSS_AS_DEPLOY_AS).toString());
-		
-		prefs.put(SEAM_RUNTIME_NAME, model.getProperty(SEAM_RUNTIME_NAME).toString());
-		
-		prefs.put(SEAM_CONNECTION_PROFILE,model.getProperty(SEAM_CONNECTION_PROFILE).toString());
-		
-		prefs.put(SESSION_BEAN_PACKAGE_NAME, model.getProperty(SESSION_BEAN_PACKAGE_NAME).toString());
-		
-		prefs.put(ENTITY_BEAN_PACKAGE_NAME, model.getProperty(ENTITY_BEAN_PACKAGE_NAME).toString());
-		
-		prefs.put(TEST_CASES_PACKAGE_NAME, model.getProperty(TEST_CASES_PACKAGE_NAME).toString());
-	
-		prefs.put(SEAM_TEST_PROJECT, 
-				model.getProperty(SEAM_TEST_PROJECT)==null?
-						"":model.getProperty(SEAM_TEST_PROJECT).toString()); //$NON-NLS-1$
-		
-		if(DEPLOY_AS_EAR.equals(model.getProperty(JBOSS_AS_DEPLOY_AS))) {
-			prefs.put(SEAM_EJB_PROJECT, 
-					model.getProperty(SEAM_EJB_PROJECT)==null?
-							"":model.getProperty(SEAM_EJB_PROJECT).toString()); //$NON-NLS-1$
-			
-			prefs.put(SEAM_EAR_PROJECT, 
-					model.getProperty(SEAM_EAR_PROJECT)==null?
-							"":model.getProperty(SEAM_EAR_PROJECT).toString()); //$NON-NLS-1$
-		}
-		
-		try {
-			prefs.flush();
-		} catch (BackingStoreException e) {
-			SeamCorePlugin.getPluginLog().logError(e);
-		}
-	}
 
 	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$
@@ -607,17 +543,17 @@
 			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
@@ -627,13 +563,13 @@
 			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$
@@ -652,13 +588,13 @@
 			}
 			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$
@@ -669,11 +605,11 @@
 //					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$
@@ -714,12 +650,12 @@
 			SeamCorePlugin.getPluginLog().logError(e);
 		}
 	}
-	
+
 	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 );
@@ -732,7 +668,7 @@
 		} else {
 			return false;
 		}
-		
+
 		try {
 			addProjectNature(project, "org.hibernate.eclipse.console.hibernateNature", new NullProgressMonitor() );
 			return true;
@@ -740,9 +676,8 @@
 			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
@@ -752,7 +687,7 @@
 		if (monitor != null && monitor.isCanceled() ) {
 			throw new OperationCanceledException();
 		}
-		
+
 		if (!project.hasNature(nature) ) {
 			IProjectDescription description = project.getDescription();
 			String[] prevNatures= description.getNatureIds();
@@ -767,4 +702,4 @@
 			return false;
 		}
 	}
-}
+}
\ No newline at end of file




More information about the jbosstools-commits mailing list