Author: rob.stryker(a)jboss.com
Date: 2009-12-17 13:25:16 -0500 (Thu, 17 Dec 2009)
New Revision: 19440
Added:
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java
Modified:
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java
Log:
Merging UI changes to allow customization of module assembly types image / text
Modified:
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
===================================================================
---
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2009-12-17
18:22:10 UTC (rev 19439)
+++
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2009-12-17
18:25:16 UTC (rev 19440)
@@ -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:
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd
===================================================================
---
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd
(rev 0)
+++
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/schema/virtualComponentLabelProvider.exsd 2009-12-17
18:25:16 UTC (rev 19440)
@@ -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:
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java 2009-12-17
18:22:10 UTC (rev 19439)
+++
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java 2009-12-17
18:25:16 UTC (rev 19440)
@@ -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:
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java 2009-12-17
18:22:10 UTC (rev 19439)
+++
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/DependencyPageExtensionManager.java 2009-12-17
18:25:16 UTC (rev 19440)
@@ -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:
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java
(rev 0)
+++
branches/jbosstools-3.1.0.RC1/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/IVirtualComponentLabelProvider.java 2009-12-17
18:25:16 UTC (rev 19440)
@@ -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);
+}