Author: dgeraskov
Date: 2009-11-16 09:04:39 -0500 (Mon, 16 Nov 2009)
New Revision: 18695
Modified:
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-4988
In performFinish method uninstall jpa-facet from <project> and install it to
<project-ejb>
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 2009-11-16
14:01:10 UTC (rev 18694)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2009-11-16
14:04:39 UTC (rev 18695)
@@ -18,20 +18,21 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
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.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
@@ -59,6 +60,7 @@
import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
import org.eclipse.wst.common.project.facet.core.IPreset;
@@ -73,7 +75,6 @@
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.ui.ServerUIUtil;
-import org.eclipse.wst.validation.internal.operations.ValidationBuilder;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.tools.jst.web.server.RegistrationHelper;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -95,6 +96,7 @@
* @author eskimo
*
*/
+@SuppressWarnings("restriction")
public class SeamProjectWizard extends WebProjectWizard {
private SeamWebProjectFirstPage firstPage;
@@ -266,9 +268,27 @@
SeamInstallWizardPage page =
(SeamInstallWizardPage)getPage(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_FACET);
page.finishPressed();
IDataModel model = page.getConfig();
- model.setProperty(ISeamFacetDataModelProperties.CREATE_EAR_PROJECTS, Boolean.TRUE);
+ model.setProperty(ISeamFacetDataModelProperties.CREATE_EAR_PROJECTS, Boolean.TRUE);
+ boolean isEAR =
ISeamFacetDataModelProperties.DEPLOY_AS_EAR.equalsIgnoreCase(model.getStringProperty(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
+ IFacetedProjectWorkingCopy fpwc = getFacetedProjectWorkingCopy();
+ IProjectFacet jpaFacet = ProjectFacetsManager.getProjectFacet("jpt.jpa");
+ IProjectFacetVersion pfv = fpwc.getProjectFacetVersion(jpaFacet);
+
+ if (isEAR && pfv != null){
+ //remove jpa facet from <project>
+ // and add it to <project>-ejb with the same model
+ action = fpwc.getProjectFacetAction(jpaFacet);
+ IDataModel dataModel = (IDataModel) action.getConfig();
+ String connectionProfileName =
dataModel.getStringProperty("JpaFacetDataModelProperties.CONNECTION");
+ if (connectionProfileName == null) throw new NullPointerException("Jpa connection
profile is null");
+ page.setJpaConnectionProfile(connectionProfileName);
+ fpwc.removeProjectFacet(jpaFacet);
+ }
+
return super.performFinish();
}
+
+ Action action = null;
/*
* (non-Javadoc)
@@ -303,10 +323,24 @@
projects.add(ejbProject);
projects.add(earProject);
}
-
-
+
if(ejbProject != null) {
provideClassPath(projects, ejbProject);
+ if (action != null) {
+ IDataModel jpaModel = (IDataModel) action.getConfig();
+ boolean isHibernatePlatform = "hibernate".equals(
+ jpaModel.getStringProperty("JpaFacetDataModelProperties.PLATFORM_ID"));
+ if (isHibernatePlatform){
+ IFile hibernateLaunchFile = ejbProject.getFile(ejbProject.getName() +
".launch"); //$NON-NLS-1$
+ if (hibernateLaunchFile.exists()){//delete the launch configuration to prevent
doubling
+ hibernateLaunchFile.delete(1, monitor);
+ }
+ }
+
+ IFacetedProject facetedProject = ProjectFacetsManager.create(ejbProject, true,
null);
+ //add facet
+ facetedProject.installProjectFacet(action.getProjectFacetVersion(),
action.getConfig(), null);
+ }
}
buildProjects(projects, monitor);