Class JmriJTablePersistenceManager
- All Implemented Interfaces:
PropertyChangeListener,EventListener,BeanInterface,PropertyChangeFirer,PropertyChangeProvider,JmriServiceProviderInterface,PreferencesManager,JTablePersistenceManager
JTablePersistenceManager. The column
preferredWidth retained for a column is the
TableColumn.getPreferredWidth(), since this preferredWidth is
available before the table column is rendered by Swing.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classstatic final classHandler for individual column preferences. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HashMap<String,HashMap<String, JmriJTablePersistenceManager.TableColumnPreferences>> protected final HashMap<String,JmriJTablePersistenceManager.JTableListener> final Stringstatic final Stringprotected final HashMap<String,List<RowSorter.SortKey>> static final Stringstatic final StringFields inherited from class jmri.beans.Bean
propertyChangeSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheState(JTable table) Add the current state for a table to the cache.voidclearState(JTable table) Remove the persistent state for a table from the cache.Get the set of Classes that this PreferencesManager can be registered as a provider of in theInstanceManager.voidinitialize(Profile profile) Initialize the PreferencesManager with preferences associated with the provided Profile.protected booleanisDirty()Get dirty (needs to be saved) state.booleanisPaused()Determine if saving persistence data is paused.booleanDetermine if persistence data is being held for a table.booleanisPersistenceDataRetained(JTable table) Determine if persistence data is being held for a table.booleanisPersisting(String name) Determine if a table is being persisted by name.booleanisPersisting(JTable table) Determine if a table is being persisted.voidPersist the user interface state for a table.voidvoidresetState(JTable table) Reset the table state to the cached state.voidsavePreferences(Profile profile) Save the preferences that this provider manages for the provided Profile.protected voidsetDirty(boolean dirty) Set dirty (needs to be saved) state.voidsetPaused(boolean paused) Pause saving persistence data to storage.protected voidsetPersistedState(String table, String column, int order, int width, SortOrder sort, boolean hidden) Set the persisted state for the given column in the given table.voidstopPersisting(JTable table) Stop persisting the table.Methods inherited from class jmri.util.prefs.AbstractPreferencesManager
addInitializationException, getInitializationExceptions, getRequires, isInitialized, isInitializedWithExceptions, isInitializing, requireAllOther, requiresNoInitializedWithExceptions, requiresNoInitializedWithExceptions, setInitialized, setInitializingMethods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.swing.JTablePersistenceManager
persist
-
Field Details
-
listeners
-
columns
-
sortKeys
-
PAUSED
- See Also:
-
TABLES_NAMESPACE
- See Also:
-
TABLES_ELEMENT
- See Also:
-
SORT_ORDER
- See Also:
-
-
Constructor Details
-
JmriJTablePersistenceManager
public JmriJTablePersistenceManager()
-
-
Method Details
-
persist
public void persist(@Nonnull JTable table, boolean resetState) throws IllegalArgumentException, NullPointerException Persist the user interface state for a table. The name returned byComponent.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
resetStateis true.Using this method with
resetStateset to true is the same asJTablePersistenceManager.resetState(javax.swing.JTable)immediately prior to callingJTablePersistenceManager.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:
persistin interfaceJTablePersistenceManager- Parameters:
table- the table to persistresetState- reset the table to the stored state if true; retain the current state if false- Throws:
IllegalArgumentException- if another table instance is already persisted by the same nameNullPointerException- if the table name is null
-
stopPersisting
Description copied from interface:JTablePersistenceManagerStop 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:
stopPersistingin interfaceJTablePersistenceManager- Parameters:
table- the table to stop persisting
-
clearState
Description copied from interface:JTablePersistenceManagerRemove the persistent state for a table from the cache. This does not cause the JTablePersistanceManager to stop persisting the table.- Specified by:
clearStatein interfaceJTablePersistenceManager- Parameters:
table- the table to clear
-
cacheState
Description copied from interface:JTablePersistenceManagerAdd the current state for a table to the cache. This does not cause the JTablePersistanceManager to start persisting the table.- Specified by:
cacheStatein interfaceJTablePersistenceManager- Parameters:
table- the table to cache
-
resetState
Description copied from interface:JTablePersistenceManagerReset the table state to the cached state. This does not cause the JTablePersistanceManager to start persisting the table.- Specified by:
resetStatein interfaceJTablePersistenceManager- Parameters:
table- the table to reset
-
setDirty
Set dirty (needs to be saved) state. Protected so that subclasses can manipulate this state.- Parameters:
dirty- true if needs to be saved
-
isDirty
Get dirty (needs to be saved) state. Protected so that subclasses can manipulate this state.- Returns:
- true if needs to be saved
-
setPaused
Description copied from interface:JTablePersistenceManagerPause saving persistence data to storage. If setting paused to false, pending persistence data is written immediately.- Specified by:
setPausedin interfaceJTablePersistenceManager- Parameters:
paused- true if saving persistence data should be paused; false otherwise.
-
isPaused
Description copied from interface:JTablePersistenceManagerDetermine if saving persistence data is paused.- Specified by:
isPausedin interfaceJTablePersistenceManager- Returns:
- true if saving persistence data is paused; false otherwise.
-
initialize
Description copied from interface:PreferencesManagerInitialize the PreferencesManager with preferences associated with the provided Profile.Implementing classes should throw an InitializationException with a user readable localized message, since it most likely be displayed to the user. Implementing classes will still want to ensure that
PreferencesManager.isInitialized(jmri.profile.Profile)orPreferencesManager.isInitializedWithExceptions(jmri.profile.Profile)return true if throwing an InitializationException to ensure that the provider is not repeatedly initialized.- Specified by:
initializein interfacePreferencesManager- Parameters:
profile- the configuration profile used for this initialization; may be null to initialize for this user regardless of profile- Throws:
InitializationException- if the user needs to be notified of an issue that prevents regular use of the application
-
savePreferences
Description copied from interface:PreferencesManagerSave the preferences that this provider manages for the provided Profile.- Specified by:
savePreferencesin interfacePreferencesManager- 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
Description copied from class:AbstractPreferencesManagerGet the set of Classes that this PreferencesManager can be registered as a provider of in theInstanceManager.This implementation returns the class of the object against which this method is called.
- Specified by:
getProvidesin interfacePreferencesManager- Overrides:
getProvidesin classAbstractPreferencesManager- 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 String table, @Nonnull String column, int order, int width, SortOrder sort, boolean hidden) Set the persisted state for the given column in the given table. The persisted state is not saved untilsavePreferences(jmri.profile.Profile)is called.- Parameters:
table- the table namecolumn- the column nameorder- order of the columnwidth- column preferredWidthsort- how the column is sortedhidden- true if column is hidden- Throws:
NullPointerException- if either name is null
-
isPersistenceDataRetained
Description copied from interface:JTablePersistenceManagerDetermine if persistence data is being held for a table.- Specified by:
isPersistenceDataRetainedin interfaceJTablePersistenceManager- Parameters:
table- the table to check against- Returns:
- true if the table has persistence data; false otherwise
-
isPersistenceDataRetained
Description copied from interface:JTablePersistenceManagerDetermine if persistence data is being held for a table.- Specified by:
isPersistenceDataRetainedin interfaceJTablePersistenceManager- Parameters:
name- the name of the table to check against- Returns:
- true if the table has persistence data; false otherwise
-
isPersisting
Description copied from interface:JTablePersistenceManagerDetermine if a table is being persisted.- Specified by:
isPersistingin interfaceJTablePersistenceManager- Parameters:
table- the table to check against- Returns:
- true if the table is being persisted; false otherwise
-
isPersisting
Description copied from interface:JTablePersistenceManagerDetermine if a table is being persisted by name.- Specified by:
isPersistingin interfaceJTablePersistenceManager- Parameters:
name- the name of the table to check against- Returns:
- true if the table is being persisted; false otherwise
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-