Author: rob.stryker(a)jboss.com
Date: 2009-12-16 00:51:07 -0500 (Wed, 16 Dec 2009)
New Revision: 19295
Added:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/SharedImages.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/FilesetVCLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java
Log:
Allows arbitrary component types to control their UI in module assembly page
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml 2009-12-16
01:13:32 UTC (rev 19294)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml 2009-12-16
05:51:07 UTC (rev 19295)
@@ -184,9 +184,16 @@
point="org.jboss.ide.eclipse.as.wtp.ui.referenceWizardFragment">
<referenceFragment
class="org.jboss.ide.eclipse.archives.webtools.ui.FilesetReferenceWizardFragment"
- icon="icons/multiple_files.gif"
+ icon="$nl$/icons/multiple_files.gif"
id="org.jboss.ide.eclipse.archives.webtools.FilesetReferenceWizardFragment"
name="Fileset">
</referenceFragment>
</extension>
+ <extension
+
point="org.jboss.ide.eclipse.as.wtp.ui.virtualComponentLabelProvider">
+ <provider
+
class="org.jboss.ide.eclipse.archives.webtools.filesets.vcf.FilesetVCLabelProvider"
+ weight="5">
+ </provider>
+ </extension>
</plugin>
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java 2009-12-16
01:13:32 UTC (rev 19294)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/IntegrationPlugin.java 2009-12-16
05:51:07 UTC (rev 19295)
@@ -49,8 +49,9 @@
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
+ SharedImages.instance().cleanup();
+ UnitedServerListenerManager.getDefault().removeListener(NewServerFilesetHandler.getDefault());
plugin = null;
- UnitedServerListenerManager.getDefault().removeListener(NewServerFilesetHandler.getDefault());
super.stop(context);
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/SharedImages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/SharedImages.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/SharedImages.java 2009-12-16
05:51:07 UTC (rev 19295)
@@ -0,0 +1,74 @@
+package org.jboss.ide.eclipse.archives.webtools;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
+import org.osgi.framework.Bundle;
+
+public class SharedImages {
+ private static SharedImages instance;
+ public static final String FILESET_IMAGE = "multiple_files"; //$NON-NLS-1$
+
+ private Hashtable<String, Object> images, descriptors;
+
+ private SharedImages () {
+ instance = this;
+ images = new Hashtable<String, Object>();
+ descriptors = new Hashtable<String, Object>();
+ Bundle pluginBundle = JBossServerUIPlugin.getDefault().getBundle();
+
+ descriptors.put(FILESET_IMAGE, createImageDescriptor(pluginBundle,
"/icons/multiple_files.gif")); //$NON-NLS-1$
+ Iterator<String> iter = descriptors.keySet().iterator();
+ while (iter.hasNext()) {
+ String key = iter.next();
+ ImageDescriptor descriptor = descriptor(key);
+ images.put(key, descriptor.createImage());
+ }
+ }
+
+ private ImageDescriptor createImageDescriptor (Bundle pluginBundle, String relativePath)
{
+ return ImageDescriptor.createFromURL(pluginBundle.getEntry(relativePath));
+ }
+
+ public static SharedImages instance() {
+ if (instance == null)
+ instance = new SharedImages();
+ return instance;
+ }
+
+ public static Image getImage(String key) {
+ return instance().image(key);
+ }
+
+ public static ImageDescriptor getImageDescriptor(String key) {
+ return instance().descriptor(key);
+ }
+
+ public Image image(String key) {
+ return (Image) images.get(key);
+ }
+
+ public ImageDescriptor descriptor(String key) {
+ return (ImageDescriptor) descriptors.get(key);
+ }
+
+ public void cleanup() {
+ Iterator<String> iter = images.keySet().iterator();
+ while (iter.hasNext()) {
+ Image image = (Image) images.get(iter.next());
+ image.dispose();
+ }
+ images = null;
+ instance = null;
+ }
+
+ protected void finalize() throws Throwable {
+ cleanup();
+ super.finalize();
+ }
+
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/FilesetVCLabelProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/FilesetVCLabelProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/FilesetVCLabelProvider.java 2009-12-16
05:51:07 UTC (rev 19295)
@@ -0,0 +1,31 @@
+package org.jboss.ide.eclipse.archives.webtools.filesets.vcf;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.jboss.ide.eclipse.archives.webtools.SharedImages;
+import org.jboss.ide.eclipse.as.wtp.ui.propertypage.IVirtualComponentLabelProvider;
+
+public class FilesetVCLabelProvider implements IVirtualComponentLabelProvider {
+
+ public FilesetVCLabelProvider() {
+ }
+
+ public boolean canHandle(IVirtualComponent component) {
+ return component instanceof WorkspaceFilesetVirtualComponent;
+ }
+
+ public Image getSourceImage(IVirtualComponent component) {
+ return SharedImages.getImage(SharedImages.FILESET_IMAGE);
+ }
+
+ public String getSourceText(IVirtualComponent component) {
+ WorkspaceFilesetVirtualComponent fileset =
(WorkspaceFilesetVirtualComponent)component;
+ String base = fileset.getRootFolderPath();
+ if( fileset.getIncludes() != null &&
!fileset.getIncludes().equals("")) //$NON-NLS-1$
+ base += " [" + fileset.getIncludes() + "]"; //$NON-NLS-1$
//$NON-NLS-2$
+ if( fileset.getExcludes() != null &&
!fileset.getExcludes().equals("")) //$NON-NLS-1$
+ base += " [" + fileset.getExcludes() + "]"; //$NON-NLS-1$
//$NON-NLS-2$
+ return base;
+ }
+
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2009-12-16 01:13:32 UTC
(rev 19294)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2009-12-16 05:51:07 UTC
(rev 19295)
@@ -3,6 +3,7 @@
<plugin>
<extension-point id="moduleDependencyPropertyPage"
name="moduleDependencyPropertyPage"
schema="schema/moduleDependencyPropertyPage.exsd"/>
<extension-point id="referenceWizardFragment"
name="referenceWizardFragment"
schema="schema/referenceWizardFragment.exsd"/>
+ <extension-point id="virtualComponentLabelProvider"
name="virtualComponentLabelProvider"
schema="schema/virtualComponentLabelProvider.exsd"/>
<extension point="org.eclipse.ui.propertyPages">
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd 2009-12-16
05:51:07 UTC (rev 19295)
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.ide.eclipse.as.wtp.ui"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.ide.eclipse.as.wtp.ui"
id="VirtualComponentLabelProvider"
name="VirtualComponentLabelProvider"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="provider"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.ide.eclipse.as.wtp.ui.propertypage.IVirtualComponentLabelProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="weight" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java 2009-12-16
01:13:32 UTC (rev 19294)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java 2009-12-16
05:51:07 UTC (rev 19295)
@@ -49,10 +49,11 @@
private DecoratingLabelProvider decProvider = new DecoratingLabelProvider(
new WorkbenchLabelProvider(), PlatformUI.getWorkbench().
getDecoratorManager().getLabelDecorator());
-
+ private IVirtualComponentLabelProvider[] delegates;
public ComponentDependencyContentProvider(AddModuleDependenciesPropertiesPage
addModuleDependenciesPropertiesPage) {
super();
decProvider.addListener(addModuleDependenciesPropertiesPage);
+ delegates = DependencyPageExtensionManager.loadDelegates();
}
public void setRuntimePaths(HashMap<IVirtualComponent, String> paths) {
@@ -81,10 +82,7 @@
if (columnIndex == 0)
return WTPOveridePlugin.getInstance().getImage("jar_obj");
else
- if(((IVirtualComponent)element).isBinary())
- return WTPOveridePlugin.getInstance().getImage("jar_obj");
- else return decProvider.getImage(((IVirtualComponent)element).getProject());
- //return ModuleCoreUIPlugin.getInstance().getImage("prj_obj");
+ return handleSourceImage((IVirtualComponent)element);
}
if (element instanceof IProject){
return decProvider.getImage(element);
@@ -122,16 +120,37 @@
return null;
}
- private String handleSourceText(IVirtualComponent comp) {
- if( comp.isBinary() && comp instanceof VirtualArchiveComponent) {
- IPath p = ((VirtualArchiveComponent)comp).getWorkspaceRelativePath();
+
+
+ private String handleSourceText(IVirtualComponent component) {
+ if( delegates != null ) {
+ for( int i = 0; i < delegates.length; i++ )
+ if( delegates[i].canHandle(component))
+ return delegates[i].getSourceText(component);
+ }
+
+ // default impl
+ if( component.isBinary() && component instanceof VirtualArchiveComponent) {
+ IPath p = ((VirtualArchiveComponent)component).getWorkspaceRelativePath();
if( p == null )
- p = new
Path(((VirtualArchiveComponent)comp).getUnderlyingDiskFile().getAbsolutePath());
+ p = new
Path(((VirtualArchiveComponent)component).getUnderlyingDiskFile().getAbsolutePath());
return p.toString();
}
- return comp.getProject().getName();
+ return component.getProject().getName();
}
+ private Image handleSourceImage(IVirtualComponent component) {
+ if( delegates != null ) {
+ for( int i = 0; i < delegates.length; i++ )
+ if( delegates[i].canHandle(component))
+ return delegates[i].getSourceImage(component);
+ }
+
+ // default impl
+ if(component.isBinary())
+ return WTPOveridePlugin.getInstance().getImage("jar_obj");
+ else return decProvider.getImage(component.getProject());
+ }
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java 2009-12-16
01:13:32 UTC (rev 19294)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java 2009-12-16
05:51:07 UTC (rev 19295)
@@ -1,8 +1,12 @@
package org.jboss.ide.eclipse.as.wtp.ui.propertypage;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -118,4 +122,38 @@
}
}
}
+
+
+ public static IVirtualComponentLabelProvider[] loadDelegates() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ WTPOveridePlugin.PLUGIN_ID, "virtualComponentLabelProvider");
//$NON-NLS-1$
+ List<IConfigurationElement> list = Arrays.asList(cf);
+ Comparator c = new Comparator<IConfigurationElement>() {
+ public int compare(IConfigurationElement o1,
+ IConfigurationElement o2) {
+ String o1String, o2String;
+ int o1int, o2int;
+ o1String=o1.getAttribute("weight");
+ o2String=o2.getAttribute("weight");
+ o1int = Integer.parseInt(o1String);
+ o2int = Integer.parseInt(o1String);
+ return o1int-o2int;
+ }
+ };
+ Collections.sort(list, c);
+ ArrayList<IVirtualComponentLabelProvider> retList = new
ArrayList<IVirtualComponentLabelProvider>();
+ Iterator<IConfigurationElement> i = list.iterator();
+ while(i.hasNext()) {
+ try {
+ retList.add((IVirtualComponentLabelProvider)i.next().createExecutableExtension("class"));
+ } catch( CoreException ce) {
+ // log
+ }
+ }
+ return (IVirtualComponentLabelProvider[]) retList
+ .toArray(new IVirtualComponentLabelProvider[retList.size()]);
+ }
+
+
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java 2009-12-16
05:51:07 UTC (rev 19295)
@@ -0,0 +1,10 @@
+package org.jboss.ide.eclipse.as.wtp.ui.propertypage;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+
+public interface IVirtualComponentLabelProvider {
+ public boolean canHandle(IVirtualComponent component);
+ public String getSourceText(IVirtualComponent component);
+ public Image getSourceImage(IVirtualComponent component);
+}