Class DefaultGlobalVariableManager

    • Method Detail

      • getXMLOrder

        public int getXMLOrder()
        Description copied from interface: Manager
        Determine the order that types should be written when storing panel files. Uses one of the constants defined in this class.

        Yes, that's an overly-centralized methodology, but it works for now.

        Specified by:
        getXMLOrder in interface Manager<GlobalVariable>
        Returns:
        write order for this Manager; larger is later.
      • createGlobalVariable

        public GlobalVariable createGlobalVariable​(java.lang.String systemName,
                                                   java.lang.String userName)
                                            throws java.lang.IllegalArgumentException
        Method to create a new GlobalVariable if the GlobalVariable does not exist.

        Returns null if a GlobalVariable with the same systemName or userName already exists, or if there is trouble creating a new GlobalVariable.

        Specified by:
        createGlobalVariable in interface GlobalVariableManager
        Parameters:
        systemName - the system name
        userName - the user name
        Returns:
        a new GlobalVariable or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • createGlobalVariable

        public GlobalVariable createGlobalVariable​(java.lang.String userName)
                                            throws java.lang.IllegalArgumentException
        Description copied from interface: GlobalVariableManager
        For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.
        Specified by:
        createGlobalVariable in interface GlobalVariableManager
        Parameters:
        userName - the user name
        Returns:
        a new GlobalVariable or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • getBeanTypeHandled

        public java.lang.String getBeanTypeHandled​(boolean plural)
        Get the user-readable name of the type of NamedBean handled by this manager.

        For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.

        Specified by:
        getBeanTypeHandled in interface Manager<GlobalVariable>
        Parameters:
        plural - true to return plural form of the type; false to return singular form
        Returns:
        a string of the bean type that the manager handles, eg Turnout, Sensor etc
      • printTree

        public void printTree​(java.util.Locale locale,
                              java.io.PrintWriter writer,
                              java.lang.String indent)
        Print the tree to a stream.
        Specified by:
        printTree in interface GlobalVariableManager
        Parameters:
        locale - The locale to be used
        writer - the stream to print the tree to
        indent - the indentation of each level
      • fireVetoableChange

        @OverridingMethodsMustInvokeSuper
        public void fireVetoableChange​(java.lang.String p,
                                       java.lang.Object old)
                                throws java.beans.PropertyVetoException
        Inform all registered listeners of a vetoable change.If the propertyName is "CanDelete" ALL listeners with an interest in the bean will throw an exception, which is recorded returned back to the invoking method, so that it can be presented back to the user.However if a listener decides that the bean can not be deleted then it should throw an exception with a property name of "DoNotDelete", this is thrown back up to the user and the delete process should be aborted.
        Parameters:
        p - The programmatic name of the property that is to be changed. "CanDelete" will inquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item.
        old - The old value of the property.
        Throws:
        java.beans.PropertyVetoException - If the recipients wishes the delete to be aborted (see above)
      • deleteBean

        public final void deleteBean​(@Nonnull
                                     GlobalVariable globalVariable,
                                     @Nonnull
                                     java.lang.String property)
                              throws java.beans.PropertyVetoException
        Method for a UI to delete a bean.

        The UI should first request a "CanDelete", this will return a list of locations (and descriptions) where the bean is in use via throwing a VetoException, then if that comes back clear, or the user agrees with the actions, then a "DoDelete" can be called which inform the listeners to delete the bean, then it will be deregistered and disposed of.

        If a property name of "DoNotDelete" is thrown back in the VetoException then the delete process should be aborted.

        Specified by:
        deleteBean in interface Manager<GlobalVariable>
        Overrides:
        deleteBean in class AbstractManager<GlobalVariable>
        Parameters:
        globalVariable - The NamedBean to be deleted
        property - The programmatic name of the request. "CanDelete" will enquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item
        Throws:
        java.beans.PropertyVetoException - If the recipients wishes the delete to be aborted (see above)