Class DefaultConditionalNGManager

    • Method Detail

      • getXMLOrder

        public int getXMLOrder()
        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<ConditionalNG>
        Returns:
        write order for this Manager; larger is later.
      • createConditionalNG

        public ConditionalNG createConditionalNG​(LogixNG logixNG,
                                                 java.lang.String systemName,
                                                 java.lang.String userName)
                                          throws java.lang.IllegalArgumentException
        Create a new ConditionalNG if the ConditionalNG does not exist.
        Specified by:
        createConditionalNG in interface ConditionalNG_Manager
        Parameters:
        logixNG - The parent LogixNG
        systemName - The system name
        userName - The user name
        Returns:
        a new ConditionalNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • createConditionalNG

        public ConditionalNG createConditionalNG​(LogixNG logixNG,
                                                 java.lang.String systemName,
                                                 java.lang.String userName,
                                                 int threadID)
                                          throws java.lang.IllegalArgumentException
        Create a new ConditionalNG if the ConditionalNG does not exist.
        Specified by:
        createConditionalNG in interface ConditionalNG_Manager
        Parameters:
        logixNG - The parent LogixNG
        systemName - The system name
        userName - The user name
        threadID - The thread ID that this ConditionalNG will execute on
        Returns:
        a new ConditionalNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • createConditionalNG

        public ConditionalNG createConditionalNG​(LogixNG logixNG,
                                                 java.lang.String userName)
                                          throws java.lang.IllegalArgumentException
        For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.
        Specified by:
        createConditionalNG in interface ConditionalNG_Manager
        Parameters:
        logixNG - The parent LogixNG
        userName - The user name
        Returns:
        a new ConditionalNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • createConditionalNG

        public ConditionalNG createConditionalNG​(LogixNG logixNG,
                                                 java.lang.String userName,
                                                 int threadID)
                                          throws java.lang.IllegalArgumentException
        For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.
        Specified by:
        createConditionalNG in interface ConditionalNG_Manager
        Parameters:
        logixNG - The parent LogixNG
        userName - The user name
        threadID - The thread ID that this ConditionalNG will execute on
        Returns:
        a new ConditionalNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • getConditionalNG

        public ConditionalNG getConditionalNG​(LogixNG logixNG,
                                              java.lang.String name)
        Locate via user name using the LogixNG, then system name if needed. Does not create a new one if nothing found
        Specified by:
        getConditionalNG in interface ConditionalNG_Manager
        Parameters:
        logixNG - The LogixNG for the user name match. If null, only do a system name match.
        name - User name or system name to match
        Returns:
        null if no match found
      • getParentLogixNG

        public LogixNG getParentLogixNG​(java.lang.String systemName)
        Find the LogixNG which has the ConditionalNG system name in its ConditionalNG_Entry list.
        Specified by:
        getParentLogixNG in interface ConditionalNG_Manager
        Parameters:
        systemName - The ConditionalNG system name.
        Returns:
        the parent LogixNG or null if none found.
      • getByUserName

        public ConditionalNG getByUserName​(LogixNG logixNG,
                                           java.lang.String name)
        Find the ConditionalNG which is a member of the LogixNG with the supplied user name.
        Specified by:
        getByUserName in interface ConditionalNG_Manager
        Parameters:
        logixNG - The LogixNG that contains the requested ConditionalNG.
        name - The requested ConditionalNG user name.
        Returns:
        the ConditionalNG or null if none found.
      • 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<ConditionalNG>
        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
      • setRunOnGUIDelayed

        public void setRunOnGUIDelayed​(boolean value)
        Set whenether execute() should run on the GUI thread at once or should dispatch the call until later, for all ConditionalNGs registered in this manager. Most tests turns off the delay to simplify the tests.
        Specified by:
        setRunOnGUIDelayed in interface ConditionalNG_Manager
        Parameters:
        value - true if execute() should run on GUI thread delayed, false otherwise.
      • 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
                                     ConditionalNG conditionalNG,
                                     @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<ConditionalNG>
        Overrides:
        deleteBean in class AbstractManager<ConditionalNG>
        Parameters:
        conditionalNG - 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)