Author: echatellier Date: 2012-04-05 12:10:32 +0200 (Thu, 05 Apr 2012) New Revision: 3352 Url: http://chorem.org/repositories/revision/lima/3352 Log: Remove code pasted form appConfig Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2012-04-04 13:25:23 UTC (rev 3351) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2012-04-05 10:10:32 UTC (rev 3352) @@ -25,7 +25,17 @@ package org.chorem.lima; +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.IOException; +import java.util.Locale; + import jaxx.runtime.JAXXUtil; + +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.actions.MiscAction; @@ -35,24 +45,10 @@ import org.nuiton.topia.TopiaContextFactory; import org.nuiton.util.ApplicationConfig; import org.nuiton.util.ArgumentsParserException; -import org.nuiton.util.FileUtil; -import org.nuiton.util.SortedProperties; import org.nuiton.util.Version; import org.nuiton.util.VersionUtil; import org.nuiton.util.converter.ConverterUtil; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Date; -import java.util.Locale; -import java.util.Properties; - -import static org.nuiton.i18n.I18n._; -import static org.nuiton.i18n.I18n.n_; - /** * La configuration de l'application. * @@ -498,96 +494,22 @@ } /** - * Save configuration, in user home directory using the - * {@link #getConfigFileName}. Default, env and commande line note saved - * - * @param excludeKeys optional list of keys to exclude from + * Override save action to propagate some option to server. */ - public void saveForUser(String... excludeKeys) { - - File file = getUserConfigFile(); - if (log.isDebugEnabled()) { - log.debug("will save user configuration in " + file); - } - try { - save(file, false, excludeKeys); - } catch (IOException eee) { - if (log.isWarnEnabled()) { - log.warn(_("nuitonutil.error.applicationconfig.save", file), - eee); - } - } - } - - /** - * Save configuration, in specified file. - * - * @param file file where config will be writen - * @param forceAll if true save all config option - * (with defaults, classpath, env, command line) - * @param excludeKeys optional list of keys to exclude from - * @throws IOException if IO pb - */ + @Override public void save(File file, boolean forceAll, String... excludeKeys) throws IOException { - // - String[] serverProperties = {"scale"}; + super.save(file, forceAll, excludeKeys); - // store sorted in file - Properties prop = new SortedProperties(); + // propagate scale option to serveur option + optionsService = LimaServiceFactory.getService(OptionsServiceMonitorable.class); - // store server properties in file - Properties serverProp = new SortedProperties(); - - if (forceAll) { - prop.putAll(defaults); - prop.putAll(classpath); + // scale server option + String scaleOption = getOption("scale"); + if (StringUtils.isNotBlank(scaleOption)) { + optionsService.setScale(scaleOption); } - prop.putAll(etcfile); - prop.putAll(homefile); - prop.putAll(curfile); - if (forceAll) { - prop.putAll(jvm); - prop.putAll(env); - prop.putAll(line); - } - prop.putAll(options); - - for (String excludeKey : excludeKeys) { - prop.remove(excludeKey); - } - - for (String serverPropertie : serverProperties) { - if (prop.containsKey(serverPropertie)) { - serverProp.put(serverPropertie, prop.get(serverPropertie)); - } - } - - // Ano #687 : create parentFile before using it in FileWriter - boolean dirCreated = FileUtil.createDirectoryIfNecessary(file.getParentFile()); - if (dirCreated && log.isDebugEnabled()) { - log.debug("Creation of config directory " + file.getParent()); - } - - OutputStream stream = new FileOutputStream(file); - try { - prop.store(stream, "Last saved " + new Date()); - } finally { - stream.close(); - } - - optionsService = - LimaServiceFactory.getService( - OptionsServiceMonitorable.class); - - if (!serverProp.isEmpty()) { - if (serverProp.containsKey("scale")) { - if (!serverProp.getProperty("scale").isEmpty()) { - optionsService.setScale(serverProp.getProperty("scale")); - } - } - } } }
participants (1)
-
echatellier@users.chorem.org