Author: snjeza
Date: 2008-09-18 18:44:11 -0400 (Thu, 18 Sep 2008)
New Revision: 10367
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java
Removed:
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/portlet/1.0/
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java
Log:
JBIDE-2792 Add runtime support for portal
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-09-18 21:36:00 UTC
(rev 10366)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-09-18 22:44:11 UTC
(rev 10367)
@@ -254,4 +254,9 @@
</catalogContribution>
</extension>
+
+ <extension
point="org.eclipse.wst.common.project.facet.core.listeners">
+ <listener
class="org.jboss.tools.portlet.core.internal.project.facet.PortletPostInstallListener"
+ eventTypes="POST_INSTALL"/>
+ </extension>
</plugin>
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-09-18
21:36:00 UTC (rev 10366)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-09-18
22:44:11 UTC (rev 10367)
@@ -46,6 +46,8 @@
static final String JBOSS_APP_FILE = "WEB-INF/jboss-app.xml";
static final String DEPLOY_JARS = "DEPLOY_JARS";
+
+ static final String PORTLET_BRIDGE_RUNTIME = "PORTLET_BRIDGE_RUNTIME";
static final String JSF_SECTION = "jsfSection";
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java 2008-09-18
21:36:00 UTC (rev 10366)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java 2008-09-18
22:44:11 UTC (rev 10367)
@@ -24,7 +24,7 @@
AbstractClasspathContainerInitializer {
public String getDescription(IPath containerPath, IJavaProject project) {
- return "JBoss Portlet Classpath Container Initializer v2.0";
+ return "JBoss Portlet Classpath Container Initializer";
}
@Override
@@ -39,7 +39,7 @@
private class Portlet10ClasspathContainer extends BasePortletClasspathContainer {
- public final static String DESCRIPTION = "JBoss Portlet Libraries v2.0";
+ public final static String DESCRIPTION = "JBoss Portlet Library";
public Portlet10ClasspathContainer(IPath path) {
super(path, DESCRIPTION, SUFFIX);
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java 2008-09-18
21:36:00 UTC (rev 10366)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java 2008-09-18
22:44:11 UTC (rev 10367)
@@ -30,6 +30,9 @@
if (propertyName.equals(IPortletConstants.DEPLOY_JARS)) {
return Boolean.TRUE;
}
+ if (propertyName.equals(IPortletConstants.PORTLET_BRIDGE_RUNTIME)) {
+ return "";
+ }
return super.getDefaultProperty(propertyName);
}
@@ -37,6 +40,7 @@
public Set<String> getPropertyNames() {
Set<String> propertyNames = super.getPropertyNames();
propertyNames.add(IPortletConstants.DEPLOY_JARS);
+ propertyNames.add(IPortletConstants.PORTLET_BRIDGE_RUNTIME);
return propertyNames;
}
}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java 2008-09-18
21:36:00 UTC (rev 10366)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java 2008-09-18
22:44:11 UTC (rev 10367)
@@ -11,7 +11,9 @@
package org.jboss.tools.portlet.core.internal.project.facet;
import java.io.File;
+import java.io.FilenameFilter;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -278,26 +280,45 @@
.getBooleanProperty(IPortletConstants.DEPLOY_JARS);
if (deployJars) {
try {
- URL installURL = FileLocator.toFileURL(PortletCoreActivator
- .getDefault().getBundle().getEntry("/"));
- String baseDir = installURL.getFile().toString();
- File libDir = new File(baseDir + "/"
- + PortletCoreActivator.RESOURCES_FOLDER + "/"
- + PortletCoreActivator.JSFPORTLET_FOLDER);
- List<File> filesToImport = Arrays.asList(libDir.listFiles());
- IVirtualComponent component = ComponentCore
- .createComponent(project);
- IVirtualFile libVirtualFile = component.getRootFolder()
- .getFile(IPortletConstants.WEB_INF_LIB);
+
+ String pbRuntime = config
+ .getStringProperty(IPortletConstants.PORTLET_BRIDGE_RUNTIME);
+ if (pbRuntime != null && pbRuntime.trim().length() > 0) {
+ pbRuntime = pbRuntime.trim();
+ File pbFolder = new File(pbRuntime);
+ if (pbFolder.exists() && pbFolder.isDirectory()) {
+ String[] fileList = pbFolder.list(new FilenameFilter() {
- IFile folder = libVirtualFile.getUnderlyingFile();
+ public boolean accept(File dir, String name) {
+ if (name.startsWith("portletbridge") ||
name.endsWith(".jar")) {
+ return true;
+ }
+ return false;
+ }
- ImportOperation importOperation = new ImportOperation(folder
- .getFullPath(), libDir,
- FileSystemStructureProvider.INSTANCE,
- PortletCoreActivator.OVERWRITE_ALL_QUERY, filesToImport);
- importOperation.setCreateContainerStructure(false);
- importOperation.run(monitor);
+ });
+
+ List<File> filesToImport = new ArrayList<File>();
+
+ for (int i = 0; i < fileList.length; i++) {
+ filesToImport.add(new File(pbRuntime,fileList[i]));
+ }
+ IVirtualComponent component = ComponentCore
+ .createComponent(project);
+ IVirtualFile libVirtualFile = component.getRootFolder()
+ .getFile(IPortletConstants.WEB_INF_LIB);
+
+ IFile folder = libVirtualFile.getUnderlyingFile();
+
+ ImportOperation importOperation = new ImportOperation(
+ folder.getFullPath(), pbFolder,
+ FileSystemStructureProvider.INSTANCE,
+ PortletCoreActivator.OVERWRITE_ALL_QUERY,
+ filesToImport);
+ importOperation.setCreateContainerStructure(false);
+ importOperation.run(monitor);
+ }
+ }
} catch (Exception e) {
PortletCoreActivator
.log(e, "Error loading classpath container");
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java 2008-09-18
21:36:00 UTC (rev 10366)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java 2008-09-18
22:44:11 UTC (rev 10367)
@@ -77,11 +77,11 @@
IJavaProject javaProject = JavaCore.create(project);
IPath containerPath = null;
- if (IPortletConstants.PORTLET_FACET_VERSION_10.equals(fv.getVersionString())) {
+ //if (IPortletConstants.PORTLET_FACET_VERSION_10.equals(fv.getVersionString())) {
containerPath = new Path(IPortletConstants.PORTLET_CONTAINER_10_ID);
- } else {
+ //} else {
containerPath = new Path(IPortletConstants.PORTLET_CONTAINER_20_ID);
- }
+ //}
IClasspathEntry entry = JavaCore.newContainerEntry(containerPath, true);
IClasspathEntry[] entries = javaProject.getRawClasspath();
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletPostInstallListener.java 2008-09-18
22:44:11 UTC (rev 10367)
@@ -0,0 +1,154 @@
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+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.events.IFacetedProjectEvent;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+public class PortletPostInstallListener implements IFacetedProjectListener {
+
+ private static final String SEAM_FACET_ID = "jst.seam";
+ private static final IOverwriteQuery OVERWRITE_NONE_QUERY = new IOverwriteQuery()
+ {
+ public String queryOverwrite(String pathString)
+ {
+ return IOverwriteQuery.NO_ALL;
+ }
+ };
+ private String portletbridgeRuntime;
+
+ public void handleEvent(IFacetedProjectEvent event) {
+ IFacetedProject facetedProject = event.getProject();
+ Set<IProjectFacetVersion> projectFacets = facetedProject
+ .getProjectFacets();
+ boolean isJSFPortlet = false;
+ boolean isSeamProject = false;
+ for (IProjectFacetVersion projectFacetVersion : projectFacets) {
+ IProjectFacet projectFacet = projectFacetVersion.getProjectFacet();
+ if (IPortletConstants.JSFPORTLET_FACET_ID.equals(projectFacet
+ .getId())) {
+ isJSFPortlet = true;
+ }
+ if (SEAM_FACET_ID.equals(projectFacet.getId())) {
+ isSeamProject = true;
+ }
+
+ }
+ if (!isJSFPortlet)
+ return;
+
+ if (isJSFPortlet) {
+ IProjectFacetActionEvent actionEvent = (IProjectFacetActionEvent) event;
+ IDataModel dataModel = (IDataModel) actionEvent.getActionConfig();
+ try {
+ portletbridgeRuntime = dataModel
+ .getStringProperty(IPortletConstants.PORTLET_BRIDGE_RUNTIME);
+ if (portletbridgeRuntime == null) {
+ PortletCoreActivator.log(null, "Invalid Portletbridge Runtime.");
+ return;
+ }
+ } catch (Exception e) {
+ //PortletCoreActivator.log(e);
+ }
+ }
+
+ if (isJSFPortlet) {
+ File portletbridgeHome = new File(portletbridgeRuntime);
+ if (!portletbridgeHome.exists()) {
+ PortletCoreActivator.log(null, "Cannot find Portletbridge Runtime.");
+ return;
+ }
+ if (!portletbridgeHome.isDirectory()) {
+ PortletCoreActivator.log(null, "Invalid Portletbridge Runtime.");
+ return;
+ }
+ File examplesHome = new File(portletbridgeHome,"examples");
+ if (!examplesHome.exists() || !examplesHome.isDirectory()) {
+ PortletCoreActivator.log(null, "Cannot find the examples directory.");
+ return;
+ }
+ File richFacesPortletZip = new File(examplesHome,"RichFacesPortlet.war");
+ if (!richFacesPortletZip.exists() || !richFacesPortletZip.isFile()) {
+ PortletCoreActivator.log(null, "Cannot find the RichFacesPortlet.war
file.");
+ return;
+ }
+ try {
+ ZipFile zipFile = new ZipFile(richFacesPortletZip);
+ ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(
+ zipFile );
+ List<ZipEntry> list = prepareList(zipFile, isSeamProject);
+
+ IProject project = facetedProject.getProject();
+ IVirtualComponent component = ComponentCore
+ .createComponent(project);
+ //IVirtualFile libVirtualFile = component.getRootFolder()
+ // .getFile(IPortletConstants.WEB_INF_LIB);
+
+ IVirtualFolder rootFolder = component.getRootFolder();
+ IContainer folder = rootFolder.getUnderlyingFolder();
+ IPath destPath = folder.getFullPath();
+
+ ImportOperation op = new ImportOperation( destPath,
+ structureProvider.getRoot( ), structureProvider, OVERWRITE_NONE_QUERY,
+ list );
+ op.run(new NullProgressMonitor() );
+ } catch (Exception e) {
+ PortletCoreActivator.log(e);
+ }
+
+ }
+ }
+
+ private List<ZipEntry> prepareList(ZipFile zipFile, boolean isSeamProject) {
+ if (zipFile == null) {
+ return null;
+ }
+ List<ZipEntry> list = new ArrayList<ZipEntry>();
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ ZipEntry entry = entries.nextElement();
+ if (entry.getName().endsWith(".jar")) {
+ if (entry.getName().startsWith("WEB-INF/lib/richfaces")) {
+ list.add(entry);
+ }
+ if (!isSeamProject) {
+ if (entry.getName().startsWith(
+ "WEB-INF/lib/commons-beanutils")
+ || entry.getName().startsWith(
+ "WEB-INF/lib/commons-digester")
+ || entry.getName().startsWith(
+ "WEB-INF/lib/jsf-facelets")) {
+ list.add(entry);
+ }
+ }
+ }
+ }
+ return list;
+ }
+
+}