Package jmri.swing

Class JmriJTablePersistenceManager

    • Method Detail

      • persist

        public void persist​(@Nonnull
                            javax.swing.JTable table,
                            boolean resetState)
                     throws java.lang.IllegalArgumentException,
                            java.lang.NullPointerException
        Persist the user interface state for a table. The name returned by Component.getName() is used to persist the table, so ensure the name is set such that it can be retrieved by the same name in a later JMRI execution.

        Note that the current state of the table, if not already persisted, at the time of this call is retained as the table state unless resetState is true.

        Using this method with resetState set to true is the same as JTablePersistenceManager.resetState(javax.swing.JTable) immediately prior to calling JTablePersistenceManager.persist(javax.swing.JTable).

        Persisting a table that is already persisted may cause the persistence state to be updated, but will not cause additional listeners to be added to the table.

        Specified by:
        persist in interface JTablePersistenceManager
        Parameters:
        table - the table to persist
        resetState - reset the table to the stored state if true; retain the current state if false
        Throws:
        java.lang.IllegalArgumentException - if another table instance is already persisted by the same name
        java.lang.NullPointerException - if the table name is null
      • stopPersisting

        public void stopPersisting​(javax.swing.JTable table)
        Description copied from interface: JTablePersistenceManager
        Stop persisting the table. This does not clear the persistence state, but merely causes the JTablePersistenceManager to stop listening to the table. No error is thrown if the table state was not being persisted.
        Specified by:
        stopPersisting in interface JTablePersistenceManager
        Parameters:
        table - the table to stop persisting
      • clearState

        public void clearState​(javax.swing.JTable table)
        Description copied from interface: JTablePersistenceManager
        Remove the persistent state for a table from the cache. This does not cause the JTablePersistanceManager to stop persisting the table.
        Specified by:
        clearState in interface JTablePersistenceManager
        Parameters:
        table - the table to clear
      • cacheState

        public void cacheState​(javax.swing.JTable table)
        Description copied from interface: JTablePersistenceManager
        Add the current state for a table to the cache. This does not cause the JTablePersistanceManager to start persisting the table.
        Specified by:
        cacheState in interface JTablePersistenceManager
        Parameters:
        table - the table to cache
      • resetState

        public void resetState​(javax.swing.JTable table)
        Description copied from interface: JTablePersistenceManager
        Reset the table state to the cached state. This does not cause the JTablePersistanceManager to start persisting the table.
        Specified by:
        resetState in interface JTablePersistenceManager
        Parameters:
        table - the table to reset
      • setDirty

        protected void setDirty​(boolean dirty)
        Set dirty (needs to be saved) state. Protected so that subclasses can manipulate this state.
        Parameters:
        dirty - true if needs to be saved
      • isDirty

        protected boolean isDirty()
        Get dirty (needs to be saved) state. Protected so that subclasses can manipulate this state.
        Returns:
        true if needs to be saved
      • setPaused

        public void setPaused​(boolean paused)
        Description copied from interface: JTablePersistenceManager
        Pause saving persistence data to storage. If setting paused to false, pending persistence data is written immediately.
        Specified by:
        setPaused in interface JTablePersistenceManager
        Parameters:
        paused - true if saving persistence data should be paused; false otherwise.
      • savePreferences

        public void savePreferences​(Profile profile)
        Description copied from interface: PreferencesManager
        Save the preferences that this provider manages for the provided Profile.
        Specified by:
        savePreferences in interface PreferencesManager
        Parameters:
        profile - the profile associated with the preferences to save; may be null to save preferences that apply to the current user regardless of profile
      • getProvides

        @Nonnull
        public java.util.Set<java.lang.Class<?>> getProvides()
        Description copied from class: AbstractPreferencesManager
        Get the set of Classes that this PreferencesManager can be registered as a provider of in the InstanceManager.

        This implementation returns the class of the object against which this method is called.

        Specified by:
        getProvides in interface PreferencesManager
        Overrides:
        getProvides in class AbstractPreferencesManager
        Returns:
        A set or list of classes. If this PreferencesManager provides an instance of no other Interfaces or abstract Classes than PreferencesManager, return an empty set instead of null.
      • setPersistedState

        protected void setPersistedState​(@Nonnull
                                         java.lang.String table,
                                         @Nonnull
                                         java.lang.String column,
                                         int order,
                                         int width,
                                         javax.swing.SortOrder sort,
                                         boolean hidden)
        Set the persisted state for the given column in the given table. The persisted state is not saved until savePreferences(jmri.profile.Profile) is called.
        Parameters:
        table - the table name
        column - the column name
        order - order of the column
        width - column preferredWidth
        sort - how the column is sorted
        hidden - true if column is hidden
        Throws:
        java.lang.NullPointerException - if either name is null
      • isPersisting

        public boolean isPersisting​(java.lang.String name)
        Description copied from interface: JTablePersistenceManager
        Determine if a table is being persisted by name.
        Specified by:
        isPersisting in interface JTablePersistenceManager
        Parameters:
        name - the name of the table to check against
        Returns:
        true if the table is being persisted; false otherwise
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener