Package com.biglybt.pifimpl.local.config
Class PluginConfigSourceImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.config.PluginConfigSourceImpl
-
- All Implemented Interfaces:
COConfigurationListener
,ParameterListener
,PluginConfigSource
public class PluginConfigSourceImpl extends java.lang.Object implements COConfigurationListener, ParameterListener, PluginConfigSource
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
data_map
private boolean
dirty
private boolean
initialised
private java.lang.String
key_prefix
private boolean
migrate_settings
private LightHashSet
params_monitored
private PluginConfig
plugin_config
private java.io.File
source_file
-
Constructor Summary
Constructors Constructor Description PluginConfigSourceImpl(PluginConfig plugin_config, java.lang.String plugin_id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configurationSaved()
void
forceSettingsMigration()
If your plugin previously used to store data in the main configuration file, you can call this method (which needs to be done soon after initialization) which will move all monitored parameters over to this object.java.io.File
getConfigFile()
Returns a file object which represents the location of the configuration file that this object interacts with.java.lang.String
getUsedKeyPrefix()
void
initialize()
This initializes this configuration object and gets the external configuration file integrated with the client.void
parameterChanged(java.lang.String full_param)
Called, when a parameter has changed.void
registerParameter(java.lang.String full_param)
void
save(boolean force)
Manually saves the configuration settings recorded by this object to disk.void
setConfigFilename(java.lang.String filename)
This method sets the filename for the configuration file that this object links to - this must be done before thePluginConfigSource.initialize()
method is called.private void
shouldBeInitialised(boolean yes)
private java.lang.String
toPluginName(java.lang.String name)
-
-
-
Field Detail
-
plugin_config
private PluginConfig plugin_config
-
source_file
private java.io.File source_file
-
initialised
private boolean initialised
-
data_map
private java.util.Map data_map
-
key_prefix
private java.lang.String key_prefix
-
dirty
private boolean dirty
-
migrate_settings
private boolean migrate_settings
-
params_monitored
private LightHashSet params_monitored
-
-
Constructor Detail
-
PluginConfigSourceImpl
public PluginConfigSourceImpl(PluginConfig plugin_config, java.lang.String plugin_id)
-
-
Method Detail
-
initialize
public void initialize()
Description copied from interface:PluginConfigSource
This initializes this configuration object and gets the external configuration file integrated with the client.It performs the following steps:
- Loads the data of any existing config file into the client.
- Registers all parameters in the file to be stored inside this configuration file (so all changes will be stored here).
- Adds a hook to allow it to be automatically saved when the client autosaves its own internal configuration files.
- Adds a hook to intercept any configuration settings created and used by the plugin and stores it internally (rather than being saved in the main the client config file).
- Specified by:
initialize
in interfacePluginConfigSource
-
getConfigFile
public java.io.File getConfigFile()
Description copied from interface:PluginConfigSource
Returns a file object which represents the location of the configuration file that this object interacts with.- Specified by:
getConfigFile
in interfacePluginConfigSource
-
setConfigFilename
public void setConfigFilename(java.lang.String filename)
Description copied from interface:PluginConfigSource
This method sets the filename for the configuration file that this object links to - this must be done before thePluginConfigSource.initialize()
method is called.- Specified by:
setConfigFilename
in interfacePluginConfigSource
- Parameters:
filename
- The filename to use.
-
save
public void save(boolean force)
Description copied from interface:PluginConfigSource
Manually saves the configuration settings recorded by this object to disk. This isn't normally required, as the client will automatically save the configuration file when the main configuration file is saved, but you can choose to save on demand if you wish.- Specified by:
save
in interfacePluginConfigSource
- Parameters:
force
- true if you want the file to be written to regardless of whether there are any changes, false if you only want to save the file if there are unsaved changes.
-
configurationSaved
public void configurationSaved()
- Specified by:
configurationSaved
in interfaceCOConfigurationListener
-
parameterChanged
public void parameterChanged(java.lang.String full_param)
Description copied from interface:ParameterListener
Called, when a parameter has changed. The listener could only react if the parameter name is relevant. Or the listener can just read all parameters again.- Specified by:
parameterChanged
in interfaceParameterListener
- Parameters:
full_param
- the name of the parameter that has changed
-
registerParameter
public void registerParameter(java.lang.String full_param)
-
getUsedKeyPrefix
public java.lang.String getUsedKeyPrefix()
-
toPluginName
private java.lang.String toPluginName(java.lang.String name)
-
shouldBeInitialised
private void shouldBeInitialised(boolean yes)
-
forceSettingsMigration
public void forceSettingsMigration()
Description copied from interface:PluginConfigSource
If your plugin previously used to store data in the main configuration file, you can call this method (which needs to be done soon after initialization) which will move all monitored parameters over to this object.You have to call this method before you initialize the object. It's also recommended that if you call this method, that you call
PluginConfigSource.save(boolean)
to save any settings copied across - probably best to be done as the last thing of thePlugin.initialize(PluginInterface)
method.- Specified by:
forceSettingsMigration
in interfacePluginConfigSource
-
-