Package jmri.implementation
Class JmriConfigurationManager
- java.lang.Object
-
- jmri.implementation.JmriConfigurationManager
-
- All Implemented Interfaces:
ConfigureManager
- Direct Known Subclasses:
AppsConfigurationManager
public class JmriConfigurationManager extends java.lang.Object implements ConfigureManager
-
-
Constructor Summary
Constructors Constructor Description JmriConfigurationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deregister(java.lang.Object o)
protected void
displayErrorListDialog(java.lang.Object list)
java.net.URL
find(java.lang.String filename)
Provide a method-specific way of locating a file to be loaded from a name.java.lang.Object
findInstance(java.lang.Class<?> c, int index)
Find the ith instance of an object of particular class that's been registered for storage.java.util.HashMap<PreferencesManager,InitializationException>
getInitializationExceptions()
java.util.List<java.lang.Object>
getInstanceList(java.lang.Class<?> c)
Returns a list of instances stored for a given class.XmlFile.Validate
getValidate()
Get the scope of validation of XML files when loading.protected void
handleQuit()
protected void
handleRestart()
protected boolean
isEditDialogRestart()
boolean
load(java.io.File file)
Create the objects defined in a particular configuration fileboolean
load(java.io.File file, boolean registerDeferred)
Create the objects defined in a particular configuration fileboolean
load(java.net.URL url)
Create the objects defined in a particular configuration fileboolean
load(java.net.URL url, boolean registerDeferred)
Create the objects defined in a particular configuration fileboolean
loadDeferred(java.io.File file)
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completedboolean
loadDeferred(java.net.URL file)
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completedboolean
makeBackup(java.io.File file)
Make a backup file.void
registerConfig(java.lang.Object o)
void
registerConfig(java.lang.Object o, int x)
void
registerPref(java.lang.Object o)
void
registerTool(java.lang.Object o)
void
registerUser(java.lang.Object o)
void
registerUserPrefs(java.lang.Object o)
void
removePrefItems()
void
setValidate(XmlFile.Validate v)
Control the scope of validation of XML files when loading.boolean
storeConfig(java.io.File file)
Stores just configuration information.void
storePrefs()
Save preferences.void
storePrefs(java.io.File file)
Save preferences.boolean
storeUser(java.io.File file)
Stores user and config information.void
storeUserPrefs(java.io.File file)
Stores just user preferences information.
-
-
-
Constructor Detail
-
JmriConfigurationManager
public JmriConfigurationManager()
-
-
Method Detail
-
registerPref
public void registerPref(java.lang.Object o)
- Specified by:
registerPref
in interfaceConfigureManager
-
removePrefItems
public void removePrefItems()
- Specified by:
removePrefItems
in interfaceConfigureManager
-
registerConfig
public void registerConfig(java.lang.Object o)
- Specified by:
registerConfig
in interfaceConfigureManager
-
registerConfig
public void registerConfig(java.lang.Object o, int x)
- Specified by:
registerConfig
in interfaceConfigureManager
-
registerTool
public void registerTool(java.lang.Object o)
- Specified by:
registerTool
in interfaceConfigureManager
-
registerUser
public void registerUser(java.lang.Object o)
- Specified by:
registerUser
in interfaceConfigureManager
-
registerUserPrefs
public void registerUserPrefs(java.lang.Object o)
- Specified by:
registerUserPrefs
in interfaceConfigureManager
-
deregister
public void deregister(java.lang.Object o)
- Specified by:
deregister
in interfaceConfigureManager
-
findInstance
public java.lang.Object findInstance(java.lang.Class<?> c, int index)
Description copied from interface:ConfigureManager
Find the ith instance of an object of particular class that's been registered for storage.Note that the index of an object can change when other objects are stored or removed. The index is for indexing over the objects stored at a moment, not for use as an identification number.
There may be synchronization issues associated with this, although they are expected to be rare in practice.
- Specified by:
findInstance
in interfaceConfigureManager
- Parameters:
c
- Class of the desired objectsindex
- a 1-based index of the object to return- Returns:
- an object of class c or null
-
getInstanceList
public java.util.List<java.lang.Object> getInstanceList(java.lang.Class<?> c)
Description copied from interface:ConfigureManager
Returns a list of instances stored for a given class.- Specified by:
getInstanceList
in interfaceConfigureManager
- Parameters:
c
- Class of the desired objects- Returns:
- an List of objects of class c or null
-
storePrefs
public void storePrefs()
Save preferences. Preferences are saved using either theJmriConfigurationProvider
orJmriPreferencesProvider
as appropriate to the register preferences handler.- Specified by:
storePrefs
in interfaceConfigureManager
-
storePrefs
public void storePrefs(java.io.File file)
Save preferences. This method callsstorePrefs()
.- Specified by:
storePrefs
in interfaceConfigureManager
- Parameters:
file
- Ignored.
-
storeUserPrefs
public void storeUserPrefs(java.io.File file)
Description copied from interface:ConfigureManager
Stores just user preferences information.- Specified by:
storeUserPrefs
in interfaceConfigureManager
- Parameters:
file
- the file to store user preferences into
-
storeConfig
public boolean storeConfig(java.io.File file)
Description copied from interface:ConfigureManager
Stores just configuration information.- Specified by:
storeConfig
in interfaceConfigureManager
- Parameters:
file
- Output file- Returns:
- true if successful; false otherwise
-
storeUser
public boolean storeUser(java.io.File file)
Description copied from interface:ConfigureManager
Stores user and config information.- Specified by:
storeUser
in interfaceConfigureManager
- Parameters:
file
- Output file- Returns:
- true if succeeded
-
load
public boolean load(java.io.File file) throws JmriException
Description copied from interface:ConfigureManager
Create the objects defined in a particular configuration file- Specified by:
load
in interfaceConfigureManager
- Parameters:
file
- Input file- Returns:
- true if succeeded
- Throws:
JmriException
- if unable to load file due to internal error
-
load
public boolean load(java.net.URL url) throws JmriException
Description copied from interface:ConfigureManager
Create the objects defined in a particular configuration file- Specified by:
load
in interfaceConfigureManager
- Parameters:
url
- Input URL- Returns:
- true if succeeded
- Throws:
JmriException
- if unable to load URL due to internal error
-
load
public boolean load(java.io.File file, boolean registerDeferred) throws JmriException
Description copied from interface:ConfigureManager
Create the objects defined in a particular configuration file- Specified by:
load
in interfaceConfigureManager
- Parameters:
file
- Input fileregisterDeferred
- true to register actions for deferred load- Returns:
- true if succeeded
- Throws:
JmriException
- if problem during load
-
load
public boolean load(java.net.URL url, boolean registerDeferred) throws JmriException
Description copied from interface:ConfigureManager
Create the objects defined in a particular configuration file- Specified by:
load
in interfaceConfigureManager
- Parameters:
url
- Input URLregisterDeferred
- true to register actions for deferred load- Returns:
- true if succeeded
- Throws:
JmriException
- if problem during load
-
displayErrorListDialog
protected void displayErrorListDialog(java.lang.Object list)
-
isEditDialogRestart
protected boolean isEditDialogRestart()
-
handleRestart
protected void handleRestart()
-
handleQuit
protected void handleQuit()
-
loadDeferred
public boolean loadDeferred(java.io.File file)
Description copied from interface:ConfigureManager
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completed- Specified by:
loadDeferred
in interfaceConfigureManager
- Parameters:
file
- Input file- Returns:
- true if succeeded
- See Also:
XmlAdapter.loadDeferred()
-
loadDeferred
public boolean loadDeferred(java.net.URL file)
Description copied from interface:ConfigureManager
Create the objects defined in a particular configuration file that have been deferred until after basic GUI construction completed- Specified by:
loadDeferred
in interfaceConfigureManager
- Parameters:
file
- Input URL- Returns:
- true if succeeded
- See Also:
XmlAdapter.loadDeferred()
-
find
public java.net.URL find(java.lang.String filename)
Description copied from interface:ConfigureManager
Provide a method-specific way of locating a file to be loaded from a name.- Specified by:
find
in interfaceConfigureManager
- Parameters:
filename
- Local filename, perhaps without path information- Returns:
- Corresponding
URL
-
makeBackup
public boolean makeBackup(java.io.File file)
Description copied from interface:ConfigureManager
Make a backup file.- Specified by:
makeBackup
in interfaceConfigureManager
- Parameters:
file
- to be backed up- Returns:
- true if successful
-
getInitializationExceptions
public java.util.HashMap<PreferencesManager,InitializationException> getInitializationExceptions()
-
setValidate
public void setValidate(XmlFile.Validate v)
Description copied from interface:ConfigureManager
Control the scope of validation of XML files when loading.- Specified by:
setValidate
in interfaceConfigureManager
- Parameters:
v
- the validation scope
-
getValidate
public XmlFile.Validate getValidate()
Description copied from interface:ConfigureManager
Get the scope of validation of XML files when loading.- Specified by:
getValidate
in interfaceConfigureManager
- Returns:
- the validation scope
-
-