org.nuiton.widget.tree
Class FilterTreeModel

java.lang.Object
  extended by org.nuiton.widget.tree.FilterTreeModel
All Implemented Interfaces:
TreeModel

public class FilterTreeModel
extends Object
implements TreeModel

Filter tree model. Take a delegate TreeModel filter it with TreeFilter.

Version:
$Revision: 300 $ Last update : $Date: 2010-11-17 22:35:44 +0100 (mer., 17 nov. 2010) $ By : $Author: sletellier $ Based on : http://forums.sun.com/thread.jspa?forumID=57&threadID=5378510
Author:
chatellier

Field Summary
protected  TreeModel delegateModel
          Real application TreeModel.
protected  TreeFilter treeFilter
          Filter to use (can be null : no filtering).
protected  Collection<TreeModelListener> treeModelListeners
          Listener for data and structure change notification.
 
Constructor Summary
FilterTreeModel(TreeModel delegateModel)
          Constructor with delegate model.
FilterTreeModel(TreeModel delegateModel, TreeFilter filter)
          Constructor with delegate model.
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
           
protected  void fireTreeStructureChanged(TreePath path)
          Send a treeStructureChanged event on all registred listeners.
 Object getChild(Object parent, int index)
           
 int getChildCount(Object parent)
           
 int getIndexOfChild(Object parent, Object child)
           
 Object getRoot()
           
 boolean isLeaf(Object node)
           
 void removeTreeModelListener(TreeModelListener l)
           
 void setFilter(TreeFilter treeFilter)
          Change filter.
 void valueForPathChanged(TreePath path, Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

treeModelListeners

protected Collection<TreeModelListener> treeModelListeners
Listener for data and structure change notification.


delegateModel

protected TreeModel delegateModel
Real application TreeModel.


treeFilter

protected TreeFilter treeFilter
Filter to use (can be null : no filtering).

Constructor Detail

FilterTreeModel

public FilterTreeModel(TreeModel delegateModel)
Constructor with delegate model.

Parameters:
delegateModel - delegate data model

FilterTreeModel

public FilterTreeModel(TreeModel delegateModel,
                       TreeFilter filter)
Constructor with delegate model.

Parameters:
delegateModel -
filter -
Method Detail

setFilter

public void setFilter(TreeFilter treeFilter)
Change filter. Send a treeStructureChanged event on all registred listeners.

Parameters:
treeFilter - new filter

fireTreeStructureChanged

protected void fireTreeStructureChanged(TreePath path)
Send a treeStructureChanged event on all registred listeners.

Parameters:
path - new path to send in notification

getChildCount

public int getChildCount(Object parent)
Specified by:
getChildCount in interface TreeModel

getChild

public Object getChild(Object parent,
                       int index)
Specified by:
getChild in interface TreeModel

getRoot

public Object getRoot()
Specified by:
getRoot in interface TreeModel

isLeaf

public boolean isLeaf(Object node)
Specified by:
isLeaf in interface TreeModel

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Specified by:
valueForPathChanged in interface TreeModel

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Specified by:
getIndexOfChild in interface TreeModel

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Specified by:
addTreeModelListener in interface TreeModel

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Specified by:
removeTreeModelListener in interface TreeModel


Copyright © 2004-2010 CodeLutin. All Rights Reserved.