Class FilteredTree

All Implemented Interfaces:
Drawable

public class FilteredTree extends AbstractFilteredViewerComposite<PatternFilter>
A simple control that provides a text widget and a tree viewer. The contents of the text widget are used to drive a PatternFilter that is on the viewer.
Since:
3.2
See Also:
  • Field Details

    • filterToolBar

      @Deprecated(since="2025-03", forRemoval=true) protected ToolBarManager filterToolBar
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of 4.13 not used anymore

      Note: As of 4.13 not used anymore

    • clearButtonControl

      @Deprecated(since="2025-03", forRemoval=true) protected Control clearButtonControl
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of 4.13 not used anymore

      Note: As of 4.13 not used anymore

      Since:
      3.5
    • treeViewer

      protected TreeViewer treeViewer
      The viewer for the filtered tree. This value should never be null after the widget creation methods are complete.
    • treeComposite

      protected Composite treeComposite
      Since:
      3.3
  • Constructor Details

    • FilteredTree

      public FilteredTree(Composite parent, boolean useNewLook, boolean useFastHashLookup)
      Create a new instance of the receiver. Subclasses that wish to override the default creation behavior may use this constructor, but must ensure that the init(composite, int, PatternFilter) method is called in the overriding constructor. *

      WARNING: Passing false as parameter for useFastHashLookup results in a slow performing tree and should not be used if the underlying data model uses a stable and correct hashCode and equals implementation.

      Parameters:
      parent - the parent Composite
      useNewLook - ignored, keep for API compliance
      useFastHashLookup - true, if tree should use fast hashlookup, false, if the tree should be slow but working for data with mutable or broken hashcode implementation. Only used if treeViewer is already initialized
      Since:
      3.116
    • FilteredTree

      public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook, boolean useFastHashLookup)
      Since:
      3.116
    • FilteredTree

      public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook, boolean useFastHashLookup, long refreshJobDelayInMillis)
      Create a new instance of the receiver.

      WARNING: Passing false as parameter for useFastHashLookup results in a slow performing tree and should not be used if the underlying data model uses a stable and correct hashCode and equals implementation.

      Parameters:
      parent - the parent Composite
      treeStyle - the style bits for the Tree
      filter - the filter to be used
      useNewLook - ignored, keep for API compliance
      useFastHashLookup - true, if tree should use fast hash lookup, false, if the tree should be slow but working for data with mutable or broken hashcode implementation. Only used if treeViewer is already initialized
      refreshJobDelayInMillis - refresh delay in ms, the time to expand the tree after debounce
      Since:
      3.132
    • FilteredTree

      @Deprecated protected FilteredTree(Composite parent)
      Deprecated.
      Create a new instance of the receiver. Subclasses that wish to override the default creation behavior may use this constructor, but must ensure that the init(composite, int, PatternFilter) method is called in the overriding constructor.

      WARNING: Using this constructor results in a slow performing tree and should not be used if the underlying data model uses a stable and correct hashCode and equals implementation. Prefer the usage of FilteredTree(Composite, boolean, boolean) if possible.

      Parameters:
      parent - the parent Composite
      Since:
      3.3
      See Also:
    • FilteredTree

      @Deprecated protected FilteredTree(Composite parent, boolean useNewLook)
      Create a new instance of the receiver. Subclasses that wish to override the default creation behavior may use this constructor, but must ensure that the init(composite, int, PatternFilter) method is called in the overriding constructor. *

      WARNING: Using this constructor results in a slow performing tree and should not be used if the underlying data model uses a stable and correct hashCode and equals implementation. Prefer the usage of FilteredTree(Composite, int, PatternFilter, boolean, boolean) if possible.

      Parameters:
      parent - the parent Composite
      useNewLook - ignored, look introduced in 3.5 is always used
      Since:
      3.5
      See Also:
    • FilteredTree

      @Deprecated public FilteredTree(Composite parent, int treeStyle, PatternFilter filter)
      Create a new instance of the receiver.

      WARNING: Using this constructor results in a slow performing tree and should not be used if the underlying data model uses a stable and correct hashCode and equals implementation. Prefer the usage of FilteredTree(Composite, int, PatternFilter, boolean, boolean) if possible.

      Parameters:
      parent - the parent Composite
      treeStyle - the style bits for the Tree
      filter - the filter to be used
    • FilteredTree

      @Deprecated public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook)
      Create a new instance of the receiver.

      WARNING: Using this constructor results in a slow performing tree and should not be used if the underlying data model uses a stable and correct hashCode and equals implementation. Prefer the usage of FilteredTree(Composite, int, PatternFilter, boolean, boolean) if possible

      Parameters:
      parent - the parent Composite
      treeStyle - the style bits for the Tree
      filter - the filter to be used
      useNewLook - ignored, look introduced in 3.5 is always used
      Since:
      3.5
  • Method Details

    • init

      protected void init(int treeStyle, PatternFilter filter)
      Description copied from class: AbstractFilteredViewerComposite
      Create the filtered viewer.
      Overrides:
      init in class AbstractFilteredViewerComposite<PatternFilter>
      Parameters:
      treeStyle - the style bits for the viewer's Control
      filter - the filter to be used
    • createControl

      protected void createControl(Composite parent, int treeStyle)
      Description copied from class: AbstractFilteredViewerComposite
      Create the filtered viewer's controls. Subclasses should override.
      Overrides:
      createControl in class AbstractFilteredViewerComposite<PatternFilter>
      Parameters:
      parent - the parent
      treeStyle - SWT style bits used to create the control
    • createTreeControl

      protected Control createTreeControl(Composite parent, int style)
      Creates and set up the tree and tree viewer. This method calls doCreateTreeViewer(Composite, int) to create the tree viewer. Subclasses should override doCreateTreeViewer(Composite, int) instead of overriding this method.
      Parameters:
      parent - parent Composite
      style - SWT style bits used to create the tree
      Returns:
      the tree
    • doCreateTreeViewer

      protected TreeViewer doCreateTreeViewer(Composite parent, int style)
      Creates the tree viewer. Subclasses may override.
      Parameters:
      parent - the parent composite
      style - SWT style bits used to create the tree viewer
      Returns:
      the tree viewer
      Since:
      3.3
    • doCreateRefreshJob

      protected WorkbenchJob doCreateRefreshJob()
      Creates a workbench job that will refresh the tree based on the current filter text. Subclasses may override.
      Returns:
      a workbench job that can be scheduled to refresh the tree
      Since:
      3.4
    • updateToolbar

      protected void updateToolbar(boolean visible)
      Updates the toolbar. The default implementation does nothing. Subclasses may override.
      Parameters:
      visible - boolean
    • createFilterText

      protected void createFilterText(Composite parent)
      Creates the filter text and adds listeners. This method calls doCreateFilterText(Composite) to create the text control. Subclasses should override doCreateFilterText(Composite) instead of overriding this method.
      Overrides:
      createFilterText in class AbstractFilteredViewerComposite<PatternFilter>
      Parameters:
      parent - Composite of the filter text
    • updateTreeSelection

      protected void updateTreeSelection(boolean setFocus)
      Updates the selection in the tree, based on the filter text.
      Parameters:
      setFocus - true if the focus should be set on the tree, false otherwise
      Since:
      3.105
    • doCreateFilterText

      protected Text doCreateFilterText(Composite parent)
      Description copied from class: AbstractFilteredViewerComposite
      Creates the text control for entering the filter text. Subclasses may override.
      Specified by:
      doCreateFilterText in class AbstractFilteredViewerComposite<PatternFilter>
      Parameters:
      parent - the parent composite
      Returns:
      the text widget
    • textChanged

      protected void textChanged()
      Description copied from class: AbstractFilteredViewerComposite
      Update the receiver after the text has changed.
      Specified by:
      textChanged in class AbstractFilteredViewerComposite<PatternFilter>
    • getPatternFilter

      public final PatternFilter getPatternFilter()
      Description copied from class: AbstractFilteredViewerComposite
      Returns the pattern filter used by this tree.
      Overrides:
      getPatternFilter in class AbstractFilteredViewerComposite<PatternFilter>
      Returns:
      The pattern filter; never null.
    • getViewer

      public TreeViewer getViewer()
      Description copied from class: AbstractFilteredViewerComposite
      Get the structured viewer of the receiver.
      Specified by:
      getViewer in class AbstractFilteredViewerComposite<PatternFilter>
      Returns:
      the structured viewer
    • setQuickSelectionMode

      public void setQuickSelectionMode(boolean enabled)
      Sets whether this filtered tree is used to make quick selections. In this mode the first match in the tree is automatically selected while filtering and the 'Enter' key is not used to move the focus to the tree.

      By default, this is set to false.

      Parameters:
      enabled - true if this filtered tree is used to make quick selections, false otherwise
      Since:
      3.105
    • getBoldFont

      public static Font getBoldFont(Object element, FilteredTree tree, PatternFilter filter)
      Return a bold font if the given element matches the given pattern. Clients can opt to call this method from a Viewer's label provider to get a bold font for which to highlight the given element in the tree.
      Parameters:
      element - element for which a match should be determined
      tree - FilteredTree in which the element resides
      filter - PatternFilter which determines a match
      Returns:
      bold font