Author: snjeza
Date: 2009-09-24 16:48:08 -0400 (Thu, 24 Sep 2009)
New Revision: 17720
Added:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/PortletProjectConfigurator.java
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java
trunk/maven/plugins/org.jboss.tools.maven.seam/META-INF/MANIFEST.MF
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/configurators/JSFProjectConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/SeamProjectConfigurator.java
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/jira/browse/JBIDE-4888 Add m2eclipse configurator for portlet
facets
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java 2009-09-24
17:29:48 UTC (rev 17719)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java 2009-09-24
20:48:08 UTC (rev 17720)
@@ -35,6 +35,9 @@
IProject project = facetedProject.getProject();
IFile pom = project.getFile(IMavenConstants.POM_FILE_NAME);
MavenLibraryProviderInstallOperationConfig mavenConfig =
(MavenLibraryProviderInstallOperationConfig) config;
+ if (mavenConfig.getModel() == null) {
+ return;
+ }
if (pom.exists()) {
// JBoss Maven Integration facet has been executed
MavenModelManager modelManager = MavenPlugin.getDefault().getMavenModelManager();
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 2009-09-24
17:29:48 UTC (rev 17719)
+++ trunk/maven/plugins/org.jboss.tools.maven.seam/META-INF/MANIFEST.MF 2009-09-24
20:48:08 UTC (rev 17720)
@@ -8,12 +8,14 @@
org.eclipse.core.runtime,
org.jboss.tools.maven.core,
org.jboss.tools.seam.core,
+ org.jboss.tools.portlet.core,
org.jboss.tools.seam.ui,
org.jboss.tools.common.model,
org.maven.ide.components.maven_model_edit,
org.eclipse.jst.j2ee.core,
org.eclipse.jst.j2ee,
- org.eclipse.wst.common.emfworkbench.integration
+ org.eclipse.wst.common.emfworkbench.integration,
+ org.eclipse.jst.jsf.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Modified: trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.xml 2009-09-24 17:29:48 UTC (rev
17719)
+++ trunk/maven/plugins/org.jboss.tools.maven.seam/plugin.xml 2009-09-24 20:48:08 UTC (rev
17720)
@@ -21,6 +21,13 @@
name="JSF Project configurator" priority="150"/>
</extension>
+ <extension point="org.maven.ide.eclipse.projectConfigurators">
+ <configurator
+ id="org.jboss.tools.maven.portlet.configurator"
+
class="org.jboss.tools.maven.seam.configurators.PortletProjectConfigurator"
+ name="Portlet Core Project configurator"
priority="155"/>
+ </extension>
+
<extension
point="org.eclipse.ui.preferencePages">
<page
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 2009-09-24
17:29:48 UTC (rev 17719)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java 2009-09-24
20:48:08 UTC (rev 17720)
@@ -1,14 +1,10 @@
package org.jboss.tools.maven.seam;
-import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -17,6 +13,7 @@
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
+import org.apache.maven.project.MavenProject;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -24,23 +21,23 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.j2ee.application.Application;
-import org.eclipse.jst.j2ee.application.EjbModule;
-import org.eclipse.jst.j2ee.application.WebModule;
-import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
+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.ui.plugin.AbstractUIPlugin;
import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
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.maven.core.IJBossMavenConstants;
import org.jboss.tools.maven.core.MavenCoreActivator;
@@ -80,6 +77,8 @@
public static final String CONFIGURE_SEAM = "configureSeam"; //$NON-NLS-1$
+ public static final String CONFIGURE_PORTLET = "configurePortlet";
//$NON-NLS-1$
+
public static final boolean CONFIGURE_SEAM_VALUE = true;
public static final String CONFIGURE_SEAM_RUNTIME = "configureSeamRuntime";
//$NON-NLS-1$
@@ -93,7 +92,17 @@
public static final String CONFIGURE_JSF = "configureJSF"; //$NON-NLS-1$
public static final boolean CONFIGURE_JSF_VALUE = true;
+
+ public static final boolean CONFIGURE_PORTLET_VALUE = true;
+
+ public static final String CONFIGURE_JSFPORTLET = "configureJSFPortlet";
//$NON-NLS-1$
+ public static final boolean CONFIGURE_JSFPORTLET_VALUE = true;
+
+ public static final String CONFIGURE_SEAMPORTLET = "configureSeamPortlet";
//$NON-NLS-1$
+
+ public static final boolean CONFIGURE_SEAMPORTLET_VALUE = true;
+
// The shared instance
private static MavenSeamActivator plugin;
@@ -893,4 +902,27 @@
IStatus status = new Status(IStatus.WARNING, PLUGIN_ID, message, null);
getDefault().getLog().log(status);
}
+
+ public String getDependencyVersion(MavenProject mavenProject, String gid, String aid) {
+ List<Dependency> dependencies = mavenProject.getDependencies();
+ for (Dependency dependency:dependencies) {
+ String groupId = dependency.getGroupId();
+ if (groupId != null && (groupId.equals(gid)) ) {
+ String artifactId = dependency.getArtifactId();
+ if (artifactId != null && artifactId.equals(aid)) {
+ return dependency.getVersion();
+ }
+ }
+ }
+ return null;
+ }
+
+ public IDataModel createJSFDataModel(IFacetedProject fproj, IProjectFacetVersion
facetVersion) {
+ IDataModel config = (IDataModel) new JSFFacetInstallDataModelProvider().create();
+ LibraryInstallDelegate libraryDelegate = new LibraryInstallDelegate(fproj,
facetVersion);
+ ILibraryProvider provider =
LibraryProviderFramework.getProvider("jsf-no-op-library-provider");
//$NON-NLS-1$
+ libraryDelegate.setLibraryProvider(provider);
+ config.setProperty(IJSFFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE,
libraryDelegate);
+ return config;
+ }
}
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 2009-09-24
17:29:48 UTC (rev 17719)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/JSFProjectConfigurator.java 2009-09-24
20:48:08 UTC (rev 17720)
@@ -1,68 +1,29 @@
package org.jboss.tools.maven.seam.configurators;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jst.j2ee.application.Application;
-import org.eclipse.jst.j2ee.application.EjbModule;
-import org.eclipse.jst.j2ee.application.Module;
-import org.eclipse.jst.j2ee.application.WebModule;
-import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
-import org.eclipse.wst.common.componentcore.ComponentCore;
+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.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
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.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.web.kb.IKbProject;
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.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.core.SeamUtil;
-import org.jboss.tools.seam.core.project.facet.SeamRuntime;
-import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
-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.SeamFacetInstallDataModelProvider;
-import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
-import org.maven.ide.eclipse.MavenPlugin;
-import org.maven.ide.eclipse.core.IMavenConstants;
import org.maven.ide.eclipse.project.IMavenProjectFacade;
import org.maven.ide.eclipse.project.MavenProjectChangedEvent;
-import org.maven.ide.eclipse.project.MavenProjectManager;
import org.maven.ide.eclipse.project.configurator.AbstractProjectConfigurator;
import org.maven.ide.eclipse.project.configurator.ProjectConfigurationRequest;
-import org.osgi.service.prefs.BackingStoreException;
public class JSFProjectConfigurator extends AbstractProjectConfigurator {
@@ -92,7 +53,6 @@
@Override
public void configure(ProjectConfigurationRequest request,
IProgressMonitor monitor) throws CoreException {
- // adds Seam capabilities if there are Seam dependencies
MavenProject mavenProject = request.getMavenProject();
IProject project = request.getProject();
configureInternal(mavenProject,project, monitor);
@@ -159,30 +119,28 @@
throws CoreException {
if (!fproj.hasProjectFacet(jsfFacet)) {
if (jsfVersionString.startsWith("1.1")) { //$NON-NLS-1$
- fproj.installProjectFacet(jsfVersion11, null, monitor);
+ IDataModel model =
MavenSeamActivator.getDefault().createJSFDataModel(fproj,jsfVersion11);
+ fproj.installProjectFacet(jsfVersion11, model, monitor);
}
if (jsfVersionString.startsWith("1.2")) { //$NON-NLS-1$
- fproj.installProjectFacet(jsfVersion12, null, monitor);
+ IDataModel model =
MavenSeamActivator.getDefault().createJSFDataModel(fproj,jsfVersion12);
+ fproj.installProjectFacet(jsfVersion12, model, monitor);
}
// FIXME
if (jsfVersionString.startsWith("2.0")) { //$NON-NLS-1$
- fproj.installProjectFacet(jsfVersion12, null, monitor);
+ IDataModel model =
MavenSeamActivator.getDefault().createJSFDataModel(fproj,jsfVersion12);
+ fproj.installProjectFacet(jsfVersion12, model, monitor);
}
}
}
-
+
private String getJSFVersion(MavenProject mavenProject) {
- List<Dependency> dependencies = mavenProject.getDependencies();
- for (Dependency dependency:dependencies) {
- String groupId = dependency.getGroupId();
- if (groupId != null && (JSF_API_GROUP_ID.equals(groupId) ||
JSF_API2_GROUP_ID.equals(groupId)) ) {
- String artifactId = dependency.getArtifactId();
- if (artifactId != null && JSF_API_ARTIFACT_ID.equals(artifactId)) {
- return dependency.getVersion();
- }
- }
- }
- return null;
+ String version = null;
+ version = MavenSeamActivator.getDefault().getDependencyVersion(mavenProject,
JSF_API_GROUP_ID, JSF_API_ARTIFACT_ID);
+ if (version == null) {
+ version = MavenSeamActivator.getDefault().getDependencyVersion(mavenProject,
JSF_API2_GROUP_ID, JSF_API_ARTIFACT_ID);
+ }
+ return version;
}
}
Added:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/PortletProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/PortletProjectConfigurator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/PortletProjectConfigurator.java 2009-09-24
20:48:08 UTC (rev 17720)
@@ -0,0 +1,168 @@
+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.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.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.portlet.core.IPortletConstants;
+import
org.jboss.tools.portlet.core.internal.project.facet.JSFPortletFacetInstallDataModelProvider;
+import
org.jboss.tools.portlet.core.internal.project.facet.PortletFacetInstallDataModelProvider;
+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 PortletProjectConfigurator extends AbstractProjectConfigurator {
+
+ private static final String PORTLET_API_GROUP_ID = "javax.portlet";
//$NON-NLS-1$
+ private static final String PORTLET_API_ARTIFACT_ID = "portlet-api";
//$NON-NLS-1$
+
+ private static final String PORTLETBRIDGE_API_GROUP_ID =
"org.jboss.portletbridge"; //$NON-NLS-1$
+ private static final String PORTLETBRIDGE_API_ARTIFACT_ID =
"portletbridge-api"; //$NON-NLS-1$
+
+ protected static final IProjectFacet dynamicWebFacet;
+ protected static final IProjectFacetVersion dynamicWebVersion;
+
+ protected static final IProjectFacet jsfFacet;
+ protected static final IProjectFacet portletFacet;
+ protected static final IProjectFacetVersion portletVersion10;
+ protected static final IProjectFacetVersion portletVersion20;
+ protected static final IProjectFacet m2Facet;
+ protected static final IProjectFacetVersion m2Version;
+ protected static final IProjectFacetVersion jsfportletFacetVersion;
+
+ static {
+ dynamicWebFacet = ProjectFacetsManager.getProjectFacet("jst.web");
//$NON-NLS-1$
+ dynamicWebVersion = dynamicWebFacet.getVersion("2.5"); //$NON-NLS-1$
+ portletFacet = ProjectFacetsManager.getProjectFacet("jboss.portlet");
//$NON-NLS-1$
+ portletVersion20 = portletFacet.getVersion("2.0"); //$NON-NLS-1$
+ portletVersion10 = portletFacet.getVersion("1.0"); //$NON-NLS-1$
+ m2Facet = ProjectFacetsManager.getProjectFacet("jboss.m2"); //$NON-NLS-1$
+ m2Version = m2Facet.getVersion("1.0"); //$NON-NLS-1$
+ jsfFacet = ProjectFacetsManager.getProjectFacet("jst.jsf"); //$NON-NLS-1$
+ jsfportletFacetVersion =
ProjectFacetsManager.getProjectFacet("jboss.jsfportlet").getVersion("1.0");
//$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @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 configurePortlet = store.getBoolean(MavenSeamActivator.CONFIGURE_PORTLET);
+ if (!configurePortlet) {
+ return;
+ }
+
+ String packaging = mavenProject.getPackaging();
+ String portletVersion =
MavenSeamActivator.getDefault().getDependencyVersion(mavenProject, PORTLET_API_GROUP_ID,
PORTLET_API_ARTIFACT_ID);
+ String jsfportletVersion =
MavenSeamActivator.getDefault().getDependencyVersion(mavenProject,
PORTLETBRIDGE_API_GROUP_ID, PORTLETBRIDGE_API_ARTIFACT_ID);
+ if (portletVersion != null) {
+ final IFacetedProject fproj = ProjectFacetsManager.create(project);
+ if ("war".equals(packaging)) { //$NON-NLS-1$
+ installWarFacets(fproj, portletVersion, jsfportletVersion, 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 portletVersion, String
jsfportletVersion, IProgressMonitor monitor) throws CoreException {
+
+ if (!fproj.hasProjectFacet(dynamicWebFacet)) {
+ MavenSeamActivator.log("The project doesn't contain the Web Module
facet.");
+ }
+ installM2Facet(fproj, monitor);
+ installPortletFacet(fproj, portletVersion, jsfportletVersion, monitor);
+ }
+
+
+ private void installPortletFacet(IFacetedProject fproj, String portletVersionString,
String jsfportletVersion, IProgressMonitor monitor)
+ throws CoreException {
+ if (!fproj.hasProjectFacet(portletFacet)) {
+ if (portletVersionString.startsWith("1.0")) { //$NON-NLS-1$
+ IDataModel model = createPortletDataModel(fproj, portletVersion10);
+ fproj.installProjectFacet(portletVersion10, model, monitor);
+ }
+ if (portletVersionString.startsWith("2.0")) { //$NON-NLS-1$
+ IDataModel model = createPortletDataModel(fproj, portletVersion20);
+ fproj.installProjectFacet(portletVersion20, model, monitor);
+ }
+ }
+ IPreferenceStore store = MavenSeamActivator.getDefault().getPreferenceStore();
+ boolean configureJSFPortlet =
store.getBoolean(MavenSeamActivator.CONFIGURE_JSFPORTLET);
+ if (!configureJSFPortlet) {
+ return;
+ }
+ if (fproj.hasProjectFacet(portletFacet) && fproj.hasProjectFacet(jsfFacet)
&& jsfportletVersion != null) {
+
+ if (!fproj.hasProjectFacet(jsfportletFacetVersion)) {
+ IDataModel model = createJSFPortletDataModel(fproj, jsfportletFacetVersion);
+ fproj.installProjectFacet(jsfportletFacetVersion, model, monitor);
+ }
+
+ }
+ }
+
+ private IDataModel createPortletDataModel(IFacetedProject fproj, IProjectFacetVersion
facetVersion) {
+ IDataModel config = (IDataModel) new PortletFacetInstallDataModelProvider().create();
+ LibraryInstallDelegate libraryDelegate = new LibraryInstallDelegate(fproj,
facetVersion);
+ ILibraryProvider provider =
LibraryProviderFramework.getProvider("portlet-no-op-library-provider");
//$NON-NLS-1$
+ libraryDelegate.setLibraryProvider(provider);
+ config.setProperty(IPortletConstants.PORTLET_LIBRARY_PROVIDER_DELEGATE,
libraryDelegate);
+ return config;
+ }
+
+ private IDataModel createJSFPortletDataModel(IFacetedProject fproj, IProjectFacetVersion
facetVersion) {
+ IDataModel config = (IDataModel) new
JSFPortletFacetInstallDataModelProvider().create();
+ LibraryInstallDelegate libraryDelegate = new LibraryInstallDelegate(fproj,
facetVersion);
+ ILibraryProvider provider =
LibraryProviderFramework.getProvider("jsfportlet-no-op-library-provider");
//$NON-NLS-1$
+ libraryDelegate.setLibraryProvider(provider);
+ config.setProperty(IPortletConstants.JSFPORTLET_LIBRARY_PROVIDER_DELEGATE,
libraryDelegate);
+ return config;
+ }
+}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/SeamProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/SeamProjectConfigurator.java 2009-09-24
17:29:48 UTC (rev 17719)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/configurators/SeamProjectConfigurator.java 2009-09-24
20:48:08 UTC (rev 17720)
@@ -83,6 +83,10 @@
protected static final IProjectFacet m2Facet;
protected static final IProjectFacetVersion m2Version;
private static final IProjectFacet seamFacet;
+ private static final IProjectFacet portletFacet;
+ private static final IProjectFacet jsfportletFacet;
+ private static final IProjectFacet seamPortletFacet;
+ private static final IProjectFacetVersion seamPortletVersion;
static {
seamFacet = ProjectFacetsManager.getProjectFacet("jst.seam"); //$NON-NLS-1$
@@ -98,6 +102,10 @@
m2Version = m2Facet.getVersion("1.0"); //$NON-NLS-1$
ejbFacet = ProjectFacetsManager.getProjectFacet("jst.ejb"); //$NON-NLS-1$
ejbVersion = ejbFacet.getVersion("3.0"); //$NON-NLS-1$
+ portletFacet = ProjectFacetsManager.getProjectFacet("jboss.portlet");
//$NON-NLS-1$
+ jsfportletFacet = ProjectFacetsManager.getProjectFacet("jboss.jsfportlet");
//$NON-NLS-1$
+ seamPortletFacet = ProjectFacetsManager.getProjectFacet("jboss.seamportlet");
//$NON-NLS-1$
+ seamPortletVersion = seamPortletFacet.getVersion("1.0"); //$NON-NLS-1$
}
@Override
@@ -293,6 +301,16 @@
setModelProperty(model, prefs,ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER);
}
}
+ IPreferenceStore store = MavenSeamActivator.getDefault().getPreferenceStore();
+ boolean configureSeamPortlet =
store.getBoolean(MavenSeamActivator.CONFIGURE_SEAMPORTLET);
+ if (!configureSeamPortlet) {
+ return;
+ }
+ if (fproj.hasProjectFacet(seamFacet) && fproj.hasProjectFacet(portletFacet)
&& fproj.hasProjectFacet(jsfportletFacet)) {
+ if (!fproj.hasProjectFacet(seamPortletFacet)) {
+ fproj.installProjectFacet(seamPortletVersion, null, monitor);
+ }
+ }
}
private void setModelProperty(IDataModel model, IEclipsePreferences prefs, String
property) {
@@ -305,7 +323,8 @@
private void installJSFFacet(IFacetedProject fproj, IProgressMonitor monitor)
throws CoreException {
if (!fproj.hasProjectFacet(jsfFacet)) {
- fproj.installProjectFacet(jsfVersion, null, monitor);
+ IDataModel model =
MavenSeamActivator.getDefault().createJSFDataModel(fproj,jsfVersion);
+ fproj.installProjectFacet(jsfVersion, model, monitor);
}
}
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 2009-09-24
17:29:48 UTC (rev 17719)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencePage.java 2009-09-24
20:48:08 UTC (rev 17720)
@@ -21,6 +21,9 @@
private Button configureSeamRuntimeButton;
private Button configureSeamArtifactsButton;
private Button configureJSFButton;
+ private Button configurePortletButton;
+ private Button configureJSFPortletButton;
+ private Button configureSeamPortletButton;
@Override
protected Control createContents(Composite parent) {
@@ -63,6 +66,21 @@
boolean configureJSF = store.getBoolean(MavenSeamActivator.CONFIGURE_JSF);
configureJSFButton.setSelection(configureJSF);
+ configurePortletButton = new Button(composite,SWT.CHECK);
+ configurePortletButton.setText("Configure JBoss Portlet Core facet when importing
Maven projects");
+ boolean configurePortlet = store.getBoolean(MavenSeamActivator.CONFIGURE_PORTLET);
+ configurePortletButton.setSelection(configurePortlet);
+
+ configureJSFPortletButton = new Button(composite,SWT.CHECK);
+ configureJSFPortletButton.setText("Configure JBoss JSF Portlet facet when
importing Maven projects");
+ boolean configureJSFPortlet =
store.getBoolean(MavenSeamActivator.CONFIGURE_JSFPORTLET);
+ configureJSFPortletButton.setSelection(configureJSFPortlet);
+
+ configureSeamPortletButton = new Button(composite,SWT.CHECK);
+ configureSeamPortletButton.setText("Configure JBoss Seam Portlet facet when
importing Maven projects");
+ boolean configureSeamPortlet =
store.getBoolean(MavenSeamActivator.CONFIGURE_SEAMPORTLET);
+ configureJSFPortletButton.setSelection(configureSeamPortlet);
+
return composite;
}
@@ -75,9 +93,15 @@
configureSeamButton.setSelection(MavenSeamActivator.CONFIGURE_SEAM_VALUE);
configureSeamRuntimeButton.setSelection(MavenSeamActivator.CONFIGURE_SEAM_RUNTIME_VALUE);
configureSeamArtifactsButton.setSelection(MavenSeamActivator.CONFIGURE_SEAM_ARTIFACTS_VALUE);
+ configurePortletButton.setSelection(MavenSeamActivator.CONFIGURE_PORTLET_VALUE);
+ configureJSFPortletButton.setSelection(MavenSeamActivator.CONFIGURE_JSFPORTLET_VALUE);
+ configureSeamPortletButton.setSelection(MavenSeamActivator.CONFIGURE_SEAMPORTLET_VALUE);
IPreferenceStore store = MavenSeamActivator.getDefault().getPreferenceStore();
store.setValue(MavenSeamActivator.CONFIGURE_SEAM,
MavenSeamActivator.CONFIGURE_SEAM_VALUE);
store.setValue(MavenSeamActivator.CONFIGURE_JSF,
MavenSeamActivator.CONFIGURE_JSF_VALUE);
+ store.setValue(MavenSeamActivator.CONFIGURE_JSFPORTLET,
MavenSeamActivator.CONFIGURE_JSFPORTLET_VALUE);
+ store.setValue(MavenSeamActivator.CONFIGURE_SEAMPORTLET,
MavenSeamActivator.CONFIGURE_SEAMPORTLET_VALUE);
+ 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);
configureSeamRuntimeButton.setEnabled(configureSeamButton.getSelection());
@@ -89,7 +113,10 @@
public boolean performOk() {
IPreferenceStore store = MavenSeamActivator.getDefault().getPreferenceStore();
store.setValue(MavenSeamActivator.CONFIGURE_SEAM, configureSeamButton.getSelection());
+ store.setValue(MavenSeamActivator.CONFIGURE_PORTLET,
configurePortletButton.getSelection());
store.setValue(MavenSeamActivator.CONFIGURE_JSF, configureJSFButton.getSelection());
+ store.setValue(MavenSeamActivator.CONFIGURE_JSFPORTLET,
configureJSFPortletButton.getSelection());
+ store.setValue(MavenSeamActivator.CONFIGURE_SEAMPORTLET,
configureSeamPortletButton.getSelection());
store.setValue(MavenSeamActivator.CONFIGURE_SEAM_RUNTIME,
configureSeamRuntimeButton.getSelection());
store.setValue(MavenSeamActivator.CONFIGURE_SEAM_ARTIFACTS,
configureSeamArtifactsButton.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 2009-09-24
17:29:48 UTC (rev 17719)
+++
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/preferences/SeamConfiguratorPreferencesInitializer.java 2009-09-24
20:48:08 UTC (rev 17720)
@@ -25,6 +25,15 @@
node.putBoolean(
MavenSeamActivator.CONFIGURE_JSF,
MavenSeamActivator.CONFIGURE_JSF_VALUE);
+ node.putBoolean(
+ MavenSeamActivator.CONFIGURE_PORTLET,
+ MavenSeamActivator.CONFIGURE_PORTLET_VALUE);
+ node.putBoolean(
+ MavenSeamActivator.CONFIGURE_JSFPORTLET,
+ MavenSeamActivator.CONFIGURE_JSFPORTLET_VALUE);
+ node.putBoolean(
+ MavenSeamActivator.CONFIGURE_SEAMPORTLET,
+ MavenSeamActivator.CONFIGURE_SEAMPORTLET_VALUE);
}
}