Author: tchemit Date: 2008-03-15 01:40:38 +0000 (Sat, 15 Mar 2008) New Revision: 1342 Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java Log: passage en maven-commandline-plugin:0.3 prochaine ?\195?\169tape : split du module 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-03-15 01:40:18 UTC (rev 1341) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-03-15 01:40:38 UTC (rev 1342) @@ -31,10 +31,7 @@ import fr.cemagref.simexplorer.is.service.remote.RemoteService; import fr.cemagref.simexplorer.is.service.remote.RemoteStorageService; import fr.cemagref.simexplorer.is.storage.SortColumn; -import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerOptionParser; -import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigLocal; -import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigMain; -import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigRemote; +import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerAbstractContext; import org.codelutin.i18n.I18n; import org.codelutin.option.ParserException; @@ -49,28 +46,10 @@ * * @author chemit */ -public class SimExplorerContext { +public class SimExplorerContext extends SimExplorerAbstractContext { private final static boolean mock = false; - /** - * le parseur utilisé au démarrage pour récupérer les options passées - * par l'utilisateur. - */ - protected SimExplorerOptionParser parser; - - /** flag pour indiquer si 'lon veut quitter l'appli après les options */ - protected boolean quit; - - /** flag pour indiquer si l'on affiche ou non l'ui principale */ - protected boolean launchUI = true; - - /** - * flag pour indiquer une première utilisation de l'application (pas de - * fichier de configuration) - */ - protected boolean firstLaunch; - /** le token pour la connexion au serveur distant */ protected String token; @@ -87,33 +66,6 @@ protected LoggableElementCache remoteCache; /** - * @return le parseur utilisé pour parser les options de la ligne de - * commande. - */ - public SimExplorerOptionParser getParser() { - if (parser == null) { - // creation du parseur - parser = new SimExplorerOptionParser(); - } - return parser; - } - - /** @return la configuration de l'application */ - public SimExplorerAbstractConfigMain getConfig() { - return getParser().getMainConfig(); - } - - /** @return la configuration de l'application */ - public SimExplorerAbstractConfigRemote getRemoteConfig() { - return getParser().getRemoteConfig(); - } - - /** @return la configuration de l'application */ - public SimExplorerAbstractConfigLocal getLocalConfig() { - return getParser().getLocalConfig(); - } - - /** * @return <code>true</code> si l'utilisateur est connecté, * <code>false</code> sinon. */ @@ -122,31 +74,6 @@ } /** - * @return <code>true</code> si on doit quitter l'application (uniquement utilisé - * lors du démarrage de l'application lors de l'exécution des options - * utilisateurs) - */ - public boolean isQuit() { - return quit; - } - - /** - * @return <code>true</code> si on doit lancer l'ui au démarrage de - * l'application, après avoir traité toutes les options utilisateurs - */ - public boolean isLaunchUI() { - return launchUI; - } - - /** - * @return <code>true</code> s'il s'agit de la première utilisation de - * l'application (aucun de fichier de configuration trouvé) - */ - public boolean isFirstLaunch() { - return firstLaunch; - } - - /** * @return le token utilisé pour identifié l'utilisateur sur le serveur distant. * <p/> * <b>Si est null ou vide cela veut que l'utilisateur n'est pas connecté.</b> @@ -155,18 +82,6 @@ return token; } - public void setQuit(boolean quit) { - this.quit = quit; - } - - public void setLaunchUI(boolean launchUI) { - this.launchUI = launchUI; - } - - public void setFirstLaunch(boolean firstLaunch) { - this.firstLaunch = firstLaunch; - } - public void setToken(String token) { this.token = token; } @@ -235,7 +150,7 @@ } } - public String loginUser(boolean remote, String login, String hashPassword) throws UnreachableServiceException { + public String loginUser(boolean remote, String login, String hashPassword) throws UnreachableServiceException { StorageService service = getStorageService(remote); try { String token; @@ -262,34 +177,19 @@ return cache; } - /** restricted access constructor */ - SimExplorerContext() { - } - /** - * Initialisation du parseur d'options. + * restricted access constructor * - * @param args les arguments passés au démarrage de l'application + * @param args argumentsfor parser + * @throws java.io.IOException if pb while saing configuration + * @throws org.codelutin.option.ParserException + * if pb while parsing arguments */ - void initContext(String... args) { - try { - // parse arguments - getParser().doParse(args); + SimExplorerContext(String... args) throws IOException, ParserException { - // init configs - getParser().initConfigs(); + super(args); - // init i18n with user locale (or default one if not found) - initI18n(); - - // mark if first launch - setFirstLaunch(!getConfig().getSource().exists()); - - } catch (ParserException e) { - throw new SimExplorerRuntimeException(e); - } catch (IOException e) { - throw new SimExplorerRuntimeException(e); - } + initServices(); } @@ -305,10 +205,8 @@ throw new SimExplorerRuntimeException(e); } } - if (localService != null) { - // init the cache - localCache = new LoggableElementCache(this, localService); - } + // init the cache + localCache = new LoggableElementCache(this, localService); } return localService; }