Search in sources :

Example 1 with XmlConfigurationWriter

use of com.mucommander.commons.conf.XmlConfigurationWriter in project mucommander by mucommander.

the class MuPreferences method write.

/**
 * Saves the muCommander CONFIGURATION.
 * @throws IOException            if an I/O error occurs.
 * @throws ConfigurationException if a CONFIGURATION related error occurs.
 */
void write() throws IOException, ConfigurationException {
    // Clear the configuration before saving to drop preferences which are unused anymore
    Configuration conf = new Configuration(MuPreferencesFile.getPreferencesFile(), () -> new XmlConfigurationReader(), out -> new XmlConfigurationWriter(out, ROOT_ELEMENT));
    for (MuPreference preference : MuPreference.values()) conf.setVariable(preference.toString(), configuration.getVariable(preference.toString()));
    // Remove preferences which are not relevant if we're not using MAC
    if (!OsFamily.MAC_OS.isCurrent()) {
        conf.removeVariable(USE_SCREEN_MENU_BAR);
    }
    configuration = conf;
    configuration.write();
}
Also used : Configuration(com.mucommander.commons.conf.Configuration) XmlConfigurationReader(com.mucommander.commons.conf.XmlConfigurationReader) XmlConfigurationWriter(com.mucommander.commons.conf.XmlConfigurationWriter)

Aggregations

Configuration (com.mucommander.commons.conf.Configuration)1 XmlConfigurationReader (com.mucommander.commons.conf.XmlConfigurationReader)1 XmlConfigurationWriter (com.mucommander.commons.conf.XmlConfigurationWriter)1