Search in sources :

Example 1 with XmlConfigurationReader

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

the class MuPreferences method read.

// - Configuration reading / writing -------------------------------------
// -----------------------------------------------------------------------
/**
 * Loads the muCommander CONFIGURATION.
 * @throws IOException            if an I/O error occurs.
 * @throws ConfigurationException if a CONFIGURATION related error occurs.
 */
void read() throws IOException, ConfigurationException {
    XmlConfigurationReader reader = new XmlConfigurationReader();
    configuration.read(reader);
    // Ensure backward compatibility
    configuration.renameVariable("show_hidden_files", SHOW_HIDDEN_FILES);
    configuration.renameVariable("auto_size_columns", AUTO_SIZE_COLUMNS);
    configuration.renameVariable("show_toolbar", TOOLBAR_VISIBLE);
    configuration.renameVariable("show_status_bar", STATUS_BAR_VISIBLE);
    configuration.renameVariable("show_command_bar", COMMAND_BAR_VISIBLE);
    // Initializes macOS specific values
    if (OsFamily.MAC_OS.isCurrent()) {
        if (configuration.getVariable(SHELL_ENCODING) == null) {
            configuration.setVariable(SHELL_ENCODING, "UTF-8");
            configuration.setVariable(AUTODETECT_SHELL_ENCODING, false);
        }
    }
}
Also used : XmlConfigurationReader(com.mucommander.commons.conf.XmlConfigurationReader)

Example 2 with XmlConfigurationReader

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

the class MuSnapshot method read.

// - Configuration reading / writing -------------------------------------
// -----------------------------------------------------------------------
/**
 * Loads the muCommander CONFIGURATION.
 * Here, we don't try to convert preferences that were changed between muCommander versions,
 * as those are 'dynamic' preferences and as such can be ignored when the user installs new version.
 *
 * @throws IOException            if an I/O error occurs.
 * @throws ConfigurationException if a CONFIGURATION related error occurs.
 */
void read() throws IOException, ConfigurationException {
    XmlConfigurationReader reader = new XmlConfigurationReader();
    configuration.read(reader);
    for (MuSnapshotable handler : snapshotables) {
        handler.read(configuration);
    }
}
Also used : XmlConfigurationReader(com.mucommander.commons.conf.XmlConfigurationReader)

Example 3 with XmlConfigurationReader

use of com.mucommander.commons.conf.XmlConfigurationReader 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

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