Author: snjeza
Date: 2010-06-14 05:03:11 -0400 (Mon, 14 Jun 2010)
New Revision: 22779
Added:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/CDIProjectConfigurator.java
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.properties
trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/Messages.java
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/JSFProjectConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/messages.properties
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencePage.java
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencesInitializer.java
Log:
https://jira.jboss.org/browse/JBIDE-6412 Add CDI Maven configurator
Modified: trunk/maven/plugins/org.jboss.tools.maven.seam/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.seam/META-INF/MANIFEST.MF 2010-06-12
09:46:44 UTC (rev 22778)
+++ trunk/maven/plugins/org.jboss.tools.maven.seam/META-INF/MANIFEST.MF 2010-06-14
09:03:11 UTC (rev 22779)
@@ -16,7 +16,8 @@
org.eclipse.jst.j2ee.core,
org.eclipse.jst.j2ee,
org.eclipse.wst.common.emfworkbench.integration,
- org.eclipse.jst.jsf.core
+ org.eclipse.jst.jsf.core,
+ org.jboss.tools.cdi.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor
Modified: trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.properties 2010-06-12 09:46:44
UTC (rev 22778)
+++ trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.properties 2010-06-14 09:03:11
UTC (rev 22779)
@@ -2,6 +2,7 @@
Bundle-Vendor = JBoss by Red Hat
Bundle-Name = Integration Seam projects with Maven
Seam_Project_configurator = Seam Project configurator
+CDI_Project_configurator = CDI Project configurator
JSF_Project_configurator = JSF Project configurator
Portlet_Core_Project_configurator = Portlet Core Project configurator
JBoss_Maven_Integration = JBoss Maven Integration
\ No newline at end of file
Modified: trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.xml 2010-06-12 09:46:44 UTC (rev
22778)
+++ trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.xml 2010-06-14 09:03:11 UTC (rev
22779)
@@ -16,6 +16,13 @@
<extension point="org.maven.ide.eclipse.projectConfigurators">
<configurator
+ id="org.jboss.tools.maven.cdi.configurator"
+
class="org.jboss.tools.maven.seam.configurators.CDIProjectConfigurator"
+ name="%CDI_Project_configurator" priority="250"/>
+ </extension>
+
+ <extension point="org.maven.ide.eclipse.projectConfigurators">
+ <configurator
id="org.jboss.tools.maven.jsf.configurator"
class="org.jboss.tools.maven.seam.configurators.JSFProjectConfigurator"
name="%JSF_Project_configurator" priority="150"/>
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java 2010-06-12
09:46:44 UTC (rev 22778)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java 2010-06-14
09:03:11 UTC (rev 22779)
@@ -40,6 +40,7 @@
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.cdi.internal.core.project.facet.CDIFacetInstallDataModelProvider;
import org.jboss.tools.maven.core.IJBossMavenConstants;
import org.jboss.tools.maven.core.MavenCoreActivator;
import org.jboss.tools.seam.core.SeamUtil;
@@ -104,6 +105,10 @@
public static final boolean CONFIGURE_SEAMPORTLET_VALUE = true;
+ public static final String CONFIGURE_CDI = "configureCDI"; //$NON-NLS-1$
+
+ public static final boolean CONFIGURE_CDI_VALUE = true;
+
// The shared instance
private static MavenSeamActivator plugin;
@@ -925,4 +930,10 @@
return config;
}
+
+ public IDataModel createCDIDataModel(IFacetedProject fproj, IProjectFacetVersion
facetVersion) {
+ IDataModel config = (IDataModel) new CDIFacetInstallDataModelProvider().create();
+
+ return config;
+ }
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/Messages.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/Messages.java 2010-06-12
09:46:44 UTC (rev 22778)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/Messages.java 2010-06-14
09:03:11 UTC (rev 22779)
@@ -13,6 +13,7 @@
public static String SeamConfiguratorPreferencePage_Configure_JBoss_Portlet_Core_facet;
public static String SeamConfiguratorPreferencePage_Configure_JBoss_Seam_Portlet_facet;
public static String SeamConfiguratorPreferencePage_Configure_JSF_facet;
+ public static String SeamConfiguratorPreferencePage_Configure_CDI_facet;
public static String SeamConfiguratorPreferencePage_Configure_Seam_Artifacts;
public static String SeamConfiguratorPreferencePage_Configure_Seam_Runtime;
public static String
SeamConfiguratorPreferencePage_Configure_Seam_when_importing_Maven_projects;
Added:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/CDIProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/CDIProjectConfigurator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/CDIProjectConfigurator.java 2010-06-14
09:03:11 UTC (rev 22779)
@@ -0,0 +1,128 @@
+package org.jboss.tools.maven.seam.configurators;
+
+import org.apache.maven.project.MavenProject;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+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;
+import org.jboss.tools.maven.core.IJBossMavenConstants;
+import
org.jboss.tools.maven.core.internal.project.facet.MavenFacetInstallDataModelProvider;
+import org.jboss.tools.maven.seam.MavenSeamActivator;
+import org.jboss.tools.maven.seam.Messages;
+import org.maven.ide.eclipse.project.IMavenProjectFacade;
+import org.maven.ide.eclipse.project.MavenProjectChangedEvent;
+import org.maven.ide.eclipse.project.configurator.AbstractProjectConfigurator;
+import org.maven.ide.eclipse.project.configurator.ProjectConfigurationRequest;
+
+public class CDIProjectConfigurator extends AbstractProjectConfigurator {
+
+ private static final String CDI_API_GROUP_ID = "javax.enterprise";
//$NON-NLS-1$
+ private static final String CDI_API_ARTIFACT_ID = "cdi-api"; //$NON-NLS-1$
+
+ protected static final IProjectFacet dynamicWebFacet;
+ protected static final IProjectFacetVersion dynamicWebVersion;
+
+ protected static final IProjectFacet cdiFacet;
+ protected static final IProjectFacetVersion cdiVersion;
+
+ protected static final IProjectFacet m2Facet;
+ protected static final IProjectFacetVersion m2Version;
+
+ static {
+ dynamicWebFacet = ProjectFacetsManager.getProjectFacet("jst.web");
//$NON-NLS-1$
+ dynamicWebVersion = dynamicWebFacet.getVersion("2.5"); //$NON-NLS-1$
+ cdiFacet = ProjectFacetsManager.getProjectFacet("jst.cdi"); //$NON-NLS-1$
+ cdiVersion = cdiFacet.getVersion("1.0"); //$NON-NLS-1$
+ m2Facet = ProjectFacetsManager.getProjectFacet("jboss.m2"); //$NON-NLS-1$
+ m2Version = m2Facet.getVersion("1.0"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void configure(ProjectConfigurationRequest request,
+ IProgressMonitor monitor) throws CoreException {
+ MavenProject mavenProject = request.getMavenProject();
+ IProject project = request.getProject();
+ configureInternal(mavenProject,project, monitor);
+ }
+
+ private void configureInternal(MavenProject mavenProject,IProject project,
+ IProgressMonitor monitor) throws CoreException {
+ IPreferenceStore store = MavenSeamActivator.getDefault().getPreferenceStore();
+ boolean configureCDI = store.getBoolean(MavenSeamActivator.CONFIGURE_CDI);
+ if (!configureCDI) {
+ return;
+ }
+
+ String packaging = mavenProject.getPackaging();
+ String cdiVersion = getCDIVersion(mavenProject);
+ if (cdiVersion != null) {
+ final IFacetedProject fproj = ProjectFacetsManager.create(project);
+ if (fproj != null && "war".equals(packaging)) { //$NON-NLS-1$
+ installWarFacets(fproj, cdiVersion, monitor);
+ }
+ }
+ }
+
+
+ @Override
+ protected void mavenProjectChanged(MavenProjectChangedEvent event,
+ IProgressMonitor monitor) throws CoreException {
+ IMavenProjectFacade facade = event.getMavenProject();
+ if(facade != null) {
+ IProject project = facade.getProject();
+ if(isWTPProject(project)) {
+ MavenProject mavenProject = facade.getMavenProject(monitor);
+ configureInternal(mavenProject, project, monitor);
+ }
+ }
+ super.mavenProjectChanged(event, monitor);
+ }
+
+ private boolean isWTPProject(IProject project) {
+ return ModuleCoreNature.getModuleCoreNature(project) != null;
+ }
+
+ private void installM2Facet(IFacetedProject fproj, IProgressMonitor monitor) throws
CoreException {
+ if (!fproj.hasProjectFacet(m2Facet)) {
+ IDataModel config = (IDataModel) new MavenFacetInstallDataModelProvider().create();
+ config.setBooleanProperty(IJBossMavenConstants.MAVEN_PROJECT_EXISTS, true);
+ fproj.installProjectFacet(m2Version, config, monitor);
+ }
+ }
+
+
+ private void installWarFacets(IFacetedProject fproj, String cdiVersion,IProgressMonitor
monitor) throws CoreException {
+
+ if (!fproj.hasProjectFacet(dynamicWebFacet)) {
+ MavenSeamActivator.log(Messages.JSFProjectConfigurator_The_project_does_not_contain_the_Web_Module_facet);
+ }
+ installCDIFacet(fproj, cdiVersion, monitor);
+ installM2Facet(fproj, monitor);
+
+ }
+
+
+ private void installCDIFacet(IFacetedProject fproj, String cdiVersionString,
IProgressMonitor monitor)
+ throws CoreException {
+ if (!fproj.hasProjectFacet(cdiFacet)) {
+ if (cdiVersionString.startsWith("1.0")) { //$NON-NLS-1$
+ IDataModel model =
MavenSeamActivator.getDefault().createCDIDataModel(fproj,cdiVersion);
+ fproj.installProjectFacet(cdiVersion, model, monitor);
+ }
+ }
+ }
+
+ private String getCDIVersion(MavenProject mavenProject) {
+ String version = null;
+ version = MavenSeamActivator.getDefault().getDependencyVersion(mavenProject,
CDI_API_GROUP_ID, CDI_API_ARTIFACT_ID);
+
+ return version;
+ }
+
+}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/JSFProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/JSFProjectConfigurator.java 2010-06-12
09:46:44 UTC (rev 22778)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/JSFProjectConfigurator.java 2010-06-14
09:03:11 UTC (rev 22779)
@@ -5,11 +5,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderFramework;
-import
org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties;
-import org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider;
import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
@@ -20,7 +15,6 @@
import
org.jboss.tools.maven.core.internal.project.facet.MavenFacetInstallDataModelProvider;
import org.jboss.tools.maven.seam.MavenSeamActivator;
import org.jboss.tools.maven.seam.Messages;
-import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetInstallDataModelProvider;
import org.maven.ide.eclipse.project.IMavenProjectFacade;
import org.maven.ide.eclipse.project.MavenProjectChangedEvent;
import org.maven.ide.eclipse.project.configurator.AbstractProjectConfigurator;
@@ -36,6 +30,7 @@
protected static final IProjectFacetVersion dynamicWebVersion;
protected static final IProjectFacet jsfFacet;
+ protected static final IProjectFacetVersion jsfVersion20;
protected static final IProjectFacetVersion jsfVersion12;
protected static final IProjectFacetVersion jsfVersion11;
protected static final IProjectFacet m2Facet;
@@ -45,6 +40,7 @@
dynamicWebFacet = ProjectFacetsManager.getProjectFacet("jst.web");
//$NON-NLS-1$
dynamicWebVersion = dynamicWebFacet.getVersion("2.5"); //$NON-NLS-1$
jsfFacet = ProjectFacetsManager.getProjectFacet("jst.jsf"); //$NON-NLS-1$
+ jsfVersion20 = jsfFacet.getVersion("2.0"); //$NON-NLS-1$
jsfVersion12 = jsfFacet.getVersion("1.2"); //$NON-NLS-1$
jsfVersion11 = jsfFacet.getVersion("1.1"); //$NON-NLS-1$
m2Facet = ProjectFacetsManager.getProjectFacet("jboss.m2"); //$NON-NLS-1$
@@ -127,10 +123,9 @@
IDataModel model =
MavenSeamActivator.getDefault().createJSFDataModel(fproj,jsfVersion12);
fproj.installProjectFacet(jsfVersion12, model, monitor);
}
- // FIXME
if (jsfVersionString.startsWith("2.0")) { //$NON-NLS-1$
- IDataModel model =
MavenSeamActivator.getDefault().createJSFDataModel(fproj,jsfVersion12);
- fproj.installProjectFacet(jsfVersion12, model, monitor);
+ IDataModel model =
MavenSeamActivator.getDefault().createJSFDataModel(fproj,jsfVersion20);
+ fproj.installProjectFacet(jsfVersion20, model, monitor);
}
}
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/messages.properties
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/messages.properties 2010-06-12
09:46:44 UTC (rev 22778)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/messages.properties 2010-06-14
09:03:11 UTC (rev 22779)
@@ -7,6 +7,7 @@
SeamConfiguratorPreferencePage_Configure_JBoss_Portlet_Core_facet=Configure JBoss Portlet
Core facet when importing Maven projects
SeamConfiguratorPreferencePage_Configure_JBoss_Seam_Portlet_facet=Configure JBoss Seam
Portlet facet when importing Maven projects
SeamConfiguratorPreferencePage_Configure_JSF_facet=Configure JSF facet when importing
Maven projects
+SeamConfiguratorPreferencePage_Configure_CDI_facet=Configure CDI facet when importing
Maven projects
SeamConfiguratorPreferencePage_Configure_Seam_Artifacts=Configure Seam Artifacts (view
folder, model source folder, package ...)
SeamConfiguratorPreferencePage_Configure_Seam_Runtime=Configure Seam Runtime
SeamConfiguratorPreferencePage_Configure_Seam_when_importing_Maven_projects=Configure
Seam when importing Maven projects
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencePage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencePage.java 2010-06-12
09:46:44 UTC (rev 22778)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencePage.java 2010-06-14
09:03:11 UTC (rev 22779)
@@ -25,6 +25,7 @@
private Button configurePortletButton;
private Button configureJSFPortletButton;
private Button configureSeamPortletButton;
+ private Button configureCDIButton;
@Override
protected Control createContents(Composite parent) {
@@ -82,6 +83,10 @@
boolean configureSeamPortlet =
store.getBoolean(MavenSeamActivator.CONFIGURE_SEAMPORTLET);
configureJSFPortletButton.setSelection(configureSeamPortlet);
+ configureCDIButton = new Button(composite,SWT.CHECK);
+ configureCDIButton.setText(Messages.SeamConfiguratorPreferencePage_Configure_CDI_facet);
+ boolean configureCDI = store.getBoolean(MavenSeamActivator.CONFIGURE_CDI);
+ configureCDIButton.setSelection(configureCDI);
return composite;
}
@@ -97,6 +102,8 @@
configurePortletButton.setSelection(MavenSeamActivator.CONFIGURE_PORTLET_VALUE);
configureJSFPortletButton.setSelection(MavenSeamActivator.CONFIGURE_JSFPORTLET_VALUE);
configureSeamPortletButton.setSelection(MavenSeamActivator.CONFIGURE_SEAMPORTLET_VALUE);
+ configureCDIButton.setSelection(MavenSeamActivator.CONFIGURE_CDI_VALUE);
+
IPreferenceStore store = MavenSeamActivator.getDefault().getPreferenceStore();
store.setValue(MavenSeamActivator.CONFIGURE_SEAM,
MavenSeamActivator.CONFIGURE_SEAM_VALUE);
store.setValue(MavenSeamActivator.CONFIGURE_JSF,
MavenSeamActivator.CONFIGURE_JSF_VALUE);
@@ -105,6 +112,7 @@
store.setValue(MavenSeamActivator.CONFIGURE_PORTLET,
MavenSeamActivator.CONFIGURE_PORTLET_VALUE);
store.setValue(MavenSeamActivator.CONFIGURE_SEAM_RUNTIME,
MavenSeamActivator.CONFIGURE_SEAM_RUNTIME_VALUE);
store.setValue(MavenSeamActivator.CONFIGURE_SEAM_ARTIFACTS,
MavenSeamActivator.CONFIGURE_SEAM_ARTIFACTS_VALUE);
+ store.setValue(MavenSeamActivator.CONFIGURE_CDI,
MavenSeamActivator.CONFIGURE_CDI_VALUE);
configureSeamRuntimeButton.setEnabled(configureSeamButton.getSelection());
configureSeamArtifactsButton.setEnabled(configureSeamButton.getSelection());
super.performDefaults();
@@ -120,6 +128,7 @@
store.setValue(MavenSeamActivator.CONFIGURE_SEAMPORTLET,
configureSeamPortletButton.getSelection());
store.setValue(MavenSeamActivator.CONFIGURE_SEAM_RUNTIME,
configureSeamRuntimeButton.getSelection());
store.setValue(MavenSeamActivator.CONFIGURE_SEAM_ARTIFACTS,
configureSeamArtifactsButton.getSelection());
+ store.setValue(MavenSeamActivator.CONFIGURE_CDI, configureCDIButton.getSelection());
return super.performOk();
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencesInitializer.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencesInitializer.java 2010-06-12
09:46:44 UTC (rev 22778)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencesInitializer.java 2010-06-14
09:03:11 UTC (rev 22779)
@@ -34,6 +34,9 @@
node.putBoolean(
MavenSeamActivator.CONFIGURE_SEAMPORTLET,
MavenSeamActivator.CONFIGURE_SEAMPORTLET_VALUE);
+ node.putBoolean(
+ MavenSeamActivator.CONFIGURE_CDI,
+ MavenSeamActivator.CONFIGURE_CDI_VALUE);
}
}