Class ProblemMarkerLabelDecorator
- java.lang.Object
-
- org.eclipse.jface.viewers.LabelDecorator
-
- org.eclipse.handly.ui.viewer.ProblemLabelDecorator
-
- org.eclipse.handly.ui.viewer.ProblemMarkerLabelDecorator
-
- All Implemented Interfaces:
org.eclipse.jface.viewers.IBaseLabelProvider,org.eclipse.jface.viewers.ILabelDecorator
public class ProblemMarkerLabelDecorator extends ProblemLabelDecorator
Decorates an element's image with error and warning overlays that represent the severity of markers attached to the element's corresponding resource. To see a problem decoration for a marker, the marker needs to be a sub-type ofIMarker.PROBLEM.Note that this decorator does not listen to problem marker changes. Hence, a viewer using this decorator requires a separate listener for updating elements on problem changes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.handly.ui.viewer.ProblemLabelDecorator
ProblemLabelDecorator.Severity
-
-
Constructor Summary
Constructors Constructor Description ProblemMarkerLabelDecorator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ProblemLabelDecorator.SeveritycomputeProblemSeverity(java.lang.Object element, org.eclipse.jface.viewers.IDecorationContext context)Computes problem severity for the given element taking into account the provided context.protected ProblemLabelDecorator.SeveritycomputeProblemSeverityFromMarkers(java.lang.Object element, org.eclipse.jface.viewers.IDecorationContext context)Computes problem severity for the given element from markers attached to the element's corresponding resource.protected static ProblemLabelDecorator.SeverityfindMaxProblemSeverity(org.eclipse.core.resources.IResource resource, int depth, TextRange textRange)Returns the maximum severity across problem markers attached to the given resource, and, optionally, to its descendants.protected IContentAdaptergetContentAdapter(org.eclipse.jface.viewers.IDecorationContext context)Returns the content adapter that defines a mapping between elements of a Handly-based model and the viewer's content.-
Methods inherited from class org.eclipse.handly.ui.viewer.ProblemLabelDecorator
addListener, decorateImage, decorateImage, decorateText, decorateText, dispose, isLabelProperty, prepareDecoration, removeListener
-
-
-
-
Method Detail
-
computeProblemSeverity
protected ProblemLabelDecorator.Severity computeProblemSeverity(java.lang.Object element, org.eclipse.jface.viewers.IDecorationContext context)
Computes problem severity for the given element taking into account the provided context.This implementation delegates to
computeProblemSeverityFromMarkers(Object, IDecorationContext), suppressing and logging aCoreExceptionif necessary.- Specified by:
computeProblemSeverityin classProblemLabelDecorator- Parameters:
element- nevernullcontext- nevernull- Returns:
- problem severity, or
nullif there is no problem
-
computeProblemSeverityFromMarkers
protected ProblemLabelDecorator.Severity computeProblemSeverityFromMarkers(java.lang.Object element, org.eclipse.jface.viewers.IDecorationContext context) throws org.eclipse.core.runtime.CoreException
Computes problem severity for the given element from markers attached to the element's corresponding resource. Takes into account the provided context.This implementation returns the maximum severity across problem markers attached to the element's corresponding resource and its descendants. If the given element could be adapted to an
IElementthrough thecontent adapterand the adapter element is anISourceConstruct, only markers thatstartstrictlywithin the source construct's text range are considered. The corresponding resource is determined as follows:-
If the given element is an
IResource, the corresponding resource is the element itself. -
Otherwise, if the given element could be adapted to an
IElementthrough the content adapter, the corresponding resource is obtained viaElements.getResource(IElement). -
Otherwise, the given element is adapted to an
IResourceviaResourceUtil.getResource(Object).
- Parameters:
element- nevernullcontext- nevernull- Returns:
- problem severity, or
nullif there is no problem - Throws:
org.eclipse.core.runtime.CoreException- if an exception occurs while accessing markers
-
If the given element is an
-
getContentAdapter
protected IContentAdapter getContentAdapter(org.eclipse.jface.viewers.IDecorationContext context)
Returns the content adapter that defines a mapping between elements of a Handly-based model and the viewer's content.This implementation requests the content adapter from the
IContentAdapterProviderregistered in the decoration context under the nameIContentAdapterProvider.class.getName(). If no provider is available, aNullContentAdapteris returned.- Parameters:
context- nevernull- Returns:
- an
IContentAdapter(nevernull)
-
findMaxProblemSeverity
protected static ProblemLabelDecorator.Severity findMaxProblemSeverity(org.eclipse.core.resources.IResource resource, int depth, TextRange textRange) throws org.eclipse.core.runtime.CoreException
Returns the maximum severity across problem markers attached to the given resource, and, optionally, to its descendants. If a text range is specified, only markers thatstartstrictlywithin the given text range are considered. Returnsnullif there are no matching markers.- Parameters:
resource- notnulldepth- how far to recurse (seeIResource.DEPTH_*constants)textRange- the text range to further constrain the marker set, ornull. Makes sense only if the given resource is a text file- Returns:
- the maximum problem severity, or
null - Throws:
org.eclipse.core.runtime.CoreException- if an exception occurs while accessing markers
-
-