Class AnnotationPreference

java.lang.Object
org.eclipse.ui.texteditor.AnnotationPreference

public class AnnotationPreference extends Object
An annotation preference provides all the information required for handing the preferences for the presentation of annotations of a specified type. The type can be changed and retrieved using the getAnnotationType and setAnnotationType methods. For each preference, getter and setter methods are provided.

Preferences that may be changed by the user also have a corresponding key that can be used to obtain the currently set value from an IPreferenceStore.

The following annotation preferences are covered:

Display Preferences controlling how and where annotations are shown

  • as text background highlighting (and respective preference key),
  • as text decorations (and respective preference key),
  • on the overview ruler (and respective preference key),
  • on the overview ruler header,
  • on the vertical ruler (and respective preference key),

Additional Display Preferences

  • the base color for annotations of this type (and respective preference key),
  • the style of text decorations that are drawn (and respective preference key),
  • the annotation image provider,
  • the quick fix image descriptor,
  • the image descriptor,
  • the symbolic image name,
  • the presentation layer.

Navigation Preferences

  • whether included in the "Go to Next Annotation" navigation action (and respective preference key),
  • whether included in the "Go to Previous Annotation" navigation action (and respective preference key),
  • whether to be shown in the "Go to Next/Previous Annotation" navigation toolbar drop down (and respective preference key).

Preference Page Preferences

  • whether the annotation type should be included on the generic annotation preference page,
  • preference label.
Since:
2.1
  • Field Details

    • STYLE_NONE

      public static final String STYLE_NONE
      Constant defining no decoration for the show in text style preference.
      Since:
      3.0
      See Also:
    • STYLE_SQUIGGLES

      public static final String STYLE_SQUIGGLES
      Constant defining squiggly decoration for the show in text style preference.
      Since:
      3.0
      See Also:
    • STYLE_PROBLEM_UNDERLINE

      public static final String STYLE_PROBLEM_UNDERLINE
      Constant defining the native problem underline decoration for the show in text style preference.

      The look of this style is platform dependent.

      Since:
      3.4
      See Also:
    • STYLE_BOX

      public static final String STYLE_BOX
      Constant defining box decoration for the show in text style preference.
      Since:
      3.0
      See Also:
    • STYLE_DASHED_BOX

      public static final String STYLE_DASHED_BOX
      Constant defining dashed box decoration for the show in text style preference.
      Since:
      3.3
      See Also:
    • STYLE_UNDERLINE

      public static final String STYLE_UNDERLINE
      Constant defining underline decoration for the show in text style preference.
      Since:
      3.0
      See Also:
    • STYLE_IBEAM

      public static final String STYLE_IBEAM
      Constant defining i-beam decoration for the show in text style preference.
      Since:
      3.0
      See Also:
    • IMAGE_DESCRIPTOR

      protected static final Object IMAGE_DESCRIPTOR
      The image to be used for drawing in the vertical ruler.
      Since:
      3.0
    • QUICK_FIX_IMAGE_DESCRIPTOR

      protected static final Object QUICK_FIX_IMAGE_DESCRIPTOR
      The Quick Fix image to be used for drawing in the vertical ruler.
      Since:
      3.2
    • PREFERENCE_LABEL

      protected static final Object PREFERENCE_LABEL
      The preference label.
      Since:
      3.0
    • PRESENTATION_LAYER

      protected static final Object PRESENTATION_LAYER
      The presentation layer.
      Since:
      3.0
    • SYMBOLIC_IMAGE_NAME

      protected static final Object SYMBOLIC_IMAGE_NAME
      The symbolic name of the image to be drawn in the vertical ruler.
      Since:
      3.0
    • HEADER_VALUE

      protected static final Object HEADER_VALUE
      Indicates whether the annotation type contributed to the overview ruler's header.
      Since:
      3.0
    • IMAGE_PROVIDER

      protected static final Object IMAGE_PROVIDER
      The annotation image provider.
      Since:
      3.0
    • INCLUDE_ON_PREFERENCE_PAGE

      protected static final Object INCLUDE_ON_PREFERENCE_PAGE
      The value for the includeOnPreferencePage property.
      Since:
      3.0
    • TEXT_PREFERENCE_KEY

      protected static final Object TEXT_PREFERENCE_KEY
      The preference key for the visibility inside text.
      Since:
      3.0
    • TEXT_PREFERENCE_VALUE

      protected static final Object TEXT_PREFERENCE_VALUE
      The visibility inside text.
      Since:
      3.0
    • COLOR_PREFERENCE_KEY

      protected static final Object COLOR_PREFERENCE_KEY
      The preference key for the presentation color.
      Since:
      3.0
    • COLOR_PREFERENCE_VALUE

      protected static final Object COLOR_PREFERENCE_VALUE
      The presentation color.
      Since:
      3.0
    • HIGHLIGHT_PREFERENCE_KEY

      protected static final Object HIGHLIGHT_PREFERENCE_KEY
      The preference key for highlighting inside text.
      Since:
      3.0
    • HIGHLIGHT_PREFERENCE_VALUE

      protected static final Object HIGHLIGHT_PREFERENCE_VALUE
      The value for highlighting inside text.
      Since:
      3.0
    • IS_GO_TO_NEXT_TARGET_KEY

      protected static final Object IS_GO_TO_NEXT_TARGET_KEY
      The preference key for go to next navigation enablement.
      Since:
      3.0
    • IS_GO_TO_NEXT_TARGET_VALUE

      protected static final Object IS_GO_TO_NEXT_TARGET_VALUE
      The value for go to next navigation enablement.
      Since:
      3.0
    • IS_GO_TO_PREVIOUS_TARGET_KEY

      protected static final Object IS_GO_TO_PREVIOUS_TARGET_KEY
      The preference key for go to previous navigation enablement.
      Since:
      3.0
    • IS_GO_TO_PREVIOUS_TARGET_VALUE

      protected static final Object IS_GO_TO_PREVIOUS_TARGET_VALUE
      The value for go to previous navigation enablement.
      Since:
      3.0
    • VERTICAL_RULER_PREFERENCE_KEY

      protected static final Object VERTICAL_RULER_PREFERENCE_KEY
      The preference key for the visibility in the vertical ruler.
      Since:
      3.0
    • VERTICAL_RULER_PREFERENCE_VALUE

      protected static final Object VERTICAL_RULER_PREFERENCE_VALUE
      The visibility in the vertical ruler.
      Since:
      3.0
    • OVERVIEW_RULER_PREFERENCE_KEY

      protected static final Object OVERVIEW_RULER_PREFERENCE_KEY
      The preference key for the visibility in the overview ruler.
      Since:
      3.0
    • OVERVIEW_RULER_PREFERENCE_VALUE

      protected static final Object OVERVIEW_RULER_PREFERENCE_VALUE
      The visibility in the overview ruler.
      Since:
      3.0
    • SHOW_IN_NAVIGATION_DROPDOWN_KEY

      protected static final Object SHOW_IN_NAVIGATION_DROPDOWN_KEY
      The preference key for the visibility in the next/previous drop down toolbar action.
      Since:
      3.0
    • SHOW_IN_NAVIGATION_DROPDOWN_VALUE

      protected static final Object SHOW_IN_NAVIGATION_DROPDOWN_VALUE
      The value for the visibility in the next/previous drop down toolbar action.
      Since:
      3.0
    • TEXT_STYLE_PREFERENCE_KEY

      protected static final Object TEXT_STYLE_PREFERENCE_KEY
      The preference key for the decoration style.
      Since:
      3.0
    • TEXT_STYLE_PREFERENCE_VALUE

      protected static final Object TEXT_STYLE_PREFERENCE_VALUE
      The value for the text decoration style.
      Since:
      3.0
    • ATTRIBUTES

      protected static final Object[] ATTRIBUTES
      Array of all supported attributes.
      Since:
      3.0
    • fAnnotationImageProvider

      public IAnnotationImageProvider fAnnotationImageProvider
      The annotation image provider.
      Since:
      3.0
    • fConfigurationElement

      public IConfigurationElement fConfigurationElement
      The configuration element from which to create the annotation image provider.
      Since:
      3.0
    • fAnnotationImageProviderAttribute

      public String fAnnotationImageProviderAttribute
      The name of the attribute used to load the annotation image provider from the configuration element.
      Since:
      3.0
  • Constructor Details

    • AnnotationPreference

      public AnnotationPreference()
      Creates a new un-initialized annotation preference. Note that instances with a null annotation type are invalid and should not be used.
    • AnnotationPreference

      public AnnotationPreference(Object annotationType, String colorKey, String textKey, String overviewRulerKey, int presentationLayer)
      Creates a new annotation preference for the given annotation type.
      Parameters:
      annotationType - the annotation type
      colorKey - the preference key for the presentation color
      textKey - the preference key for the visibility inside text
      overviewRulerKey - the preference key for the visibility in the overview ruler
      presentationLayer - the presentation layer
  • Method Details

    • setValue

      protected void setValue(Object attribute, Object value)
      Sets the given value for the given attribute.
      Parameters:
      attribute - the attribute
      value - the attribute value
      Since:
      3.0
    • setValue

      protected void setValue(Object attribute, int value)
      Sets the given value for the given attribute.
      Parameters:
      attribute - the attribute
      value - the attribute value
      Since:
      3.0
    • setValue

      protected void setValue(Object attribute, boolean value)
      Sets the given value for the given attribute.
      Parameters:
      attribute - the attribute
      value - the attribute value
      Since:
      3.0
    • getStringValue

      protected String getStringValue(Object attribute)
      Returns the value of the given attribute as string.
      Parameters:
      attribute - the attribute
      Returns:
      the attribute value
      Since:
      3.0
    • getBooleanValue

      protected boolean getBooleanValue(Object attribute)
      Returns the value of the given attribute as boolean.
      Parameters:
      attribute - the attribute
      Returns:
      the attribute value
      Since:
      3.0
    • getIntegerValue

      protected int getIntegerValue(Object attribute)
      Returns the value of the given attribute as integer.
      Parameters:
      attribute - the attribute
      Returns:
      the attribute value
      Since:
      3.0
    • getValue

      public Object getValue(Object attribute)
      Returns the value of the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      the attribute value
      Since:
      3.0
    • hasValue

      public boolean hasValue(Object attribute)
      Returns whether the given attribute is defined.
      Parameters:
      attribute - the attribute
      Returns:
      true if the attribute has a value false otherwise
      Since:
      3.0
    • isPreferenceKey

      public boolean isPreferenceKey(String key)
      Returns whether the given string is a preference key.
      Parameters:
      key - the string to test
      Returns:
      true if the string is a preference key
    • getAnnotationType

      public Object getAnnotationType()
      Returns the annotation type. Should not be null in a completely set up instance.
      Returns:
      the annotation type, null if the receiver has not been initialized yet
    • getMarkerType

      @Deprecated public String getMarkerType()
      Deprecated.
      since 3.0
      Returns the marker type.
      Returns:
      the marker type, or null if none is set
    • getSeverity

      @Deprecated public int getSeverity()
      Deprecated.
      since 3.0
      Returns the marker severity.
      Returns:
      the marker severity
    • setAnnotationType

      public void setAnnotationType(Object annotationType)
      Sets the annotation type. Note that instances with a null annotation type are considered invalid and should not be used with the framework.
      Parameters:
      annotationType - the annotation type
    • setMarkerType

      public void setMarkerType(String markerType)
      Sets the marker type.
      Parameters:
      markerType - the marker type
    • setSeverity

      public void setSeverity(int severity)
      Sets the marker severity.
      Parameters:
      severity - the marker severity
    • getColorPreferenceKey

      public String getColorPreferenceKey()
      Returns the preference key for the presentation color.
      Returns:
      the preference key for the presentation color or null if none is set
    • getColorPreferenceValue

      public RGB getColorPreferenceValue()
      Returns the default presentation color.
      Returns:
      the default presentation color or null if none is set
    • getPreferenceLabel

      public String getPreferenceLabel()
      Returns the presentation string for this annotation type.
      Returns:
      the presentation string for this annotation type or null if none is set
    • getOverviewRulerPreferenceKey

      public String getOverviewRulerPreferenceKey()
      Returns the preference key for the visibility in the overview ruler.
      Returns:
      the preference key for the visibility in the overview ruler or null if none is set
    • getOverviewRulerPreferenceValue

      public boolean getOverviewRulerPreferenceValue()
      Returns the default visibility in the overview ruler.
      Returns:
      the default visibility in the overview ruler
    • getVerticalRulerPreferenceKey

      public String getVerticalRulerPreferenceKey()
      Returns the preference key for the visibility in the vertical ruler.
      Returns:
      the preference key for the visibility in the vertical ruler or null if none is set
      Since:
      3.0
    • getVerticalRulerPreferenceValue

      public boolean getVerticalRulerPreferenceValue()
      Returns the default visibility in the vertical ruler.
      Returns:
      the default visibility in the vertical ruler
      Since:
      3.0
    • getPresentationLayer

      public int getPresentationLayer()
      Returns the presentation layer.
      Returns:
      the presentation layer
    • getTextPreferenceKey

      public String getTextPreferenceKey()
      Returns the preference key for the visibility inside text.
      Returns:
      the preference key for the visibility inside text or null if none is set
    • getTextPreferenceValue

      public boolean getTextPreferenceValue()
      Returns the default visibility inside text.
      Returns:
      the default visibility inside text
    • getHighlightPreferenceKey

      public String getHighlightPreferenceKey()
      Returns the preference key for highlighting inside text.
      Returns:
      the preference key for highlighting inside text or null if none is set
      Since:
      3.0
    • getHighlightPreferenceValue

      public boolean getHighlightPreferenceValue()
      Returns the default value for highlighting inside text.
      Returns:
      the default value for highlighting inside text
      Since:
      3.0
    • contributesToHeader

      public boolean contributesToHeader()
      Returns whether the annotation type contributes to the header of the overview ruler.
      Returns:
      true if the annotation type contributes to the header of the overview ruler
    • setColorPreferenceKey

      public void setColorPreferenceKey(String colorKey)
      Sets the preference key for the presentation color.
      Parameters:
      colorKey - the preference key
    • setColorPreferenceValue

      public void setColorPreferenceValue(RGB colorValue)
      Sets the default presentation color.
      Parameters:
      colorValue - the default color
    • setPreferenceLabel

      public void setPreferenceLabel(String label)
      Sets the presentation label of this annotation type.
      Parameters:
      label - the presentation label
    • setOverviewRulerPreferenceKey

      public void setOverviewRulerPreferenceKey(String overviewRulerKey)
      Sets the preference key for the visibility in the overview ruler.
      Parameters:
      overviewRulerKey - the preference key
    • setOverviewRulerPreferenceValue

      public void setOverviewRulerPreferenceValue(boolean overviewRulerValue)
      Sets the default visibility in the overview ruler.
      Parameters:
      overviewRulerValue - true if visible by default, false otherwise
    • setVerticalRulerPreferenceKey

      public void setVerticalRulerPreferenceKey(String verticalRulerKey)
      Sets the preference key for the visibility in the vertical ruler.
      Parameters:
      verticalRulerKey - the preference key
      Since:
      3.0
    • setVerticalRulerPreferenceValue

      public void setVerticalRulerPreferenceValue(boolean verticalRulerValue)
      Sets the default visibility in the vertical ruler.
      Parameters:
      verticalRulerValue - true if visible by default, false otherwise
      Since:
      3.0
    • setPresentationLayer

      public void setPresentationLayer(int presentationLayer)
      Sets the presentation layer.
      Parameters:
      presentationLayer - the presentation layer
    • setTextPreferenceKey

      public void setTextPreferenceKey(String textKey)
      Sets the preference key for the visibility of squiggles inside text.
      Parameters:
      textKey - the preference key
    • setTextPreferenceValue

      public void setTextPreferenceValue(boolean textValue)
      Sets the default visibility inside text.
      Parameters:
      textValue - true if visible by default, false otherwise
    • setHighlightPreferenceKey

      public void setHighlightPreferenceKey(String highlightKey)
      Sets the preference key for highlighting inside text.
      Parameters:
      highlightKey - the preference key
      Since:
      3.0
    • setHighlightPreferenceValue

      public void setHighlightPreferenceValue(boolean highlightValue)
      Sets the default value for highlighting inside text.
      Parameters:
      highlightValue - true if highlighted in text by default, false otherwise
      Since:
      3.0
    • setContributesToHeader

      public void setContributesToHeader(boolean contributesToHeader)
      Sets whether the annotation type contributes to the overview ruler's header.
      Parameters:
      contributesToHeader - true if in header, false otherwise
    • isGoToNextNavigationTarget

      public boolean isGoToNextNavigationTarget()
      Returns the default value for go to next navigation enablement.
      Returns:
      true if enabled by default
      Since:
      3.0
    • setIsGoToNextNavigationTarget

      public void setIsGoToNextNavigationTarget(boolean isGoToNextNavigationTarget)
      Sets the default value for go to next navigation enablement.
      Parameters:
      isGoToNextNavigationTarget - true if enabled by default
      Since:
      3.0
    • getIsGoToNextNavigationTargetKey

      public String getIsGoToNextNavigationTargetKey()
      Returns the preference key for go to next navigation enablement.
      Returns:
      the preference key or null if the key is undefined
      Since:
      3.0
    • setIsGoToNextNavigationTargetKey

      public void setIsGoToNextNavigationTargetKey(String isGoToNextNavigationTargetKey)
      Sets the preference key for go to next navigation enablement.
      Parameters:
      isGoToNextNavigationTargetKey - true if enabled by default
      Since:
      3.0
    • isGoToPreviousNavigationTarget

      public boolean isGoToPreviousNavigationTarget()
      Returns the default value for go to previous navigation enablement.
      Returns:
      true if enabled by default
      Since:
      3.0
    • setIsGoToPreviousNavigationTarget

      public void setIsGoToPreviousNavigationTarget(boolean isGoToPreviousNavigationTarget)
      Sets the default value for go to previous navigation enablement.
      Parameters:
      isGoToPreviousNavigationTarget - true if enabled by default
      Since:
      3.0
    • getIsGoToPreviousNavigationTargetKey

      public String getIsGoToPreviousNavigationTargetKey()
      Returns the preference key for go to previous navigation enablement.
      Returns:
      the preference key or null if the key is undefined
      Since:
      3.0
    • setIsGoToPreviousNavigationTargetKey

      public void setIsGoToPreviousNavigationTargetKey(String isGoToPreviousNavigationTargetKey)
      Sets the preference key for go to previous navigation enablement.
      Parameters:
      isGoToPreviousNavigationTargetKey - the preference key
      Since:
      3.0
    • getShowInNextPrevDropdownToolbarActionKey

      public String getShowInNextPrevDropdownToolbarActionKey()
      Returns the preference key for the visibility in the next/previous drop down toolbar action.
      Returns:
      the preference key or null if the key is undefined
      Since:
      3.0
    • setShowInNextPrevDropdownToolbarActionKey

      public void setShowInNextPrevDropdownToolbarActionKey(String showInNextPrevDropdownToolbarActionKey)
      Sets the preference key for the visibility in the next/previous drop down toolbar action.
      Parameters:
      showInNextPrevDropdownToolbarActionKey - the preference key
      Since:
      3.0
    • isShowInNextPrevDropdownToolbarAction

      public boolean isShowInNextPrevDropdownToolbarAction()
      Returns the default value for the visibility in the next/previous drop down toolbar action.
      Returns:
      true if enabled by default
      Since:
      3.0
    • setShowInNextPrevDropdownToolbarAction

      public void setShowInNextPrevDropdownToolbarAction(boolean showInNextPrevDropdownToolbarAction)
      Sets the default value for the visibility in the next/previous drop down toolbar action.
      Parameters:
      showInNextPrevDropdownToolbarAction - true if enabled by default
      Since:
      3.0
    • setTextStylePreferenceKey

      public void setTextStylePreferenceKey(String key)
      Sets the preference key for the text style property.
      Parameters:
      key - the new key
      Since:
      3.0
    • getTextStylePreferenceKey

      public String getTextStylePreferenceKey()
      Returns the preference key for the decoration style used when the annotation is shown in text.
      Returns:
      the preference key for the decoration style or null if the key is undefined
      Since:
      3.0
    • getTextStyleValue

      public String getTextStyleValue()
      Returns the value for the decoration style used when the annotation is shown in text.
      Returns:
      the value for the decoration style or null if the key is undefined
      Since:
      3.0
    • setTextStyleValue

      public void setTextStyleValue(String value)
      Sets the value for the text style property.
      Parameters:
      value - the new text decoration style
      Since:
      3.0
    • getImageDescriptor

      public ImageDescriptor getImageDescriptor()
      Returns the image descriptor for the image to be drawn in the vertical ruler. The provided image is only used, if getAnnotationImageProvider returns null.
      Returns:
      the image descriptor or null
      Since:
      3.0
    • setImageDescriptor

      public void setImageDescriptor(ImageDescriptor descriptor)
      Sets the image descriptor for the image to be drawn in the vertical ruler.
      Parameters:
      descriptor - the image descriptor
      Since:
      3.0
    • getSymbolicImageName

      public String getSymbolicImageName()
      Returns the symbolic name of the image to be drawn in the vertical ruler. The image is only used if getImageDescriptor returns null.
      Returns:
      the symbolic name of the image or null
      Since:
      3.0
    • setSymbolicImageName

      public void setSymbolicImageName(String symbolicImageName)
      Sets the symbolic name of the image to be drawn in the vertical ruler.
      Parameters:
      symbolicImageName - the symbolic image name
      Since:
      3.0
    • getAnnotationImageProvider

      public IAnnotationImageProvider getAnnotationImageProvider()
      Returns the annotation image provider. If no default annotation image provider has been set, this method checks whether the annotation image provider data has been set. If so, an annotation image provider is created if the configuration element's plug-in is loaded. When an annotation image provider has been created successfully, it is set as the default annotation image provider.
      Returns:
      the annotation image provider
      Since:
      3.0
    • setAnnotationImageProvider

      public void setAnnotationImageProvider(IAnnotationImageProvider provider)
      Sets the annotation image provider who provides images for annotations of the specified annotation type.
      Parameters:
      provider - the annotation image provider
      Since:
      3.0
    • setAnnotationImageProviderData

      public void setAnnotationImageProviderData(IConfigurationElement configurationElement, String annotationImageProviderAttribute)
      Sets the data needed to create the annotation image provider.
      Parameters:
      configurationElement - the configuration element
      annotationImageProviderAttribute - the attribute of the configuration element
      Since:
      3.0
    • setIncludeOnPreferencePage

      public void setIncludeOnPreferencePage(boolean includeOnPreferencePage)
      Sets the property of this annotation preference whether it should be included on the default annotation preference page.
      Parameters:
      includeOnPreferencePage - the new value
      Since:
      3.0
    • isIncludeOnPreferencePage

      public boolean isIncludeOnPreferencePage()
      Returns the property of the receiver of whether it should be included on the default annotation preference page.
      Returns:
      the includeOnPreferencePage property
      Since:
      3.0
    • merge

      public void merge(AnnotationPreference preference)
      Merges the values of the given preference into this preference. Existing values will not be overwritten. Subclasses may extend.
      Parameters:
      preference - the preference to merge into this preference
      Since:
      3.0
    • setQuickFixImageDescriptor

      public void setQuickFixImageDescriptor(ImageDescriptor descriptor)
      Sets the Quick Fix image descriptor for the image to be drawn in the vertical ruler.
      Parameters:
      descriptor - the image descriptor
      Since:
      3.2
    • getQuickFixImageDescriptor

      public ImageDescriptor getQuickFixImageDescriptor()
      Returns the Quick Fix image descriptor for the image to be drawn in the vertical ruler. The provided image is only used, if getAnnotationImageProvider returns null.
      Returns:
      the image descriptor or null
      Since:
      3.2