Package jmri.beans

Class PreferencesBean

    • Constructor Detail

      • PreferencesBean

        public PreferencesBean​(Profile profile)
        Create the PreferencesBean.
        Parameters:
        profile - the Profile this PreferencesBean is associated with; if null is not associated with a Profile, but applies application wide
    • Method Detail

      • getProfile

        @Nonnull
        public Profile getProfile()
        Get the profile associated with this PreferencesBean.
        Returns:
        the profile
      • isDirty

        public boolean isDirty()
        Check if this preferences bean has a state that needs to be saved.
        Returns:
        true if unsaved; false otherwise
      • isRestartRequired

        public boolean isRestartRequired()
        Check if this preferences bean requires the application to be restarted to take effect.
        Returns:
        true if a restart is required; false otherwise
      • setRestartRequired

        protected void setRestartRequired()
        Set if restart needs to be required for some preferences to take effect.
      • setIsDirty

        protected void setIsDirty​(boolean value)
        Set if preferences need to be saved.
        Parameters:
        value - true to indicate need to save; false otherwise
      • firePropertyChange

        public void firePropertyChange​(String propertyName,
                                       Object oldValue,
                                       Object newValue)
        Fire a property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.

        As a side effect, calls to isDirty will return true if oldValue and newValue differ or are null.

        Specified by:
        firePropertyChange in interface PropertyChangeFirer
        Overrides:
        firePropertyChange in class Bean
        Parameters:
        propertyName - the programmatic name of the property that was changed
        oldValue - the old value of the property
        newValue - the new value of the property
      • firePropertyChange

        public void firePropertyChange​(String propertyName,
                                       boolean oldValue,
                                       boolean newValue)
        Fire a property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.

        As a side effect, calls to isDirty will return true if oldValue and newValue differ and propertyName is not "dirty".

        Specified by:
        firePropertyChange in interface PropertyChangeFirer
        Overrides:
        firePropertyChange in class Bean
        Parameters:
        propertyName - the programmatic name of the property that was changed
        oldValue - the old value of the property
        newValue - the new value of the property
      • firePropertyChange

        public void firePropertyChange​(String propertyName,
                                       int oldValue,
                                       int newValue)
        Fire a property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.

        As a side effect, calls to isDirty will return true if oldValue and newValue differ.

        Specified by:
        firePropertyChange in interface PropertyChangeFirer
        Overrides:
        firePropertyChange in class Bean
        Parameters:
        propertyName - the programmatic name of the property that was changed
        oldValue - the old value of the property
        newValue - the new value of the property