r1151 - in trunk/simexplorer-is/simexplorer-is-swing: . src/java/fr/cemagref/simexplorer/is/ui/swing src/java/fr/cemagref/simexplorer/is/ui/swing/actions src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions
Author: tchemit Date: 2008-02-20 19:15:32 +0000 (Wed, 20 Feb 2008) New Revision: 1151 Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerAbstractOptionAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java Removed: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerAbstractOptionAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerCommonActions.java Modified: trunk/simexplorer-is/simexplorer-is-swing/pom.xml trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java Log: move to commandline package Modified: trunk/simexplorer-is/simexplorer-is-swing/pom.xml =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/pom.xml 2008-02-20 19:14:54 UTC (rev 1150) +++ trunk/simexplorer-is/simexplorer-is-swing/pom.xml 2008-02-20 19:15:32 UTC (rev 1151) @@ -125,8 +125,10 @@ <prefix>SimExplorer</prefix> <i18nPrefix>simexplorer</i18nPrefix> <source>${basedir}/src/resources/commandline.properties</source> - <parserPackageName>fr.cemagref.simexplorer.is.ui.swing</parserPackageName> - <actionSuperClass>fr.cemagref.simexplorer.is.ui.swing.actions.SimExplorerAbstractOptionAction</actionSuperClass> + <parserPackageName>fr.cemagref.simexplorer.is.ui.swing.commandline</parserPackageName> + <actionSuperClass> + fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionAction + </actionSuperClass> </configuration> </execution> </executions> Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-02-20 19:14:54 UTC (rev 1150) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-02-20 19:15:32 UTC (rev 1151) @@ -19,7 +19,7 @@ package fr.cemagref.simexplorer.is.ui.swing; import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; -import fr.cemagref.simexplorer.is.ui.swing.actions.SimExplorerCommonActions; +import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerCommonActions; import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerOptionParser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerAbstractOptionAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerAbstractOptionAction.java 2008-02-20 19:14:54 UTC (rev 1150) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerAbstractOptionAction.java 2008-02-20 19:15:32 UTC (rev 1151) @@ -1,47 +0,0 @@ -/* -* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,2008 Code Lutin. -* -* 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.actions; - -import fr.cemagref.simexplorer.is.ui.swing.SimExplorer; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext; -import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerOptionParser; -import org.codelutin.option.Option; -import org.codelutin.option.OptionAction; - -/** - * Implantation de base des actions spécifiques au parseur <b><code>SimExplorerOptionParser</code></b>. - * - * @author chemit - * @see OptionAction - */ -public abstract class SimExplorerAbstractOptionAction<O extends Option> extends org.codelutin.option.OptionAction<O, SimExplorerOptionParser> { - - protected SimExplorerContext context; - - public SimExplorerAbstractOptionAction() { - super(SimExplorer.getContext().getParser()); - } - - public SimExplorerContext getContext() { - if (context == null) { - context = SimExplorer.getContext(); - } - return context; - } -} Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerCommonActions.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerCommonActions.java 2008-02-20 19:14:54 UTC (rev 1150) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerCommonActions.java 2008-02-20 19:15:32 UTC (rev 1151) @@ -1,148 +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.actions; - -import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigMain; -import fr.cemagref.simexplorer.is.ui.swing.commandline.options.SimExplorerOptionEditConfig; -import fr.cemagref.simexplorer.is.ui.swing.commandline.options.SimExplorerOptionShowConfig; -import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionConfig; -import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionEditConfig; -import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionHelp; -import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionResetConfig; -import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionShowConfig; -import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionUi; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import static org.codelutin.i18n.I18n._; -import org.codelutin.option.Config; -import org.codelutin.option.ui.ConfigTableModel; -import org.codelutin.option.ui.ConfigUI; - -import java.io.IOException; -import java.io.StringWriter; - -/** - * The class to define all common actions that IsisFish can launch at init time. - * - * @author chemit - */ -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() throws Exception { - log.info("required help action"); - StringWriter writer = new StringWriter(); - getParser().printUsage(writer, "SimExplorer SI v " + getContext().getConfig().getVersion()); - printConfig(writer, getParser().getMainConfig()); - writer.append('\n'); - log.info(writer); - getContext().setQuit(true); - } - } - - public static class ConfigAction extends SimExplorerAbstractOptionActionConfig { - - protected void run() throws Exception { - // Do nothing, this action is treated while init of config files - } - } - - public static class ShowConfigAction extends SimExplorerAbstractOptionActionShowConfig { - @Override - protected void beforeAll(SimExplorerOptionShowConfig... options) { - super.beforeAll(options); - // check we have not twice config - } - - public void run() throws Exception { - SimExplorerAbstractConfigMain conf; - conf = getParser().getMainConfig(); - - 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); - getContext().setQuit(true); - } - } - - public static class EditConfigAction extends SimExplorerAbstractOptionActionEditConfig { - @Override - protected void beforeAll(SimExplorerOptionEditConfig... options) { - super.beforeAll(options); - // check we have not twice config - } - - public void run() throws Exception { - SimExplorerAbstractConfigMain conf; - conf = getParser().getMainConfig(); - if (isAll()) { - ConfigUI.showUI(conf, ConfigTableModel.TypeModel.all); - } else if (isTec()) { - ConfigUI.showTechnicalUI(conf); - } else { - ConfigUI.showUI(conf); - } - - StringWriter writer = new StringWriter(); - printConfig(writer, conf); - log.info("required editConfig pour category [" + conf.getCategory() + "]" + writer); - } - } - - public static class ResetConfigAction extends SimExplorerAbstractOptionActionResetConfig { - - public void run() throws Exception { - //IsisFish.firstLaunch = true; - //IsisFish.resetConfig = true; - getContext().getConfig().getConfigFileName().delete(); - log.info(_("simexplorer.message.reset.user.configuration")); - getContext().setFirstLaunch(true); - } - - } - - public static class UiAction extends SimExplorerAbstractOptionActionUi { - protected boolean init = false; - - public void run() throws Exception { - Boolean bool = isValue(); - boolean launchUI = bool != null && bool; - log.info(option.getUsedAlias() + ", value:" + bool); - getContext().setLaunchUI(launchUI); - if (init) { - getContext().setQuit(true); - } - init = true; - } - } -} Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerAbstractOptionAction.java (from rev 1150, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerAbstractOptionAction.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerAbstractOptionAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerAbstractOptionAction.java 2008-02-20 19:15:32 UTC (rev 1151) @@ -0,0 +1,47 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,2008 Code Lutin. +* +* 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.SimExplorer; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext; +import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerOptionParser; +import org.codelutin.option.Option; +import org.codelutin.option.OptionAction; + +/** + * Implantation de base des actions spécifiques au parseur <b><code>SimExplorerOptionParser</code></b>. + * + * @author chemit + * @see OptionAction + */ +public abstract class SimExplorerAbstractOptionAction<O extends Option> extends org.codelutin.option.OptionAction<O, SimExplorerOptionParser> { + + protected SimExplorerContext context; + + public SimExplorerAbstractOptionAction() { + super(SimExplorer.getContext().getParser()); + } + + public SimExplorerContext getContext() { + if (context == null) { + context = SimExplorer.getContext(); + } + return context; + } +} Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java (from rev 1150, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SimExplorerCommonActions.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/commandline/actions/SimExplorerCommonActions.java 2008-02-20 19:15:32 UTC (rev 1151) @@ -0,0 +1,148 @@ +/* +* ##% 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.commandline.configs.SimExplorerAbstractConfigMain; +import fr.cemagref.simexplorer.is.ui.swing.commandline.options.SimExplorerOptionEditConfig; +import fr.cemagref.simexplorer.is.ui.swing.commandline.options.SimExplorerOptionShowConfig; +import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionConfig; +import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionEditConfig; +import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionHelp; +import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionResetConfig; +import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionShowConfig; +import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerAbstractOptionActionUi; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import static org.codelutin.i18n.I18n._; +import org.codelutin.option.Config; +import org.codelutin.option.ui.ConfigTableModel; +import org.codelutin.option.ui.ConfigUI; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * The class to define all common actions that IsisFish can launch at init time. + * + * @author chemit + */ +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() throws Exception { + log.info("required help action"); + StringWriter writer = new StringWriter(); + getParser().printUsage(writer, "SimExplorer SI v " + getContext().getConfig().getVersion()); + printConfig(writer, getParser().getMainConfig()); + writer.append('\n'); + log.info(writer); + getContext().setQuit(true); + } + } + + public static class ConfigAction extends SimExplorerAbstractOptionActionConfig { + + protected void run() throws Exception { + // Do nothing, this action is treated while init of config files + } + } + + public static class ShowConfigAction extends SimExplorerAbstractOptionActionShowConfig { + @Override + protected void beforeAll(SimExplorerOptionShowConfig... options) { + super.beforeAll(options); + // check we have not twice config + } + + public void run() throws Exception { + SimExplorerAbstractConfigMain conf; + conf = getParser().getMainConfig(); + + 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); + getContext().setQuit(true); + } + } + + public static class EditConfigAction extends SimExplorerAbstractOptionActionEditConfig { + @Override + protected void beforeAll(SimExplorerOptionEditConfig... options) { + super.beforeAll(options); + // check we have not twice config + } + + public void run() throws Exception { + SimExplorerAbstractConfigMain conf; + conf = getParser().getMainConfig(); + if (isAll()) { + ConfigUI.showUI(conf, ConfigTableModel.TypeModel.all); + } else if (isTec()) { + ConfigUI.showTechnicalUI(conf); + } else { + ConfigUI.showUI(conf); + } + + StringWriter writer = new StringWriter(); + printConfig(writer, conf); + log.info("required editConfig pour category [" + conf.getCategory() + "]" + writer); + } + } + + public static class ResetConfigAction extends SimExplorerAbstractOptionActionResetConfig { + + public void run() throws Exception { + //IsisFish.firstLaunch = true; + //IsisFish.resetConfig = true; + getContext().getConfig().getConfigFileName().delete(); + log.info(_("simexplorer.message.reset.user.configuration")); + getContext().setFirstLaunch(true); + } + + } + + public static class UiAction extends SimExplorerAbstractOptionActionUi { + protected boolean init = false; + + public void run() throws Exception { + Boolean bool = isValue(); + boolean launchUI = bool != null && bool; + log.info(option.getUsedAlias() + ", value:" + bool); + getContext().setLaunchUI(launchUI); + if (init) { + getContext().setQuit(true); + } + init = true; + } + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org