Author: tchemit Date: 2008-03-16 06:34:45 +0000 (Sun, 16 Mar 2008) New Revision: 1361 Removed: branches/20080315_before_commandline_split/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java Log: delte common actions from project : generated by maven-commandline-plugin :) Deleted: branches/20080315_before_commandline_split/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java =================================================================== --- branches/20080315_before_commandline_split/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java 2008-03-16 03:45:57 UTC (rev 1360) +++ branches/20080315_before_commandline_split/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java 2008-03-16 06:34:45 UTC (rev 1361) @@ -1,132 +0,0 @@ -/* -* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin, -* Benjamin Poussin, Tony Chemit -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.ui.swing.commandline.actions; - -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; -import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerAbstractContext; -import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerConfigMain; -import fr.cemagref.simexplorer.is.ui.swing.commandline.options.SimExplorerOptionEditConfig; -import fr.cemagref.simexplorer.is.ui.swing.commandline.options.SimExplorerOptionShowConfig; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import static org.codelutin.i18n.I18n._; -import org.codelutin.option.Config; - -import java.io.IOException; -import java.io.StringWriter; - -/** - * The class to define all common actions that IsisFish can launch at init time. - * - * @author chemit - */ - at org.codelutin.option.OptionActionAnnotation -public class SimExplorerCommonActions { - - private static final Log log = LogFactory.getLog(SimExplorerCommonActions.class); - - static void printConfig(StringWriter writer, Config config) throws IOException { - writer.append('\n').append(config.toString()); - writer.flush(); - } - - public static class HelpAction extends SimExplorerAbstractOptionActionHelp { - - - protected void run(SimExplorerAbstractContext context) throws Exception { - log.info("required help action"); - StringWriter writer = new StringWriter(); - context.getParser().printUsage(writer, "SimExplorer SI v " + context.getConfig().getVersion()); - printConfig(writer, context.getConfig()); - writer.append('\n'); - log.info(writer); - context.setQuit(true); - } - - } - - public static class ConfigAction extends SimExplorerAbstractOptionActionChangeConfig { - - protected void run(SimExplorerAbstractContext context) throws Exception { - // Do nothing, this action is treated while init of config files - } - } - - public static class ShowConfigAction extends SimExplorerAbstractOptionActionShowConfig { - @Override - protected void beforeAll(SimExplorerAbstractContext context, SimExplorerOptionShowConfig... options) { - super.beforeAll(context, options); - // check we have not twice config - } - - public void run(SimExplorerAbstractContext context) throws Exception { - SimExplorerConfigMain conf; - conf = context.getConfig(); - - String category = option.getConstantArgumentValue(0); - if (conf == null) { - throw new IllegalArgumentException("could not found a configuration with category " + category); - } - log.info("required showConfig pour category [" + category + "]"); - StringWriter writer = new StringWriter(); - printConfig(writer, conf); - log.info(writer); - context.setQuit(true); - } - } - - public static class EditConfigAction extends SimExplorerAbstractOptionActionEditConfig { - @Override - protected void beforeAll(SimExplorerAbstractContext context, SimExplorerOptionEditConfig... options) { - super.beforeAll(context, options); - // check we have not twice config - } - - public void run(SimExplorerAbstractContext context) throws Exception { - log.info("required editConfig action"); - SimExplorerActionManager.fireAction("config", this); - } - } - - public static class ResetConfigAction extends SimExplorerAbstractOptionActionResetConfig { - - public void run(SimExplorerAbstractContext context) throws Exception { - context.getConfig().getConfigFileName().delete(); - log.info(_("simexplorer.message.reset.user.configuration")); - context.setFirstLaunch(true); - } - - } - - public static class UiAction extends SimExplorerAbstractOptionActionUi { - protected boolean init = false; - - public void run(SimExplorerAbstractContext context) throws Exception { - Boolean bool = isFlag(); - boolean launchUI = bool != null && bool; - log.info(option.getUsedAlias() + ", value:" + bool); - context.setLaunchUI(launchUI); - if (init) { - context.setQuit(true); - } - init = true; - } - } -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org