JBoss Tools SVN: r9480 - in trunk/portlet/plugins/org.jboss.tools.portlet.core: src/org/jboss/tools/portlet/core and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-08-03 20:41:46 -0400 (Sun, 03 Aug 2008)
New Revision: 9480
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletConfigurationPresetFactory10.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDataModelProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDelegate.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetUninstallDelegate.java
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/project/facet/JSFPortletFacetInstallDelegate.java
Log:
JBIDE-2234 JBoss Seam Portlet
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-08-02 03:11:36 UTC (rev 9479)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-08-04 00:41:46 UTC (rev 9480)
@@ -3,11 +3,17 @@
<plugin>
<extension point="org.eclipse.wst.common.project.facet.core.facets">
+ <category id="portlet.category">
+ <label>JBoss Portlets</label>
+ <description>JBoss Portlets</description>
+ </category>
+
<project-facet id="jboss.portlet">
- <label>JBoss Portlet</label>
+ <label>JBoss Core Portlet</label>
<description>
Adds support for the Java Portlet API.
</description>
+ <member category="portlet.category "/>
<default-version version="2.0"/>
</project-facet>
@@ -89,6 +95,7 @@
<description>
Adds support for the JSF Portlet.
</description>
+ <member category="portlet.category "/>
<default-version version="1.0"/>
</project-facet>
@@ -146,6 +153,77 @@
id="org.jboss.tools.portlet.core.internal.jsfportletlibrarycontainer.v10"/>
</extension>
+ <extension point="org.eclipse.wst.common.project.facet.core.facets">
+
+ <project-facet id="jboss.seamportlet">
+ <label>JBoss Seam Portlet</label>
+ <description>
+ Adds support for the Seam Portlet.
+ </description>
+ <member category="portlet.category "/>
+ <default-version version="1.0"/>
+ </project-facet>
+
+ <project-facet-version facet="jboss.seamportlet" version="1.0">
+ <constraint>
+ <and>
+ <requires facet="jst.java" version="[5.0"/>
+ <requires facet="jst.web" version="[2.3"/>
+ <requires facet="jboss.portlet" version="[1.0"/>
+ <requires facet="jboss.jsfportlet" version="[1.0"/>
+ <requires facet="jst.jsf" version="[1.2"/>
+ <requires facet="jst.seam" version="[2.0"/>
+ </and>
+ </constraint>
+ </project-facet-version>
+
+ <action id="jboss.seamportlet.install" facet="jboss.seamportlet" type="INSTALL" version="1.0">
+ <delegate class="org.jboss.tools.portlet.core.internal.project.facet.SeamPortletFacetInstallDelegate"/>
+ <config-factory class="org.jboss.tools.portlet.core.internal.project.facet.SeamPortletFacetInstallDataModelProvider"/>
+ </action>
+
+ <action id="jboss.seamportlet.uninstall" facet="jboss.seamportlet" type="UNINSTALL" version="1.0" >
+ <delegate class="org.jboss.tools.portlet.core.internal.project.facet.SeamPortletFacetUninstallDelegate"/>
+ </action>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.presets">
+ <static-preset id="preset.jboss.seamportlet.v20">
+ <label>JBoss Seam Portlet Project v2.0</label>
+ <facet id="jst.java" version="5.0" />
+ <facet id="jst.web" version="2.5"/>
+ <facet id="jst.jsf" version="1.2"/>
+ <facet id="jboss.portlet" version="2.0" />
+ <facet id="jboss.jsfportlet" version="1.0" />
+ <facet id="jboss.seamportlet" version="1.0" />
+ <facet id="jst.seam" version="2.0" />
+ <description>JBoss Seam Portlet Project v2.0</description>
+ </static-preset>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.presets">
+ <dynamic-preset id="preset.jboss.seamportlet.v10">
+ <factory class="org.jboss.tools.portlet.core.internal.project.facet.SeamPortletConfigurationPresetFactory10"/>
+ </dynamic-preset>
+ </extension>
+
+ <extension point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <supported>
+ <runtime-component any="true"/>
+ <facet id="jboss.seamportlet" version="1.0"/>
+ </supported>
+ </extension>
+
+ <!--
+ <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer class="org.jboss.tools.portlet.core.internal.SeamPortlet10LibrariesContainerInitializer"
+ id="org.jboss.tools.portlet.core.internal.seamportletlibrarycontainer.v10"/>
+ </extension>
+ -->
+
<extension point="org.eclipse.wst.xml.core.catalogContributions">
<catalogContribution id="default">
<public
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-08-02 03:11:36 UTC (rev 9479)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-08-04 00:41:46 UTC (rev 9480)
@@ -23,6 +23,8 @@
static final String JSFPORTLET_FACET_ID="jboss.jsfportlet";
+ static final String SEAMPORTLET_FACET_ID="jboss.seamportlet";
+
static final String CONFIG_PATH = "WEB-INF/portlet.xml";
static final String PORTLET_FACET_VERSION_10 = "1.0";
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-08-02 03:11:36 UTC (rev 9479)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java 2008-08-04 00:41:46 UTC (rev 9480)
@@ -265,7 +265,6 @@
util.configureFilterMapping(project, monitor, filterName,
servletName);
- // FIXME add Seam settings
}
}, modelPath);
}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletConfigurationPresetFactory10.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletConfigurationPresetFactory10.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletConfigurationPresetFactory10.java 2008-08-04 00:41:46 UTC (rev 9480)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * Copyright (c) 2008 BEA Systems, Inc. and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik
+ ******************************************************************************/
+
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jst.common.project.facet.JavaFacetUtils;
+import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
+import org.eclipse.wst.common.project.facet.core.IDynamicPreset;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
+import org.eclipse.wst.common.project.facet.core.IPresetFactory;
+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.PresetDefinition;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.portlet.core.IPortletConstants;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
+ * @author snjeza
+ */
+
+public final class SeamPortletConfigurationPresetFactory10
+
+implements IPresetFactory {
+ public PresetDefinition createPreset(final String presetId,
+ final Map<String, Object> context)
+
+ throws CoreException {
+ final IFacetedProjectBase fproj = (IFacetedProjectBase) context
+ .get(IDynamicPreset.CONTEXT_KEY_FACETED_PROJECT);
+ final IProjectFacetVersion webFacetVersion = fproj
+ .getProjectFacetVersion(WebFacetUtils.WEB_FACET);
+ final IProjectFacet PORTLET_FACET = ProjectFacetsManager.getProjectFacet(IPortletConstants.PORTLET_FACET_ID);
+ final IProjectFacetVersion portletFacetVersion = PORTLET_FACET.getVersion(IPortletConstants.PORTLET_FACET_VERSION_10);
+ final IProjectFacet JSF_FACET = ProjectFacetsManager.getProjectFacet("jst.jsf");
+ final IProjectFacetVersion jsfFacetVersion = JSF_FACET.getVersion("1.2");
+ final IProjectFacet SEAM_FACET = ProjectFacetsManager.getProjectFacet("jst.seam");
+ final IProjectFacetVersion seamFacetVersion = SEAM_FACET.getVersion("2.0");
+ if (webFacetVersion != null
+ && webFacetVersion.compareTo(WebFacetUtils.WEB_23) >= 0 &&
+ portletFacetVersion != null) {
+ final Set<IProjectFacetVersion> facets = new HashSet<IProjectFacetVersion>();
+ final IProjectFacet jsfPortletFacet = ProjectFacetsManager
+ .getProjectFacet(IPortletConstants.JSFPORTLET_FACET_ID);
+ final IProjectFacetVersion jsfPortletVersion = jsfPortletFacet
+ .getVersion(IPortletConstants.JSFPORTLET_FACET_VERSION_10);
+ facets.add(jsfPortletVersion);
+ facets.add(webFacetVersion);
+ facets.add(JavaFacetUtils.JAVA_50);
+ facets.add(portletFacetVersion);
+ facets.add(jsfFacetVersion);
+ facets.add(seamFacetVersion);
+ return new PresetDefinition("JBoss Seam Portlet Project v1.0",
+ "JBoss Seam Portlet Project v1.0", facets);
+ }
+ return null;
+ }
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDataModelProvider.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDataModelProvider.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDataModelProvider.java 2008-08-04 00:41:46 UTC (rev 9480)
@@ -0,0 +1,39 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.util.Set;
+
+import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
+import org.jboss.tools.portlet.core.IPortletConstants;
+
+/**
+ * @author snjeza
+ *
+ */
+public class SeamPortletFacetInstallDataModelProvider extends
+ FacetInstallDataModelProvider implements IPortletConstants {
+
+ @Override
+ public Object getDefaultProperty(String propertyName) {
+ if(propertyName.equals(FACET_ID)){
+ return IPortletConstants.SEAMPORTLET_FACET_ID;
+ }
+
+ return super.getDefaultProperty(propertyName);
+ }
+
+ @Override
+ public Set<String> getPropertyNames() {
+ Set<String> propertyNames = super.getPropertyNames();
+ return propertyNames;
+ }
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDelegate.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDelegate.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetInstallDelegate.java 2008-08-04 00:41:46 UTC (rev 9480)
@@ -0,0 +1,154 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.Path;
+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.model.IModelProvider;
+import org.eclipse.jst.javaee.web.WebApp;
+import org.eclipse.jst.javaee.web.WebAppVersionType;
+import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
+import org.eclipse.jst.jsf.facesconfig.emf.StateManagerType;
+import org.eclipse.jst.jsf.facesconfig.emf.ViewHandlerType;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+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.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.portlet.core.IJBossWebUtil;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.JBossWebUtil;
+import org.jboss.tools.portlet.core.JBossWebUtil25;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class SeamPortletFacetInstallDelegate implements IDelegate {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse
+ * .core.resources.IProject,
+ * org.eclipse.wst.common.project.facet.core.IProjectFacetVersion,
+ * java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(final IProject project, final IProjectFacetVersion fv,
+ final Object cfg, final IProgressMonitor monitor)
+ throws CoreException {
+
+ if (monitor != null) {
+ monitor.beginTask("", 1);
+ }
+ try {
+ IDataModel config = null;
+
+ if (cfg != null) {
+ config = (IDataModel) cfg;
+ } else {
+ throw new CoreException(
+ PortletCoreActivator
+ .getStatus("Internal Error creating JBoss Seam Portlet Facet. Missing configuration."));
+ }
+
+ // check whether web.xml is available for update
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ if (provider == null) {
+ throw new CoreException(
+ PortletCoreActivator
+ .getStatus("Cannot configure web module for JBoss Seam Portlet Facet"));
+ } else if (!(provider.validateEdit(null, null).isOK())) {
+ if (!(provider.validateEdit(null, null).isOK())) {
+ throw new CoreException(PortletCoreActivator
+ .getStatus("The web.xml file is not updateable"));
+ }
+ }
+
+ configureWebApp(project, monitor, config);
+
+ if (monitor != null) {
+ monitor.worked(1);
+ }
+
+ } finally {
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
+ }
+
+ private void configureWebApp(final IProject project,
+ final IProgressMonitor monitor, IDataModel config) {
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ IPath modelPath = new Path("WEB-INF").append("web.xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean exists = project.getProjectRelativePath().append(modelPath)
+ .toFile().exists();
+ if (isWebApp25(provider.getModelObject()) && !exists) {
+ modelPath = IModelProvider.FORCESAVE;
+ }
+ provider.modify(new Runnable() {
+ public void run() {
+ IJBossWebUtil util = null;
+
+ if (isWebApp25(provider.getModelObject())) {
+ util = new JBossWebUtil25();
+ } else {
+ util = new JBossWebUtil();
+ }
+ String name = "org.jboss.portletbridge.ExceptionHandler";
+ String value = "org.jboss.portletbridge.SeamExceptionHandlerImpl";
+ String description = null;
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ // FIXME optional for Seam portlets version 2.1.x and up
+ name = "javax.faces.LIFECYCLE_ID";
+ value = "SEAM_PORTLET";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+ }
+ }, modelPath);
+ }
+
+ private boolean isWebApp25(final Object webApp) {
+ if (webApp instanceof WebApp
+ && ((WebApp) webApp).getVersion() == WebAppVersionType._25_LITERAL)
+ return true;
+ return false;
+ }
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetUninstallDelegate.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetUninstallDelegate.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/SeamPortletFacetUninstallDelegate.java 2008-08-04 00:41:46 UTC (rev 9480)
@@ -0,0 +1,34 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+/**
+ * @author snjeza
+ *
+ */
+public class SeamPortletFacetUninstallDelegate implements IDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
17 years, 4 months
JBoss Tools SVN: r9479 - in trunk: core/plugins/org.jboss.ide.eclipse.archives.ui and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-01 23:11:36 -0400 (Fri, 01 Aug 2008)
New Revision: 9479
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProviderDelegate.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootBridgeContentProvider.java
Removed:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java
Log:
JBIDE-460 - archives view in common nav
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -55,7 +55,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
-import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProviderDelegate;
import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
@@ -94,7 +94,7 @@
previewGroup.setLayout(new FormLayout());
previewViewer = new TreeViewer(previewGroup);
previewViewer.setLabelProvider(new ArchivesLabelProvider());
- previewViewer.setContentProvider(new ArchivesContentProvider());
+ previewViewer.setContentProvider(new ArchivesContentProviderDelegate());
FormData warPreviewData = new FormData();
warPreviewData.left = new FormAttachment(0,5);
warPreviewData.right = new FormAttachment(100,-5);
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2008-08-02 03:11:36 UTC (rev 9479)
@@ -89,14 +89,16 @@
<includes>
<contentExtension
isRoot="true"
- pattern="org.jboss.ide.eclipse.archives.ui.archivesRootContent">
- </contentExtension>
- <contentExtension
- isRoot="true"
pattern="org.jboss.ide.eclipse.archives.ui.archivesContent">
</contentExtension>
</includes>
</viewerContentBinding>
+ <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <contentExtension pattern="org.jboss.ide.eclipse.archives.ui.archivesRootBridgeContent"/>
+ </includes>
+ </viewerContentBinding>
+
</extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
@@ -104,9 +106,9 @@
activeByDefault="true"
contentProvider="org.jboss.ide.eclipse.archives.ui.views.ArchivesRootContentProvider"
icon="icons/jar_obj.gif"
- id="org.jboss.ide.eclipse.archives.ui.archivesRootContent"
+ id="org.jboss.ide.eclipse.archives.ui.archivesContent"
labelProvider="org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider"
- name="Archives Content Root"
+ name="Archives Content"
priority="normal"
providesSaveables="true">
<triggerPoints>
@@ -114,16 +116,25 @@
value="org.eclipse.core.resources.IWorkspaceRoot">
</instanceof>
</triggerPoints>
+ <possibleChildren>
+ <or>
+ <instanceof
+ value="org.jboss.ide.eclipse.archives.core.model.IArchiveNode">
+ </instanceof>
+ </or>
+ </possibleChildren>
+ <actionProvider
+ class="org.jboss.ide.eclipse.archives.ui.views.ArchivesActionProvider"
+ id="org.jboss.ide.eclipse.archives.ui.views.ArchivesActionProvider1">
+ </actionProvider>
</navigatorContent>
<navigatorContent
- activeByDefault="true"
- contentProvider="org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider"
+ contentProvider="org.jboss.ide.eclipse.archives.ui.views.ArchivesRootBridgeContentProvider"
icon="icons/jar_obj.gif"
- id="org.jboss.ide.eclipse.archives.ui.archivesContent"
+ id="org.jboss.ide.eclipse.archives.ui.archivesRootBridgeContent"
labelProvider="org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider"
- name="Archives Content"
- priority="normal"
- providesSaveables="true">
+ name="Project Archives"
+ priority="lower">
<triggerPoints>
<instanceof
value="org.eclipse.core.resources.IProject">
@@ -131,7 +142,7 @@
</triggerPoints>
<actionProvider
class="org.jboss.ide.eclipse.archives.ui.views.ArchivesActionProvider"
- id="org.jboss.ide.eclipse.archives.ui.views.ArchivesActionProvider">
+ id="org.jboss.ide.eclipse.archives.ui.views.ArchivesActionProvider2">
</actionProvider>
<possibleChildren>
<or>
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -1,6 +1,5 @@
package org.jboss.ide.eclipse.archives.ui.providers;
-import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.graphics.Image;
@@ -13,7 +12,8 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
-import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider.DelayProxy;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProviderDelegate.DelayProxy;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProviderDelegate.WrappedProject;
public class ArchivesLabelProvider extends BaseLabelProvider implements ILabelProvider {
@@ -44,8 +44,15 @@
}
private Image internalGetImage(Object element) {
- if( element instanceof IProject )
- return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
+ if( element instanceof WrappedProject ) {
+ switch(((WrappedProject)element).getType()) {
+ case WrappedProject.NAME:
+ return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
+ case WrappedProject.CATEGORY:
+ return ArchivesSharedImages.getImage(ArchivesSharedImages.IMG_PACKAGE);
+ }
+ }
+
if( element instanceof IArchiveNode ) {
IArchiveNode node = (IArchiveNode) element;
if (node != null) {
@@ -69,10 +76,16 @@
}
private String internalGetText(Object element) {
+ if( element instanceof WrappedProject ) {
+ switch(((WrappedProject)element).getType()) {
+ case WrappedProject.NAME:
+ return (((WrappedProject)element).getElement().getName());
+ case WrappedProject.CATEGORY:
+ return "Project Archives";
+ }
+ }
if( element instanceof DelayProxy )
return "Loading...";
- if( element instanceof IProject)
- return ((IProject)element).getProject().getName();
if( element instanceof IArchiveNode ) {
switch (((IArchiveNode)element).getNodeType()) {
case IArchiveNode.TYPE_ARCHIVE: return getPackageText((IArchive)element);
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -224,8 +224,7 @@
* the implementations of the action, where the action does its work etc
*/
- private void createFolder ()
- {
+ private void createFolder () {
IInputValidator validator = new IInputValidator () {
public String isValid(String newText) {
IArchiveNode selected = getSelectedNode();
Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -1,99 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.views;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.jboss.ide.eclipse.archives.core.build.RegisterArchivesJob;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-
-public class ArchivesContentProvider implements ITreeContentProvider {
-
- protected ArrayList<Viewer> viewersInUse = new ArrayList<Viewer>();
- protected ArrayList<IProject> loadingProjects = new ArrayList<IProject>();
-
- public Object[] getChildren(Object parentElement) {
- if( parentElement instanceof IProject ) {
- IProject p = (IProject)parentElement;
-
- // if currently loading, always send a delay
- if( loadingProjects.contains(p))
- return new Object[]{new DelayProxy(p)};
-
- if( ArchivesModel.instance().isProjectRegistered(p.getLocation()))
- return ArchivesModel.instance().getRoot(p.getLocation()).getAllChildren();
- if( ArchivesModel.instance().canReregister(p.getLocation())) {
- loadingProjects.add(p);
- DelayProxy dp = new DelayProxy(p);
- launchRegistrationThread(dp);
- return new Object[]{dp};
- }
- }
- if( parentElement instanceof IArchiveNode )
- return ((IArchiveNode)parentElement).getAllChildren();
- return new Object[0];
- }
-
- public static class DelayProxy {
- public IProject project;
- public DelayProxy(IProject p) {this.project = p; }
- }
-
- protected void launchRegistrationThread(final DelayProxy dp) {
- Runnable callback = new Runnable() {
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- loadingProjects.remove(dp.project);
- Iterator it = viewersInUse.iterator();
- while(it.hasNext()) {
- Viewer next = ((Viewer)it.next());
- if( next instanceof StructuredViewer)
- ((StructuredViewer)next).refresh(dp.project);
- else
- next.refresh();
- }
- }
- });
- }
- };
- RegisterArchivesJob job = new RegisterArchivesJob(new IProject[]{dp.project}, callback);
- job.schedule();
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if( element instanceof IArchiveNode )
- return getChildren(element).length > 0;
- if( element instanceof IResource )
- return ArchivesModel.instance().canReregister(((IResource)element).getLocation());
- return true;
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if( newInput != null) {
- if( !viewersInUse.contains(viewer)) {
- viewersInUse.add(viewer);
- }
- } else {
- viewersInUse.remove(viewer);
- }
- }
-
-}
Copied: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProviderDelegate.java (from rev 9476, trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java)
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProviderDelegate.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProviderDelegate.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -0,0 +1,184 @@
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.ide.eclipse.archives.core.build.RegisterArchivesJob;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+
+public class ArchivesContentProviderDelegate implements ITreeContentProvider, IArchiveModelListener {
+
+ // Because all viewers need to be updated, this must be a singleton
+ private static ArchivesContentProviderDelegate singleton;
+ public static ArchivesContentProviderDelegate getDefault() {
+ if( singleton == null )
+ singleton = new ArchivesContentProviderDelegate();
+ return singleton;
+ }
+
+ public static class WrappedProject {
+ public static final int NAME = 1;
+ public static final int CATEGORY = 2;
+ private IProject element;
+ private int type;
+ public WrappedProject(IProject element) { this.element = element; }
+ public WrappedProject(IProject element, int type) { this.element = element; this.type = type;}
+ public IProject getElement() { return element; }
+ public int getType() { return type; }
+ public boolean equals(Object otherObject) {
+ if( otherObject instanceof WrappedProject && element.equals(((WrappedProject)otherObject).element))
+ return true;
+ return false;
+ }
+ }
+
+ public static class DelayProxy {
+ public WrappedProject wProject;
+ public IProject project;
+ public DelayProxy(WrappedProject wp) {
+ this.wProject = wp;
+ this.project = wProject.element;
+ }
+ }
+
+ public ArchivesContentProviderDelegate() {
+ ArchivesModel.instance().addModelListener(this);
+ }
+ public ArchivesContentProviderDelegate(boolean addListener) {
+ if( addListener)
+ ArchivesModel.instance().addModelListener(this);
+ }
+
+ protected ArrayList<Viewer> viewersInUse = new ArrayList<Viewer>();
+ protected ArrayList<IProject> loadingProjects = new ArrayList<IProject>();
+
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof WrappedProject ) {
+ WrappedProject wp = (WrappedProject)parentElement;
+ IProject p = ((WrappedProject)parentElement).getElement();
+
+ // if currently loading, always send a delay
+ if( loadingProjects.contains(p))
+ return new Object[]{new DelayProxy(wp)};
+
+ if( ArchivesModel.instance().isProjectRegistered(p.getLocation()))
+ return ArchivesModel.instance().getRoot(p.getLocation()).getAllChildren();
+ if( ArchivesModel.instance().canReregister(p.getLocation())) {
+ loadingProjects.add(p);
+ DelayProxy dp = new DelayProxy(wp);
+ launchRegistrationThread(dp);
+ return new Object[]{dp};
+ }
+ }
+ if( parentElement instanceof IArchiveNode )
+ return ((IArchiveNode)parentElement).getAllChildren();
+ return new Object[0];
+ }
+
+
+ protected void launchRegistrationThread(final DelayProxy dp) {
+ Runnable callback = new Runnable() {
+ public void run() {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ loadingProjects.remove(dp.project);
+ Iterator<Viewer> it = viewersInUse.iterator();
+ while(it.hasNext()) {
+ Viewer next = ((Viewer)it.next());
+ if( next instanceof StructuredViewer)
+ ((StructuredViewer)next).refresh(dp.wProject);
+ else
+ next.refresh();
+ }
+ }
+ });
+ }
+ };
+ RegisterArchivesJob job = new RegisterArchivesJob(new IProject[]{dp.project}, callback);
+ job.schedule();
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ if( element instanceof IArchiveNode )
+ return getChildren(element).length > 0;
+ if( element instanceof IResource )
+ return ArchivesModel.instance().canReregister(((IResource)element).getLocation());
+ return true;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ ArchivesModel.instance().removeModelListener(this);
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if( newInput != null) {
+ if( !viewersInUse.contains(viewer)) {
+ viewersInUse.add(viewer);
+ }
+ } else {
+ viewersInUse.remove(viewer);
+ }
+ }
+ public void modelChanged(IArchiveNodeDelta delta) {
+
+ final IArchiveNode[] topChanges;
+ if( delta.getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
+ topChanges = getChanges(delta);
+ else if( delta.getKind() == IArchiveNodeDelta.NO_CHANGE)
+ return;
+ else
+ topChanges = new IArchiveNode[]{delta.getPostNode()};
+
+ final Viewer[] viewers = (Viewer[]) viewersInUse.toArray(new Viewer[viewersInUse.size()]);
+
+ // now go through and refresh them
+ Display.getDefault().asyncExec(new Runnable () {
+ public void run () {
+ for( int i = 0; i < topChanges.length; i++ ) {
+ for (int j = 0; j < viewers.length; j++ ) {
+ if( viewers[j] instanceof StructuredViewer ) {
+ ((StructuredViewer)viewers[j]).refresh(topChanges[i]);
+ if( viewers[j] instanceof TreeViewer ) {
+ ((TreeViewer)viewers[j]).expandToLevel(topChanges[i], 1);
+ }
+ } else
+ viewers[j].refresh();
+ }
+ }
+ }
+ });
+ }
+
+ protected IArchiveNode[] getChanges(IArchiveNodeDelta delta) {
+
+ IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
+ ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
+ for( int i = 0; i < children.length; i++ ) {
+ if( children[i].getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
+ list.addAll(Arrays.asList(getChanges(children[i])));
+ else
+ list.add(children[i].getPostNode());
+ }
+ return list.toArray(new IArchiveNode[list.size()]);
+ }
+
+}
Property changes on: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProviderDelegate.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootBridgeContentProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootBridgeContentProvider.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootBridgeContentProvider.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -0,0 +1,39 @@
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProviderDelegate.WrappedProject;
+
+public class ArchivesRootBridgeContentProvider implements ITreeContentProvider {
+ private ArchivesContentProviderDelegate delegate;
+ public ArchivesRootBridgeContentProvider() {
+ delegate = ArchivesContentProviderDelegate.getDefault();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof IProject )
+ return new Object[] { new WrappedProject((IProject)parentElement, WrappedProject.CATEGORY) };
+ return delegate.getChildren(parentElement);
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return delegate.hasChildren(element);
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ delegate.inputChanged(viewer, oldInput, newInput);
+ }
+
+}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -8,11 +8,16 @@
import org.eclipse.jface.viewers.Viewer;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProviderDelegate.WrappedProject;
public class ArchivesRootContentProvider implements ITreeContentProvider {
+ private ArchivesContentProviderDelegate delegate;
+ public ArchivesRootContentProvider() {
+ delegate = ArchivesContentProviderDelegate.getDefault();
+ }
public Object[] getChildren(Object parentElement) {
- return new Object[0];
+ return delegate.getChildren(parentElement);
}
public Object getParent(Object element) {
@@ -20,7 +25,7 @@
}
public boolean hasChildren(Object element) {
- return false;
+ return delegate.hasChildren(element);
}
public Object[] getElements(Object inputElement) {
@@ -31,19 +36,28 @@
for( int i = 0; i < projects.length; i++ )
if( ArchivesModel.instance().canReregister(projects[i].getLocation()))
tmp.add(projects[i]);
- return (IProject[]) tmp.toArray(new IProject[tmp.size()]);
+ return wrap((IProject[]) tmp.toArray(new IProject[tmp.size()]));
}
IProject cp = ProjectArchivesCommonView.getInstance().getCurrentProject();
if( cp != null )
- return new Object[]{cp};
+ return wrap(new IProject[]{cp});
}
return new Object[]{};
}
+ protected Object[] wrap(IProject[] objs) {
+ WrappedProject[] projs = new WrappedProject[objs.length];
+ for( int i = 0; i < projs.length; i++)
+ projs[i] = new WrappedProject(objs[i], WrappedProject.NAME);
+ return projs;
+ }
+
public void dispose() {
+ delegate.dispose();
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ delegate.inputChanged(viewer, oldInput, newInput);
}
private boolean showProjectRoot () {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -12,7 +12,6 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.INullSelectionListener;
import org.eclipse.ui.ISelectionListener;
@@ -22,15 +21,12 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.CommonNavigator;
import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
-public class ProjectArchivesCommonView extends CommonNavigator implements IArchiveModelListener {
+public class ProjectArchivesCommonView extends CommonNavigator {
protected static ProjectArchivesCommonView instance;
protected ISelectionListener selectionListener;
protected IProject currentProject;
@@ -53,13 +49,11 @@
public void init(IViewSite site) throws PartInitException {
super.init(site);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);
- ArchivesModel.instance().addModelListener(this);
}
public void dispose() {
super.dispose();
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);
- ArchivesModel.instance().removeModelListener(this);
}
protected ISelectionListener createSelectionListener() {
@@ -97,14 +91,6 @@
};
}
- public void modelChanged(IArchiveNodeDelta delta) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- getCommonViewer().refresh();
- }
- });
- }
-
public IProject getCurrentProject() {
return currentProject;
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java 2008-08-02 00:40:46 UTC (rev 9478)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java 2008-08-02 03:11:36 UTC (rev 9479)
@@ -8,7 +8,7 @@
import org.eclipse.swt.widgets.Label;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
-import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProviderDelegate;
import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
@@ -34,7 +34,7 @@
new Label(main, SWT.NONE).setText("Preview");
TreeViewer previewTree = new TreeViewer(main);
- previewTree.setContentProvider(new ArchivesContentProvider());
+ previewTree.setContentProvider(new ArchivesContentProviderDelegate(false));
previewTree.setLabelProvider(new ArchivesLabelProvider());
previewTree.setInput(wizard.getArchive());
17 years, 4 months
JBoss Tools SVN: r9478 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-01 20:40:46 -0400 (Fri, 01 Aug 2008)
New Revision: 9478
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/RegisterArchivesJob.java
Log:
JBIDE-460 - archives view in common nav
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/RegisterArchivesJob.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/RegisterArchivesJob.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/RegisterArchivesJob.java 2008-08-02 00:40:46 UTC (rev 9478)
@@ -0,0 +1,36 @@
+package org.jboss.ide.eclipse.archives.core.build;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+
+public class RegisterArchivesJob extends Job {
+ private IProject[] projects;
+ private Runnable callback;
+ public RegisterArchivesJob(IProject[] projects, Runnable callback) {
+ super("Register Project Archives");
+ this.projects = projects;
+ this.callback = callback;
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ // register the projects
+ for( int i = 0; i < projects.length; i++ ) {
+ try {
+ ArchivesModel.instance().registerProject(projects[i].getLocation(), monitor);
+ } catch( ArchivesModelException ame ) {
+ IStatus status = new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID, ame.getMessage(), ame);
+ return status;
+ }
+ }
+
+ callback.run();
+ return Status.OK_STATUS;
+ }
+
+}
17 years, 4 months
JBoss Tools SVN: r9477 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-01 20:40:16 -0400 (Fri, 01 Aug 2008)
New Revision: 9477
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEARAction.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEJBJARAction.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewWARAction.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java
Log:
JBIDE-460 - archives view in common nav
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEARAction.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEARAction.java 2008-08-02 00:40:00 UTC (rev 9476)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEARAction.java 2008-08-02 00:40:16 UTC (rev 9477)
@@ -22,48 +22,43 @@
package org.jboss.ide.eclipse.as.ui.packages;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.actions.ActionWithDelegate;
-import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
import org.jboss.ide.eclipse.as.core.extensions.archives.EarArchiveType;
-public class NewEARAction extends ActionWithDelegate {
+public class NewEARAction implements IActionDelegate {
+ private IStructuredSelection selection;
public void run() {
AbstractArchiveWizard wizard = new NewEARWizard();
- wizard.init(PlatformUI.getWorkbench(), ProjectArchivesView.getInstance().getSelection());
+ wizard.init(PlatformUI.getWorkbench(), selection);
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
dialog.open();
}
- public IStructuredSelection getSelection() {
- return ProjectArchivesView.getInstance().getSelection();
- }
- public ImageDescriptor getImageDescriptor() {
- return ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_EJB_JAR);
+ public void run(IAction action) {
+ run();
}
-
- public String getText() {
- return "EAR";
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if( selection instanceof IStructuredSelection)
+ this.selection = (IStructuredSelection)selection;
}
- public String getToolTipText() {
- return "Create a new EAR archive";
- }
-
public void init(IViewPart view) {
-
}
public static class NewEARWizard extends AbstractArchiveWizard {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEJBJARAction.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEJBJARAction.java 2008-08-02 00:40:00 UTC (rev 9476)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewEJBJARAction.java 2008-08-02 00:40:16 UTC (rev 9477)
@@ -22,50 +22,38 @@
package org.jboss.ide.eclipse.as.ui.packages;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.PlatformUI;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.actions.ActionWithDelegate;
-import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
import org.jboss.ide.eclipse.as.core.extensions.archives.EjbArchiveType;
-public class NewEJBJARAction extends ActionWithDelegate implements IViewActionDelegate {
-
+public class NewEJBJARAction implements IActionDelegate {
+ private IStructuredSelection selection;
public void run() {
AbstractArchiveWizard wizard = new NewEJBWizard();
- wizard.init(PlatformUI.getWorkbench(), ProjectArchivesView.getInstance().getSelection());
+ wizard.init(PlatformUI.getWorkbench(), selection);
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
dialog.open();
}
- public IStructuredSelection getSelection() {
- return ProjectArchivesView.getInstance().getSelection();
+
+ public void run(IAction action) {
+ run();
}
-
- public ImageDescriptor getImageDescriptor() {
- return ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_EJB_JAR);
+ public void selectionChanged(IAction action, ISelection selection) {
+ if( selection instanceof IStructuredSelection)
+ this.selection = (IStructuredSelection)selection;
}
-
- public String getText() {
- return "EJB JAR";
- }
-
- public String getToolTipText() {
- return "Create a new EJB JAR archive";
- }
-
- public void init(IViewPart view) {
-
- }
public static class NewEJBWizard extends AbstractArchiveWizard {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewWARAction.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewWARAction.java 2008-08-02 00:40:00 UTC (rev 9476)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/NewWARAction.java 2008-08-02 00:40:16 UTC (rev 9477)
@@ -22,47 +22,41 @@
package org.jboss.ide.eclipse.as.ui.packages;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.actions.ActionWithDelegate;
-import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
import org.jboss.ide.eclipse.as.core.extensions.archives.WarArchiveType;
-public class NewWARAction extends ActionWithDelegate implements IViewActionDelegate {
-
+public class NewWARAction implements IActionDelegate {
+ private IStructuredSelection selection;
public void run() {
NewWARWizard wizard = new NewWARWizard();
- wizard.init(PlatformUI.getWorkbench(), ProjectArchivesView.getInstance().getSelection());
+ wizard.init(PlatformUI.getWorkbench(), selection);
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
dialog.open();
}
-
- public ImageDescriptor getImageDescriptor() {
- return ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_WAR);
+
+ public void run(IAction action) {
+ run();
}
-
- public String getText() {
- return "WAR";
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if( selection instanceof IStructuredSelection)
+ this.selection = (IStructuredSelection)selection;
}
+
- public String getToolTipText() {
- return "Create a new WAR archive";
- }
-
- public void init(IViewPart view) {
-
- }
-
public static class NewWARWizard extends AbstractArchiveWizard {
private WarPreviewPage warInfoPage;
@@ -107,9 +101,4 @@
"You can customize this structure further after pressing finish.";
}
}
-
- public IStructuredSelection getSelection() {
- return ProjectArchivesView.getInstance().getSelection();
- }
-
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java 2008-08-02 00:40:00 UTC (rev 9476)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java 2008-08-02 00:40:16 UTC (rev 9477)
@@ -54,8 +54,8 @@
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider;
import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider;
import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
17 years, 4 months
JBoss Tools SVN: r9476 - in trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui: actions and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-01 20:40:00 -0400 (Fri, 01 Aug 2008)
New Revision: 9476
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
Removed:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/ActionWithDelegate.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/dialogs/
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesContentProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/garbage/
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/NodeContribution.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewArchiveAction.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewJARAction.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
Log:
JBIDE-460 - archives view in common nav
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/NodeContribution.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/NodeContribution.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/NodeContribution.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -24,7 +24,7 @@
try {
actionDelegate = (INodeActionDelegate) element.createExecutableExtension("class");
} catch (CoreException e) {
-//TODO Trace.trace(getClass(), e);
+ //TODO Trace.trace(getClass(), e);
}
String iconPath = element.getAttribute("icon");
Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/ActionWithDelegate.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/ActionWithDelegate.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/ActionWithDelegate.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -1,47 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-
-public abstract class ActionWithDelegate extends Action implements IActionDelegate, ISelectionListener {
-
-/*
- * Constructors
- */
- public ActionWithDelegate () {
- }
-
- public ActionWithDelegate(String text) {
- super(text);
- }
-
- public ActionWithDelegate(String text, ImageDescriptor image) {
- super(text, image);
- }
-
- public ActionWithDelegate(String text, int style) {
- super(text, style);
- }
-
-
-
- public abstract void run ();
-
- public void run(IAction action) {
- run();
- }
-
- public abstract IStructuredSelection getSelection();
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- }
-
-}
\ No newline at end of file
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewArchiveAction.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewArchiveAction.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewArchiveAction.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -29,15 +29,14 @@
try {
action = (IActionDelegate) element.createExecutableExtension("class");
} catch (CoreException e) {
-//TODO Trace.trace(getClass(), e);
+ //TODO
}
String iconPath = element.getAttribute("icon");
String pluginId = element.getDeclaringExtension().getNamespaceIdentifier();
Bundle bundle = Platform.getBundle(pluginId);
URL iconURL = FileLocator.find(bundle, new Path(iconPath), null);
- if (iconURL == null)
- {
+ if (iconURL == null) {
iconURL = bundle.getEntry(iconPath);
}
icon = ImageDescriptor.createFromURL(iconURL);
@@ -52,8 +51,7 @@
return icon;
}
- public Image getIcon()
- {
+ public Image getIcon() {
return iconImage;
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewJARAction.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewJARAction.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewJARAction.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -1,42 +1,33 @@
package org.jboss.ide.eclipse.archives.ui.actions;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.PlatformUI;
-import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
import org.jboss.ide.eclipse.archives.ui.wizards.NewJARWizard;
-public class NewJARAction extends ActionWithDelegate {
+public class NewJARAction implements IActionDelegate {
public void run() {
try {
- NewJARWizard wizard = new NewJARWizard();
-
- wizard.init(PlatformUI.getWorkbench(), getSelection());
-
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
- int response = dialog.open();
- if (response == Dialog.OK) {
- }
+ NewJARWizard wizard = new NewJARWizard();
+ wizard.init(PlatformUI.getWorkbench(), selection);
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
+ dialog.open();
} catch( Exception e ) {
- e.printStackTrace();
+ // TODO
}
}
- public IStructuredSelection getSelection() {
- return ProjectArchivesView.getInstance().getSelection();
+ private IStructuredSelection selection;
+ public void run(IAction action) {
+ run();
}
- public ImageDescriptor getImageDescriptor() {
- return ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_NEW_PACKAGE);
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ if( selection instanceof IStructuredSelection) {
+ this.selection = (IStructuredSelection)selection;
+ }
}
-
- public String getText() {
- return "JAR";
- }
-
- public String getToolTipText() {
- return "Create a new JAR package";
- }
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -21,7 +21,6 @@
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
-import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
public class MainPreferencePage extends PropertyPage implements
IWorkbenchPreferencePage {
@@ -183,8 +182,9 @@
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_FULL_FILESET_ROOT_DIR, showFullFilesetRootDir.getSelection(), getElement());
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT, showProjectRoot.getSelection(), getElement());
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS, showAllProjects.getSelection(), getElement());
- if( ProjectArchivesView.getInstance() != null )
- ProjectArchivesView.getInstance().refreshViewer(null);
+ // TODO FIX THIS
+// if( ProjectArchivesCommonView.getInstance() != null )
+// ProjectArchivesCommonView.getInstance().refreshViewer(null);
return true;
}
Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesContentProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesContentProvider.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesContentProvider.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -1,87 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.providers;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
-import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
-
-public class ArchivesContentProvider implements ITreeContentProvider {
-
- public ArchivesContentProvider () {
- }
-
- public static class WrappedProject {
- private IProject project;
- public WrappedProject (IProject proj) { project = proj; }
- public IProject getProject() { return project; }
- }
-
- private boolean showProjectRoot () {
- return PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT);
- }
-
- private Object[] wrapProjects(IProject[] project) {
- Object[] ret = new Object[project.length];
- for( int i = 0; i < project.length; i++ )
- ret[i] = new WrappedProject(project[i]);
- return ret;
- }
- public Object[] getChildren(Object parentElement) {
-
- if( parentElement instanceof Object[] ) return (Object[])parentElement;
-
-
- if( parentElement instanceof IArchiveModelRootNode && showProjectRoot()) {
- IProject[] projects;
- if( PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS)) {
- projects = ProjectArchivesView.getInstance().getAllProjectsWithPackages();
- } else {
- String projName = ((IArchiveModelRootNode)parentElement).getProjectPath().lastSegment();
- projects = new IProject[] { ResourcesPlugin.getWorkspace().getRoot().getProject(projName) };
- }
- return wrapProjects(projects);
- }
-
- if( parentElement instanceof IArchiveModelRootNode)
- return ((IArchiveModelRootNode)parentElement).getAllChildren();
-
- if( parentElement instanceof ArchivesModel ) {
- // return all that's there
- }
- if( parentElement instanceof WrappedProject ) {
- return ModelUtil.getProjectArchives(((WrappedProject)parentElement).getProject().getLocation());
- }
- if( parentElement instanceof IArchiveNode ) {
- return ((IArchiveNode)parentElement).getAllChildren();
- }
- return new Object[] {};
- }
-
- public Object getParent(Object element) {
- if( element instanceof IArchiveNode )
- return ((IArchiveNode)element).getParent();
- if( element instanceof WrappedProject )
- return ArchivesModel.instance().getRoot(((WrappedProject)element).getProject().getLocation());
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public void dispose() {}
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
-}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -1,7 +1,8 @@
package org.jboss.ide.eclipse.archives.ui.providers;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -12,9 +13,9 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider.WrappedProject;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider.DelayProxy;
-public class ArchivesLabelProvider implements ILabelProvider {
+public class ArchivesLabelProvider extends BaseLabelProvider implements ILabelProvider {
/*
@@ -43,8 +44,7 @@
}
private Image internalGetImage(Object element) {
- element = unwrapElement(element);
- if( element instanceof WrappedProject )
+ if( element instanceof IProject )
return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
if( element instanceof IArchiveNode ) {
IArchiveNode node = (IArchiveNode) element;
@@ -69,9 +69,10 @@
}
private String internalGetText(Object element) {
- element = unwrapElement(element);
- if( element instanceof WrappedProject)
- return ((WrappedProject)element).getProject().getName();
+ if( element instanceof DelayProxy )
+ return "Loading...";
+ if( element instanceof IProject)
+ return ((IProject)element).getProject().getName();
if( element instanceof IArchiveNode ) {
switch (((IArchiveNode)element).getNodeType()) {
case IArchiveNode.TYPE_ARCHIVE: return getPackageText((IArchive)element);
@@ -124,21 +125,4 @@
return text;
}
-
-
- protected Object unwrapElement(Object element) {
- return element; // to be used if we wrap everything for preferences
- }
-
-
- public void addListener(ILabelProviderListener listener) {}
-
- public void dispose() { }
-
- public boolean isLabelProperty(Object element, String property) {
- return true;
- }
-
- public void removeListener(ILabelProviderListener listener) { }
-
}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesActionProvider.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -0,0 +1,361 @@
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
+import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
+import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
+import org.jboss.ide.eclipse.archives.ui.NodeContribution;
+import org.jboss.ide.eclipse.archives.ui.actions.NewArchiveAction;
+import org.jboss.ide.eclipse.archives.ui.wizards.FilesetWizard;
+import org.jboss.ide.eclipse.archives.ui.wizards.NewJARWizard;
+
+public class ArchivesActionProvider extends CommonActionProvider {
+ public static final String NEW_PACKAGE_MENU_ID = "org.jboss.ide.eclipse.archives.ui.newPackageMenu";
+ public static final String NODE_CONTEXT_MENU_ID = "org.jboss.ide.eclipse.archives.ui.nodeContextMenu";
+ public static final String NEW_PACKAGE_ADDITIONS = "newPackageAdditions";
+
+ private MenuManager newPackageManager;
+ private NodeContribution[] nodePopupMenuContributions;
+ private NewArchiveAction[] newPackageActions;
+ private Action editAction, deleteAction, newFolderAction, newFilesetAction;
+ private Action buildAction;
+ private ICommonViewerSite site;
+
+ public ArchivesActionProvider() {
+ }
+
+ public void init(ICommonActionExtensionSite aSite) {
+ newPackageActions = ExtensionManager.findNewArchiveActions();
+ nodePopupMenuContributions = ExtensionManager.findNodePopupMenuContributions();
+ Arrays.sort(nodePopupMenuContributions);
+ site = aSite.getViewSite();
+ createActions();
+ newPackageManager = new MenuManager(ArchivesUIMessages.ProjectPackagesView_newPackageMenu_label, NEW_PACKAGE_MENU_ID);
+ newPackageManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ public void fillContextMenu(IMenuManager manager) {
+ menuAboutToShow2(manager);
+ }
+
+ public void menuAboutToShow2(IMenuManager manager) {
+ addNewPackageActions(newPackageManager);
+
+ IStructuredSelection selection = getSelection();
+ if (selection != null && !selection.isEmpty()) {
+ Object element = selection.getFirstElement();
+
+ if (element instanceof IProject) {
+ manager.add(newPackageManager);
+ manager.add(buildAction);
+ buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildProjectAction_label);
+ } else if( element instanceof IArchiveNode ){
+ IArchiveNode node = (IArchiveNode)element;
+
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE
+ || node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+ manager.add(newPackageManager);
+ manager.add(newFolderAction);
+ manager.add(newFilesetAction);
+ manager.add(new Separator());
+ }
+
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ editAction.setText(ArchivesUIMessages.ProjectPackagesView_editPackageAction_label);
+ deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label);
+ editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT));
+ buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildArchiveAction_label);
+ manager.add(buildAction);
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+ editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFolderAction_label);
+ deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFolderAction_label);
+ editAction.setImageDescriptor(platformDescriptor(ISharedImages.IMG_OBJ_FOLDER));
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
+ editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFilesetAction_label);
+ deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFilesetAction_label);
+ editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES));
+ }
+ manager.add(editAction);
+ manager.add(deleteAction);
+ addContextMenuContributions(node, manager);
+ }
+ } else {
+ manager.add(newPackageManager);
+ }
+ }
+
+ protected void createActions() {
+ newFolderAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFolderAction_label, platformDescriptor(ISharedImages.IMG_OBJ_FOLDER)) { //$NON-NLS-1$
+ public void run () {
+ createFolder();
+ }
+ };
+
+ newFilesetAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFilesetAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES)) { //$NON-NLS-1$
+ public void run () {
+ createFileset();
+ }
+ };
+
+ deleteAction = new Action (ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label, platformDescriptor(ISharedImages.IMG_TOOL_DELETE)) { //$NON-NLS-1$
+ public void run () {
+ deleteSelectedNode();
+ }
+ };
+
+ editAction = new Action (ArchivesUIMessages.ProjectPackagesView_editPackageAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT)) { //$NON-NLS-1$
+ public void run () {
+ editSelectedNode();
+ }
+ };
+
+ buildAction = new Action("", ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_BUILD_PACKAGES)) {
+ public void run() {
+ buildSelectedNode(getSelectedObject());
+ }
+ };
+ }
+
+
+
+
+ private void addContextMenuContributions (final IArchiveNode context, IMenuManager mgr) {
+
+ for( int i = 0; i < nodePopupMenuContributions.length; i++ ) {
+ final NodeContribution contribution = nodePopupMenuContributions[i];
+ if ( contribution.getActionDelegate().isEnabledFor(context)) {
+ Action action = new Action () {
+ public String getId() {
+ return contribution.getId();
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return contribution.getIcon();
+ }
+
+ public String getText() {
+ return contribution.getLabel();
+ }
+
+ public void run() {
+ contribution.getActionDelegate().run(context);
+ }
+ };
+ mgr.add(action);
+ }
+ }
+ }
+
+
+ /**
+ * Adds the new package type actions (which come from an extension point)
+ * to the menu.
+ * @param manager
+ */
+ private void addNewPackageActions (IMenuManager manager) {
+ for( int i = 0; i < newPackageActions.length; i++ ) {
+ NewArchiveAction action = newPackageActions[i];
+ ActionWrapper wrapped = new ActionWrapper(action);
+ wrapped.selectionChanged(getSelection());
+ manager.add(wrapped);
+ }
+ }
+
+ public class ActionWrapper extends Action {
+ private NewArchiveAction action;
+ public ActionWrapper(NewArchiveAction act) {
+ this.action = act;
+ }
+ public String getId() {
+ return action.getId();
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return action.getIconDescriptor();
+ }
+
+ public String getText() {
+ return action.getLabel();
+ }
+
+ public void run() {
+ action.getAction().run(null);
+ }
+
+ public void selectionChanged(IStructuredSelection sel) {
+ action.getAction().selectionChanged(this, sel);
+ }
+ }
+
+
+ /*
+ * Methods below are called from the standard actions,
+ * the implementations of the action, where the action does its work etc
+ */
+
+ private void createFolder ()
+ {
+ IInputValidator validator = new IInputValidator () {
+ public String isValid(String newText) {
+ IArchiveNode selected = getSelectedNode();
+
+ boolean folderExists = false;
+ IArchiveNode[] folders = selected.getChildren(IArchiveNode.TYPE_ARCHIVE_FOLDER);
+ for (int i = 0; i < folders.length; i++) {
+ IArchiveFolder folder = (IArchiveFolder) folders[i];
+ if (folder.getName().equals(newText)) {
+ folderExists = true; break;
+ }
+ }
+
+ if (folderExists) {
+ return ArchivesUIMessages.bind(
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_warnFolderExists, newText);
+
+ }
+ return null;
+ }
+ };
+
+ InputDialog dialog = new InputDialog(getShell(),
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, "", validator);
+
+ int response = dialog.open();
+ if (response == Dialog.OK) {
+ String[] folderPaths = dialog.getValue().split("[\\\\/]");
+ IArchiveNode selected = getSelectedNode();
+ IArchiveFolder current = null;
+ IArchiveFolder temp = null;
+
+ for(int i = folderPaths.length-1; i >= 0 ; i-- ) {
+ temp = ArchiveNodeFactory.createFolder();
+ temp.setName(folderPaths[i]);
+ if( current == null )
+ current = temp;
+ else {
+ temp.addChild(current);
+ current = temp;
+ }
+ }
+
+ selected.addChild(current);
+ new SaveArchivesJob(selected.getProjectPath()).schedule();
+ }
+ }
+
+ private void createFileset () {
+ IArchiveNode selected = getSelectedNode();
+ WizardDialog dialog = new WizardDialog(getShell(), new FilesetWizard(null, selected));
+ dialog.open();
+ }
+
+ private void editSelectedNode () {
+ IArchiveNode node = getSelectedNode();
+ if (node != null) {
+ if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
+ IArchiveFileSet fileset = (IArchiveFileSet) node;
+ WizardDialog dialog = new WizardDialog(getShell(), new FilesetWizard(fileset, node.getParent()));
+ dialog.open();
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ IArchive pkg = (IArchive) node;
+ WizardDialog dialog = new WizardDialog(getShell(), new NewJARWizard(pkg));
+ dialog.open();
+ } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
+ // folder can do the model save here.
+ IArchiveFolder folder = (IArchiveFolder) node;
+ InputDialog dialog = new InputDialog(getShell(),
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
+ ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, folder.getName(), null);
+
+ int response = dialog.open();
+ if (response == Dialog.OK) {
+ folder.setName(dialog.getValue());
+ new SaveArchivesJob(folder.getProjectPath()).schedule();
+ }
+ }
+ }
+ }
+
+ private void buildSelectedNode(final Object selected) {
+ new Job("Build Archive Node") {
+ protected IStatus run(IProgressMonitor monitor) {
+ if( selected == null ) return Status.OK_STATUS;
+ if (selected instanceof IArchiveNode &&
+ ((IArchiveNode)selected).getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ new ArchiveBuildDelegate().fullArchiveBuild((IArchive)selected);
+ } else if( selected != null && selected instanceof IProject ){
+ new ArchiveBuildDelegate().fullProjectBuild(((IProject)selected).getProject().getLocation());
+ } else {
+ new ArchiveBuildDelegate().fullArchiveBuild(((IArchiveNode)selected).getRootArchive());
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+
+ private void deleteSelectedNode () {
+ IArchiveNode node = getSelectedNode();
+ if (node != null) {
+ final IArchiveNode parent = (IArchiveNode) node.getParent();
+ parent.removeChild(node);
+ SaveArchivesJob job = new SaveArchivesJob(parent.getProjectPath());
+ job.schedule();
+ }
+ }
+
+
+ private IArchiveNode getSelectedNode () {
+ Object selected = getSelectedObject();
+ if( selected instanceof IArchiveNode )
+ return ((IArchiveNode)selected);
+ return null;
+ }
+ private Object getSelectedObject() {
+ IStructuredSelection selection = getSelection();
+ if (selection != null && !selection.isEmpty())
+ return selection.getFirstElement();
+ return null;
+ }
+ private IStructuredSelection getSelection() {
+ return (IStructuredSelection) site.getSelectionProvider().getSelection();
+ }
+
+ private ImageDescriptor platformDescriptor(String desc) {
+ return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(desc);
+ }
+ private Shell getShell() {
+ return site.getShell();
+ }
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesContentProvider.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -0,0 +1,99 @@
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.ide.eclipse.archives.core.build.RegisterArchivesJob;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+
+public class ArchivesContentProvider implements ITreeContentProvider {
+
+ protected ArrayList<Viewer> viewersInUse = new ArrayList<Viewer>();
+ protected ArrayList<IProject> loadingProjects = new ArrayList<IProject>();
+
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof IProject ) {
+ IProject p = (IProject)parentElement;
+
+ // if currently loading, always send a delay
+ if( loadingProjects.contains(p))
+ return new Object[]{new DelayProxy(p)};
+
+ if( ArchivesModel.instance().isProjectRegistered(p.getLocation()))
+ return ArchivesModel.instance().getRoot(p.getLocation()).getAllChildren();
+ if( ArchivesModel.instance().canReregister(p.getLocation())) {
+ loadingProjects.add(p);
+ DelayProxy dp = new DelayProxy(p);
+ launchRegistrationThread(dp);
+ return new Object[]{dp};
+ }
+ }
+ if( parentElement instanceof IArchiveNode )
+ return ((IArchiveNode)parentElement).getAllChildren();
+ return new Object[0];
+ }
+
+ public static class DelayProxy {
+ public IProject project;
+ public DelayProxy(IProject p) {this.project = p; }
+ }
+
+ protected void launchRegistrationThread(final DelayProxy dp) {
+ Runnable callback = new Runnable() {
+ public void run() {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ loadingProjects.remove(dp.project);
+ Iterator it = viewersInUse.iterator();
+ while(it.hasNext()) {
+ Viewer next = ((Viewer)it.next());
+ if( next instanceof StructuredViewer)
+ ((StructuredViewer)next).refresh(dp.project);
+ else
+ next.refresh();
+ }
+ }
+ });
+ }
+ };
+ RegisterArchivesJob job = new RegisterArchivesJob(new IProject[]{dp.project}, callback);
+ job.schedule();
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ if( element instanceof IArchiveNode )
+ return getChildren(element).length > 0;
+ if( element instanceof IResource )
+ return ArchivesModel.instance().canReregister(((IResource)element).getLocation());
+ return true;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if( newInput != null) {
+ if( !viewersInUse.contains(viewer)) {
+ viewersInUse.add(viewer);
+ }
+ } else {
+ viewersInUse.remove(viewer);
+ }
+ }
+
+}
Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesMenuHandler.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -1,405 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.views;
-
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
-import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
-import org.jboss.ide.eclipse.archives.ui.NodeContribution;
-import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
-import org.jboss.ide.eclipse.archives.ui.actions.ActionWithDelegate;
-import org.jboss.ide.eclipse.archives.ui.actions.NewArchiveAction;
-import org.jboss.ide.eclipse.archives.ui.actions.NewJARAction;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider.WrappedProject;
-import org.jboss.ide.eclipse.archives.ui.wizards.FilesetWizard;
-import org.jboss.ide.eclipse.archives.ui.wizards.NewJARWizard;
-
-/**
- * Manages the actions associated with the view
- * @author rstryker
- *
- */
-public class ArchivesMenuHandler {
- public static final String NEW_PACKAGE_MENU_ID = "org.jboss.ide.eclipse.archives.ui.newPackageMenu";
- public static final String NODE_CONTEXT_MENU_ID = "org.jboss.ide.eclipse.archives.ui.nodeContextMenu";
- public static final String NEW_PACKAGE_ADDITIONS = "newPackageAdditions";
-
- private MenuManager newPackageManager, contextMenuManager;
- private NodeContribution[] nodePopupMenuContributions;
- private NewArchiveAction[] newPackageActions;
- private Menu treeContextMenu;
- private TreeViewer packageTree;
-
- private Action editAction, deleteAction, newFolderAction, newFilesetAction;
- private NewJARAction newJARAction;
- private Action buildAction;
-
- public ArchivesMenuHandler(TreeViewer viewer) {
- this.packageTree = viewer;
-
- // load from extensions
- newPackageActions = ExtensionManager.findNewArchiveActions();
- nodePopupMenuContributions = ExtensionManager.findNodePopupMenuContributions();
- Arrays.sort(nodePopupMenuContributions);
-
-
- createActions();
- createMenu();
- createContextMenu();
- addToActionBars();
- }
-
- private void addToActionBars() {
- IActionBars bars = getSite().getActionBars();
- bars.getToolBarManager().add(buildAction);
- }
-
- /**
- * Creates the primary menu as well as adds the package actions to it
- *
- */
- private void createMenu () {
- newPackageManager = new MenuManager(ArchivesUIMessages.ProjectPackagesView_newPackageMenu_label, NEW_PACKAGE_MENU_ID);
- addNewPackageActions(newPackageManager);
- newPackageManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- private void createContextMenu () {
- contextMenuManager = new MenuManager(NODE_CONTEXT_MENU_ID); //$NON-NLS-1$
- contextMenuManager.setRemoveAllWhenShown(true);
- contextMenuManager.addMenuListener(new IMenuListener () {
- public void menuAboutToShow(IMenuManager manager) {
- IStructuredSelection selection = (IStructuredSelection) packageTree.getSelection();
- if (selection != null && !selection.isEmpty()) {
- Object element = selection.getFirstElement();
-
- if (element instanceof WrappedProject) {
- newJARAction.setEnabled(true);
- manager.add(newPackageManager);
- manager.add(buildAction);
- buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildProjectAction_label);
- } else if( element instanceof IArchiveNode ){
- IArchiveNode node = (IArchiveNode)element;
-
- if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE
- || node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER)
- {
- newJARAction.setEnabled(true);
- manager.add(newPackageManager);
-
- manager.add(newFolderAction);
- manager.add(newFilesetAction);
- manager.add(new Separator());
- }
-
- if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- editAction.setText(ArchivesUIMessages.ProjectPackagesView_editPackageAction_label); //$NON-NLS-1$
- deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label); //$NON-NLS-1$
- editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT));
- buildAction.setText(ArchivesUIMessages.ProjectPackagesView_buildArchiveAction_label);
- manager.add(buildAction);
- } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFolderAction_label); //$NON-NLS-1$
- deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFolderAction_label); //$NON-NLS-1$
- editAction.setImageDescriptor(platformDescriptor(ISharedImages.IMG_OBJ_FOLDER));
- } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
- editAction.setText(ArchivesUIMessages.ProjectPackagesView_editFilesetAction_label); //$NON-NLS-1$
- deleteAction.setText(ArchivesUIMessages.ProjectPackagesView_deleteFilesetAction_label); //$NON-NLS-1$
- editAction.setImageDescriptor(ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES));
- }
- manager.add(editAction);
- manager.add(deleteAction);
- addContextMenuContributions(node);
- }
- } else {
- manager.add(newPackageManager);
- }
- }
- });
-
- treeContextMenu = contextMenuManager.createContextMenu(packageTree.getTree());
- packageTree.getTree().setMenu(treeContextMenu);
-
- getSite().registerContextMenu(NEW_PACKAGE_MENU_ID, newPackageManager, packageTree);
- }
-
- protected void createActions() {
- newJARAction = new NewJARAction();
- newJARAction.setEnabled(false);
-
- newFolderAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFolderAction_label, platformDescriptor(ISharedImages.IMG_OBJ_FOLDER)) { //$NON-NLS-1$
- public void run () {
- createFolder();
- }
- };
-
- newFilesetAction = new Action(ArchivesUIMessages.ProjectPackagesView_newFilesetAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_MULTIPLE_FILES)) { //$NON-NLS-1$
- public void run () {
- createFileset();
- }
- };
-
- deleteAction = new Action (ArchivesUIMessages.ProjectPackagesView_deletePackageAction_label, platformDescriptor(ISharedImages.IMG_TOOL_DELETE)) { //$NON-NLS-1$
- public void run () {
- deleteSelectedNode();
- }
- };
-
- editAction = new Action (ArchivesUIMessages.ProjectPackagesView_editPackageAction_label, ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_PACKAGE_EDIT)) { //$NON-NLS-1$
- public void run () {
- editSelectedNode();
- }
- };
-
- buildAction = new ActionWithDelegate("", ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_BUILD_PACKAGES)) {
- public void run() {
- buildSelectedNode(getSelectedObject());
- }
-
- public IStructuredSelection getSelection() {
- return ProjectArchivesView.getInstance().getSelection();
- }
- };
- }
-
- private void addContextMenuContributions (final IArchiveNode context) {
-
- for( int i = 0; i < nodePopupMenuContributions.length; i++ ) {
- try {
-
- final NodeContribution contribution = nodePopupMenuContributions[i];
- if ( contribution.getActionDelegate().isEnabledFor(context)) {
- Action action = new Action () {
- public String getId() {
- return contribution.getId();
- }
-
- public ImageDescriptor getImageDescriptor() {
- return contribution.getIcon();
- }
-
- public String getText() {
- return contribution.getLabel();
- }
-
- public void run() {
- contribution.getActionDelegate().run(context);
- }
- };
- contextMenuManager.add(action);
- }
- } catch( Exception e) {}
- }
-
- }
-
-
- /**
- * Adds the new package type actions (which come from an extension point)
- * to the menu.
- * @param manager
- */
- private void addNewPackageActions (IMenuManager manager) {
- for( int i = 0; i < newPackageActions.length; i++ ) {
- final NewArchiveAction action = newPackageActions[i];
-
- Action actionWrapper = new Action () {
- public String getId() {
- return action.getId();
- }
-
- public ImageDescriptor getImageDescriptor() {
- return action.getIconDescriptor();
- }
-
- public String getText() {
- return action.getLabel();
- }
-
- public void run() {
- action.getAction().run(this);
- }
- };
-
- manager.add(actionWrapper);
- }
- }
-
-
-
-
- /*
- * Methods below are called from the standard actions,
- * the implementations of the action, where the action does its work etc
- */
-
- private void createFolder ()
- {
- IInputValidator validator = new IInputValidator () {
- public String isValid(String newText) {
- IArchiveNode selected = getSelectedNode();
-
- boolean folderExists = false;
- IArchiveNode[] folders = selected.getChildren(IArchiveNode.TYPE_ARCHIVE_FOLDER);
- for (int i = 0; i < folders.length; i++) {
- IArchiveFolder folder = (IArchiveFolder) folders[i];
- if (folder.getName().equals(newText)) {
- folderExists = true; break;
- }
- }
-
- if (folderExists) {
- return ArchivesUIMessages.bind(
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_warnFolderExists, newText);
-
- }
- return null;
- }
- };
-
- InputDialog dialog = new InputDialog(getSite().getShell(),
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, "", validator);
-
- int response = dialog.open();
- if (response == Dialog.OK) {
- String[] folderPaths = dialog.getValue().split("[\\\\/]");
- IArchiveNode selected = getSelectedNode();
- IArchiveFolder current = null;
- IArchiveFolder temp = null;
-
- for(int i = folderPaths.length-1; i >= 0 ; i-- ) {
- temp = ArchiveNodeFactory.createFolder();
- temp.setName(folderPaths[i]);
- if( current == null )
- current = temp;
- else {
- temp.addChild(current);
- current = temp;
- }
- }
-
- selected.addChild(current);
- new SaveArchivesJob(selected.getProjectPath()).schedule();
- }
- }
-
- private void createFileset () {
- IArchiveNode selected = getSelectedNode();
- WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(null, selected));
- dialog.open();
- }
-
- private void editSelectedNode () {
- IArchiveNode node = getSelectedNode();
- if (node != null) {
- if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
- IArchiveFileSet fileset = (IArchiveFileSet) node;
- WizardDialog dialog = new WizardDialog(getSite().getShell(), new FilesetWizard(fileset, node.getParent()));
- dialog.open();
- } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- IArchive pkg = (IArchive) node;
- WizardDialog dialog = new WizardDialog(getSite().getShell(), new NewJARWizard(pkg));
- dialog.open();
- } else if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- // folder can do the model save here.
- IArchiveFolder folder = (IArchiveFolder) node;
- InputDialog dialog = new InputDialog(getSite().getShell(),
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_title,
- ArchivesUIMessages.ProjectPackagesView_createFolderDialog_message, folder.getName(), null);
-
- int response = dialog.open();
- if (response == Dialog.OK) {
- folder.setName(dialog.getValue());
- new SaveArchivesJob(folder.getProjectPath()).schedule();
- }
- }
- }
- }
-
- private void buildSelectedNode(final Object selected) {
- new Job("Build Archive Node") {
- protected IStatus run(IProgressMonitor monitor) {
- if( selected == null ) return Status.OK_STATUS;
- if (selected instanceof IArchiveNode &&
- ((IArchiveNode)selected).getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- new ArchiveBuildDelegate().fullArchiveBuild((IArchive)selected);
- } else if( selected != null && selected instanceof WrappedProject ){
- new ArchiveBuildDelegate().fullProjectBuild(((WrappedProject)selected).getProject().getLocation());
- } else {
- new ArchiveBuildDelegate().fullArchiveBuild(((IArchiveNode)selected).getRootArchive());
- }
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- private void deleteSelectedNode () {
- IArchiveNode node = getSelectedNode();
- if (node != null) {
- final IArchiveNode parent = (IArchiveNode) node.getParent();
- parent.removeChild(node);
- SaveArchivesJob job = new SaveArchivesJob(parent.getProjectPath());
- job.schedule();
- }
- }
-
- /*
- * Utility methods below
- */
-
- private IViewSite getSite() {
- return (IViewSite) ProjectArchivesView.getInstance().getSite();
- }
-
- private IArchiveNode getSelectedNode () {
- Object selected = getSelectedObject();
- if( selected instanceof IArchiveNode )
- return ((IArchiveNode)selected);
- return null;
- }
- private Object getSelectedObject() {
- IStructuredSelection selection = (IStructuredSelection) ProjectArchivesView.getInstance().getSelection();
- if (selection != null && !selection.isEmpty())
- return selection.getFirstElement();
- return null;
- }
-
- private ImageDescriptor platformDescriptor(String desc) {
- return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(desc);
- }
-
-}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ArchivesRootContentProvider.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -0,0 +1,55 @@
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
+
+public class ArchivesRootContentProvider implements ITreeContentProvider {
+
+ public Object[] getChildren(Object parentElement) {
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if( showProjectRoot() ) {
+ if( showAllProjects() ) {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ ArrayList<IProject> tmp = new ArrayList<IProject>();
+ for( int i = 0; i < projects.length; i++ )
+ if( ArchivesModel.instance().canReregister(projects[i].getLocation()))
+ tmp.add(projects[i]);
+ return (IProject[]) tmp.toArray(new IProject[tmp.size()]);
+ }
+ IProject cp = ProjectArchivesCommonView.getInstance().getCurrentProject();
+ if( cp != null )
+ return new Object[]{cp};
+ }
+ return new Object[]{};
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ private boolean showProjectRoot () {
+ return PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT);
+ }
+ private boolean showAllProjects () {
+ return PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS);
+ }
+}
Added: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java (rev 0)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -0,0 +1,150 @@
+package org.jboss.ide.eclipse.archives.ui.views;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.INullSelectionListener;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
+import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
+import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
+
+public class ProjectArchivesCommonView extends CommonNavigator implements IArchiveModelListener {
+ protected static ProjectArchivesCommonView instance;
+ protected ISelectionListener selectionListener;
+ protected IProject currentProject;
+ public static ProjectArchivesCommonView getInstance() { return instance; }
+ public ProjectArchivesCommonView() {
+ super();
+ instance = this;
+ selectionListener = createSelectionListener();
+ }
+ protected IAdaptable getInitialInput() {
+ currentProject = null;
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ public void createPartControl(Composite aParent) {
+ super.createPartControl(aParent);
+ addBuildActionToSite();
+ }
+
+ public void init(IViewSite site) throws PartInitException {
+ super.init(site);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);
+ ArchivesModel.instance().addModelListener(this);
+ }
+
+ public void dispose() {
+ super.dispose();
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);
+ ArchivesModel.instance().removeModelListener(this);
+ }
+
+ protected ISelectionListener createSelectionListener() {
+ return new INullSelectionListener() {
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if( part == instance )
+ return;
+ if (!(selection instanceof IStructuredSelection))
+ return;
+
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ IProject project = getProject(element);
+ if( project != null ) {
+ currentProject = project;
+ if( showProjectRoot())
+ getCommonViewer().setInput(ResourcesPlugin.getWorkspace().getRoot());
+ else
+ getCommonViewer().setInput(currentProject);
+ }
+ }
+
+ public IProject getProject (Object element) {
+ if( element instanceof IStructuredSelection)
+ element = ((IStructuredSelection)element).getFirstElement();
+
+ if (element instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable)element;
+ IResource resource = (IResource) adaptable.getAdapter(IResource.class);
+ if( resource != null )
+ return resource.getProject();
+ }
+ return null;
+ }
+
+ };
+ }
+
+ public void modelChanged(IArchiveNodeDelta delta) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ getCommonViewer().refresh();
+ }
+ });
+ }
+
+ public IProject getCurrentProject() {
+ return currentProject;
+ }
+ private boolean showProjectRoot () {
+ return PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT);
+ }
+
+ public void addBuildActionToSite() {
+ Action buildAction = new Action("", ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_BUILD_PACKAGES)) {
+ public void run() {
+ buildSelection(getSelectedObject());
+ }
+ };
+ IActionBars bars = ((IViewSite)getSite()).getActionBars();
+ bars.getToolBarManager().add(buildAction);
+ }
+
+ private void buildSelection(final Object selected) {
+ new Job("Build Archive Node") {
+ protected IStatus run(IProgressMonitor monitor) {
+ if( selected == null ) return Status.OK_STATUS;
+ if( selected instanceof IProject ) {
+ new ArchiveBuildDelegate().fullProjectBuild(((IProject)selected).getLocation());
+ } else if (selected instanceof IArchiveNode &&
+ ((IArchiveNode)selected).getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
+ new ArchiveBuildDelegate().fullArchiveBuild((IArchive)selected);
+ } else if( selected != null && selected instanceof IProject ){
+ new ArchiveBuildDelegate().fullProjectBuild(((IProject)selected).getProject().getLocation());
+ } else {
+ new ArchiveBuildDelegate().fullArchiveBuild(((IArchiveNode)selected).getRootArchive());
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+
+ private Object getSelectedObject() {
+ IStructuredSelection selection = (IStructuredSelection)getCommonViewer().getSelection();
+ if (selection != null && !selection.isEmpty())
+ return selection.getFirstElement();
+ return null;
+ }
+}
Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -1,381 +0,0 @@
-package org.jboss.ide.eclipse.archives.ui.views;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-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.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.INullSelectionListener;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.ViewPart;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
-import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
-import org.jboss.ide.eclipse.archives.ui.ExtensionManager;
-import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
-import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
-import org.jboss.ide.eclipse.archives.ui.actions.NewArchiveAction;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
-
-public class ProjectArchivesView extends ViewPart implements IArchiveModelListener {
-
- protected static ProjectArchivesView instance;
- public static ProjectArchivesView getInstance() {
- return instance;
- }
-
-
- protected ISelectionListener selectionListener;
- public ProjectArchivesView() {
- instance = this;
- selectionListener = createSelectionListener();
- }
-
- public void init(IViewSite site) throws PartInitException {
- super.init(site);
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);
- ArchivesModel.instance().addModelListener(this);
- }
-
- public void dispose() {
- super.dispose();
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);
- ArchivesModel.instance().removeModelListener(this);
- }
-
-
- protected ISelectionListener createSelectionListener() {
- return new INullSelectionListener() {
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!(selection instanceof IStructuredSelection))
- return;
-
- Object element = ((IStructuredSelection)selection).getFirstElement();
- IProject project = getProject(element);
- if( project != null ) {
- viewSelectionChanged(project);
- } else {
- if( getCurrentProject() != null && !getCurrentProject().exists() ) {
- viewSelectionChanged(null);
- }
- }
- }
-
- public IProject getProject (Object element) {
- if( element instanceof IStructuredSelection)
- element = ((IStructuredSelection)element).getFirstElement();
-
- if (element instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable)element;
- IResource resource = (IResource) adaptable.getAdapter(IResource.class);
- if( resource != null )
- return resource.getProject();
- }
- return null;
- }
-
- };
- }
-
-
- // parts
- private PageBook book;
- private IProject project;
- private ArchivesContentProvider contentProvider = new ArchivesContentProvider();
- private ArchivesLabelProvider labelProvider = new ArchivesLabelProvider();
- private Composite emptyComposite, viewerComposite, loadingPackagesComposite, noSelectionComposite;
- private IProgressMonitor loadingProgress;
- private TreeViewer packageViewer;
- private ArchivesMenuHandler menuHandler;
- public void createPartControl(Composite parent) {
- book = new PageBook(parent, SWT.NONE);
- addEmptyComposite(book);
- addLoadingComposite(book);
- addViewerComposite(book);
- addNoSelectionComposite(book);
- book.showPage(noSelectionComposite);
- menuHandler = new ArchivesMenuHandler(packageViewer);
- }
-
- protected void addNoSelectionComposite(PageBook book) {
- noSelectionComposite = new Composite(book, SWT.NONE);
- noSelectionComposite.setLayout(new FillLayout());
- Label label = new Label(noSelectionComposite, SWT.NONE);
- label.setText(ArchivesUIMessages.ProjectPackagesView_noProjectSelectedMessage);
- }
- protected void addEmptyComposite(PageBook book) {
- emptyComposite = new Composite(book, SWT.NONE);
- emptyComposite.setLayout(new FormLayout());
- Label l = new Label(emptyComposite, SWT.NONE);
- l.setText(ArchivesUIMessages.ProjectPackagesView_createPackagesMessage);
-
- Composite actionsComposite = new Composite(emptyComposite, SWT.NONE);
-
-
- FormData lData = new FormData();
- lData.left = new FormAttachment(0,5);
- lData.top = new FormAttachment(0,5);
- l.setLayoutData(lData);
-
- FormData actionsData = new FormData();
- actionsData.left = new FormAttachment(0,5);
- actionsData.top = new FormAttachment(l,5);
- actionsData.bottom = new FormAttachment(100,-5);
-
- actionsComposite.setLayoutData(actionsData);
-
- actionsComposite.setLayout(new GridLayout(1, false));
- addNewPackageActions(actionsComposite);
-
- }
-
-
- private void addNewPackageActions (Composite composite) {
- NewArchiveAction[] actions = ExtensionManager.findNewArchiveActions();
- for (int i = 0; i < actions.length; i++) {
- final NewArchiveAction action = actions[i];
-
- Composite linkComposite = new Composite(composite, SWT.NONE);
- linkComposite.setLayout(createGridLayoutWithNoMargins(2));
- linkComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- new Label(linkComposite, SWT.NONE).setImage(action.getIcon());
-
- Link actionLink = new Link(linkComposite, SWT.NONE);
- actionLink.setText("<a href=\"create\">" + action.getLabel() + "</a>");
- actionLink.addSelectionListener(new SelectionListener () {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- action.getAction().run(null);
- }
- });
- }
- }
-
- private GridLayout createGridLayoutWithNoMargins (int columns) {
- GridLayout layout = new GridLayout(columns, false);
- layout.marginBottom = layout.marginHeight = layout.marginLeft = 0;
- layout.marginRight = layout.marginTop = layout.marginWidth = 0;
-
- return layout;
- }
-
- protected void addLoadingComposite(PageBook book) {
- loadingPackagesComposite = new Composite(book, SWT.NONE);
- loadingPackagesComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
- loadingProgress = new ProgressMonitorPart(loadingPackagesComposite, null);
-
- }
- protected void addViewerComposite(PageBook book) {
- viewerComposite = new Composite(book, SWT.NONE);
- viewerComposite.setLayout(new FillLayout());
- packageViewer = new TreeViewer(viewerComposite, SWT.NONE);
- packageViewer.setContentProvider(contentProvider);
- packageViewer.setLabelProvider(labelProvider);
- }
-
-
- public void setFocus() {
- }
- public void viewSelectionChanged(IProject project) {
- if( project == null ) {
- this.project = null;
- packageViewer.setInput(null);
- book.showPage(noSelectionComposite);
- return;
- }
-
- IArchiveModelRootNode node = (IArchiveModelRootNode) packageViewer.getInput();
- if (node != null)
- {
- IPath projectPath = node.getProjectPath();
-
- if( project.getLocation().equals(projectPath))
- return;
- }
-
- if( !project.isAccessible() ) {
- book.showPage(noSelectionComposite);
- } else if( ArchivesModel.instance().canReregister(project.getLocation()) ) {
- if( ArchivesModel.instance().isProjectRegistered(project.getLocation()))
- book.showPage(viewerComposite);
- else {
- this.project = project;
- book.showPage(loadingPackagesComposite);
- if( PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS, project, true)) {
- registerProjects(getAllProjectsWithPackages(), this.project);
- } else {
- registerProjects(new IProject[] {this.project}, this.project);
- }
- return;
- }
- } else {
- book.showPage(emptyComposite);
- }
-
- this.project = project;
- packageViewer.setInput(ArchivesModel.instance().getRoot(project.getLocation()));
- }
-
- public IProject getCurrentProject() {
- return project;
- }
-
- /**
- * Registers the projects if and only if a file exists already
- * @param projects
- * @param projectToShow
- */
- protected void registerProjects(final IProject[] projects, final IProject projectToShow) {
- new Job("Register Project Archives") {
- protected IStatus run(IProgressMonitor monitor) {
- // register the projects
- for( int i = 0; i < projects.length; i++ ) {
- try {
- ArchivesModel.instance().registerProject(projects[i].getLocation(), loadingProgress);
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, ame.getMessage(), ame);
- return status;
- }
- }
-
- // then refresh the view (if no errors)
- getSite().getShell().getDisplay().asyncExec(new Runnable () {
- public void run () {
- book.showPage(viewerComposite);
- packageViewer.setInput(ArchivesModel.instance().getRoot(projectToShow.getLocation()));
- }
- });
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- public IProject[] getAllProjectsWithPackages() {
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList<IProject> list = new ArrayList<IProject>();
- for( int i = 0; i < projects2.length; i++ ) {
- if( projects2[i].isAccessible() && ArchivesModel.instance().canReregister(projects2[i].getLocation())) {
- list.add(projects2[i]);
- }
- }
- return list.toArray(new IProject[list.size()]);
- }
- public IStructuredSelection getSelection() {
- return (IStructuredSelection)packageViewer.getSelection();
- }
-
-
- public void modelChanged(IArchiveNodeDelta delta) {
- boolean update = true;
- try {
- if( project == null ) return;
- if( delta.getPostNode() == null && delta.getPreNode() == null ) return;
- if( delta.getPreNode() == null ) update = delta.getPostNode().getProjectPath().equals(project.getLocation());
- else if( delta.getPostNode() == null ) update = delta.getPreNode().getProjectPath().equals(project.getLocation());
- else update = delta.getPreNode().getProjectPath().equals(project.getLocation()) || delta.getPostNode().getProjectPath().equals(project);
- } catch( Exception e ) {}
-
- if( !update ) return;
-
- final IArchiveNode[] topChanges;
- if( delta.getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
- topChanges = getChanges(delta);
- else if( delta.getKind() == IArchiveNodeDelta.NO_CHANGE)
- topChanges = new IArchiveNode[]{};
- else
- topChanges = new IArchiveNode[]{delta.getPostNode()};
-
- // now go through and refresh them
- getSite().getShell().getDisplay().asyncExec(new Runnable () {
- public void run () {
- for( int i = 0; i < topChanges.length; i++ ) {
- if( topChanges.length == 1 && topChanges[0] instanceof IArchiveModelRootNode) {
- // we have a changed IArchiveModelNode. Something's different
- IArchiveModelRootNode inputModel = (IArchiveModelRootNode) packageViewer.getInput();
- IArchiveModelRootNode newModel = (IArchiveModelRootNode)topChanges[0];
- if( inputModel == null || (inputModel.getProjectPath().equals(newModel.getProjectPath()) && inputModel != newModel)) {
- // they have the same path but are different objects.
- // Model was probably reloaded from disk and could be completely different
- book.showPage(viewerComposite);
- packageViewer.setInput(newModel);
- packageViewer.expandAll();
- return;
- } else {
- packageViewer.refresh();
- return;
- }
- } else {
- // just refresh whatever is the top changed element (archive probably)
- packageViewer.refresh(topChanges[i]);
- packageViewer.expandToLevel(topChanges[i], 1);
- }
- }
- }
- });
-
- }
- protected IArchiveNode[] getChanges(IArchiveNodeDelta delta) {
-
- IArchiveNodeDelta[] children = delta.getAllAffectedChildren();
- ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i].getKind() == IArchiveNodeDelta.DESCENDENT_CHANGED)
- list.addAll(Arrays.asList(getChanges(children[i])));
- else
- list.add(children[i].getPostNode());
- }
- return list.toArray(new IArchiveNode[list.size()]);
- }
-
- public void refreshViewer(final Object node) {
- getSite().getShell().getDisplay().asyncExec(new Runnable () {
- public void run () {
- if( node == null ) {
- Object[] els = packageViewer.getExpandedElements();
- packageViewer.refresh();
- packageViewer.setExpandedElements(els);
- } else {
- packageViewer.refresh(node);
- }
- }
- });
- }
-}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2008-08-02 00:39:43 UTC (rev 9475)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/AbstractArchiveWizard.java 2008-08-02 00:40:00 UTC (rev 9476)
@@ -20,7 +20,6 @@
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
-import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
import org.jboss.ide.eclipse.archives.ui.wizards.pages.ArchiveInfoWizardPage;
public abstract class AbstractArchiveWizard extends WizardWithNotification implements INewWizard {
@@ -33,11 +32,6 @@
protected IArchiveNode initialDestinationNode;
public AbstractArchiveWizard () {
- this.project = ProjectArchivesView.getInstance().getCurrentProject();
- IStructuredSelection selection = ProjectArchivesView.getInstance().getSelection();
- Object s = selection.getFirstElement();
- if( s instanceof IArchiveNode )
- initialDestinationNode = (IArchiveNode)s;
}
public AbstractArchiveWizard (IArchive existingPackage) {
@@ -115,7 +109,8 @@
public void init(IWorkbench workbench, IStructuredSelection selection) {
if (selection == null) return;
- project = ProjectArchivesView.getInstance().getCurrentProject();
+ project = null;
+
Object selected = (selection.isEmpty() ? project : selection.getFirstElement());
if (selected instanceof IArchiveNode) {
@@ -125,9 +120,10 @@
}
project = ResourcesPlugin.getWorkspace().getRoot().getProject(node.getProjectName());
} else if (selected instanceof IContainer) {
+ project = ((IContainer)selected).getProject();
initialDestinationPath = ((IContainer)selected).getFullPath().toString();
isPathWorkspaceRelative = true;
- } else {
+ } else if( project != null ){
initialDestinationPath = project.getFullPath().toString();
isPathWorkspaceRelative = true;
}
17 years, 4 months
JBoss Tools SVN: r9475 - trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-01 20:39:43 -0400 (Fri, 01 Aug 2008)
New Revision: 9475
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java
Log:
JBIDE-460 - archives view in common nav
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java 2008-08-02 00:34:07 UTC (rev 9474)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/DefaultJARConfigWizardPage.java 2008-08-02 00:39:43 UTC (rev 9475)
@@ -7,8 +7,8 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
-import org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProvider;
import org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider;
+import org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider;
import org.jboss.ide.eclipse.archives.ui.wizards.AbstractArchiveWizard;
import org.jboss.ide.eclipse.archives.ui.wizards.WizardPageWithNotification;
17 years, 4 months
JBoss Tools SVN: r9474 - in trunk/core/plugins/org.jboss.ide.eclipse.archives.ui: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-08-01 20:34:07 -0400 (Fri, 01 Aug 2008)
New Revision: 9474
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
Log:
JBIDE-460 - archives view in common nav
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF 2008-08-01 17:21:03 UTC (rev 9473)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/META-INF/MANIFEST.MF 2008-08-02 00:34:07 UTC (rev 9474)
@@ -12,7 +12,8 @@
org.jboss.ide.eclipse.archives.core,
org.eclipse.jdt.ui;bundle-version="3.4.0",
org.eclipse.debug.ui;bundle-version="3.4.0",
- org.eclipse.core.variables;bundle-version="3.2.100"
+ org.eclipse.core.variables;bundle-version="3.2.100",
+ org.eclipse.ui.navigator;bundle-version="3.3.100"
Eclipse-LazyStart: true
Export-Package: org.jboss.ide.eclipse.archives.ui,
org.jboss.ide.eclipse.archives.ui.actions,
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2008-08-01 17:21:03 UTC (rev 9473)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/plugin.xml 2008-08-02 00:34:07 UTC (rev 9474)
@@ -9,7 +9,7 @@
<view
allowMultiple="false"
category="org.jboss.ide.eclipse.ui.views"
- class="org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView"
+ class="org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesCommonView"
icon="icons/jar_obj.gif"
id="org.jboss.ide.eclipse.archives.ui.ProjectArchivesView"
name="Project archives"/>
@@ -77,4 +77,70 @@
<initializer class="org.jboss.ide.eclipse.archives.ui.PrefsInitializer"/>
</extension>
+
+
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewer
+ viewerId="org.jboss.ide.eclipse.archives.ui.ProjectArchivesView">
+ </viewer>
+ <viewerContentBinding
+ viewerId="org.jboss.ide.eclipse.archives.ui.ProjectArchivesView">
+ <includes>
+ <contentExtension
+ isRoot="true"
+ pattern="org.jboss.ide.eclipse.archives.ui.archivesRootContent">
+ </contentExtension>
+ <contentExtension
+ isRoot="true"
+ pattern="org.jboss.ide.eclipse.archives.ui.archivesContent">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ activeByDefault="true"
+ contentProvider="org.jboss.ide.eclipse.archives.ui.views.ArchivesRootContentProvider"
+ icon="icons/jar_obj.gif"
+ id="org.jboss.ide.eclipse.archives.ui.archivesRootContent"
+ labelProvider="org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider"
+ name="Archives Content Root"
+ priority="normal"
+ providesSaveables="true">
+ <triggerPoints>
+ <instanceof
+ value="org.eclipse.core.resources.IWorkspaceRoot">
+ </instanceof>
+ </triggerPoints>
+ </navigatorContent>
+ <navigatorContent
+ activeByDefault="true"
+ contentProvider="org.jboss.ide.eclipse.archives.ui.views.ArchivesContentProvider"
+ icon="icons/jar_obj.gif"
+ id="org.jboss.ide.eclipse.archives.ui.archivesContent"
+ labelProvider="org.jboss.ide.eclipse.archives.ui.providers.ArchivesLabelProvider"
+ name="Archives Content"
+ priority="normal"
+ providesSaveables="true">
+ <triggerPoints>
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ </triggerPoints>
+ <actionProvider
+ class="org.jboss.ide.eclipse.archives.ui.views.ArchivesActionProvider"
+ id="org.jboss.ide.eclipse.archives.ui.views.ArchivesActionProvider">
+ </actionProvider>
+ <possibleChildren>
+ <or>
+ <instanceof
+ value="org.jboss.ide.eclipse.archives.core.model.IArchiveNode">
+ </instanceof>
+ </or>
+ </possibleChildren>
+ </navigatorContent>
+ </extension>
+
</plugin>
17 years, 4 months
JBoss Tools SVN: r9473 - in trunk/documentation/movies: rich_faces_demo and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2008-08-01 13:21:03 -0400 (Fri, 01 Aug 2008)
New Revision: 9473
Added:
trunk/documentation/movies/rich_faces_demo/
trunk/documentation/movies/rich_faces_demo/rich_faces_demo.htm
trunk/documentation/movies/rich_faces_demo/rich_faces_demo.js
trunk/documentation/movies/rich_faces_demo/rich_faces_demo.swf
Log:
Added: trunk/documentation/movies/rich_faces_demo/rich_faces_demo.htm
===================================================================
--- trunk/documentation/movies/rich_faces_demo/rich_faces_demo.htm (rev 0)
+++ trunk/documentation/movies/rich_faces_demo/rich_faces_demo.htm 2008-08-01 17:21:03 UTC (rev 9473)
@@ -0,0 +1,27 @@
+
+<HTML>
+<head>
+<link rel="stylesheet" href="../resources/tools.css" type="text/css"/>
+<link xmlns="" rel="shortcut icon" type="image/vnd.microsoft.icon" href="../resources/images/favicon.ico"/>
+</head>
+
+<BODY>
+<div class="book">
+<p id="title"><a href="http://www.jboss.org" class="site_href">
+<strong>JBoss.org</strong></a><a href="http://docs.jboss.org/" class="doc_href">
+<strong >Community Demos</strong></a></p>
+
+<center><OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="850" HEIGHT="684" CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version=7,0,0,0">
+<PARAM NAME=movie VALUE="rich_faces_demo.swf">
+<PARAM NAME=play VALUE=true>
+<PARAM NAME=loop VALUE=false>
+<PARAM NAME=wmode VALUE=transparent>
+<PARAM NAME=quality VALUE=low>
+<EMBED SRC="rich_faces_demo.swf" WIDTH=850 HEIGHT=684 quality=low loop=false wmode=transparent TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=Sh...">
+</EMBED>
+</OBJECT></center>
+</div>
+
+<SCRIPT src='rich_faces_demo.js'></script>
+</BODY>
+</HTML>
Added: trunk/documentation/movies/rich_faces_demo/rich_faces_demo.js
===================================================================
--- trunk/documentation/movies/rich_faces_demo/rich_faces_demo.js (rev 0)
+++ trunk/documentation/movies/rich_faces_demo/rich_faces_demo.js 2008-08-01 17:21:03 UTC (rev 9473)
@@ -0,0 +1,3 @@
+obj=document.getElementsByTagName('object');
+for (var i=0; i<obj.length; ++i)
+ obj[i].outerHTML=obj[i].outerHTML;
Added: trunk/documentation/movies/rich_faces_demo/rich_faces_demo.swf
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/movies/rich_faces_demo/rich_faces_demo.swf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years, 4 months
JBoss Tools SVN: r9472 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2008-08-01 11:26:17 -0400 (Fri, 01 Aug 2008)
New Revision: 9472
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
Log:
remove obsolete references to entity/model graphview
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2008-08-01 13:46:18 UTC (rev 9471)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2008-08-01 15:26:17 UTC (rev 9472)
@@ -342,9 +342,8 @@
<newWizardShortcut id="org.hibernate.eclipse.console.wizards.ConsoleConfigurationCreationWizard"/>
<newWizardShortcut id="org.hibernate.eclipse.console.wizards.NewReverseEngineeringFileWizard"/>
<viewShortcut id="org.hibernate.eclipse.console.views.KnownConfigurationsView"/>
- <viewShortcut id="org.hibernate.eclipse.graph.EntityGraphView"/>
<viewShortcut id="org.hibernate.eclipse.console.views.QueryPageTabView"/>
- <viewShortcut id="org.hibernate.eclipse.console.views.DynamicQueryTranslatorView"/>
+ <viewShortcut id="org.hibernate.eclipse.console.views.DynamicSQLPreviewView"/>
</perspectiveExtension>
</extension>
<extension
17 years, 4 months
JBoss Tools SVN: r9471 - in trunk/portlet/plugins/org.jboss.tools.portlet.core: META-INF and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-08-01 09:46:18 -0400 (Fri, 01 Aug 2008)
New Revision: 9471
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-beanutils-1.7.0.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-collections-3.2.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-digester-1.8.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-lang-2.1.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-logging-1.0.4.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/jsf-facelets-1.1.14.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-api-1.0.0-SNAPSHOT.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-impl-1.0.0-SNAPSHOT.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-api-3.2.2-20080725.050700-44.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-impl-3.2.2-20080725.050700-44.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/ui.jar
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.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/JSFPortletFacetUninstallDelegate.java
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF
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/PortletCoreActivator.java
Log:
JBIDE-2574 Support for JSF portlets
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF 2008-08-01 13:41:55 UTC (rev 9470)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF 2008-08-01 13:46:18 UTC (rev 9471)
@@ -12,8 +12,14 @@
org.eclipse.jst.j2ee,
org.eclipse.jdt.core,
org.jboss.ide.eclipse.as.classpath.core,
+ org.eclipse.jst.j2ee.core,
org.eclipse.jst.j2ee.web,
- org.eclipse.jst.common.frameworks
+ org.eclipse.emf.common,
+ org.eclipse.emf.ecore,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.ui.ide,
+ org.eclipse.jem,
+ org.eclipse.jst.jsf.facesconfig
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.portlet.core,
org.jboss.tools.portlet.core.internal,
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/dtdsAndSchemas/jboss-app_2_6.dtd 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!--
+<!DOCTYPE jboss-app PUBLIC
+ "-//JBoss Portal//DTD JBoss Web Application 2.6//EN"
+ "http://www.jboss.org/portal/dtd/jboss-app_2_6.dtd">
+-->
+
+<!ELEMENT jboss-app (app-name?)>
+
+<!--
+When a web application is deployed, the context path under wich it is deployed
+is taken as application name. The application name value in this descriptor is
+used to override it. When a component references a references a portlet, it needs to
+reference the application too and if the portlet application war file is renammed
+the reference is not valid anymore. Therefore this tag is used to have an application
+name that does not depend upon the context path under which the application is deployed.
+-->
+<!ELEMENT app-name (#PCDATA)>
\ No newline at end of file
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-08-01 13:41:55 UTC (rev 9470)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-08-01 13:46:18 UTC (rev 9471)
@@ -82,6 +82,70 @@
id="org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v20"/>
</extension>
+ <extension point="org.eclipse.wst.common.project.facet.core.facets">
+
+ <project-facet id="jboss.jsfportlet">
+ <label>JBoss JSF Portlet</label>
+ <description>
+ Adds support for the JSF Portlet.
+ </description>
+ <default-version version="1.0"/>
+ </project-facet>
+
+ <project-facet-version facet="jboss.jsfportlet" version="1.0">
+ <constraint>
+ <and>
+ <requires facet="jst.java" version="[5.0"/>
+ <requires facet="jst.web" version="[2.3"/>
+ <requires facet="jboss.portlet" version="[1.0"/>
+ <requires facet="jst.jsf" version="[1.2"/>
+ </and>
+ </constraint>
+ </project-facet-version>
+
+ <action id="jboss.jsfportlet.install" facet="jboss.jsfportlet" type="INSTALL" version="1.0">
+ <delegate class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletFacetInstallDelegate"/>
+ <config-factory class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletFacetInstallDataModelProvider"/>
+ </action>
+
+ <action id="jboss.jsfportlet.uninstall" facet="jboss.jsfportlet" type="UNINSTALL" version="1.0" >
+ <delegate class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletFacetUninstallDelegate"/>
+ </action>
+
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.presets">
+ <static-preset id="preset.jboss.jsfportlet.v20">
+ <label>JBoss JSF Portlet Project v2.0</label>
+ <facet id="jst.java" version="5.0" />
+ <facet id="jst.web" version="2.5"/>
+ <facet id="jst.jsf" version="1.2"/>
+ <facet id="jboss.portlet" version="2.0" />
+ <facet id="jboss.jsfportlet" version="1.0" />
+ <description>JBoss JSF Portlet Project v2.0</description>
+ </static-preset>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.presets">
+ <dynamic-preset id="preset.jboss.jsfportlet.v10">
+ <factory class="org.jboss.tools.portlet.core.internal.project.facet.JSFPortletConfigurationPresetFactory10"/>
+ </dynamic-preset>
+ </extension>
+
+ <extension point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <supported>
+ <runtime-component any="true"/>
+ <facet id="jboss.jsfportlet" version="1.0"/>
+ </supported>
+ </extension>
+
+ <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer class="org.jboss.tools.portlet.core.internal.JSFPortlet10LibrariesContainerInitializer"
+ id="org.jboss.tools.portlet.core.internal.jsfportletlibrarycontainer.v10"/>
+ </extension>
+
<extension point="org.eclipse.wst.xml.core.catalogContributions">
<catalogContribution id="default">
<public
@@ -96,6 +160,11 @@
publicId="-//JBoss Portal//DTD JBoss Portlet 2.6//EN"
uri="dtdsAndSchemas/jboss-portlet_2_6.dtd"
webURL="http://www.jboss.org/portal/dtd/jboss-portlet_2_6.dtd" />
+
+ <public
+ publicId="-//JBoss Portal//DTD JBoss Web Application 2.6//EN"
+ uri="dtdsAndSchemas/jboss-app_2_6.dtd"
+ webURL="http://www.jboss.org/portal/dtd/jboss-app_2_6.dtd" />
<uri
name="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-beanutils-1.7.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-beanutils-1.7.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-collections-3.2.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-collections-3.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-digester-1.8.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-digester-1.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-lang-2.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-lang-2.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-logging-1.0.4.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/commons-logging-1.0.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/jsf-facelets-1.1.14.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/jsf-facelets-1.1.14.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-api-1.0.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-api-1.0.0-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-impl-1.0.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/portletbridge-impl-1.0.0-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-api-3.2.2-20080725.050700-44.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-api-3.2.2-20080725.050700-44.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-impl-3.2.2-20080725.050700-44.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/richfaces-impl-3.2.2-20080725.050700-44.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/ui.jar
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.core/resources/jsfportlet/ui.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IJBossWebUtil.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,26 @@
+package org.jboss.tools.portlet.core;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface IJBossWebUtil {
+
+ static final Object JSF_SERVLET_CLASS = "javax.faces.webapp.FacesServlet";
+ static final String WEB_INF_FACES_CONFIG_XML = "/WEB-INF/faces-config.xml";
+ static final String JAVAX_FACES_CONFIG_FILES = "javax.faces.CONFIG_FILES";
+
+ void configureContextParam( IProject project,
+ IProgressMonitor monitor,String name, String value,String description);
+
+ void configureFilter(IProject project,
+ IProgressMonitor monitor, String name, String className,String displayName,
+ String description);
+
+ void configureFilterMapping(IProject project,
+ IProgressMonitor monitor, String name, String servletName);
+
+ String findJsfServlet(Object modelObject);
+
+ String getFacesConfig(IProject project,
+ IProgressMonitor monitor);
+}
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-08-01 13:41:55 UTC (rev 9470)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -10,8 +10,8 @@
************************************************************************************/
package org.jboss.tools.portlet.core;
-import org.eclipse.core.runtime.IPath;
+
/**
* @author snjeza
*
@@ -21,18 +21,34 @@
static final String PORTLET_FACET_ID="jboss.portlet";
+ static final String JSFPORTLET_FACET_ID="jboss.jsfportlet";
+
static final String CONFIG_PATH = "WEB-INF/portlet.xml";
static final String PORTLET_FACET_VERSION_10 = "1.0";
static final String PORTLET_FACET_VERSION_20 = "2.0";
+
+ static final String JSFPORTLET_FACET_VERSION_10 = "1.0";
static final String PORTLET_CONTAINER_10_ID = "org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v10";
static final String PORTLET_CONTAINER_20_ID = "org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v20";
+
+ static final String JSFPORTLET_CONTAINER_10_ID = "org.jboss.tools.portlet.core.internal.jsfportletlibrarycontainer.v10";
static final String PORTLET_INSTANCES_FILE = "WEB-INF/portlet-instances.xml";
static final String PORTLET_OBJECT_FILE = "WEB-INF/default-object.xml";
+ static final String JBOSS_APP_FILE = "WEB-INF/jboss-app.xml";
+
+ static final String DEPLOY_JARS = "DEPLOY_JARS";
+
+ static final String JSF_SECTION = "jsfSection";
+
+ static final String WEB_INF_LIB = "WEB-INF/lib";
+
+ static final String JBOSS_PORTLET_FILE = "WEB-INF/jboss-portlet.xml";
+
}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,254 @@
+package org.jboss.tools.portlet.core;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jem.java.JavaClass;
+import org.eclipse.jst.j2ee.common.CommonFactory;
+import org.eclipse.jst.j2ee.common.Description;
+import org.eclipse.jst.j2ee.common.ParamValue;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.jst.j2ee.webapplication.ContextParam;
+import org.eclipse.jst.j2ee.webapplication.DispatcherType;
+import org.eclipse.jst.j2ee.webapplication.Filter;
+import org.eclipse.jst.j2ee.webapplication.FilterMapping;
+import org.eclipse.jst.j2ee.webapplication.Servlet;
+import org.eclipse.jst.j2ee.webapplication.WebApp;
+import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+
+public class JBossWebUtil implements IJBossWebUtil {
+
+ public void configureContextParam(IProject project,
+ IProgressMonitor monitor, String name, String value,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // handle context-param settings
+ // if contained this param
+ List list = null;
+ if (webApp.getVersionID() == 23) {
+ // for servlet 2.3
+ list = webApp.getContexts();
+ } else {
+ // for servlet 2.4
+ list = webApp.getContextParams();
+ }
+
+ int index = getContextParamIndexByName(list, name);
+ if (index >= 0) {
+ String ret = query.queryOverwrite("Context-param '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+
+ // remove old item
+ list.remove(index);
+ }
+
+ if (webApp.getVersionID() == 23) {
+ // create context-param object
+ ContextParam param = WebapplicationFactory.eINSTANCE
+ .createContextParam();
+ param.setParamName(name);
+ param.setParamValue(value);
+ if (description != null)
+ param.setDescription(description);
+
+ param.setWebApp(webApp);
+ } else {
+ // create ParamValue object for servlet 2.4
+ ParamValue param = CommonFactory.eINSTANCE.createParamValue();
+ param.setName(name);
+ param.setValue(value);
+ if (description != null) {
+ Description descriptionObj = CommonFactory.eINSTANCE
+ .createDescription();
+ descriptionObj.setValue(description);
+ param.getDescriptions().add(descriptionObj);
+ param.setDescription(description);
+ }
+
+ // add into list
+ webApp.getContextParams().add(param);
+ }
+
+ }
+
+ private int getContextParamIndexByName(List list, String name) {
+ if (list == null || name == null)
+ return -1;
+ Iterator it = list.iterator();
+ int index = 0;
+ while (it.hasNext()) {
+ // get param object
+ Object paramObj = it.next();
+ // for servlet 2.3
+ if (paramObj instanceof ContextParam) {
+ ContextParam param = (ContextParam) paramObj;
+ if (name.equals(param.getParamName()))
+ return index;
+ }
+ // for servlet 2.4
+ if (paramObj instanceof ParamValue) {
+ ParamValue param = (ParamValue) paramObj;
+ if (name.equals(param.getName()))
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
+ public void configureFilter(IProject project, IProgressMonitor monitor,
+ String name, String className, String displayName,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // handle filter settings
+
+ // if contained this filter
+ Object obj = webApp.getFilterNamed(name);
+ if (obj != null) {
+ String ret = query.queryOverwrite("Filter '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)
+ || IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+
+ // remove old item
+ webApp.getFilters().remove(obj);
+ }
+
+ // create filter object
+ Filter filter = WebapplicationFactory.eINSTANCE.createFilter();
+ filter.setName(name);
+ filter.setFilterClassName(className);
+ filter.setDescription(description);
+ filter.setDisplayName(displayName);
+ webApp.getFilters().add(filter);
+ }
+
+ public void configureFilterMapping(IProject project,
+ IProgressMonitor monitor, String name, String servletName) {
+ // FIXME check if filter mapping already exists
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // create FilterMapping object
+ FilterMapping mapping = WebapplicationFactory.eINSTANCE
+ .createFilterMapping();
+ // get filter by name
+ Filter filter = webApp.getFilterNamed(name);
+ if (filter != null) {
+ mapping.setFilter(filter);
+ mapping.setServletName(servletName);
+ EList dispatcherTypes = mapping.getDispatcherType();
+ dispatcherTypes.add(DispatcherType.REQUEST_LITERAL);
+ dispatcherTypes.add(DispatcherType.FORWARD_LITERAL);
+ dispatcherTypes.add(DispatcherType.INCLUDE_LITERAL);
+ // get Servlet object
+ Servlet servlet = webApp.getServletNamed(servletName);
+ mapping.setServlet(servlet);
+ // if (uri != null || servlet != null)
+ webApp.getFilterMappings().add(mapping);
+ }
+
+ }
+
+ private Object getFilterMappingByKey(List list, String key) {
+ if (list == null || key == null)
+ return null;
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ // get filter-mapping object
+ FilterMapping filterMapping = (FilterMapping) it.next();
+ if (filterMapping != null) {
+ String name = filterMapping.getFilter().getName();
+ String servletName = filterMapping.getServletName();
+ String uri = filterMapping.getUrlPattern();
+ String curKey = getFilterMappingString(name, servletName, uri);
+ if (key.equals(curKey))
+ return filterMapping;
+ }
+ }
+ return null;
+ }
+
+ private String getFilterMappingString(String name, String servletName,
+ String uri) {
+ return (name != null ? name : "") //$NON-NLS-1$
+ + (servletName != null ? servletName : "") //$NON-NLS-1$
+ + (uri != null ? uri : ""); //$NON-NLS-1$
+ }
+
+ private WebApp getWebApp(IProject project, IProgressMonitor monitor) {
+ if (monitor.isCanceled())
+ return null;
+ if (project == null) {
+ return null;
+ }
+ IModelProvider modelProvider = ModelProviderManager
+ .getModelProvider(project);
+ Object modelObject = modelProvider.getModelObject();
+ if (!(modelObject instanceof WebApp)) {
+ // TODO log
+ return null;
+ }
+ return (WebApp) modelObject;
+ }
+
+ public String findJsfServlet(Object modelObject) {
+ WebApp webApp = (WebApp) modelObject;
+ Iterator it = webApp.getServlets().iterator();
+
+ while (it.hasNext()) {
+ Servlet servlet = (Servlet) it.next();
+ JavaClass servletClass = servlet.getServletClass();
+ if (servletClass != null
+ && servletClass.getInstanceClassName().trim().equals(
+ JSF_SERVLET_CLASS)) {
+ return servlet.getServletName();
+ }
+ }
+ return null;
+ }
+
+ public String getFacesConfig(IProject project,
+ IProgressMonitor monitor) {
+ WebApp webApp = getWebApp(project, monitor);
+ EList contextParams = webApp.getContextParams();
+ for (Iterator iterator = contextParams.iterator(); iterator.hasNext();) {
+ Object paramObj = (Object) iterator.next();
+ if (paramObj instanceof ContextParam) {
+ ContextParam param = (ContextParam) paramObj;
+ if (JAVAX_FACES_CONFIG_FILES.equals(param.getParamName()))
+ return param.getParamValue();
+ }
+ }
+ return WEB_INF_FACES_CONFIG_XML;
+ }
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/JBossWebUtil25.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,268 @@
+package org.jboss.tools.portlet.core;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.jst.javaee.core.Description;
+import org.eclipse.jst.javaee.core.DisplayName;
+import org.eclipse.jst.javaee.core.JavaeeFactory;
+import org.eclipse.jst.javaee.core.ParamValue;
+import org.eclipse.jst.javaee.core.UrlPatternType;
+import org.eclipse.jst.javaee.web.DispatcherType;
+import org.eclipse.jst.javaee.web.Filter;
+import org.eclipse.jst.javaee.web.FilterMapping;
+import org.eclipse.jst.javaee.web.Servlet;
+import org.eclipse.jst.javaee.web.WebApp;
+import org.eclipse.jst.javaee.web.WebFactory;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+
+public class JBossWebUtil25 implements IJBossWebUtil {
+
+ public void configureContextParam(IProject project,
+ IProgressMonitor monitor, String name, String value,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+ List list = webApp.getContextParams();
+ int index = getContextParamIndexByName(list, name);
+ if (index >= 0) {
+ String ret = query.queryOverwrite("Context-param '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+
+ // remove old item
+ list.remove(index);
+ }
+
+ ParamValue param = JavaeeFactory.eINSTANCE.createParamValue();
+ param.setParamName(name);
+ param.setParamValue(value);
+ if (description != null) {
+ Description descriptionObj = JavaeeFactory.eINSTANCE
+ .createDescription();
+ descriptionObj.setValue(description);
+ param.getDescriptions().add(descriptionObj);
+
+ }
+
+ // add into list
+ webApp.getContextParams().add(param);
+
+ }
+
+ private int getContextParamIndexByName(List list, String name) {
+ if (list == null || name == null)
+ return -1;
+ Iterator it = list.iterator();
+ int index = 0;
+ while (it.hasNext()) {
+ Object paramObj = it.next();
+ if (paramObj instanceof ParamValue) {
+ ParamValue param = (ParamValue) paramObj;
+ if (name.equals(param.getParamName()))
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
+ public void configureFilter(IProject project, IProgressMonitor monitor,
+ String name, String className, String displayName,
+ String description) {
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // if contained this filter
+ Object obj = getFilterByName(webApp, name);
+ if (obj != null) {
+ String ret = query.queryOverwrite("Filter '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)
+ || IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ // remove old item
+ webApp.getFilters().remove(obj);
+ }
+ // create filter object
+ Filter filter = WebFactory.eINSTANCE.createFilter();
+ filter.setFilterName(name);
+ filter.setFilterClass(className);
+ DisplayName dName = JavaeeFactory.eINSTANCE.createDisplayName();
+ dName.setValue(displayName);
+ filter.getDisplayNames().add(dName);
+ Description descriptionObj = JavaeeFactory.eINSTANCE
+ .createDescription();
+ descriptionObj.setValue(description);
+ webApp.getFilters().add(filter);
+
+ }
+
+ private Object getFilterByName(WebApp webApp, String name) {
+ if (webApp == null || name == null)
+ return null;
+ List filters = webApp.getFilters();
+ for (Iterator iterator = filters.iterator(); iterator.hasNext();) {
+ Filter filter = (Filter) iterator.next();
+ if (filter != null && name.equals(filter.getFilterName()))
+ return filter;
+ }
+
+ return null;
+ }
+
+ public void configureFilterMapping(IProject project,
+ IProgressMonitor monitor, String name, String servletName) {
+ // FIXME check if filter mapping already exists
+ WebApp webApp = getWebApp(project, monitor);
+ if (webApp == null)
+ return;
+ IOverwriteQuery query = PortletCoreActivator.OVERWRITE_ALL_QUERY;
+
+ // if contained this filter-mapping
+ Object obj = getFilterMappingByKey(webApp.getFilterMappings(), name);
+ if (obj != null) {
+ String ret = query.queryOverwrite("Filter-mapping '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ // check overwrite query result
+ if (IOverwriteQuery.NO.equalsIgnoreCase(ret)
+ || IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) {
+ monitor.setCanceled(true);
+ return;
+ }
+ // remove old item
+ webApp.getFilterMappings().remove(obj);
+ }
+ // filter name
+ // create FilterMapping object
+ FilterMapping mapping = WebFactory.eINSTANCE.createFilterMapping();
+ // get filter by name
+ Filter filter = (Filter) getFilterByName(webApp, name);
+ if (filter != null) {
+ mapping.setFilterName(filter.getFilterName());
+ mapping.getDispatchers().add(DispatcherType.REQUEST_LITERAL);
+ mapping.getDispatchers().add(DispatcherType.FORWARD_LITERAL);
+ mapping.getDispatchers().add(DispatcherType.INCLUDE_LITERAL);
+ mapping.getServletNames().add(servletName);
+
+ // get Servlet object
+ // Servlet servlet = findServletByName(webApp, servletName);
+ // mapping.setServlet(servlet);
+ // if (servlet != null || uri != null)
+ webApp.getFilterMappings().add(mapping);
+ }
+ }
+
+ private Object getFilterMappingByKey(List list, String key) {
+ if (list == null || key == null)
+ return null;
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ // get filter-mapping object
+ FilterMapping filterMapping = (FilterMapping) it.next();
+ if (filterMapping != null) {
+ String name = filterMapping.getFilterName();
+ List servletNames = filterMapping.getServletNames();
+ for (Iterator iterator = servletNames.iterator(); iterator
+ .hasNext();) {
+ String servletName = (String) iterator.next();
+ List urlPatterns = filterMapping.getUrlPatterns();
+ for (Iterator iterator2 = urlPatterns.iterator(); iterator2
+ .hasNext();) {
+ UrlPatternType urlPattern = (UrlPatternType) iterator2
+ .next();
+ String uri = urlPattern.getValue();
+ String curKey = getFilterMappingString(name,
+ servletName, uri);
+ if (key.equals(curKey))
+ return filterMapping;
+ }
+
+ }
+
+ }
+ }
+ return null;
+ }
+
+ private String getFilterMappingString(String name, String servletName,
+ String uri) {
+ return (name != null ? name : "") //$NON-NLS-1$
+ + (servletName != null ? servletName : "") //$NON-NLS-1$
+ + (uri != null ? uri : ""); //$NON-NLS-1$
+ }
+
+ private Servlet findServletByName(WebApp webApp, String name) {
+ Iterator it = webApp.getServlets().iterator();
+ while (it.hasNext()) {
+ Servlet servlet = (Servlet) it.next();
+ if (servlet.getServletName() != null
+ && servlet.getServletName().trim().equals(name)) {
+ return servlet;
+ }
+ }
+ return null;
+ }
+
+ private WebApp getWebApp(IProject project, IProgressMonitor monitor) {
+ if (monitor.isCanceled())
+ return null;
+ if (project == null) {
+ return null;
+ }
+ IModelProvider modelProvider = ModelProviderManager
+ .getModelProvider(project);
+ Object modelObject = modelProvider.getModelObject();
+ if (!(modelObject instanceof WebApp)) {
+ return null;
+ }
+ WebApp webApp = (WebApp) modelObject;
+ return webApp;
+ }
+
+ public String findJsfServlet(Object modelObject) {
+ WebApp webApp = (WebApp) modelObject;
+ Iterator it = webApp.getServlets().iterator();
+ while (it.hasNext()) {
+ Servlet servlet = (Servlet) it.next();
+ if (servlet.getServletClass() != null
+ && servlet.getServletClass().trim().equals(
+ JSF_SERVLET_CLASS)) {
+ return servlet.getServletName();
+ }
+ }
+ return null;
+ }
+
+ public String getFacesConfig(IProject project, IProgressMonitor monitor) {
+ WebApp webApp = getWebApp(project, monitor);
+ List contextParams = webApp.getContextParams();
+ for (Iterator iterator = contextParams.iterator(); iterator.hasNext();) {
+ Object paramObj = (Object) iterator.next();
+ if (paramObj instanceof ParamValue) {
+ ParamValue param = (ParamValue) paramObj;
+ if (JAVAX_FACES_CONFIG_FILES.equals(param.getParamName()))
+ return param.getParamValue();
+ }
+ }
+ return WEB_INF_FACES_CONFIG_XML;
+ }
+
+}
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/PortletCoreActivator.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/PortletCoreActivator.java 2008-08-01 13:41:55 UTC (rev 9470)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/PortletCoreActivator.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -4,7 +4,6 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
@@ -21,6 +20,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.osgi.framework.BundleContext;
@@ -31,10 +31,18 @@
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.portlet.core";
+ public static final String RESOURCES_FOLDER = "resources";
+ public static final String JSFPORTLET_FOLDER = "jsfportlet";
+ public static final IOverwriteQuery OVERWRITE_ALL_QUERY = new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return IOverwriteQuery.ALL;
+ }
+ };
+
// The shared instance
private static PortletCoreActivator plugin;
-
+
/**
* The constructor
*/
@@ -43,7 +51,9 @@
/*
* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -52,7 +62,9 @@
/*
* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -61,7 +73,7 @@
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static PortletCoreActivator getDefault() {
@@ -73,42 +85,50 @@
* @return IModelProvider
*/
public static IModelProvider getModelProvider(IProject webProject) {
- IModelProvider provider = ModelProviderManager.getModelProvider(webProject);
+ IModelProvider provider = ModelProviderManager
+ .getModelProvider(webProject);
Object webAppObj = provider.getModelObject();
- if (webAppObj == null){
+ if (webAppObj == null) {
return null;
- }
+ }
return provider;
}
-
+
public static IStatus getStatus(String message) {
- return new Status(IStatus.ERROR,PLUGIN_ID,message);
-
+ return new Status(IStatus.ERROR, PLUGIN_ID, message);
+
}
- public static void createPortletXml(String versionString,IProject project, IProgressMonitor monitor) {
+ public static void createPortletXml(String versionString, IProject project,
+ IProgressMonitor monitor) {
IPath portletXmlPath = ComponentCore.createComponent(project)
- .getRootFolder().getUnderlyingFolder().getRawLocation().append(
- new Path(IPortletConstants.CONFIG_PATH));
+ .getRootFolder().getUnderlyingFolder().getRawLocation().append(
+ new Path(IPortletConstants.CONFIG_PATH));
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-
+
if (IPortletConstants.PORTLET_FACET_VERSION_20.equals(versionString)) {
- buffer.append("<portlet-app xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\"");
+ buffer
+ .append("<portlet-app xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\"");
buffer.append("\n\t");
- buffer.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
- buffer.append("\n\t");
- buffer.append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\" ");
- buffer.append("\n\t");
- buffer.append("version=\"2.0\">");
+ buffer
+ .append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
+ buffer.append("\n\t");
+ buffer
+ .append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\" ");
+ buffer.append("\n\t");
+ buffer.append("version=\"2.0\">");
} else {
- buffer.append("<portlet-app xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"");
+ buffer
+ .append("<portlet-app xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"");
buffer.append("\n\t");
- buffer.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
- buffer.append("\n\t");
- buffer.append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"");
- buffer.append("\n\t");
- buffer.append("version=\"1.0\">");
+ buffer
+ .append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
+ buffer.append("\n\t");
+ buffer
+ .append("xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"");
+ buffer.append("\n\t");
+ buffer.append("version=\"1.0\">");
}
buffer.append("\n\n");
buffer.append("</portlet-app>");
@@ -133,44 +153,85 @@
}
}
}
-
+
}
public static void log(Exception e, String message) {
- IStatus status = new Status(IStatus.ERROR,PLUGIN_ID,message,e);
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
PortletCoreActivator.getDefault().getLog().log(status);
}
-
+
public static void log(Throwable e) {
- IStatus status = new Status(IStatus.ERROR,PLUGIN_ID,e.getLocalizedMessage(),e);
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e
+ .getLocalizedMessage(), e);
PortletCoreActivator.getDefault().getLog().log(status);
}
- public static void createPortletInstances(IProject project, IFile file) throws CoreException, UnsupportedEncodingException {
-
+ public static void createPortletInstances(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buffer.append("<!DOCTYPE deployments PUBLIC \n");
- buffer.append("\"-//JBoss Portal//DTD Portlet Instances 2.6//EN\"\n");
- buffer.append("\"http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd\">");
- buffer.append("<deployments>");
- buffer.append("</deployments>");
-
- ByteArrayInputStream source = new ByteArrayInputStream(buffer.toString().getBytes("UTF8"));
- file.create(source, true, new NullProgressMonitor());
+ buffer.append("\"-//JBoss Portal//DTD Portlet Instances 2.6//EN\"\n");
+ buffer
+ .append("\"http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd\">");
+ buffer.append("<deployments>");
+ buffer.append("</deployments>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
}
-
-public static void createPortletObject(IProject project, IFile file) throws CoreException, UnsupportedEncodingException {
-
+
+ public static void createPortletObject(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buffer.append("<!DOCTYPE deployments PUBLIC \n");
- buffer.append("\"-//JBoss Portal//DTD Portal Object 2.6//EN\"\n");
- buffer.append("\"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd\">");
- buffer.append("<deployments>");
- buffer.append("</deployments>");
-
- ByteArrayInputStream source = new ByteArrayInputStream(buffer.toString().getBytes("UTF8"));
- file.create(source, true, new NullProgressMonitor());
+ buffer.append("\"-//JBoss Portal//DTD Portal Object 2.6//EN\"\n");
+ buffer
+ .append("\"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd\">");
+ buffer.append("<deployments>");
+ buffer.append("</deployments>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
}
+
+ public static void createJBossApp(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ buffer.append("<!DOCTYPE jboss-app PUBLIC \n");
+ buffer.append("\"-//JBoss Portal//DTD JBoss Web Application 2.6//EN\"\n");
+ buffer.append("\"http://www.jboss.org/portal/dtd/jboss-app_2_6.dtd\">");
+ buffer.append("<jboss-app>");
+ buffer.append("</jboss-app>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
+ }
+
+ public static void createJBossPortlet(IProject project, IFile file)
+ throws CoreException, UnsupportedEncodingException {
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ buffer.append("<!DOCTYPE portlet-app PUBLIC \n");
+ buffer
+ .append("\"-//JBoss Portal//DTD JBoss Portlet 2.6//EN\"\n");
+ buffer.append("\"http://www.jboss.org/portal/dtd/jboss-portlet_2_6.dtd\">");
+ buffer.append("<portlet-app>");
+ buffer.append("</portlet-app>");
+
+ ByteArrayInputStream source = new ByteArrayInputStream(buffer
+ .toString().getBytes("UTF8"));
+ file.create(source, true, new NullProgressMonitor());
+ }
+
}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/JSFPortlet10LibrariesContainerInitializer.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,126 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer;
+import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainerInitializer;
+import org.jboss.ide.eclipse.as.classpath.core.xpl.ClasspathDecorations;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortlet10LibrariesContainerInitializer extends
+ AbstractClasspathContainerInitializer {
+
+ public String getDescription(IPath containerPath, IJavaProject project) {
+ return "JBoss JSF Portlet Classpath Container Initializer v1.0";
+ }
+
+ @Override
+ protected AbstractClasspathContainer createClasspathContainer(IPath path) {
+ return new JSFPortlet10ClasspathContainer(path);
+ }
+
+ @Override
+ protected String getClasspathContainerID() {
+ return IPortletConstants.JSFPORTLET_CONTAINER_10_ID;
+ }
+
+ private class JSFPortlet10ClasspathContainer extends AbstractClasspathContainer {
+
+ public final static String SUFFIX = PortletCoreActivator.JSFPORTLET_FOLDER;//$NON-NLS-1$
+ public final static String PREFIX = "org.jboss.tools.portlet.core";
+ public final static String DESCRIPTION = "JBoss JSF Portlet Libraries v1.0";
+
+ public JSFPortlet10ClasspathContainer(IPath path) {
+ super(path, DESCRIPTION, SUFFIX);
+ }
+
+ @Override
+ protected String getBaseDir() {
+ try {
+ URL installURL = FileLocator.toFileURL(PortletCoreActivator
+ .getDefault().getBundle().getEntry("/"));
+ return installURL.getFile().toString();
+ } catch (IOException e) {
+ PortletCoreActivator
+ .log(e, "Error loading classpath container");
+ }
+ return null;
+ }
+
+ @Override
+ protected IClasspathEntry[] computeEntries() {
+ ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+
+ String baseDir = getBaseDir();
+ if (baseDir == null)
+ return new IClasspathEntry[0];
+
+ File libDir = new File(baseDir
+ + "/" + PortletCoreActivator.RESOURCES_FOLDER + "/" + PortletCoreActivator.JSFPORTLET_FOLDER);//$NON-NLS-1$ //$NON-NLS-2$
+
+ File[] jars = libDir.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return (file.toString().endsWith(".jar"));//$NON-NLS-1$
+ }
+ });
+
+ if (jars != null) {
+ for (int i = 0; i < jars.length; i++) {
+ File jarFile = jars[i];
+
+ IPath entryPath = new Path(jarFile.toString());
+
+ IPath sourceAttachementPath = null;
+ IPath sourceAttachementRootPath = null;
+
+ final ClasspathDecorations dec = decorations
+ .getDecorations(getDecorationManagerKey(getPath()
+ .toString()), entryPath.toString());
+
+ IClasspathAttribute[] attrs = {};
+ if (dec != null) {
+ sourceAttachementPath = dec.getSourceAttachmentPath();
+ sourceAttachementRootPath = dec
+ .getSourceAttachmentRootPath();
+ attrs = dec.getExtraAttributes();
+ }
+
+ IAccessRule[] access = {};
+ IClasspathEntry entry = JavaCore.newLibraryEntry(entryPath,
+ sourceAttachementPath, sourceAttachementRootPath,
+ access, attrs, false);
+ entries.add(entry);
+ }
+ }
+
+ return entries.toArray(new IClasspathEntry[entries.size()]);
+ }
+ }
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletConfigurationPresetFactory10.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * Copyright (c) 2008 BEA Systems, Inc. and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Konstantin Komissarchik
+ ******************************************************************************/
+
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jst.common.project.facet.JavaFacetUtils;
+import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
+import org.eclipse.wst.common.project.facet.core.IDynamicPreset;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
+import org.eclipse.wst.common.project.facet.core.IPresetFactory;
+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.PresetDefinition;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.portlet.core.IPortletConstants;
+
+/**
+ * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
+ * @author snjeza
+ */
+
+public final class JSFPortletConfigurationPresetFactory10
+
+implements IPresetFactory {
+ public PresetDefinition createPreset(final String presetId,
+ final Map<String, Object> context)
+
+ throws CoreException {
+ final IFacetedProjectBase fproj = (IFacetedProjectBase) context
+ .get(IDynamicPreset.CONTEXT_KEY_FACETED_PROJECT);
+ final IProjectFacetVersion webFacetVersion = fproj
+ .getProjectFacetVersion(WebFacetUtils.WEB_FACET);
+ final IProjectFacet PORTLET_FACET = ProjectFacetsManager.getProjectFacet(IPortletConstants.PORTLET_FACET_ID);
+ final IProjectFacetVersion portletFacetVersion = PORTLET_FACET.getVersion(IPortletConstants.PORTLET_FACET_VERSION_10);
+ final IProjectFacet JSF_FACET = ProjectFacetsManager.getProjectFacet("jst.jsf");
+ final IProjectFacetVersion jsfFacetVersion = JSF_FACET.getVersion("1.2");
+ if (webFacetVersion != null
+ && webFacetVersion.compareTo(WebFacetUtils.WEB_23) >= 0 &&
+ portletFacetVersion != null) {
+ final Set<IProjectFacetVersion> facets = new HashSet<IProjectFacetVersion>();
+ final IProjectFacet jsfPortletFacet = ProjectFacetsManager
+ .getProjectFacet(IPortletConstants.JSFPORTLET_FACET_ID);
+ final IProjectFacetVersion jsfPortletVersion = jsfPortletFacet
+ .getVersion(IPortletConstants.JSFPORTLET_FACET_VERSION_10);
+ facets.add(jsfPortletVersion);
+ facets.add(webFacetVersion);
+ facets.add(JavaFacetUtils.JAVA_50);
+ facets.add(portletFacetVersion);
+ facets.add(jsfFacetVersion);
+ return new PresetDefinition("JBoss JSF Portlet Project v1.0",
+ "JBoss JSF Portlet Project v1.0", facets);
+ }
+ return null;
+ }
+}
Added: 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 (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDataModelProvider.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,42 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.util.Set;
+
+import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
+import org.jboss.tools.portlet.core.IPortletConstants;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortletFacetInstallDataModelProvider extends
+ FacetInstallDataModelProvider implements IPortletConstants {
+
+ @Override
+ public Object getDefaultProperty(String propertyName) {
+ if(propertyName.equals(FACET_ID)){
+ return IPortletConstants.JSFPORTLET_FACET_ID;
+ }
+ if (propertyName.equals(IPortletConstants.DEPLOY_JARS)) {
+ return Boolean.TRUE;
+ }
+ return super.getDefaultProperty(propertyName);
+ }
+
+ @Override
+ public Set<String> getPropertyNames() {
+ Set<String> propertyNames = super.getPropertyNames();
+ propertyNames.add(IPortletConstants.DEPLOY_JARS);
+ return propertyNames;
+ }
+}
Added: 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 (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetInstallDelegate.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,326 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.Path;
+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.model.IModelProvider;
+import org.eclipse.jst.javaee.web.WebApp;
+import org.eclipse.jst.javaee.web.WebAppVersionType;
+import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
+import org.eclipse.jst.jsf.facesconfig.emf.StateManagerType;
+import org.eclipse.jst.jsf.facesconfig.emf.ViewHandlerType;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+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.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.portlet.core.IJBossWebUtil;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.JBossWebUtil;
+import org.jboss.tools.portlet.core.JBossWebUtil25;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortletFacetInstallDelegate implements IDelegate {
+
+ private static final String ORG_JBOSS_PORTLET_STATE_MANAGER = "org.jboss.portletbridge.application.PortletStateManager";
+ private static final String ORG_JBOSS_PORTLET_VIEW_HANDLER = "org.jboss.portletbridge.application.PortletViewHandler";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse
+ * .core.resources.IProject,
+ * org.eclipse.wst.common.project.facet.core.IProjectFacetVersion,
+ * java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(final IProject project, final IProjectFacetVersion fv,
+ final Object cfg, final IProgressMonitor monitor)
+ throws CoreException {
+
+ if (monitor != null) {
+ monitor.beginTask("", 1);
+ }
+ try {
+ IDataModel config = null;
+
+ if (cfg != null) {
+ config = (IDataModel) cfg;
+ } else {
+ throw new CoreException(
+ PortletCoreActivator
+ .getStatus("Internal Error creating JBoss JSF Portlet Facet. Missing configuration."));
+ }
+
+ // check whether web.xml is available for update
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ if (provider == null) {
+ throw new CoreException(
+ PortletCoreActivator
+ .getStatus("Cannot configure web module for JBoss JSF Portlet Facet"));
+ } else if (!(provider.validateEdit(null, null).isOK())) {
+ if (!(provider.validateEdit(null, null).isOK())) {
+ throw new CoreException(PortletCoreActivator
+ .getStatus("The web.xml file is not updateable"));
+ }
+ }
+
+ configureFacesConfig(project, monitor, config);
+
+ configureClassPath(project, monitor, config);
+
+ configureWebApp(project, monitor, config);
+
+ if (monitor != null) {
+ monitor.worked(1);
+ }
+
+ } finally {
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
+ }
+
+ private void configureFacesConfig(IProject project,
+ IProgressMonitor monitor, IDataModel config) {
+
+ String facesConfigString = getFacesConfigFile(project, monitor);
+ FacesConfigArtifactEdit facesConfigEdit = null;
+ try {
+ facesConfigEdit = FacesConfigArtifactEdit
+ .getFacesConfigArtifactEditForWrite(project,
+ facesConfigString);
+ FacesConfigType facesConfig = facesConfigEdit.getFacesConfig();
+ EList applications = facesConfig.getApplication();
+ ApplicationType applicationType = null;
+ boolean applicationExists = false;
+ if (applications.size() <= 0) {
+ applicationType = FacesConfigFactory.eINSTANCE
+ .createApplicationType();
+ } else {
+ applicationType = (ApplicationType) applications.get(0);
+ applicationExists = true;
+ }
+ boolean viewHandlerExists = false;
+ for (Iterator iterator = applications.iterator(); iterator
+ .hasNext();) {
+ ApplicationType application = (ApplicationType) iterator.next();
+ EList viewHandlers = applicationType.getViewHandler();
+ for (Iterator iterator2 = viewHandlers.iterator(); iterator2
+ .hasNext();) {
+ ViewHandlerType viewHandler = (ViewHandlerType) iterator2
+ .next();
+ if (ORG_JBOSS_PORTLET_VIEW_HANDLER.equals(viewHandler
+ .getTextContent())) {
+ viewHandlerExists = true;
+ }
+ }
+ }
+ if (!viewHandlerExists) {
+ ViewHandlerType viewHandler = FacesConfigFactory.eINSTANCE
+ .createViewHandlerType();
+ viewHandler.setTextContent(ORG_JBOSS_PORTLET_VIEW_HANDLER);
+ applicationType.getViewHandler().add(viewHandler);
+ }
+ boolean stateManagerExists = false;
+ for (Iterator iterator = applications.iterator(); iterator
+ .hasNext();) {
+ ApplicationType application = (ApplicationType) iterator.next();
+ EList stateManagers = applicationType.getStateManager();
+ for (Iterator iterator2 = stateManagers.iterator(); iterator2
+ .hasNext();) {
+ StateManagerType stateManager = (StateManagerType) iterator2
+ .next();
+ if (ORG_JBOSS_PORTLET_STATE_MANAGER.equals(stateManager
+ .getTextContent())) {
+ stateManagerExists = true;
+ }
+ }
+ }
+ if (!stateManagerExists) {
+ StateManagerType stateManager = FacesConfigFactory.eINSTANCE
+ .createStateManagerType();
+ stateManager.setTextContent(ORG_JBOSS_PORTLET_STATE_MANAGER);
+ applicationType.getStateManager().add(stateManager);
+ }
+ if (!applicationExists) {
+ facesConfig.getApplication().add(applicationType);
+ }
+ facesConfigEdit.save(monitor);
+
+ } finally {
+ if (facesConfigEdit != null) {
+ facesConfigEdit.dispose();
+ }
+ }
+ }
+
+ private String getFacesConfigFile(IProject project, IProgressMonitor monitor) {
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ if (isWebApp25(provider.getModelObject())) {
+ return new JBossWebUtil25().getFacesConfig(project, monitor);
+ }
+ return new JBossWebUtil().getFacesConfig(project, monitor);
+ }
+
+ private void configureWebApp(final IProject project,
+ final IProgressMonitor monitor, IDataModel config) {
+ final IModelProvider provider = PortletCoreActivator
+ .getModelProvider(project);
+ IPath modelPath = new Path("WEB-INF").append("web.xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean exists = project.getProjectRelativePath().append(modelPath)
+ .toFile().exists();
+ if (isWebApp25(provider.getModelObject()) && !exists) {
+ modelPath = IModelProvider.FORCESAVE;
+ }
+ provider.modify(new Runnable() {
+ public void run() {
+ IJBossWebUtil util = null;
+
+ if (isWebApp25(provider.getModelObject())) {
+ util = new JBossWebUtil25();
+ } else {
+ util = new JBossWebUtil();
+ }
+ String name = "org.ajax4jsf.VIEW_HANDLERS";
+ String value = "org.jboss.portletbridge.application.FaceletPortletViewHandler";
+ String description = null;
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ name = "javax.portlet.faces.renderPolicy";
+ value = "ALWAYS_DELEGATE";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ // RichFaces settings
+
+ name = "org.richfaces.LoadStyleStrategy";
+ value = "NONE";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ name = "org.richfaces.LoadScriptStrategy";
+ value = "NONE";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ name = "org.ajax4jsf.RESOURCE_URI_PREFIX";
+ value = "rfRes";
+ util.configureContextParam(project, monitor, name, value,
+ description);
+
+ String displayName = "Ajax4jsf Filter";
+ String filterName = "ajax4jsf";
+ String className = "org.ajax4jsf.Filter";
+ util.configureFilter(project, monitor, filterName, className,
+ displayName, description);
+
+ String servletName = util.findJsfServlet(provider
+ .getModelObject());
+ if (servletName == null) {
+ RuntimeException e = new RuntimeException(
+ "Cannot find the JSF servlet");
+ PortletCoreActivator.log(e);
+ throw e;
+ }
+ util.configureFilterMapping(project, monitor, filterName,
+ servletName);
+
+ // FIXME add Seam settings
+ }
+ }, modelPath);
+ }
+
+ private void configureClassPath(final IProject project,
+ final IProgressMonitor monitor, IDataModel config)
+ throws JavaModelException {
+ IJavaProject javaProject = JavaCore.create(project);
+
+ boolean deployJars = config
+ .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);
+
+ IFile folder = libVirtualFile.getUnderlyingFile();
+
+ ImportOperation importOperation = new ImportOperation(folder
+ .getFullPath(), libDir,
+ FileSystemStructureProvider.INSTANCE,
+ PortletCoreActivator.OVERWRITE_ALL_QUERY, filesToImport);
+ importOperation.setCreateContainerStructure(false);
+ importOperation.run(monitor);
+ } catch (Exception e) {
+ PortletCoreActivator
+ .log(e, "Error loading classpath container");
+ }
+ } else {
+ IPath containerPath = new Path(
+ IPortletConstants.JSFPORTLET_CONTAINER_10_ID);
+
+ IClasspathEntry entry = JavaCore.newContainerEntry(containerPath,
+ true);
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
+ System.arraycopy(entries, 0, newEntries, 0, entries.length);
+ newEntries[entries.length] = entry;
+ javaProject.setRawClasspath(newEntries, monitor);
+ }
+ }
+
+ private boolean isWebApp25(final Object webApp) {
+ if (webApp instanceof WebApp
+ && ((WebApp) webApp).getVersion() == WebAppVersionType._25_LITERAL)
+ return true;
+ return false;
+ }
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetUninstallDelegate.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetUninstallDelegate.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/JSFPortletFacetUninstallDelegate.java 2008-08-01 13:46:18 UTC (rev 9471)
@@ -0,0 +1,34 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal.project.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+/**
+ * @author snjeza
+ *
+ */
+public class JSFPortletFacetUninstallDelegate implements IDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
17 years, 4 months