Class ProblemMarkerLabelDecorator
- All Implemented Interfaces:
org.eclipse.jface.viewers.IBaseLabelProvider
,org.eclipse.jface.viewers.ILabelDecorator
IMarker.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
-
Method Summary
Modifier and TypeMethodDescriptionprotected ProblemLabelDecorator.Severity
computeProblemSeverity
(Object element, org.eclipse.jface.viewers.IDecorationContext context) Computes problem severity for the given element taking into account the provided context.protected ProblemLabelDecorator.Severity
computeProblemSeverityFromMarkers
(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.Severity
findMaxProblemSeverity
(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 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.Methods inherited from class org.eclipse.handly.ui.viewer.ProblemLabelDecorator
addListener, decorateImage, decorateImage, decorateText, decorateText, dispose, isLabelProperty, prepareDecoration, removeListener
-
Constructor Details
-
ProblemMarkerLabelDecorator
public ProblemMarkerLabelDecorator()
-
-
Method Details
-
computeProblemSeverity
protected ProblemLabelDecorator.Severity computeProblemSeverity(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 aCoreException
if necessary.- Specified by:
computeProblemSeverity
in classProblemLabelDecorator
- Parameters:
element
- nevernull
context
- nevernull
- Returns:
- problem severity, or
null
if there is no problem
-
computeProblemSeverityFromMarkers
protected ProblemLabelDecorator.Severity computeProblemSeverityFromMarkers(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
IElement
through thecontent adapter
and the adapter element is anISourceConstruct
, only markers thatstart
strictly
within 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
IElement
through the content adapter, the corresponding resource is obtained viaElements.getResource(IElement)
. -
Otherwise, the given element is adapted to an
IResource
viaResourceUtil.getResource(Object)
.
- Parameters:
element
- nevernull
context
- nevernull
- Returns:
- problem severity, or
null
if there is no problem - Throws:
org.eclipse.core.runtime.CoreException
- if an exception occurs while accessing markers
-
If the given element is an
-
getContentAdapter
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
IContentAdapterProvider
registered in the decoration context under the nameIContentAdapterProvider.class.getName()
. If no provider is available, aNullContentAdapter
is 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 thatstart
strictly
within the given text range are considered. Returnsnull
if there are no matching markers.- Parameters:
resource
- notnull
depth
- 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
-