Class AbstractCatalogTree
- All Implemented Interfaces:
Serializable,Comparable<NamedBean>,TreeModel,PropertyChangeProvider,CatalogTree,NamedBean
- Direct Known Subclasses:
CatalogTreeFS,CatalogTreeIndex
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException -
Field Summary
FieldsModifier and TypeFieldDescription(package private) HashMap<PropertyChangeListener,String> protected final String(package private) PropertyChangeSupport(package private) HashMap<PropertyChangeListener,String> Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, rootFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCatalogTree(String sysname) AbstractCatalogTree(String sysname, String username) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeleteLock(NamedBean lock) voidAdd aPropertyChangeListenerto the listener list.voidaddPropertyChangeListener(PropertyChangeListener l, String beanRef, String listenerRef) Request a call-back when a bound property changes.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Add aPropertyChangeListenerfor a specific property.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener, String beanRef, String listenerRef) Request a call-back when a bound property changes.intcompareSystemNameSuffix(String suffix1, String suffix2, NamedBean n) Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)operation.describeState(int state) Provide human-readable, localized version of state value.voiddispose()Deactivate this object, so that it releases as many resources as possible and no longer effects others.protected voidfirePropertyChange(String p, Object old, Object n) For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.Get associated comment text.Get the textual reference for the specific listenerReturns a list of all the listeners referencesintNumber of current listeners.Get allPropertyChangeListeners currently attached to this object.getPropertyChangeListeners(String propertyName) Get allPropertyChangeListeners currently listening to changes to the specified property.Get a list of all the property change listeners that are registered using a specific namegetRoot()Get the root element of the tree as a jmri.CatalogTreeNode object (Instead of Object, as parent swing.TreeModel provides).intgetState()Provide generic access to internal state.Get a system-specific name.User's identification for the item.voidinsertNodes(String pathToRoot) Starting point to recursively add nodes to the tree by scanning a file directoryabstract voidinsertNodes(String pName, String pPath, CatalogTreeNode pParent) Recursively add nodes to the treebooleanvoidremoveDeleteLock(NamedBean lock) voidRemove the specified listener from this object.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Remove the specified listener of the specified property from this object.voidsetComment(String comment) Set associated comment text.voidsetState(int s) Provide generic access to internal state.voidSet the user name, normalizing it if needed.voidupdateListenerRef(PropertyChangeListener l, String newName) voidMethods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChangedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.NamedBean
compareTo, getDisplayName, getDisplayName, getProperty, getPropertyKeys, getRecommendedToolTip, getUsageReport, removeProperty, setProperty, toStringMethods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, isLeaf, removeTreeModelListener, valueForPathChanged
-
Field Details
-
mSystemName
-
pcs
-
register
-
listenerRefs
-
-
Constructor Details
-
AbstractCatalogTree
-
AbstractCatalogTree
-
-
Method Details
-
getBeanType
Description copied from interface:NamedBeanFor instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanTypein interfaceNamedBean- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
insertNodes
Recursively add nodes to the tree- Specified by:
insertNodesin interfaceCatalogTree- Parameters:
pName- Name of the resource to be scanned; this is only used for the human-readable treepPath- Path to this resource, including the pName partpParent- Node for the parent of the resource to be scanned, e.g. where in the tree to insert it.
-
insertNodes
Starting point to recursively add nodes to the tree by scanning a file directory- Specified by:
insertNodesin interfaceCatalogTree- Parameters:
pathToRoot- Path to Directory to be scanned
-
getRoot
Get the root element of the tree as a jmri.CatalogTreeNode object (Instead of Object, as parent swing.TreeModel provides).- Specified by:
getRootin interfaceCatalogTree- Specified by:
getRootin interfaceTreeModel- Overrides:
getRootin classDefaultTreeModel- Returns:
- the root element
-
getComment
Get associated comment text.- Specified by:
getCommentin interfaceNamedBean- Returns:
- the comment or null
-
setComment
Set associated comment text.Comments can be any valid text.
- Specified by:
setCommentin interfaceNamedBean- Parameters:
comment- Null means no comment associated.
-
addPropertyChangeListener
Description copied from interface:PropertyChangeProviderAdd aPropertyChangeListenerto the listener list.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
l- The PropertyChangeListener to be added
-
addPropertyChangeListener
Description copied from interface:PropertyChangeProviderAdd aPropertyChangeListenerfor a specific property.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to listen on.listener- The PropertyChangeListener to be added
-
removePropertyChangeListener
Description copied from interface:PropertyChangeProviderRemove the specified listener from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
l- ThePropertyChangeListenerto remove.
-
removePropertyChangeListener
Description copied from interface:PropertyChangeProviderRemove the specified listener of the specified property from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to stop listening to.listener- ThePropertyChangeListenerto remove.
-
getPropertyChangeListeners
Description copied from interface:PropertyChangeProviderGet allPropertyChangeListeners currently attached to this object.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
Description copied from interface:PropertyChangeProviderGet allPropertyChangeListeners currently listening to changes to the specified property.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Parameters:
propertyName- the name of the property of interest- Returns:
- an array of PropertyChangeListeners
-
getNumPropertyChangeListeners
Number of current listeners. May return -1 if the information is not available for some reason.- Specified by:
getNumPropertyChangeListenersin interfaceNamedBean- Returns:
- the number of listeners.
-
addPropertyChangeListener
Description copied from interface:NamedBeanRequest a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.- Specified by:
addPropertyChangeListenerin interfaceNamedBean- Parameters:
l- The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internallybeanRef- 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 anotherlistenerRef- A textual reference for the listener, that can be presented to the user when a delete is called
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener, String beanRef, String listenerRef) Description copied from interface:NamedBeanRequest a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.- Specified by:
addPropertyChangeListenerin interfaceNamedBean- Parameters:
propertyName- The name of the property to listen tolistener- The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internallybeanRef- 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 anotherlistenerRef- A textual reference for the listener, that can be presented to the user when a delete is called
-
getPropertyChangeListenersByReference
@CheckReturnValue public PropertyChangeListener[] getPropertyChangeListenersByReference(String name) Description copied from interface:NamedBeanGet a list of all the property change listeners that are registered using a specific name- Specified by:
getPropertyChangeListenersByReferencein interfaceNamedBean- Parameters:
name- The name (either system or user) that the listener has registered as referencing this namedBean- Returns:
- empty list if none
-
getListenerRefs
Description copied from interface:NamedBeanReturns a list of all the listeners references- Specified by:
getListenerRefsin interfaceNamedBean- Returns:
- a list of textual references
-
updateListenerRef
- Specified by:
updateListenerRefin interfaceNamedBean
-
getListenerRef
Description copied from interface:NamedBeanGet the textual reference for the specific listener- Specified by:
getListenerRefin interfaceNamedBean- Parameters:
l- the listener of interest- Returns:
- the textual reference
-
getSystemName
Description copied from interface:NamedBeanGet a system-specific name. This encodes the hardware addressing information. Any given system name must be unique within the layout.- Specified by:
getSystemNamein interfaceNamedBean- Returns:
- the system-specific name
-
getUserName
Description copied from interface:NamedBeanUser's identification for the item. Bound parameter so manager(s) can listen to changes. Any given user name must be unique within the layout. Must not match the system name.- Specified by:
getUserNamein interfaceNamedBean- Returns:
- null if not set
-
setUserName
Description copied from interface:NamedBeanSet the user name, normalizing it if needed.- Specified by:
setUserNamein interfaceNamedBean- Parameters:
s- the new user name
-
firePropertyChange
-
dispose
Description copied from interface:NamedBeanDeactivate 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.
-
getState
Description copied from interface:NamedBeanProvide 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 is provided to make scripts easier to read.
-
describeState
Description copied from interface:NamedBeanProvide human-readable, localized version of state value.This method is intended for use when presenting to a human operator.
- Specified by:
describeStatein interfaceNamedBean- Parameters:
state- the state to describe- Returns:
- the state in localized form
-
setState
Description copied from interface:NamedBeanProvide 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 is provided to make scripts access easier to read.
- Specified by:
setStatein interfaceNamedBean- Parameters:
s- the state- Throws:
JmriException- general error when setting the state fails
-
addDeleteLock
-
removeDeleteLock
-
isDeleteAllowed
-
vetoableChange
- Specified by:
vetoableChangein interfaceNamedBean- Throws:
PropertyVetoException
-
compareSystemNameSuffix
@CheckReturnValue public int compareSystemNameSuffix(@Nonnull String suffix1, @Nonnull String suffix2, @Nonnull NamedBean n) Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)operation. This is intended to be a system-specific comparison that understands the various formats, etc. By default, does an alphanumeric-by-chunks comparison- Specified by:
compareSystemNameSuffixin interfaceNamedBean- Parameters:
suffix1- The suffix for the 1st bean in the comparisonsuffix2- The suffix for the 2nd bean in the comparisonn- The other (second) NamedBean in the comparison- Returns:
- -1,0,+1 for ordering if the names are well-formed; may not provide proper ordering if the names are not well-formed.
-