Author: tchemit Date: 2008-01-24 11:08:58 +0000 (Thu, 24 Jan 2008) New Revision: 483 Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerContext.java Log: javadoc + normalisation nom storage service Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerContext.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerContext.java 2008-01-24 10:39:32 UTC (rev 482) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerContext.java 2008-01-24 11:08:58 UTC (rev 483) @@ -18,10 +18,10 @@ * ##% */ package fr.cemagref.simexplorer.is.ui; +import fr.cemagref.simexplorer.is.security.service.AuthenticationService; +import fr.cemagref.simexplorer.is.service.MockStorageServiceImpl; +import fr.cemagref.simexplorer.is.service.StorageService; import fr.cemagref.simexplorer.is.ui.actions.SimExplorerCommonActions; -import fr.cemagref.simexplorer.is.service.StorageService; -import fr.cemagref.simexplorer.is.service.MockStorageServiceImpl; -import fr.cemagref.simexplorer.is.security.service.AuthenticationService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.option.ParserException; @@ -41,9 +41,10 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(SimExplorerContext.class); + /** - * le parseur utilisaé au démarrage pour récupérer les options passées - * par l'utilisateur + * le parseur utilisé au démarrage pour récupérer les options passées + * par l'utilisateur. */ protected SimExplorerOptionParser parser; @@ -68,21 +69,26 @@ /** le service de données distant */ protected StorageService storageService; + /** le service d'authentification */ protected AuthenticationService authenticationService; + /** + * @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(); // enregistrement des actions concretes parser.registerActions(SimExplorerCommonActions.class); - // enregistrement des configs concretes parser.registerConfig(SimExplorerConfig.class); } return parser; } + /** @return la configuration de l'application */ public SimExplorerConfig getConfig() { return (SimExplorerConfig) getParser().getMainConfig(); } @@ -95,6 +101,11 @@ return token == null || token.isEmpty(); } + /** + * Sauvegarde la configuration courante de l'utilisateur. + * + * @throws IOException si problème lors de l'écriture du fichier de configuration + */ public void save() throws IOException { if (getConfig().getSource() == null) { return; @@ -108,6 +119,10 @@ } } + /** + * Sauvegarde la configuration de l'utilisateur sans soulever d'exception + * si un problème est survenu lors de l'opération. + */ public void saveSafely() { try { save(); @@ -116,22 +131,64 @@ } } + /** + * @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> + */ public String getToken() { return token; } + /** @return le service de storage locale */ + public StorageService getLocalStorageService() { + if (storageService == null) { + storageService = new MockStorageServiceImpl(); + } + return storageService; + } + + /** @return le service de storage distant */ + public StorageService getRemoteStorageService() { + if (remoteStorageService == null) { + remoteStorageService = new MockStorageServiceImpl(); + } + return remoteStorageService; + } + + /** @return le service d'authentification */ + public AuthenticationService getAuthenticationService() { + if (authenticationService == null) { + //authenticationService = new AuthenticationService(); + } + return authenticationService; + } + public void setQuit(boolean quit) { this.quit = quit; } @@ -153,6 +210,11 @@ } + /** + * Initialisation du parseur d'options. + * + * @param args les arguments passés au démarrage de l'application + */ void initParser(String... args) { try { getParser().doParse(args); @@ -163,29 +225,8 @@ } } + /** Initialisation de la configuration utilisateur */ void initConfig() { getConfig().initI18n(); } - - - public StorageService getStorageService() { - if (storageService == null) { - storageService = new MockStorageServiceImpl(); - } - return storageService; - } - - public StorageService getRemoteStorageService() { - if (remoteStorageService == null) { - remoteStorageService = new MockStorageServiceImpl(); - } - return remoteStorageService; - } - - public AuthenticationService getAuthenticationService() { - if (authenticationService == null) { - //authenticationService = new AuthenticationService(); - } - return authenticationService; - } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org