Author: tchemit
Date: 2008-01-20 14:09:47 +0000 (Sun, 20 Jan 2008)
New Revision: 279
Removed:
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerException.java
Log:
on d?\195?\169place toutes les classes vers ui
Deleted: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java 2008-01-20 14:09:34 UTC (rev 278)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java 2008-01-20 14:09:47 UTC (rev 279)
@@ -1,166 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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;
-
-import fr.cemagref.simexplorer.is.service.MockStorageServiceImpl;
-import fr.cemagref.simexplorer.is.service.StorageService;
-import fr.cemagref.simexplorer.is.ui.swing.JConfigUI;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTabManager;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI;
-import org.codelutin.i18n.I18n;
-import org.codelutin.option.ui.ConfigTableModel;
-
-import java.io.IOException;
-
-/**
- * L'application principale
- *
- * @author chemit
- */
-public class SimExplorer {
-
- /** le context principal de l'application */
- protected static SimExplorerContext context;
-
- /** l'ui principale de l'application */
- protected static SimExplorerMainUI ui;
-
- /** le service de données local */
- private static StorageService remoteStorageService;
-
- /** le service de données distant */
- protected static StorageService storageService;
-
- public static SimExplorerContext getContext() {
- checkInitContext();
- return context;
- }
-
- public static SimExplorerMainUI getUI() {
- checkInitContext();
- if (ui == null) {
- ui = new SimExplorerMainUI();
- ui.postInit();
- }
- return ui;
- }
-
- public static void reloadUI() {
- ui = null;
- JConfigUI.reloadUI();
- SimExplorerTabManager.reloadUI();
- }
-
- /**
- * initialisation de l'application :
- * <p/>
- * chargement du context
- *
- * @param args les arguments passés à l'application
- */
- public static void init(String... args) {
-
- // init context
- context = new SimExplorerContext();
-
- // init i18n
- I18n.initISO88591();
-
- // init parser
- context.initParser(args);
-
- // init config
- context.initConfig();
-
- // save config
- try {
- context.save();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- /** Lancement de l'ui après init de l'application. */
- public static void launch() {
-
- // init ui
- SimExplorerMainUI mainUI = getUI();
-
- SimExplorerConfig conf = getContext().getConfig();
-
- if (conf.isShowLocalTab()) {
- // show local tab
- mainUI.getToolbar().getToggleTab_local().doClick();
- }
- if (conf.isShowRemoteTab()) {
- // show remote tab
- mainUI.getToolbar().getToggleTab_remote().doClick();
- }
- if (conf.isShowSynchTab()) {
- // show synchronize tab
- mainUI.getToolbar().getToggleTab_synchronize().doClick();
- }
-
- mainUI.setVisible(true);
- }
-
- public static void main(String... args) throws Exception {
-
- // init application (parser,config,i18n,...)
- init(args);
-
- // launch actions required
- context.getParser().doAllActions();
-
- // show edit config if first launch
- if (SimExplorer.context.isFirstLaunch()) {
- JConfigUI.showUI(context.getConfig(), ConfigTableModel.TypeModel.all);
- }
-
- // launch ui only if required
- if (!context.isQuit() && context.isLaunchUI()) {
- launch();
- }
-
- }
-
- public static StorageService getStorageService() {
- if (storageService == null) {
- storageService = new MockStorageServiceImpl();
- }
- return storageService;
- }
-
- public static StorageService getRemoteStorageService() {
- if (remoteStorageService == null) {
- remoteStorageService = new MockStorageServiceImpl();
- }
- return remoteStorageService;
- }
-
- protected static void checkInitContext() {
- if (context == null) {
- throw new IllegalStateException("context is null, you must init first the " + SimExplorer.class.getName() + " class via init method");
- }
- }
-
- protected SimExplorer() {
- // protected restricted access
- }
-}
Deleted: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java 2008-01-20 14:09:34 UTC (rev 278)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerConfig.java 2008-01-20 14:09:47 UTC (rev 279)
@@ -1,132 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin,
-* 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;
-
-import fr.cemagref.simexplorer.is.configs.SimExplorerAbstractConfigMain;
-import fr.cemagref.simexplorer.is.options.SimExplorerOptionConfig;
-import fr.cemagref.simexplorer.is.options.SimExplorerOptionConfigFile;
-import fr.cemagref.simexplorer.is.SimExplorerOptionParser;
-import org.codelutin.i18n.I18n;
-import org.codelutin.i18n.LanguageEnum;
-import org.codelutin.i18n.CountryEnum;
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.ConfigPropertyKey;
-import org.codelutin.option.OptionParser;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * L'implantation concrete de la config principale
- *
- * @author chemit
- */
-public class SimExplorerConfig extends SimExplorerAbstractConfigMain {
-
- public SimExplorerConfig() {
- super();
- String home = System.getProperty("user.home");
- if (home == null) {
- // this is a serious fatal error
- throw new RuntimeException("simexplorer.error.user.home");
- }
- doInit();
- }
-
- public void init() throws Exception {
- log.info("start for category [" + category + "] -------------------------");
-
- SimExplorerOptionParser parser = SimExplorer.getContext().getParser();
- initConfigFile(parser);
- log.info("config file : " + getSource());
- // chargement des valeurs par défaut
- loadFromDefaultValue();
- // après le chargement des valeurs par défaut
- // la configuration n'est pas modifiée
- clearModified();
- // surcharge à partir du fichier de configuration de l'utilisateur
- loadFromSource();
- // surcharge à partir des propriétés système
- loadFromSystem();
- // surcharge à partir des propriétés de la jvm
- loadFromJvm();
- // surcharge à partir de l'option config de la ligne de commande
- loadFromOptions(parser);
- clearModified();
- for (String s : this.toString().split("\n")) {
- log.debug(s);
- }
- log.info("end for category [" + category + "] ---------------------------");
- }
-
- protected void initConfigFile(OptionParser parser) {
- File file;
- if (parser.isOptionEnabled(SimExplorerOptionParser.CONFIG_FILE_OPTION_KEY)) {
- // surcharge config file
- SimExplorerOptionConfigFile option = SimExplorerOptionParser.CONFIG_FILE_OPTION_KEY.getOptions().get(0);
-
- file = option.getConfigFile();
- } else {
- String home = System.getProperty("user.home", "");
- File root = new File(home);
- file = new File(root, SimExplorerConfig.CONFIG_FILE_NAME_PROPERTY_KEY.getDefaultValue().getName());
- if (!file.exists()) {
- SimExplorer.getContext().setFirstLaunch(true);
- try {
- file.createNewFile();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
- if (containsKey(SimExplorerConfig.CONFIG_FILE_NAME_PROPERTY_KEY)) {
- setProperty(SimExplorerConfig.CONFIG_FILE_NAME_PROPERTY_KEY, file);
- }
- setSource(file);
- }
-
- public void initI18n() {
- I18n.initISO88591(getLanguage().name(), getCountry().name());
- }
-
- protected void loadFromOptions(SimExplorerOptionParser parser) throws Exception {
- if (!parser.isOptionEnabled(SimExplorerOptionParser.CONFIG_OPTION_KEY)) {
- return;
- }
- // surcharge config file
- for (SimExplorerOptionConfig option : SimExplorerOptionParser.CONFIG_OPTION_KEY.getOptions()) {
- if (getCategory().equals(SimExplorerOptionParser.MAIN_CONFIG_KEY.getCategory())) {
- ConfigPropertyKey<?> propKey = getPropertyKey(option.getKey());
- if (propKey == null) {
- // fatal error , could not found a matching configuration property
- throw new IllegalArgumentException(_("simexplorer.error.unfound.config.property", category, option.getKey()));
- }
- Object oldVal = propKey.getCurrentValue();
- setProperty(propKey, option.getValue());
- Object newVal = propKey.getCurrentValue();
- log.info(_("simexplorer.change.config.property", category, propKey, oldVal, newVal));
- }
- }
- }
-
- public void setI18n(LanguageEnum language, CountryEnum country) {
- setLanguage(language);
- setCountry(country);
- }
-}
\ No newline at end of file
Deleted: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-01-20 14:09:34 UTC (rev 278)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-01-20 14:09:47 UTC (rev 279)
@@ -1,146 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* 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;
-
-import fr.cemagref.simexplorer.is.actions.SimExplorerCommonActions;
-import fr.cemagref.simexplorer.is.ui.swing.bean.ApplicationBean;
-import fr.cemagref.simexplorer.is.ui.swing.bean.ListApplicationBean;
-import fr.cemagref.simexplorer.is.SimExplorerOptionParser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.option.ParserException;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-/**
- * Le context de l'application, implanté en singleton.
- * <p/>
- * Contient la configuration de l'application, le parseur d'options,...
- *
- * @author chemit
- */
-public class SimExplorerContext {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(SimExplorerContext.class);
-
- private SimExplorerOptionParser parser;
- private boolean quit;
- private boolean launchUI = true;
- private boolean firstLaunch;
-
- protected ListApplicationBean localApplications;
- protected ListApplicationBean remoteApplications;
- protected ApplicationBean applicationBean;
-
- public ApplicationBean getApplicationBean() {
- return applicationBean;
- }
-
- public ListApplicationBean getLocalApplications() {
- return localApplications;
- }
-
- public ListApplicationBean getRemoteApplications() {
- return remoteApplications;
- }
-
- public SimExplorerOptionParser getParser() {
- if (parser == null) {
- // creation du parseur
- parser = new SimExplorerOptionParser();
- // enregistrement des actions concretes
- parser.registerActions(SimExplorerCommonActions.class);
-
- // enregistrement des configs concretes
- parser.registerConfig(SimExplorerConfig.class);
- }
- return parser;
- }
-
- public SimExplorerConfig getConfig() {
- return (SimExplorerConfig) getParser().getMainConfig();
- }
-
- public void save() throws IOException {
- if (getConfig().getSource() == null) {
- return;
- }
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(getConfig().getSource()));
- try {
- getConfig().save(out);
- } finally {
- out.flush();
- out.close();
- }
- }
-
- public void saveSafely() {
- try {
- save();
- } catch (Exception e) {
- log.warn("simexplorer.error.unsafe.save.config" + e.getMessage(), e);
- }
- }
-
- public void setQuit(boolean quit) {
- this.quit = quit;
- }
-
- public boolean isQuit() {
- return quit;
- }
-
- public void setLaunchUI(boolean launchUI) {
- this.launchUI = launchUI;
- }
-
- public boolean isLaunchUI() {
- return launchUI;
- }
-
- public void setFirstLaunch(boolean firstLaunch) {
- this.firstLaunch = firstLaunch;
- }
-
- public boolean isFirstLaunch() {
- return firstLaunch;
- }
-
- /** restricted access constructor */
- SimExplorerContext() {
-
- }
-
- void initParser(String... args) {
- try {
- getParser().doParse(args);
- } catch (ParserException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- void initConfig() {
- getConfig().initI18n();
- }
-}
Deleted: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerException.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerException.java 2008-01-20 14:09:34 UTC (rev 278)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerException.java 2008-01-20 14:09:47 UTC (rev 279)
@@ -1,44 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
-* Tony Chemit, Gabriel Landais
-*
-* 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;
-
-/**
- * Exception de base.
- *
- * @author chemit
- */
-public class SimExplorerException extends Exception {
-
- private static final long serialVersionUID = -8288416952045350383L;
-
- public SimExplorerException() {
- }
-
- public SimExplorerException(Throwable cause) {
- super(cause);
- }
-
- public SimExplorerException(String message) {
- super(message);
- }
-
- public SimExplorerException(String message, Throwable cause) {
- super(message, cause);
- }
-}