jmri.jmrit.catalog
Class AbstractCatalogTree

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by jmri.jmrit.catalog.AbstractCatalogTree
All Implemented Interfaces:
Serializable, TreeModel, CatalogTree, NamedBean
Direct Known Subclasses:
CatalogTreeFS, CatalogTreeIndex

public abstract class AbstractCatalogTree
extends DefaultTreeModel
implements CatalogTree

TreeModel used by CatalogPanel to create a tree of resources.

Author:
Pete Cressman Copyright 2009
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Fields inherited from interface jmri.CatalogTree
FILESYS, IMAGE, NOFILTER, SCRIPT, SOUND, XML
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
AbstractCatalogTree(String sysname)
           
AbstractCatalogTree(String sysname, String username)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void addPropertyChangeListener(PropertyChangeListener l, String beanRef, String listenerRef)
          Request a call-back when a bound property changes.
 void dispose()
          Deactivate this object, so that it releases as many resources as possible and no longer effects others.
protected  void firePropertyChange(String p, Object old, Object n)
           
 String getComment()
          Get associated comment text.
 String getDisplayName()
           
 String getListenerRef(PropertyChangeListener l)
          Get the textual reference for the specific listener
 ArrayList<String> getListenerRefs()
          Returns a list of all the listerners references
 int getNumPropertyChangeListeners()
          Number of current listeners.
 ArrayList<PropertyChangeListener> getPropertyChangeListeners(String name)
          Get a list of all the property change listeners that are registered using a specific name
 int getState()
          Provide generic access to internal state.
 String getSystemName()
          Get a system-specific name.
 String getUserName()
           
 void insertNodes(String pathToRoot)
          Starting point to recursively add nodes to the tree by scanning a file directory
abstract  void insertNodes(String pName, String pPath, CatalogTreeNode pParent)
          Recursively add nodes to the tree
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a request for a call-back when a bound property changes.
 void setComment(String comment)
          Set associated comment text.
 void setState(int s)
          Provide generic access to internal state.
 void setUserName(String s)
           
 void updateListenerRef(PropertyChangeListener l, String newName)
           
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.NamedBean
getProperty, getPropertyKeys, setProperty
 
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getRoot, isLeaf, removeTreeModelListener, valueForPathChanged
 

Constructor Detail

AbstractCatalogTree

public AbstractCatalogTree(String sysname,
                           String username)

AbstractCatalogTree

public AbstractCatalogTree(String sysname)
Method Detail

insertNodes

public abstract void insertNodes(String pName,
                                 String pPath,
                                 CatalogTreeNode pParent)
Recursively add nodes to the tree

Specified by:
insertNodes in interface CatalogTree
Parameters:
pName - Name of the resource to be scanned; this is only used for the human-readable tree
pPath - Path to this resource, including the pName part
pParent - Node for the parent of the resource to be scanned, e.g. where in the tree to insert it.

insertNodes

public void insertNodes(String pathToRoot)
Starting point to recursively add nodes to the tree by scanning a file directory

Specified by:
insertNodes in interface CatalogTree
Parameters:
pathToRoot - Path to Directory to be scanned

getComment

public String getComment()
Get associated comment text.

Specified by:
getComment in interface NamedBean

setComment

public void setComment(String comment)
Set associated comment text.

Comments can be any valid text.

Specified by:
setComment in interface NamedBean
Parameters:
comment - Null means no comment associated.

getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface NamedBean

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface NamedBean

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Description copied from interface: NamedBean
Remove a request for a call-back when a bound property changes.

Specified by:
removePropertyChangeListener in interface NamedBean

getNumPropertyChangeListeners

public int getNumPropertyChangeListeners()
Number of current listeners. May return -1 if the information is not available for some reason.

Specified by:
getNumPropertyChangeListeners in interface NamedBean

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l,
                                      String beanRef,
                                      String listenerRef)
Description copied from interface: NamedBean
Request a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.

Specified by:
addPropertyChangeListener in interface NamedBean
Parameters:
l - - Listener
beanRef - - The name (either system or user) that the listener uses for this namedBean, this parameter is used to help determine when which listeners should be moved when the username is moved from one bean to another.
listenerRef - - A textual reference for the listener, that can be presented to the user when a delete is called

getPropertyChangeListeners

public ArrayList<PropertyChangeListener> getPropertyChangeListeners(String name)
Description copied from interface: NamedBean
Get a list of all the property change listeners that are registered using a specific name

Specified by:
getPropertyChangeListeners in interface NamedBean
Parameters:
name - - The name (either system or user) that the listener has registered as referencing this namedBean

getListenerRefs

public ArrayList<String> getListenerRefs()
Description copied from interface: NamedBean
Returns a list of all the listerners references

Specified by:
getListenerRefs in interface NamedBean

updateListenerRef

public void updateListenerRef(PropertyChangeListener l,
                              String newName)
Specified by:
updateListenerRef in interface NamedBean

getListenerRef

public String getListenerRef(PropertyChangeListener l)
Description copied from interface: NamedBean
Get the textual reference for the specific listener

Specified by:
getListenerRef in interface NamedBean

getSystemName

public String getSystemName()
Description copied from interface: NamedBean
Get a system-specific name. This encodes the hardware addressing information.

Specified by:
getSystemName in interface NamedBean

getUserName

public String getUserName()
Specified by:
getUserName in interface NamedBean

setUserName

public void setUserName(String s)
Specified by:
setUserName in interface NamedBean

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)

dispose

public void dispose()
Description copied from interface: NamedBean
Deactivate this object, so that it releases as many resources as possible and no longer effects others.

For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.

Specified by:
dispose in interface NamedBean

getState

public int getState()
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. getCommandedState in Turnout) This provided to make Jython script access easier to read.

Specified by:
getState in interface NamedBean

setState

public void setState(int s)
              throws JmriException
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. setCommandedState in Turnout) This provided to make Jython script access easier to read.

Specified by:
setState in interface NamedBean
Throws:
JmriException - general error when cant do the needed operation


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads