Class SourceViewerDecorationSupport
- java.lang.Object
-
- org.eclipse.ui.texteditor.SourceViewerDecorationSupport
-
public class SourceViewerDecorationSupport extends Object
Support class used by text editors to draw and update decorations on the source viewer and its rulers. An instance of this class is independent of a certain editor and must be configured with the needed preference keys and helper objects before it can be used.Once configured, an instance may be installed (see
install
) on a preference store, from then on monitoring the configured preference settings and changing the respective decorations. Callinguninstall
will unregister the listeners with the preferences store and must be called before changing the preference store by another call toinstall
.
dispose
will uninstall the support and remove any decorations from the viewer. It is okay to reuse aSourceViewerDecorationSupport
instance after disposing it.SourceViewerDecorationSupport
can draw the following decorations:- matching character highlighting,
- current line highlighting,
- print margin, and
- annotations.
Annotations are managed for the overview ruler and also drawn onto the text widget by an
AnnotationPainter
instance.Subclasses may add decorations but should adhere to the lifecyle described above.
- Since:
- 2.1
- See Also:
AnnotationPainter
-
-
Constructor Summary
Constructors Constructor Description SourceViewerDecorationSupport(ISourceViewer sourceViewer, IOverviewRuler overviewRuler, IAnnotationAccess annotationAccess, ISharedTextColors sharedTextColors)
Creates a new decoration support for the given viewer.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected AnnotationPainter
createAnnotationPainter()
Creates and configures the annotation painter and configures.void
dispose()
Disposes this decoration support.protected void
handlePreferenceStoreChanged(PropertyChangeEvent event)
void
hideAnnotationOverview()
Hides the annotation overview.void
install(IPreferenceStore store)
Installs this decoration support on the given preference store.void
setAnnotationPainterPreferenceKeys(Object type, String colorKey, String editorKey, String overviewRulerKey, int layer)
Sets the preference keys for the annotation painter.void
setAnnotationPreference(AnnotationPreference info)
Sets the preference info for the annotation painter.void
setCharacterPairMatcher(ICharacterPairMatcher pairMatcher)
Sets the character pair matcher for the matching character painter.void
setCursorLinePainterPreferenceKeys(String enableKey, String colorKey)
Sets the preference keys for the cursor line painter.void
setMarginPainterPreferenceKeys(String enableKey, String colorKey, String columnKey)
Sets the preference keys for the margin painter.void
setMatchingCharacterPainterPreferenceKeys(String enableKey, String colorKey)
Sets the preference keys for the matching character painter.void
setMatchingCharacterPainterPreferenceKeys(String enableKey, String colorKey, String highlightCharacterAtCaretLocationKey, String enclosingPeerCharactersKey)
Sets the preference keys for the matching character painter.void
setSymbolicFontName(String symbolicFontName)
Deprecated.As of 4.8, this is no longer usedvoid
uninstall()
Uninstalls this support from the preference store it has previously been installed on.void
updateOverviewDecorations()
Updates the annotation overview for all configured annotation types.
-
-
-
Constructor Detail
-
SourceViewerDecorationSupport
public SourceViewerDecorationSupport(ISourceViewer sourceViewer, IOverviewRuler overviewRuler, IAnnotationAccess annotationAccess, ISharedTextColors sharedTextColors)
Creates a new decoration support for the given viewer.- Parameters:
sourceViewer
- the source vieweroverviewRuler
- the viewer's overview rulerannotationAccess
- the annotation accesssharedTextColors
- the shared text color manager
-
-
Method Detail
-
install
public void install(IPreferenceStore store)
Installs this decoration support on the given preference store. It assumes that this support has completely been configured.- Parameters:
store
- the preference store
-
updateOverviewDecorations
public void updateOverviewDecorations()
Updates the annotation overview for all configured annotation types.
-
uninstall
public void uninstall()
Uninstalls this support from the preference store it has previously been installed on. If there is no such preference store, this call is without effect.
-
dispose
public void dispose()
Disposes this decoration support. Internally callsuninstall
.
-
setCharacterPairMatcher
public void setCharacterPairMatcher(ICharacterPairMatcher pairMatcher)
Sets the character pair matcher for the matching character painter.- Parameters:
pairMatcher
- the character pair matcher
-
setAnnotationPainterPreferenceKeys
public void setAnnotationPainterPreferenceKeys(Object type, String colorKey, String editorKey, String overviewRulerKey, int layer)
Sets the preference keys for the annotation painter.- Parameters:
type
- the annotation typecolorKey
- the preference key for the coloreditorKey
- the preference key for the presentation in the text areaoverviewRulerKey
- the preference key for the presentation in the overview rulerlayer
- the layer
-
setAnnotationPreference
public void setAnnotationPreference(AnnotationPreference info)
Sets the preference info for the annotation painter.- Parameters:
info
- the preference info to be set
-
setCursorLinePainterPreferenceKeys
public void setCursorLinePainterPreferenceKeys(String enableKey, String colorKey)
Sets the preference keys for the cursor line painter.- Parameters:
enableKey
- the preference key for the cursor line paintercolorKey
- the preference key for the color used by the cursor line painter
-
setMarginPainterPreferenceKeys
public void setMarginPainterPreferenceKeys(String enableKey, String colorKey, String columnKey)
Sets the preference keys for the margin painter.- Parameters:
enableKey
- the preference key for the margin paintercolorKey
- the preference key for the color used by the margin paintercolumnKey
- the preference key for the margin column
-
setMatchingCharacterPainterPreferenceKeys
public void setMatchingCharacterPainterPreferenceKeys(String enableKey, String colorKey)
Sets the preference keys for the matching character painter.Use
setMatchingCharacterPainterPreferenceKeys(String, String, String, String)
if highlighting of character at caret location or enclosing peer characters is required.- Parameters:
enableKey
- the preference key for the matching character paintercolorKey
- the preference key for the color used by the matching character painter
-
setMatchingCharacterPainterPreferenceKeys
public void setMatchingCharacterPainterPreferenceKeys(String enableKey, String colorKey, String highlightCharacterAtCaretLocationKey, String enclosingPeerCharactersKey)
Sets the preference keys for the matching character painter.- Parameters:
enableKey
- the preference key for the matching character paintercolorKey
- the preference key for the color used by the matching character painterhighlightCharacterAtCaretLocationKey
- the preference key for highlighting character at caret locationenclosingPeerCharactersKey
- the preference key for highlighting enclosing peer characters- Since:
- 3.8
-
setSymbolicFontName
@Deprecated public void setSymbolicFontName(String symbolicFontName)
Deprecated.As of 4.8, this is no longer usedSets the symbolic font name that is used for computing the margin width.- Parameters:
symbolicFontName
- the symbolic font name
-
handlePreferenceStoreChanged
protected void handlePreferenceStoreChanged(PropertyChangeEvent event)
-
createAnnotationPainter
protected AnnotationPainter createAnnotationPainter()
Creates and configures the annotation painter and configures.- Returns:
- an annotation painter
- Since:
- 3.0
-
hideAnnotationOverview
public void hideAnnotationOverview()
Hides the annotation overview.
-
-