Class StyledCellLabelProvider

    • Field Detail

      • COLORS_ON_SELECTION

        public static final int COLORS_ON_SELECTION
        Style constant for indicating that the styled colors are to be applied even it the viewer's item is selected. Default is not to apply colors.
        See Also:
        Constant Field Values
      • NO_FOCUS

        public static final int NO_FOCUS
        Style constant for indicating to draw the focus if requested by the owner draw event. Default is to draw the focus.
        See Also:
        Constant Field Values
    • Constructor Detail

      • StyledCellLabelProvider

        public StyledCellLabelProvider()
        Creates a new StyledCellLabelProvider. By default, owner draw is enabled, focus is drawn and no colors are painted on selected elements.
      • StyledCellLabelProvider

        public StyledCellLabelProvider​(int style)
        Creates a new StyledCellLabelProvider. By default, owner draw is enabled.
        Parameters:
        style - the style bits
        See Also:
        COLORS_ON_SELECTION, NO_FOCUS
    • Method Detail

      • isOwnerDrawEnabled

        public boolean isOwnerDrawEnabled()
        Returns true is the owner draw rendering is enabled for this label provider. By default owner draw rendering is enabled. If owner draw rendering is disabled, rending is done by the viewer and no styled ranges (see ViewerCell.getStyleRanges()) are drawn.
        Returns:
        true is the rendering of styles is enabled.
      • setOwnerDrawEnabled

        public void setOwnerDrawEnabled​(boolean enabled)
        Specifies whether owner draw rendering is enabled for this label provider. By default owner draw rendering is enabled. If owner draw rendering is disabled, rendering is done by the viewer and no styled ranges (see ViewerCell.getStyleRanges()) are drawn. It is the caller's responsibility to also call StructuredViewer.refresh() or similar methods to update the underlying widget.
        Parameters:
        enabled - specifies if owner draw rendering is enabled
      • getViewer

        protected final ColumnViewer getViewer()
        Returns the viewer on which this label provider is installed on or null if the label provider is not installed.
        Returns:
        the viewer on which this label provider is installed on or null if the label provider is not installed.
      • getColumn

        protected final ViewerColumn getColumn()
        Returns the column on which this label provider is installed on or null if the label provider is not installed.
        Returns:
        the column on which this label provider is installed on or null if the label provider is not installed.
      • dispose

        public void dispose()
        Description copied from class: BaseLabelProvider
        The BaseLabelProvider implementation of this IBaseLabelProvider method clears its internal listener list. Subclasses may extend but should call the super implementation.
        Specified by:
        dispose in interface IBaseLabelProvider
        Overrides:
        dispose in class BaseLabelProvider
      • prepareStyleRange

        protected StyleRange prepareStyleRange​(StyleRange styleRange,
                                               boolean applyColors)
        Prepares the given style range before it is applied to the label. This method makes sure that no colors are drawn when the element is selected. The current version of the StyledCellLabelProvider will also ignore all font settings on the style range. Clients can override.
        Parameters:
        styleRange - the style range to prepare. the style range element must not be modified
        applyColors - specifies if colors should be applied.
        Returns:
        returns the style range to use on the label
      • erase

        protected void erase​(Event event,
                             Object element)
        Handle the erase event. The default implementation does nothing to ensure keep native selection highlighting working.
        Overrides:
        erase in class OwnerDrawLabelProvider
        Parameters:
        event - the erase event
        element - the model object
        See Also:
        SWT.EraseItem
      • styleDecoratedString

        public static StyledString styleDecoratedString​(String decoratedString,
                                                        StyledString.Styler decorationStyler,
                                                        StyledString styledString)
        Applies decoration styles to the decorated string and adds the styles of the previously undecorated string.

        If the decoratedString contains the styledString, then the result keeps the styles of the styledString and styles the decorations with the decorationStyler. Otherwise, the decorated string is returned without any styles.

        Parameters:
        decoratedString - the decorated string
        decorationStyler - the styler to use for the decoration or null for no styles
        styledString - the original styled string
        Returns:
        the styled decorated string (can be the given styledString)
        Since:
        3.5