Package org.eclipse.team.ui.synchronize
Class AbstractSynchronizeLabelProvider
java.lang.Object
org.eclipse.team.ui.synchronize.AbstractSynchronizeLabelProvider
- All Implemented Interfaces:
IBaseLabelProvider
,ILabelProvider
- Direct Known Subclasses:
SynchronizationLabelProvider
A label provider wrapper that adds synchronization image and/or text decorations
to the image and label obtained from the delegate provider.
- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(ILabelProviderListener listener) Adds a listener to this label provider.protected Image
decorateImage
(Image base, Object element) Decorate the image with the appropriate diff decorations.protected String
decorateText
(String base, Object element) Decorate the text with the appropriate diff decorations.void
dispose()
Disposes of this label provider.protected Image
getCompareImage
(Image base, int compareKind) Returns an image showing the specified change kind applied to a given base image.protected Image
getDelegateImage
(Object element) Return the image for the item from the delegate label provider.protected abstract ILabelProvider
Return the label provider that will return the text and image appropriate for the given model element.protected String
getDelegateText
(Object element) Obtain the text for the object from the delegate label provider.protected IDiff
Return the sync kind of the given element.Method that provides a custom font for elements that are busy.Returns the image for the label of the given element.protected int
getMarkerSeverity
(Object element) Return the marker severity (one of IMarker.SEVERITY_ERROR or IMarker.SEVERITY_WARNING) to be overlayed on the given element or -1 if there are no markers.Returns the text for the label of the given element.protected boolean
hasDecendantConflicts
(Object element) Return whether the given element has descendant conflicts.protected boolean
Return whether the given element is busy (i.e. is involved in an operation.protected abstract boolean
Return whether the label provider should decorate with the synchronization state.protected boolean
Indicate whether the overlays provided by this class should be applied.boolean
isLabelProperty
(Object element, String property) Returns whether the label would be affected by a change to the given property of the given element.protected boolean
Returns whether the synchronization state should be included in the text of the label.void
removeListener
(ILabelProviderListener listener) Removes a listener to this label provider.
-
Constructor Details
-
AbstractSynchronizeLabelProvider
public AbstractSynchronizeLabelProvider()
-
-
Method Details
-
getImage
Description copied from interface:ILabelProvider
Returns the image for the label of the given element. The image is owned by the label provider and must not be disposed directly. Instead, dispose the label provider when no longer needed.- Specified by:
getImage
in interfaceILabelProvider
- Parameters:
element
- the element for which to provide the label image- Returns:
- the image used to label the element, or
null
if there is no image for the given object
-
decorateImage
Decorate the image with the appropriate diff decorations. By default, this method uses the diff associated with the given element to determine how to decorate the image. It then uses theCompareConfiguration.getImage(Image, int)
method to apply the decoration to the base image.- Parameters:
base
- the base image to be decorated.element
- the element- Returns:
- the image decorated appropriately using the diff associated with the element
- See Also:
-
getDelegateImage
Return the image for the item from the delegate label provider.- Parameters:
element
- the element- Returns:
- the image for the item from the delegate label provider
-
getCompareImage
Returns an image showing the specified change kind applied to a given base image.- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
getText
Description copied from interface:ILabelProvider
Returns the text for the label of the given element.- Specified by:
getText
in interfaceILabelProvider
- Parameters:
element
- the element for which to provide the label text- Returns:
- the text string used to label the element, or
null
if there is no text label for the given object
-
getDelegateText
Obtain the text for the object from the delegate label provider.- Parameters:
element
- the element- Returns:
- the text label for the element
-
decorateText
Decorate the text with the appropriate diff decorations. By default, this method uses the diff associated with the given element to determine how to decorate the text.- Parameters:
base
- the base text to be decorated.element
- the element- Returns:
- the text decorated appropriately using the diff associated with the element
- See Also:
-
addListener
Description copied from interface:IBaseLabelProvider
Adds a listener to this label provider. Has no effect if an identical listener is already registered.Label provider listeners are informed about state changes that affect the rendering of the viewer that uses this label provider.
- Specified by:
addListener
in interfaceIBaseLabelProvider
- Parameters:
listener
- a label provider listener
-
dispose
public void dispose()Description copied from interface:IBaseLabelProvider
Disposes of this label provider. When a label provider is attached to a viewer, the viewer will automatically call this method when the viewer is being closed. When label providers are used outside of the context of a viewer, it is the client's responsibility to ensure that this method is called when the provider is no longer needed.- Specified by:
dispose
in interfaceIBaseLabelProvider
-
isLabelProperty
Description copied from interface:IBaseLabelProvider
Returns whether the label would be affected by a change to the given property of the given element. This can be used to optimize a non-structural viewer update. If the property mentioned in the update does not affect the label, then the viewer need not update the label.- Specified by:
isLabelProperty
in interfaceIBaseLabelProvider
- Parameters:
element
- the elementproperty
- the property- Returns:
true
if the label would be affected, andfalse
if it would be unaffected
-
removeListener
Description copied from interface:IBaseLabelProvider
Removes a listener to this label provider. Has no effect if an identical listener is not registered.- Specified by:
removeListener
in interfaceIBaseLabelProvider
- Parameters:
listener
- a label provider listener
-
isSyncInfoInTextEnabled
protected boolean isSyncInfoInTextEnabled()Returns whether the synchronization state should be included in the text of the label. By default, the Team preference is used to determine what to return. Subclasses may override.- Returns:
- whether the synchronization state should be included in the text of the label
-
getDelegateLabelProvider
Return the label provider that will return the text and image appropriate for the given model element. Subclasses are responsible for disposing of the label provider.- Returns:
- the label provider that will return the text and image appropriate for the given model element
-
isDecorationEnabled
protected abstract boolean isDecorationEnabled()Return whether the label provider should decorate with the synchronization state.- Returns:
- whether the label provider should decorate with the synchronization state
-
getDiff
Return the sync kind of the given element. This is used to determine how to decorate the image and label of the element. The sync kind is described in theSyncInfo
class. Anull
is returned by default.- Parameters:
element
- the element being tested- Returns:
- the sync kind of the given element
-
isIncludeOverlays
protected boolean isIncludeOverlays()Indicate whether the overlays provided by this class should be applied. By default,false
is returned. Subclasses may override and control individual overlays by overriding the appropriate query methods. Overlays provided by this class include problem marker severity (getMarkerSeverity(Object)
), propagated conflicts (hasDecendantConflicts(Object)
and busy state (isBusy(Object)
).- Returns:
- whether the overlays provided by this class should be applied
-
getMarkerSeverity
Return the marker severity (one of IMarker.SEVERITY_ERROR or IMarker.SEVERITY_WARNING) to be overlayed on the given element or -1 if there are no markers. By Default, the element is adapted to resource mapping in order to look for markers.Although this class handles providing the overlays, it does not react to marker changes. Subclasses must issue label updates when the markers on a logical model element change.
- Parameters:
element
- the element- Returns:
- the marker severity
-
hasDecendantConflicts
Return whether the given element has descendant conflicts. By default,false
is returned. Subclasses may override.- Parameters:
element
- the element- Returns:
- whether the given element has descendant conflicts
-
isBusy
Return whether the given element is busy (i.e. is involved in an operation. By default,false
is returned. Subclasses may override.- Parameters:
element
- the element- Returns:
- whether the given element is busy
-
getFont
Method that provides a custom font for elements that are busy. Although this label provider does not implementIFontProvider
, subclasses that wish to get busy indication using a font can do so.- Parameters:
element
- the element- Returns:
- the font to indicate that the element is busy
-