Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 124416 Details for
Bug 260909
[Markers] markerImageProviders extension point does not work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch
patch_260909_2.txt (text/plain), 38.77 KB, created by
Hitesh
on 2009-02-02 08:52:11 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Hitesh
Created:
2009-02-02 08:52:11 EST
Size:
38.77 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java,v >retrieving revision 1.6 >diff -u -r1.6 MarkerGroupingEntry.java >--- src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java 24 Mar 2008 19:13:34 -0000 1.6 >+++ src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java 2 Feb 2009 13:43:27 -0000 >@@ -11,7 +11,13 @@ > > package org.eclipse.ui.views.markers.internal; > >+import java.net.URL; >+ >+import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.internal.views.markers.MarkerSupportInternalUtilities; > > /** >@@ -24,11 +30,12 @@ > public class MarkerGroupingEntry { > > private static final String PRIORITY = "priority"; //$NON-NLS-1$ >- >+ > private MarkerGroup markerGroup; > private String label; > private String id; > private int sortPriority; >+ private ImageDescriptor imageDescriptor; > > /** > * Create a new instance of the receiver from element. >@@ -39,6 +46,13 @@ > id = element.getAttribute(MarkerSupportInternalUtilities.ATTRIBUTE_ID); > sortPriority = Integer.valueOf(element.getAttribute(PRIORITY)) > .intValue(); >+ String imagePath = element >+ .getAttribute(MarkerSupportInternalUtilities.ATTRIBUTE_ICON); >+ if (imagePath != null) { >+ URL url = FileLocator.find(Platform.getBundle(element >+ .getContributor().getName()), new Path(imagePath), null); >+ imageDescriptor = ImageDescriptor.createFromURL(url); >+ } > } > > /** >@@ -107,4 +121,12 @@ > return markerGroup; > } > >+ /** >+ * Returns the icon for the receiver. >+ * >+ * @return ImageDescriptor >+ */ >+ public ImageDescriptor getImageDescriptor() { >+ return imageDescriptor; >+ } > } >Index: src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java,v >retrieving revision 1.9 >diff -u -r1.9 TypeMarkerGroup.java >--- src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java 24 Mar 2008 19:13:34 -0000 1.9 >+++ src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java 2 Feb 2009 13:43:27 -0000 >@@ -11,8 +11,13 @@ > > package org.eclipse.ui.views.markers.internal; > >+import java.util.HashMap; >+import java.util.Map; >+ > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; > import org.eclipse.ui.internal.ide.Policy; > import org.eclipse.ui.views.markers.MarkerItem; > >@@ -25,6 +30,7 @@ > */ > public class TypeMarkerGroup extends MarkerGroup { > >+ private Map entries=new HashMap(); > /** > * TypeMarkerField is the MarkerField used for MarkerGroupungs > * >@@ -102,6 +108,33 @@ > markerField = new TypeMarkerField(); > } > >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.views.markers.internal.MarkerGroup#findGroupValue(java >+ * .lang.String, org.eclipse.core.resources.IMarker) >+ */ >+ public MarkerGroupingEntry findGroupValue(String typeId, IMarker marker) { >+ TypesMarkerGroupingEntry entry = (TypesMarkerGroupingEntry) entries >+ .get(typeId); >+ if (entry == null) { >+ String groupName = MarkerSupportRegistry.getInstance().getCategory( >+ marker); >+ if (groupName == null) { >+ MarkerType mkType = MarkerTypesModel.getInstance().getType( >+ typeId); >+ groupName = mkType.getLabel(); >+ } >+ entry = new TypesMarkerGroupingEntry(groupName, null); >+ entry.setGroup(this); >+ entries.put(typeId, entry); >+ } >+ // update the icon >+ entry.setImageDescriptor(IDEWorkbenchPlugin.getDefault() >+ .getMarkerImageProviderRegistry().getImageDescriptor(marker)); >+ return entry; >+ } > /* (non-Javadoc) > * @see org.eclipse.ui.views.markers.internal.MarkerGroup#getId() > */ >@@ -116,4 +149,26 @@ > return name; > } > >+ private class TypesMarkerGroupingEntry extends MarkerGroupingEntry { >+ private ImageDescriptor imageDescriptor; >+ >+ public TypesMarkerGroupingEntry(String label, >+ ImageDescriptor imageDescriptor) { >+ super(label); >+ this.imageDescriptor = imageDescriptor; >+ } >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.views.markers.internal.MarkerGroupingEntry# >+ * getImageDescriptor() >+ */ >+ public ImageDescriptor getImageDescriptor() { >+ return imageDescriptor; >+ } >+ >+ void setImageDescriptor(ImageDescriptor imageDescriptor) { >+ this.imageDescriptor = imageDescriptor; >+ } >+ } > } >Index: src/org/eclipse/ui/internal/views/markers/MarkerEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerEntry.java,v >retrieving revision 1.13 >diff -u -r1.13 MarkerEntry.java >--- src/org/eclipse/ui/internal/views/markers/MarkerEntry.java 8 Dec 2008 19:11:53 -0000 1.13 >+++ src/org/eclipse/ui/internal/views/markers/MarkerEntry.java 2 Feb 2009 13:43:27 -0000 >@@ -18,7 +18,9 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IPath; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; > import org.eclipse.ui.internal.ide.Policy; > import org.eclipse.ui.views.markers.MarkerViewUtil; > import org.eclipse.ui.views.markers.internal.MarkerMessages; >@@ -359,4 +361,13 @@ > collationKeys = null; > attributeCache.clear(); > } >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.views.markers.MarkerItem#getImageDescriptor() >+ */ >+ public ImageDescriptor getImageDescriptor() { >+ if(marker!=null){ >+ return IDEWorkbenchPlugin.getDefault().getMarkerImageProviderRegistry().getImageDescriptor(marker); >+ } >+ return super.getImageDescriptor(); >+ } > } >Index: src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java,v >retrieving revision 1.4 >diff -u -r1.4 MarkerSeverityAndDescriptionField.java >--- src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java 11 Mar 2008 15:29:23 -0000 1.4 >+++ src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java 2 Feb 2009 13:43:27 -0000 >@@ -11,7 +11,7 @@ > > package org.eclipse.ui.internal.views.markers; > >-import org.eclipse.core.resources.IMarker; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ViewerCell; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.views.markers.MarkerItem; >@@ -53,15 +53,10 @@ > * @return Image or <code>null</code> > */ > private Image getImage(MarkerItem item) { >- >- int severity = -1; >- if (item.getMarker() == null) >- severity = ((MarkerCategory) item).getHighestSeverity(); >- else >- severity = MarkerSupportInternalUtilities.getSeverity(item); >- >- if (severity >= IMarker.SEVERITY_WARNING) >- return MarkerSupportInternalUtilities.getSeverityImage(severity); >+ ImageDescriptor descriptor=item.getImageDescriptor(); >+ if(descriptor!=null){ >+ return getImageManager().createImage(descriptor); >+ } > return null; > > } >Index: src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java,v >retrieving revision 1.23 >diff -u -r1.23 CachedMarkerBuilder.java >--- src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java 8 Dec 2008 19:11:53 -0000 1.23 >+++ src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java 2 Feb 2009 13:43:26 -0000 >@@ -39,6 +39,7 @@ > import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.ui.IMemento; >@@ -275,6 +276,17 @@ > if (previous != null) { > // Are we at a category boundary? > if (sorter.compareCategory(previous, elements[i]) != 0) { >+ MarkerEntry entry=markers.elementAt(categoryStart); >+ IMarker marker=entry.getMarker(); >+ ImageDescriptor imgDesc=null; >+ if(marker!=null){ >+ try{ >+ String typeID=marker.getType(); >+ imgDesc=getCategoryGroup().findGroupValue(typeID, marker).getImageDescriptor(); >+ }catch(CoreException e){ >+ Policy.handle(e); >+ } >+ } > categories > .add(new MarkerCategory( > this, >@@ -284,7 +296,7 @@ > .getMarkerField() > .getValue( > markers >- .elementAt(categoryStart)))); >+ .elementAt(categoryStart)),imgDesc)); > categoryStart = i; > } > } >@@ -293,9 +305,19 @@ > } > > if (end >= categoryStart) { >+ MarkerEntry entry=markers.elementAt(categoryStart); >+ IMarker marker=entry.getMarker(); >+ ImageDescriptor imgDesc=null; >+ if(marker!=null){ >+ try{ >+ String typeID=marker.getType(); >+ imgDesc=getCategoryGroup().findGroupValue(typeID, marker).getImageDescriptor(); >+ }catch(CoreException e){ >+ Policy.handle(e); >+ } >+ } > categories.add(new MarkerCategory(this, categoryStart, end, >- getCategoryGroup().getMarkerField().getValue( >- markers.elementAt(categoryStart)))); >+ getCategoryGroup().getMarkerField().getValue(entry),imgDesc)); > } > > MarkerCategory[] nodes = new MarkerCategory[categories.size()]; >Index: src/org/eclipse/ui/internal/views/markers/MarkerCategory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCategory.java,v >retrieving revision 1.4 >diff -u -r1.4 MarkerCategory.java >--- src/org/eclipse/ui/internal/views/markers/MarkerCategory.java 24 Mar 2008 19:13:33 -0000 1.4 >+++ src/org/eclipse/ui/internal/views/markers/MarkerCategory.java 2 Feb 2009 13:43:26 -0000 >@@ -12,6 +12,7 @@ > package org.eclipse.ui.internal.views.markers; > > import org.eclipse.core.resources.IMarker; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.osgi.util.NLS; > import org.eclipse.ui.views.markers.MarkerItem; > import org.eclipse.ui.views.markers.internal.MarkerMessages; >@@ -29,6 +30,8 @@ > private CachedMarkerBuilder cachedMarkerBuilder; > > private int severity = -1; >+ >+ private ImageDescriptor imageDescriptor; > > /** > * Create a new instance of the receiver that has the markers between >@@ -46,7 +49,24 @@ > end = endIndex; > name = categoryName; > } >+ /** >+ * Create a new instance of the receiver that has the markers between >+ * startIndex and endIndex showing. >+ * >+ * @param cachedMarkerBuilder >+ * @param startIndex >+ * @param endIndex >+ * @param imageDescriptor >+ * the builder used to generate the children lazily. >+ * >+ */ >+ MarkerCategory(CachedMarkerBuilder cachedMarkerBuilder, int startIndex, >+ int endIndex, String categoryName,ImageDescriptor imageDescriptor) { >+ this(cachedMarkerBuilder, startIndex, endIndex, categoryName); >+ this.imageDescriptor=imageDescriptor; >+ } > >+ > /* (non-Javadoc) > * @see org.eclipse.ui.internal.views.markers.MarkerSupportItem#getChildren() > */ >@@ -154,4 +174,10 @@ > return false; > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.views.markers.MarkerItem#getImageDescriptor() >+ */ >+ public ImageDescriptor getImageDescriptor() { >+ return imageDescriptor; >+ } > } >Index: src/org/eclipse/ui/views/markers/MarkerItem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerItem.java,v >retrieving revision 1.6 >diff -u -r1.6 MarkerItem.java >--- src/org/eclipse/ui/views/markers/MarkerItem.java 2 May 2008 19:37:07 -0000 1.6 >+++ src/org/eclipse/ui/views/markers/MarkerItem.java 2 Feb 2009 13:43:27 -0000 >@@ -13,6 +13,7 @@ > > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.resources.IResource; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.internal.views.markers.MarkerSupportInternalUtilities; > > /** >@@ -101,4 +102,13 @@ > public IMarker getMarker() { > return null; > } >+ >+ /** >+ * Returns the image for receiver's marker. >+ * >+ * @return ImageDescriptor >+ */ >+ public ImageDescriptor getImageDescriptor() { >+ return null; >+ } > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.xml,v >retrieving revision 1.283 >diff -u -r1.283 plugin.xml >--- plugin.xml 19 Jan 2009 14:35:31 -0000 1.283 >+++ plugin.xml 2 Feb 2009 13:43:24 -0000 >@@ -1419,11 +1419,13 @@ > <markerGroupingEntry > id="org.eclipse.ui.ide.allMarkers.errorSeverity" > label="%markerGrouping.errors" >+ icon="$nl$/icons/full/obj16/error_tsk.gif" > priority="30"> > </markerGroupingEntry> > <markerGroupingEntry > id="org.eclipse.ui.ide.allMarkers.warningSeverity" > label="%markerGrouping.warnings" >+ icon="$nl$/icons/full/obj16/warn_tsk.gif" > priority="20"> > </markerGroupingEntry> > <markerGroupingEntry >Index: schema/markerSupport.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/schema/markerSupport.exsd,v >retrieving revision 1.41 >diff -u -r1.41 markerSupport.exsd >--- schema/markerSupport.exsd 26 Mar 2008 15:30:03 -0000 1.41 >+++ schema/markerSupport.exsd 2 Feb 2009 13:43:25 -0000 >@@ -2,15 +2,20 @@ > <!-- Schema file written by PDE --> > <schema targetNamespace="org.eclipse.ui.ide" xmlns="http://www.w3.org/2001/XMLSchema"> > <annotation> >- <appinfo> >+ <appInfo> > <meta.schema plugin="org.eclipse.ui.ide" id="markerSupport" name="Marker Support"/> >- </appinfo> >+ </appInfo> > <documentation> > The Marker Support extension point defines extensions to the workbench tools that show markers such as the problems, bookmarks and tasks views. > </documentation> > </annotation> > > <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> > <complexType> > <sequence> > <element ref="problemFilter" minOccurs="0" maxOccurs="unbounded"/> >@@ -34,9 +39,9 @@ > <documentation> > > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute translatable="true"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="id" type="string"> >@@ -143,9 +148,9 @@ > <documentation> > The id of a marker that is enabled by default. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.markers/@id"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > </complexType> >@@ -166,9 +171,9 @@ > <documentation> > The label is the human readable name that will be presented to the user. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute translatable="true"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > </complexType> >@@ -186,9 +191,9 @@ > <documentation> > The id of the markerType > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.markers/@id"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > </complexType> >@@ -213,9 +218,9 @@ > <documentation> > The id of the markerType this grouping applies to. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.markers/@id"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="attribute" type="string"> >@@ -259,9 +264,9 @@ > <documentation> > The label is the human readable String that will be used to create the entry in the Group By-> menu for this marker grouping. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute translatable="true"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="id" type="string" use="required"> >@@ -328,9 +333,9 @@ > <documentation> > The translable label of the entry. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute translatable="true"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="priority" type="string" use="required"> >@@ -340,6 +345,17 @@ > </documentation> > </annotation> > </attribute> >+ <attribute name="icon" type="string"> >+ <annotation> >+ <documentation> >+ Specified with a plug-in relative path, the icon for the grouping entry. >+ <em>Since: 3.5</em> >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="resource"/> >+ </appInfo> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -370,9 +386,9 @@ > <documentation> > The name attribute is the human readable name of the content generator. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute translatable="true"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="defaultMarkerGrouping" type="string"> >@@ -404,9 +420,9 @@ > <documentation> > The class is the type used to instantiate the field. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="java" basedOn="org.eclipse.ui.views.markers.MarkerField:"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="name" type="string" use="required"> >@@ -421,9 +437,9 @@ > <documentation> > The icon is the plug-in relative path for the icon. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="resource"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="filterClass" type="string"> >@@ -431,9 +447,9 @@ > <documentation> > The filterClass is the class that does filtering on this field when enabled. If this is not specified no filtering will occur based on this field. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="java" basedOn="org.eclipse.ui.views.markers.MarkerFieldFilter:"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="filterConfigurationClass" type="string"> >@@ -441,9 +457,9 @@ > <documentation> > The filterConfigurationClass is an optional area that is used for configuration of the field in a filter dialog. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="java" basedOn="org.eclipse.ui.views.markers.FilterConfigurationArea:"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > </complexType> >@@ -461,9 +477,9 @@ > <documentation> > The id is the id of the markerField being referred to. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="identifier" basedOn="org.eclipse.ui.ide.markerSupport/markerField/@id"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="visible" type="boolean"> >@@ -495,9 +511,9 @@ > <documentation> > The human readable name of the grouping. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute translatable="true"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="values" type="string"> >@@ -505,9 +521,9 @@ > <documentation> > The values is a class that specifies the values that are to be set in the filterClass of a markerField for the enclosing markerContentGenerator. > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="java" basedOn="org.eclipse.ui.views.markers.FiltersContributionParameters:"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > <attribute name="scope"> >@@ -568,27 +584,27 @@ > <documentation> > The id of the generator being extended > </documentation> >- <appinfo> >+ <appInfo> > <meta.attribute kind="identifier" basedOn="org.eclipse.ui.ide.markerSupport/markerContentGenerator/@id"/> >- </appinfo> >+ </appInfo> > </annotation> > </attribute> > </complexType> > </element> > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="since"/> >- </appinfo> >+ </appInfo> > <documentation> > 3.2 > </documentation> > </annotation> > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="examples"/> >- </appinfo> >+ </appInfo> > <documentation> > The following is an example of a problem filter definition in the marker support. This example only shows java warnings on the selected element and it's children and filters out those with the String NON-NLS > <p> >@@ -613,18 +629,18 @@ > > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="implementation"/> >- </appinfo> >+ </appInfo> > <documentation> > The severity markerGrouping is provided in the org.eclipse.ui.ide plug-in by default. > </documentation> > </annotation> > > <annotation> >- <appinfo> >+ <appInfo> > <meta.section type="copyright"/> >- </appinfo> >+ </appInfo> > <documentation> > Copyright (c) 2005, 2007 IBM Corporation and others.<br> > All rights reserved. This program and the accompanying materials are made >Index: src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java,v >retrieving revision 1.17 >diff -u -r1.17 MarkerImageProviderRegistry.java >--- src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java 24 Mar 2008 19:13:35 -0000 1.17 >+++ src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java 2 Feb 2009 13:43:26 -0000 >@@ -11,10 +11,18 @@ > package org.eclipse.ui.internal.ide.registry; > > import java.net.URL; >-import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.Map; >+import java.util.Set; >+import java.util.SortedMap; >+import java.util.TreeMap; > > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; >@@ -22,145 +30,242 @@ > import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; > import org.eclipse.ui.internal.ide.IMarkerImageProvider; > import org.eclipse.ui.internal.ide.Policy; >+import org.eclipse.ui.views.markers.internal.MarkerType; >+import org.eclipse.ui.views.markers.internal.MarkerTypesModel; > import org.osgi.framework.Bundle; > > /** >- * Implementation of a marker image registry which maps either >- * a marker type to a provider or to a static image. >+ * Implementation of a marker image registry which maps either a marker type to >+ * a provider or to a static image. > */ > public class MarkerImageProviderRegistry { >- private static final String ATT_PROVIDER_CLASS = "class";//$NON-NLS-1$ >+ private static final String ATT_PROVIDER_CLASS = "class";//$NON-NLS-1$ > >- private static final String ATT_ICON = "icon";//$NON-NLS-1$ >+ private static final String ATT_ICON = "icon";//$NON-NLS-1$ > >- private static final String ATT_MARKER_TYPE = "markertype";//$NON-NLS-1$ >+ private static final String ATT_MARKER_TYPE = "markertype";//$NON-NLS-1$ > >- private static final String ATT_ID = "id";//$NON-NLS-1$ >+ private static final String ATT_ID = "id";//$NON-NLS-1$ > >- private static final String MARKER_ATT_KEY = "org.eclipse.ui.internal.registry.MarkerImageProviderRegistry";//$NON-NLS-1$ >- >- private static final String TAG_PROVIDER = "imageprovider";//$NON-NLS-1$ >- >- private ArrayList descriptors = new ArrayList(); >- >- class Descriptor { >- String id; >- >- String markerType; >- >- String className; >- >- String imagePath; >- >- ImageDescriptor imageDescriptor; >- >- IConfigurationElement element; >- >- Bundle pluginBundle; >- >- IMarkerImageProvider provider; >- } >- >- /** >- * Initialize this new MarkerImageProviderRegistry. >- */ >- public MarkerImageProviderRegistry() { >- class MarkerImageReader extends IDERegistryReader { >- protected boolean readElement(IConfigurationElement element) { >- if (element.getName().equals(TAG_PROVIDER)) { >- addProvider(element); >- return true; >- } >- >- return false; >- } >- >- public void readRegistry() { >- readRegistry(Platform.getExtensionRegistry(), >- IDEWorkbenchPlugin.IDE_WORKBENCH, >- IDEWorkbenchPlugin.PL_MARKER_IMAGE_PROVIDER); >- } >- } >- >- new MarkerImageReader().readRegistry(); >- } >- >- /** >- * Creates a descriptor for the marker provider extension >- * and add it to the list of providers. >- */ >- public void addProvider(IConfigurationElement element) { >- Descriptor desc = new Descriptor(); >- desc.element = element; >- desc.pluginBundle = Platform.getBundle(element.getNamespace()); >- desc.id = element.getAttribute(ATT_ID); >- desc.markerType = element.getAttribute(ATT_MARKER_TYPE); >- desc.imagePath = element.getAttribute(ATT_ICON); >- desc.className = element.getAttribute(ATT_PROVIDER_CLASS); >- if (desc.imagePath != null) { >- desc.imageDescriptor = getImageDescriptor(desc); >- } >- if (desc.className == null) { >- //Don't need to keep these references. >- desc.element = null; >- desc.pluginBundle = null; >- } >- descriptors.add(desc); >- } >- >- /** >- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(Object) >- */ >- public ImageDescriptor getImageDescriptor(IMarker marker) { >- int size = descriptors.size(); >- for (int i = 0; i < size; i++) { >- Descriptor desc = (Descriptor) descriptors.get(i); >- try { >- if (marker.isSubtypeOf(desc.markerType)) { >- if (desc.className != null) { >- if (desc.pluginBundle.getState()==Bundle.ACTIVE) { >- //-- Get the image descriptor from the provider. >- //-- Save the image descriptor url as a persistable property, so a >- //image descriptor can be created without activating the plugin next >- //time the workbench is started. >- if (desc.provider == null) { >- desc.provider = (IMarkerImageProvider) IDEWorkbenchPlugin >- .createExtension(desc.element, >- ATT_PROVIDER_CLASS); >- } >- String path = desc.provider.getImagePath(marker); >- if (path != desc.imagePath) { >- desc.imagePath = path; >- desc.imageDescriptor = getImageDescriptor(desc); >- return desc.imageDescriptor; >- } >- return desc.imageDescriptor; >- } else { >- if (desc.imageDescriptor == null) { >- //Create a image descriptor to be used until the plugin gets activated. >- desc.imagePath = (String) marker >- .getAttribute(MARKER_ATT_KEY); >- desc.imageDescriptor = getImageDescriptor(desc); >- } >- return desc.imageDescriptor; >- } >- } else if (desc.imageDescriptor != null) { >- return desc.imageDescriptor; >- } >- } >- } catch (CoreException e) { >- Policy.handle(e); >- return null; >- } >- } >- return null; >- } >- >- /** >- * Returns the image descriptor with the given relative path. >- */ >- ImageDescriptor getImageDescriptor(Descriptor desc) { >- URL url = Platform.find(desc.pluginBundle, new Path(desc.imagePath)); >- return ImageDescriptor.createFromURL(url); >- } >+ //private static final String MARKER_ATT_KEY = "org.eclipse.ui.internal.registry.MarkerImageProviderRegistry";//$NON-NLS-1$ >+ >+ private static final String TAG_PROVIDER = "imageprovider";//$NON-NLS-1$ >+ >+ private SortedMap descriptors = new TreeMap(); >+ >+ private Map typesMap = new HashMap(); >+ >+ class Descriptor { >+ String id; >+ >+ String markerType; >+ >+ String className; >+ >+ String imagePath; >+ >+ ImageDescriptor imageDescriptor; >+ >+ IConfigurationElement element; >+ >+ Bundle pluginBundle; >+ >+ IMarkerImageProvider provider; >+ >+ } >+ >+ /** >+ * Initialize this new MarkerImageProviderRegistry. >+ */ >+ public MarkerImageProviderRegistry() { >+ class MarkerImageReader extends IDERegistryReader { >+ protected boolean readElement(IConfigurationElement element) { >+ if (element.getName().equals(TAG_PROVIDER)) { >+ addProvider(element, false); >+ return true; >+ } >+ >+ return false; >+ } >+ >+ public void readRegistry() { >+ readRegistry(Platform.getExtensionRegistry(), >+ IDEWorkbenchPlugin.IDE_WORKBENCH, >+ IDEWorkbenchPlugin.PL_MARKER_IMAGE_PROVIDER); >+ } >+ } >+ >+ new MarkerImageReader().readRegistry(); >+ } >+ >+ /** >+ * Creates a descriptor for the marker provider extension and add it to the >+ * list of providers. >+ * @param element >+ */ >+ public void addProvider(IConfigurationElement element) { >+ addProvider(element, true); >+ } >+ >+ /** >+ * Creates a descriptor for the marker provider extension and add it to the >+ * list of providers. >+ * >+ * @param element >+ * @param updateTypesMap >+ * true checks to see if the new provider is a better >+ * alternative for another marker type and updates >+ * the internal map accordingly >+ */ >+ private void addProvider(IConfigurationElement element, >+ boolean updateTypesMap) { >+ Descriptor desc = new Descriptor(); >+ desc.element = element; >+ desc.pluginBundle = Platform.getBundle(element.getContributor().getName()); >+ desc.id = element.getAttribute(ATT_ID); >+ desc.markerType = element.getAttribute(ATT_MARKER_TYPE); >+ desc.imagePath = element.getAttribute(ATT_ICON); >+ desc.className = element.getAttribute(ATT_PROVIDER_CLASS); >+ if (desc.imagePath != null) { >+ desc.imageDescriptor = getImageDescriptor(desc); >+ } >+ if (desc.className == null) { >+ // Don't need to keep these references. >+ desc.element = null; >+ desc.pluginBundle = null; >+ } >+ descriptors.put(desc.markerType, desc); >+ typesMap.put(desc.markerType, desc); >+ if (updateTypesMap) { >+ // only check marker types not declaring an imageprovider extension >+ Set keys = new HashSet(typesMap.keySet()); >+ keys.removeAll(descriptors.keySet()); >+ Iterator iterator = keys.iterator(); >+ // check to see if the addition is a better alternative for another >+ // marker type >+ while (iterator.hasNext()) { >+ String mkId = (String) iterator.next(); >+ MarkerType type = MarkerTypesModel.getInstance().getType(mkId); >+ MarkerType otherType = MarkerTypesModel.getInstance().getType( >+ desc.markerType); >+ // check super >+ if (type.isSubtypeOf(otherType)) { >+ Descriptor oldDesc = (Descriptor) typesMap.get(mkId); >+ MarkerType oldSuper = MarkerTypesModel.getInstance() >+ .getType(oldDesc.markerType); >+ // check if the new one is closer to the type in hierarchy >+ // than the old one >+ if (otherType.isSubtypeOf(oldSuper)) { >+ typesMap.put(mkId, desc); >+ } >+ } >+ } >+ } >+ } >+ >+ /** >+ * Returns the ImageDescriptor for the given marker by querying the >+ * markerImageProvider extension declared for its type.If a >+ * markerImageProvider is not directly declared for a type, then a provider >+ * declared for one of its super type is used. Returns the image specified >+ * by the IMarkerImageProvider class or the static image declared in the >+ * extension. A null is returned for types not having a markerImageProvider. >+ * >+ * @param marker >+ * @return ImageDescriptor >+ * @see org.eclipse.ui.internal.ide.IMarkerImageProvider >+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(Object) >+ */ >+ public ImageDescriptor getImageDescriptor(IMarker marker) { >+ String typeId = null; >+ try { >+ typeId = marker.getType(); >+ } catch (CoreException e1) { >+ Policy.handle(e1); >+ return null; >+ } >+ Descriptor descriptor = getDescriptorFor(typeId); >+ if (descriptor == null) { >+ return null; >+ } >+ if (descriptor.className == null) { >+ return descriptor.imageDescriptor; >+ } >+ try { >+ // TODO: Decide whether to activate contributing bundle or not >+ // Note: plugin activation should be expected by the client >+ // if a class is specified.The marker's image may be expected >+ // to be different based on attributes. >+ >+ /*String persistedPath = (String) marker.getAttribute(MARKER_ATT_KEY); >+ if (descriptor.pluginBundle.getState() == Bundle.ACTIVE >+ || (persistedPath == null && descriptor.imageDescriptor == null)) {*/ >+ >+ if (descriptor.provider == null) { >+ descriptor.provider = (IMarkerImageProvider) IDEWorkbenchPlugin >+ .createExtension(descriptor.element, >+ ATT_PROVIDER_CLASS); >+ } >+ String path = descriptor.provider.getImagePath(marker); >+ >+ // marker.setAttribute(MARKER_ATT_KEY, path); >+ >+ if (path != descriptor.imagePath) { >+ descriptor.imagePath = path; >+ descriptor.imageDescriptor = getImageDescriptor(descriptor); >+ } >+ >+ /*} else if (persistedPath != null) { >+ descriptor.imagePath = persistedPath; >+ descriptor.imageDescriptor = getImageDescriptor(descriptor); >+ }*/ >+ return descriptor.imageDescriptor; >+ } catch (CoreException e) { >+ Policy.handle(e); >+ return null; >+ } >+ } >+ >+ /** >+ * @param typeId >+ * @return Descriptor >+ */ >+ private Descriptor getDescriptorFor(String typeId) { >+ Descriptor descriptor = (Descriptor) typesMap.get(typeId); >+ if (descriptor == null) { >+ MarkerType markerType = MarkerTypesModel.getInstance().getType( >+ typeId); >+ LinkedList queue = new LinkedList(); >+ queue.addLast(markerType); >+ while (!queue.isEmpty()) { >+ MarkerType type = (MarkerType) queue.removeFirst(); >+ descriptor = (Descriptor) descriptors.get(type.getId()); >+ if (descriptor != null) { >+ typesMap.put(typeId, descriptor); >+ break; >+ } >+ MarkerType[] subTypes = type.getSupertypes(); >+ // TODO: Decide whether to sort or keep in order in which they >+ // were declared >+ /*Arrays.sort(subTypes, new Comparator() { >+ public int compare(Object o1, Object o2) { >+ return ((MarkerType) o1).getId().compareTo( >+ ((MarkerType) o2).getId()); >+ } >+ });*/ >+ for (int j = 0; j < subTypes.length; j++) { >+ queue.addLast(subTypes[j]); >+ } >+ } >+ } >+ return descriptor; >+ } >+ >+ /** >+ * Returns the image descriptor with the given relative path. >+ */ >+ private ImageDescriptor getImageDescriptor(Descriptor desc) { >+ URL url = FileLocator.find(desc.pluginBundle, new Path(desc.imagePath), null); >+ return ImageDescriptor.createFromURL(url); >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 260909
:
124016
|
124017
| 124416 |
124787
|
124788