Example usage for org.apache.commons.configuration XMLConfiguration setAutoSave

List of usage examples for org.apache.commons.configuration XMLConfiguration setAutoSave

Introduction

In this page you can find the example usage for org.apache.commons.configuration XMLConfiguration setAutoSave.

Prototype

public void setAutoSave(boolean autoSave) 

Source Link

Usage

From source file:org.parosproxy.paros.Constant.java

private void upgradeFrom1_1_0(XMLConfiguration config) throws ConfigurationException {
    // Upgrade the regexs
    // ZAP: Changed to use ZapXmlConfiguration, to enforce the same character encoding when reading/writing configurations.
    XMLConfiguration newConfig = new ZapXmlConfiguration(getPathDefaultConfigFile().toFile());
    newConfig.setAutoSave(false);

    copyAllProperties(newConfig, config, "pscans");
}

From source file:org.parosproxy.paros.Constant.java

private void upgradeFrom1_2_0(XMLConfiguration config) throws ConfigurationException {
    // Upgrade the regexs
    // ZAP: Changed to use ZapXmlConfiguration, to enforce the same character encoding when reading/writing configurations.
    XMLConfiguration newConfig = new ZapXmlConfiguration(getPathDefaultConfigFile().toFile());
    newConfig.setAutoSave(false);

    copyProperty(newConfig, config, "view.editorView");
    copyProperty(newConfig, config, "view.brkPanelView");
    copyProperty(newConfig, config, "view.showMainToolbar");
}

From source file:org.programmatori.domotica.own.emulator.ConfigBus.java

private void loadConfig20(XMLConfiguration config) {
    if (config.getInt("statusSave", 0) == 1) {
        config.setAutoSave(save);
    }//from  w ww.j  ava2 s  .  c o  m

    int pos = 0;
    List<?> areas = config.configurationsAt("area");
    for (Iterator<?> iter = areas.iterator(); iter.hasNext();) {
        HierarchicalConfiguration areaConf = (HierarchicalConfiguration) iter.next();
        String area = config.getString("area(" + pos + ")[@id]");

        int posC = 0;
        List<?> components = areaConf.getList("component");
        for (Iterator<?> iterC = components.iterator(); iterC.hasNext();) {
            String value = (String) iterC.next();

            String type = areaConf.getString("component(" + posC + ")[@type]");
            String lightPoint = areaConf.getString("component(" + posC + ")[@pl]");

            SCSComponent c = null;
            if (type.equals("light")) {
                c = Light.create(this, area, lightPoint, value);
            } else if (type.equals("blind")) {
                c = Blind.create(this, area, lightPoint, value);
            } else if (type.equals("power")) {
                c = PowerUnit.create(this, area, value);
            }
            add(c);
            if (c instanceof Thread) {
                Thread t = (Thread) c;
                t.start();
            }
            posC++;
        }

        //         int posC = 0;
        //         List<?> components = config.configurationsAt("component");
        //         for (Iterator<?> iterC = components.iterator(); iter.hasNext();) {
        //            HierarchicalConfiguration component = (HierarchicalConfiguration ) iter.next();
        //
        //            String type = areaConf.getString("component(" + posC + ")[@type]");
        //            String lightPoint = areaConf.getString("component(" + posC + ")[@pl]");
        //
        //            String value = component.getString("value");

        pos++;
    }
}

From source file:org.programmatori.domotica.own.emulator.ConfigBus.java

private void loadConfig10(XMLConfiguration config) {
    if (config.getInt("statusSave", 0) == 1) {
        config.setAutoSave(save);
    }//from  w w w.j  a  v a 2  s  .  c  o  m

    int pos = 0;
    List<?> components = config.configurationsAt("component");
    for (Iterator<?> iter = components.iterator(); iter.hasNext();) {
        HierarchicalConfiguration component = (HierarchicalConfiguration) iter.next();

        String type = config.getString("component(" + pos + ")[@type]");
        String area = component.getString("area");
        String lightPoint = component.getString("lightPoint");
        String value = component.getString("value");

        SCSComponent c = null;
        if (type.equals("light")) {
            c = Light.create(this, area, lightPoint, value);
        } else if (type.equals("blind")) {
            c = Blind.create(this, area, lightPoint, value);
        }
        add(c);
        if (c instanceof Thread) {
            Thread t = (Thread) c;
            t.start();
        }

        pos++;
    }
}

From source file:pl.otros.logview.gui.LogViewMainFrame.java

private static XMLConfiguration getConfiguration(String file) {
    XMLConfiguration commonConfiguration = new XMLConfiguration();
    File commonConfigurationFile = new File(file);
    // load common configuration
    if (commonConfigurationFile.exists()) {
        LOGGER.info("Loading common configuration from " + commonConfigurationFile.getAbsolutePath());
        try {/*from w ww . jav a 2 s. c o m*/
            commonConfiguration.load(commonConfigurationFile);
        } catch (ConfigurationException e) {
            LOGGER.severe("Can't load configuration, creating new " + e.getMessage());
        }
    } else {
        LOGGER.info("Common configuration file do not exist");
    }
    // load user specific configuration
    if (!AllPluginables.USER_CONFIGURATION_DIRECTORY.exists()) {
        LOGGER.info("Creating user specific OtrosLogViewer configuration directory "
                + AllPluginables.USER_CONFIGURATION_DIRECTORY.getAbsolutePath());
        AllPluginables.USER_CONFIGURATION_DIRECTORY.mkdirs();
        AllPluginables.USER_FILTER.mkdirs();
        AllPluginables.USER_LOG_IMPORTERS.mkdirs();
        AllPluginables.USER_MARKERS.mkdirs();
        AllPluginables.USER_MESSAGE_FORMATTER_COLORZIERS.mkdirs();
    }
    XMLConfiguration userConfiguration = new XMLConfiguration();
    File userConfigurationFile = new File(AllPluginables.USER_CONFIGURATION_DIRECTORY + File.separator + file);
    userConfiguration.setFile(userConfigurationFile);
    if (userConfigurationFile.exists()) {
        try {
            userConfiguration.load();
        } catch (ConfigurationException e) {
            LOGGER.severe(String.format("Can't load user configuration from %s: %s",
                    userConfigurationFile.getAbsolutePath(), e.getMessage()));
        }
    }
    Iterator<?> keys = commonConfiguration.getKeys();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        if (!userConfiguration.containsKey(key)) {
            userConfiguration.setProperty(key, commonConfiguration.getProperty(key));
        }
    }
    userConfiguration.setAutoSave(true);
    return userConfiguration;
}

From source file:pl.otros.logview.gui.LogViewMainFrame.java

private static Configuration getVfsFavoritesConfiguration() {
    File file = new File(AllPluginables.USER_CONFIGURATION_DIRECTORY + File.separator + "vfsFavorites.xml");
    XMLConfiguration configuration = new XMLConfiguration();
    configuration.setFile(file);/*from w ww.jav  a 2  s  .  co m*/
    if (file.exists()) {
        try {
            configuration.load();
        } catch (ConfigurationException e) {
            LOGGER.severe(String.format("Can't load user configuration from %s: %s", file.getAbsolutePath(),
                    e.getMessage()));
        }
    }
    configuration.setAutoSave(true);
    return configuration;
}

From source file:pl.otros.logview.persistance.PersistentConfiguration.java

private static XMLConfiguration getXMLConfiguration(String file) {
    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    try {/*from w ww.  ja va  2  s  .co m*/
        xmlConfiguration = new XMLConfiguration();
        xmlConfiguration.setFile(new File(file));
        xmlConfiguration.load();
        xmlConfiguration.setAutoSave(true);
    } catch (ConfigurationException e) {
        LOGGER.severe("Can't load configuration, creating new " + e.getMessage());

        try {
            xmlConfiguration.save();
            xmlConfiguration.setAutoSave(true);
        } catch (ConfigurationException e1) {
            LOGGER.severe("Can't create persistent configuration: " + e1.getMessage());
        }
    }
    return xmlConfiguration;
}