Tree filtering

Nuiton-widget provide basic model based tree filtering.

API

Only two classes are provided:

  • TreeFilter : Interface for tree filter implementation
  • TreeFilterModel : Filtered tree model

The TreeFilter currently has only one method include which must return true only if parameter node must be displayed.

Using

Define your filtered tree:

public class Test {

  protected FilterTreeModel filterModel;

  [...]

  protected void buildUI() {

    TreeModel realModel = ...
    filterModel = new FilterTreeModel(realModel);

    JTree tree = new JTree(filterModel);

    [...]
  }

Then apply filtering (when filter need to be updated):

[...]
protected void updateFilter(String filterString) {
      TreeFilter myTreeFilter = new MyTreeFilter(filterString);
      filterModel.setTreeFilter(myTreeFilter);
}