it.amattioli.applicate.browsing
Class DefaultTreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

Show UML class diagram
java.lang.Object
  extended by it.amattioli.applicate.browsing.DefaultTreeBrowser<I,T>
All Implemented Interfaces:
Browser<I,T>, TreeBrowser<I,T>, CommandListener, Selector<T>, it.amattioli.dominate.util.PropertyChangeEmitter, EventListener

public class DefaultTreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
extends Object
implements TreeBrowser<I,T>, it.amattioli.dominate.util.PropertyChangeEmitter


Constructor Summary
protected DefaultTreeBrowser()
           
  DefaultTreeBrowser(Class<T> entityClass, I rootId, String childrenPropertyName, String parentPropertyName)
           
  DefaultTreeBrowser(it.amattioli.dominate.Repository<I,T> repository, I rootId, String childrenPropertyName, String parentPropertyName)
           
 
Method Summary
 void addContentChangeListener(ContentChangeListener listener)
          Add a listener for events fired when the browser content changes.
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void addSelectionListener(SelectionListener listener)
          Register a listener for the object selection.
 void commandDone(CommandEvent evt)
          This method will be called every time a CommandEvent is fired by the command to which this listener has been added.
 void deselect()
           
protected  void fireContentChange()
           
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
           
 List<T> getChildrenOf(T target)
          Retrieves the list of the children of a given node
 T getParentOf(T target)
           
 TreePath getPathOf(T target)
          Retrieves the path of node
 T getRoot()
          Retrieves the root of the tree
 I getRootId()
           
 T getSelectedObject()
          Retrieves the object currently selected.
 TreePath getSelectedPath()
          Retrieves the path of the selected object
 it.amattioli.dominate.Specification<T> getSpecification()
           
 T getTargetOf(TreePath path)
          Retrieves a tree node given its path inside the tree
 void next()
          Select next node in tree.
 void previous()
          Select previous node in tree.
 void release()
          Releases eventually acquired resources.
 void removeContentChangeListener(ContentChangeListener listener)
          Remove a listener for events fired when the browser content changes.
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void removeSelectionListener(SelectionListener listener)
          Remove a listener from the collection of the listeners that will be notified when an object is slected in this browser.
 void select(T selected)
          Select a node
 void select(TreePath path)
          Select a node given its path
 void setRootId(I rootId)
           
 void setSpecification(it.amattioli.dominate.Specification<T> spec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTreeBrowser

protected DefaultTreeBrowser()

DefaultTreeBrowser

public DefaultTreeBrowser(it.amattioli.dominate.Repository<I,T> repository,
                          I rootId,
                          String childrenPropertyName,
                          String parentPropertyName)

DefaultTreeBrowser

public DefaultTreeBrowser(Class<T> entityClass,
                          I rootId,
                          String childrenPropertyName,
                          String parentPropertyName)
Method Detail

getRootId

public I getRootId()

setRootId

public void setRootId(I rootId)

getRoot

public T getRoot()
Description copied from interface: TreeBrowser
Retrieves the root of the tree

Specified by:
getRoot in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
Returns:

getChildrenOf

public List<T> getChildrenOf(T target)
Description copied from interface: TreeBrowser
Retrieves the list of the children of a given node

Specified by:
getChildrenOf in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
Returns:

getParentOf

public T getParentOf(T target)

getPathOf

public TreePath getPathOf(T target)
Description copied from interface: TreeBrowser
Retrieves the path of node

Specified by:
getPathOf in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
Returns:

getTargetOf

public T getTargetOf(TreePath path)
Description copied from interface: TreeBrowser
Retrieves a tree node given its path inside the tree

Specified by:
getTargetOf in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
Returns:

select

public void select(TreePath path)
Description copied from interface: TreeBrowser
Select a node given its path

Specified by:
select in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

select

public void select(T selected)
Description copied from interface: TreeBrowser
Select a node

Specified by:
select in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

deselect

public void deselect()
Specified by:
deselect in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

getSelectedObject

public T getSelectedObject()
Description copied from interface: Selector
Retrieves the object currently selected.

Specified by:
getSelectedObject in interface Selector<T extends it.amattioli.dominate.Entity<I>>
Returns:
the object currently selected or null if no object is selected

getSelectedPath

public TreePath getSelectedPath()
Description copied from interface: TreeBrowser
Retrieves the path of the selected object

Specified by:
getSelectedPath in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
Returns:

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Description copied from interface: Selector
Register a listener for the object selection. Every time an object is selected in this browser all the registered objects will be notified.

Specified by:
addSelectionListener in interface Selector<T extends it.amattioli.dominate.Entity<I>>
Parameters:
listener - the listener to be registered

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Description copied from interface: Selector
Remove a listener from the collection of the listeners that will be notified when an object is slected in this browser.

Specified by:
removeSelectionListener in interface Selector<T extends it.amattioli.dominate.Entity<I>>
Parameters:
listener - the listener to be removed

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface it.amattioli.dominate.util.PropertyChangeEmitter

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface it.amattioli.dominate.util.PropertyChangeEmitter

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)

commandDone

public void commandDone(CommandEvent evt)
Description copied from interface: CommandListener
This method will be called every time a CommandEvent is fired by the command to which this listener has been added.

Specified by:
commandDone in interface CommandListener
Parameters:
evt - the fired event

release

public void release()
Description copied from interface: Browser
Releases eventually acquired resources. After calling this method the browser can no longer be used.

Specified by:
release in interface Browser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

addContentChangeListener

public void addContentChangeListener(ContentChangeListener listener)
Description copied from interface: Browser
Add a listener for events fired when the browser content changes.

Specified by:
addContentChangeListener in interface Browser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
Parameters:
listener - the listener to be added

removeContentChangeListener

public void removeContentChangeListener(ContentChangeListener listener)
Description copied from interface: Browser
Remove a listener for events fired when the browser content changes.

Specified by:
removeContentChangeListener in interface Browser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>
Parameters:
listener - the listener to be removed

fireContentChange

protected void fireContentChange()

next

public void next()
Description copied from interface: TreeBrowser
Select next node in tree. If the current selected node has children the first children will be selected, otherwise the next sibling. If the current node is the last sibling its parent next sibling will be selected.

Specified by:
next in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

previous

public void previous()
Description copied from interface: TreeBrowser
Select previous node in tree. If the current selected node is the first of its sibling its parent will be selected otherwise the first children of its parent previous sibling will be selected.

Specified by:
previous in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

getSpecification

public it.amattioli.dominate.Specification<T> getSpecification()
Specified by:
getSpecification in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>

setSpecification

public void setSpecification(it.amattioli.dominate.Specification<T> spec)
Specified by:
setSpecification in interface TreeBrowser<I extends Serializable,T extends it.amattioli.dominate.Entity<I>>


Copyright © 2011. All Rights Reserved.