Class AbstractCatalogTree

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addDeleteLock​(NamedBean lock)  
      void addPropertyChangeListener​(java.beans.PropertyChangeListener l)
      Add a PropertyChangeListener to the listener list.
      void addPropertyChangeListener​(java.beans.PropertyChangeListener l, java.lang.String beanRef, java.lang.String listenerRef)
      Request a call-back when a bound property changes.
      void addPropertyChangeListener​(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
      Add a PropertyChangeListener for a specific property.
      void addPropertyChangeListener​(java.lang.String propertyName, java.beans.PropertyChangeListener listener, java.lang.String beanRef, java.lang.String listenerRef)
      Request a call-back when a bound property changes.
      int compareSystemNameSuffix​(java.lang.String suffix1, java.lang.String suffix2, NamedBean n)
      Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for the NamedBean.compareTo(jmri.NamedBean) operation.
      java.lang.String describeState​(int state)
      Provide human-readable, localized version of state value.
      void dispose()
      Deactivate this object, so that it releases as many resources as possible and no longer effects others.
      protected void firePropertyChange​(java.lang.String p, java.lang.Object old, java.lang.Object n)  
      java.lang.String getBeanType()
      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.
      java.lang.String getComment()
      Get associated comment text.
      java.lang.String getListenerRef​(java.beans.PropertyChangeListener l)
      Get the textual reference for the specific listener
      java.util.ArrayList<java.lang.String> getListenerRefs()
      Returns a list of all the listeners references
      int getNumPropertyChangeListeners()
      Number of current listeners.
      java.beans.PropertyChangeListener[] getPropertyChangeListeners()
      Get all PropertyChangeListeners currently attached to this object.
      java.beans.PropertyChangeListener[] getPropertyChangeListeners​(java.lang.String propertyName)
      Get all PropertyChangeListeners currently listening to changes to the specified property.
      java.beans.PropertyChangeListener[] getPropertyChangeListenersByReference​(java.lang.String name)
      Get a list of all the property change listeners that are registered using a specific name
      CatalogTreeNode getRoot()
      Get the root element of the tree as a jmri.CatalogTreeNode object (Instead of Object, as parent swing.TreeModel provides).
      int getState()
      Provide generic access to internal state.
      java.lang.String getSystemName()
      Get a system-specific name.
      java.lang.String getUserName()
      User's identification for the item.
      void insertNodes​(java.lang.String pathToRoot)
      Starting point to recursively add nodes to the tree by scanning a file directory
      abstract void insertNodes​(java.lang.String pName, java.lang.String pPath, CatalogTreeNode pParent)
      Recursively add nodes to the tree
      boolean isDeleteAllowed()  
      void removeDeleteLock​(NamedBean lock)  
      void removePropertyChangeListener​(java.beans.PropertyChangeListener l)
      Remove the specified listener from this object.
      void removePropertyChangeListener​(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
      Remove the specified listener of the specified property from this object.
      void setComment​(java.lang.String comment)
      Set associated comment text.
      void setState​(int s)
      Provide generic access to internal state.
      void setUserName​(java.lang.String s)
      Set the user name, normalizing it if needed.
      void updateListenerRef​(java.beans.PropertyChangeListener l, java.lang.String newName)  
      void vetoableChange​(java.beans.PropertyChangeEvent evt)  
      • Methods 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, valueForPathChanged
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.tree.TreeModel

        addTreeModelListener, getChild, getChildCount, getIndexOfChild, isLeaf, removeTreeModelListener, valueForPathChanged
    • Field Detail

      • mSystemName

        protected final java.lang.String mSystemName
      • pcs

        java.beans.PropertyChangeSupport pcs
      • register

        java.util.HashMap<java.beans.PropertyChangeListener,​java.lang.String> register
      • listenerRefs

        java.util.HashMap<java.beans.PropertyChangeListener,​java.lang.String> listenerRefs
    • Method Detail

      • getBeanType

        @CheckReturnValue
        public java.lang.String getBeanType()
        Description copied from interface: NamedBean
        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.
        Specified by:
        getBeanType in interface NamedBean
        Returns:
        a string of the bean type, eg Turnout, Sensor etc
      • insertNodes

        public abstract void insertNodes​(java.lang.String pName,
                                         java.lang.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​(java.lang.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
      • getRoot

        @CheckReturnValue
        public CatalogTreeNode getRoot()
        Get the root element of the tree as a jmri.CatalogTreeNode object (Instead of Object, as parent swing.TreeModel provides).
        Specified by:
        getRoot in interface CatalogTree
        Specified by:
        getRoot in interface javax.swing.tree.TreeModel
        Overrides:
        getRoot in class javax.swing.tree.DefaultTreeModel
        Returns:
        the root element
      • setComment

        public void setComment​(java.lang.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.
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener l,
                                              java.lang.String beanRef,
                                              java.lang.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 - The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internally
        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
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.lang.String propertyName,
                                              java.beans.PropertyChangeListener listener,
                                              java.lang.String beanRef,
                                              java.lang.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:
        propertyName - The name of the property to listen to
        listener - The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internally
        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
      • getListenerRef

        @CheckReturnValue
        public java.lang.String getListenerRef​(java.beans.PropertyChangeListener l)
        Description copied from interface: NamedBean
        Get the textual reference for the specific listener
        Specified by:
        getListenerRef in interface NamedBean
        Parameters:
        l - the listener of interest
        Returns:
        the textual reference
      • getSystemName

        @CheckReturnValue
        public java.lang.String getSystemName()
        Description copied from interface: NamedBean
        Get a system-specific name. This encodes the hardware addressing information. Any given system name must be unique within the layout.
        Specified by:
        getSystemName in interface NamedBean
        Returns:
        the system-specific name
      • getUserName

        @CheckReturnValue
        public java.lang.String getUserName()
        Description copied from interface: NamedBean
        User'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:
        getUserName in interface NamedBean
        Returns:
        null if not set
      • setUserName

        public void setUserName​(java.lang.String s)
        Description copied from interface: NamedBean
        Set the user name, normalizing it if needed.
        Specified by:
        setUserName in interface NamedBean
        Parameters:
        s - the new user name
      • firePropertyChange

        protected void firePropertyChange​(java.lang.String p,
                                          java.lang.Object old,
                                          java.lang.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

        @CheckReturnValue
        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 is provided to make scripts easier to read.

        Specified by:
        getState in interface NamedBean
        Returns:
        the state
      • describeState

        @CheckReturnValue
        public java.lang.String describeState​(int state)
        Description copied from interface: NamedBean
        Provide human-readable, localized version of state value.

        This method is intended for use when presenting to a human operator.

        Specified by:
        describeState in interface NamedBean
        Parameters:
        state - the state to describe
        Returns:
        the state in localized form
      • 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 is provided to make scripts access easier to read.

        Specified by:
        setState in interface NamedBean
        Parameters:
        s - the state
        Throws:
        JmriException - general error when setting the state fails
      • vetoableChange

        public void vetoableChange​(java.beans.PropertyChangeEvent evt)
                            throws java.beans.PropertyVetoException
        Specified by:
        vetoableChange in interface NamedBean
        Throws:
        java.beans.PropertyVetoException
      • compareSystemNameSuffix

        @CheckReturnValue
        public int compareSystemNameSuffix​(@Nonnull
                                           java.lang.String suffix1,
                                           @Nonnull
                                           java.lang.String suffix2,
                                           @Nonnull
                                           NamedBean n)
        Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for the NamedBean.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:
        compareSystemNameSuffix in interface NamedBean
        Parameters:
        suffix1 - The suffix for the 1st bean in the comparison
        suffix2 - The suffix for the 2nd bean in the comparison
        n - 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.