net.sourceforge.java.util.gui.jface.viewers
Class TreeViewerFilter

java.lang.Object
  extended byorg.eclipse.jface.viewers.ViewerFilter
      extended bynet.sourceforge.java.util.gui.jface.viewers.TreeViewerFilter

public class TreeViewerFilter
extends ViewerFilter

ViewerFilter implementation to filter a TreeViewer displaying an ITreeElement structure based on a arbitrary keyword.

Author:
Sebastian Machhausen

Field Summary
private  String filterText
           The filter text.
private  TreeViewer viewer
           The TreeViewer that is being filtered
 
Constructor Summary
TreeViewerFilter(TreeViewer viewer)
           Creates a new TreeViewFilter for the specified TreeViewer.
 
Method Summary
 Object[] filter(Viewer viewer, Object parent, Object[] elements)
           Filters the given elements for the given viewer.
 String getFilterText()
           Gets the filter text.
 boolean select(Viewer viewer, Object parentElement, Object element)
           Decides whether or not the element in the parentElement structure displayed in the specified Viewer has to be selected.
 void setFilterText(String filterText)
           Sets the filter text to the specified value.
private  void updateFilterTag(Object element)
           Updates the IFilterTag of the specified element depending on the filter status.
 
Methods inherited from class org.eclipse.jface.viewers.ViewerFilter
filter, isFilterProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewer

private TreeViewer viewer

The TreeViewer that is being filtered


filterText

private String filterText

The filter text. null or an empty String indicates no filtering

Constructor Detail

TreeViewerFilter

public TreeViewerFilter(TreeViewer viewer)

Creates a new TreeViewFilter for the specified TreeViewer.

Parameters:
viewer - the TreeViewer to create the TreeViewFilter for
Method Detail

filter

public Object[] filter(Viewer viewer,
                       Object parent,
                       Object[] elements)

Filters the given elements for the given viewer. The input array is not modified. The default implementation of this method calls select on each element in the array, and returns only those elements for which select returns true.

Parameters:
viewer - the Viewer to filter
parent - the parent element
elements - the elements to filter
Returns:
the filtered elements

select

public boolean select(Viewer viewer,
                      Object parentElement,
                      Object element)

Decides whether or not the element in the parentElement structure displayed in the specified Viewer has to be selected.

Parameters:
viewer - the Viewer for which selection is done
parentElement - the parent element
element - the element to potentially select
Returns:
true if the specified element was selected; false if it was rejected

updateFilterTag

private void updateFilterTag(Object element)

Updates the IFilterTag of the specified element depending on the filter status.

Parameters:
element - the element to update the filter status for

getFilterText

public String getFilterText()

Gets the filter text.

Returns:
the filter text; null or an empty String indicates no filtering, i.e. disabled filtering

setFilterText

public void setFilterText(String filterText)

Sets the filter text to the specified value.

Parameters:
filterText - the filter text to set; null or an empty String for no filtering, i.e. disabled filtering