ca.odell.glazedlists.swing
Class EventTreeModel<E>

java.lang.Object
  extended by ca.odell.glazedlists.swing.EventTreeModel<E>
All Implemented Interfaces:
ListEventListener<E>, EventListener, TreeModel

public class EventTreeModel<E>
extends Object
implements TreeModel, ListEventListener<E>

Adapt a TreeList for use in a JTree.

Ongoing problem: TreeList cannot cache all tree data on the swing thread proxy due to the extra data in a tree.

Developer Preview this class is still under heavy development and subject to API changes. It's also really slow at the moment and won't scale to lists of size larger than a hundred or so efficiently.

Author:
jessewilson

Field Summary
protected  List<TreeModelListener> listenerList
          Listeners.
protected  TransformedList swingThreadSource
          the proxy moves events to the Swing Event Dispatch thread
 
Constructor Summary
EventTreeModel(TreeList<E> source)
          Creates a new tree model that extracts the tree data from the given source.
 
Method Summary
 void addTreeModelListener(TreeModelListener listener)
          
 void dispose()
          Releases the resources consumed by this EventTreeModel so that it may eventually be garbage collected.
 Object getChild(Object parent, int index)
          
 int getChildCount(Object parent)
          
 int getIndexOfChild(Object parent, Object child)
          
 Object getRoot()
          
 boolean isLeaf(Object node)
          
 void listChanged(ListEvent<E> listChanges)
          When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.
 void removeTreeModelListener(TreeModelListener listener)
          
 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

swingThreadSource

protected TransformedList swingThreadSource
the proxy moves events to the Swing Event Dispatch thread


listenerList

protected List<TreeModelListener> listenerList
Listeners.

Constructor Detail

EventTreeModel

public EventTreeModel(TreeList<E> source)
Creates a new tree model that extracts the tree data from the given source.

Parameters:
source - a TreeList that provides the tree data
Method Detail

getRoot

public Object getRoot()

Specified by:
getRoot in interface TreeModel

getChild

public Object getChild(Object parent,
                       int index)

Specified by:
getChild in interface TreeModel

getChildCount

public int getChildCount(Object parent)

Specified by:
getChildCount 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 listener)

Specified by:
addTreeModelListener in interface TreeModel

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener listener)

Specified by:
removeTreeModelListener in interface TreeModel

listChanged

public void listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.

It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.

Specified by:
listChanged in interface ListEventListener<E>
Parameters:
listChanges - a ListEvent describing the changes to the list

dispose

public void dispose()
Releases the resources consumed by this EventTreeModel so that it may eventually be garbage collected.

An EventTreeModel will be garbage collected without a call to dispose(), but not before its source EventList is garbage collected. By calling dispose(), you allow the EventTreeModel to be garbage collected before its source EventList. This is necessary for situations where an EventTreeModel is short-lived but its source EventList is long-lived.

Warning: It is an error to call any method on an EventTreeModel after it has been disposed.



Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by hbrands at 2013-02-12 20:58