Author: tchemit Date: 2008-01-24 10:39:32 +0000 (Thu, 24 Jan 2008) New Revision: 482 Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerContext.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java Log: acc?\195?\168s aux services depui le context de l'appli Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java 2008-01-24 10:36:35 UTC (rev 481) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java 2008-01-24 10:39:32 UTC (rev 482) @@ -18,12 +18,10 @@ * ##% */ package fr.cemagref.simexplorer.is.ui; -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.SimExplorerActionManager; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; -import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; import org.codelutin.i18n.I18n; import org.codelutin.option.ui.ConfigTableModel; @@ -42,12 +40,6 @@ /** 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; @@ -141,20 +133,6 @@ } - 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 SimExplorerRuntimeException("context is null, you must init first the " + SimExplorer.class.getName() + " class via init method"); 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:36:35 UTC (rev 481) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerContext.java 2008-01-24 10:39:32 UTC (rev 482) @@ -19,6 +19,9 @@ package fr.cemagref.simexplorer.is.ui; 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; @@ -59,6 +62,14 @@ /** le token pour la connexion au serveur distant */ protected String token; + /** le service de données local */ + protected StorageService remoteStorageService; + + /** le service de données distant */ + protected StorageService storageService; + + protected AuthenticationService authenticationService; + public SimExplorerOptionParser getParser() { if (parser == null) { // creation du parseur @@ -76,6 +87,14 @@ return (SimExplorerConfig) getParser().getMainConfig(); } + /** + * @return <code>true</code> si l'utilisateur est connecté, + * <code>false</code> sinon. + */ + public boolean isConnected() { + return token == null || token.isEmpty(); + } + public void save() throws IOException { if (getConfig().getSource() == null) { return; @@ -147,4 +166,26 @@ 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; + } } Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java 2008-01-24 10:36:35 UTC (rev 481) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractTabAction.java 2008-01-24 10:39:32 UTC (rev 482) @@ -21,8 +21,8 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; import fr.cemagref.simexplorer.is.service.StorageService; -import fr.cemagref.simexplorer.is.ui.SimExplorer; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; +import fr.cemagref.simexplorer.is.security.service.AuthenticationService; import jaxx.runtime.JAXXObject; import jaxx.runtime.builder.TabModel; import org.apache.commons.beanutils.Converter; @@ -107,17 +107,9 @@ protected int getCount(boolean remote, String token, String query) throws Exception { int size; if (query == null || query.isEmpty()) { - if (remote) { - size = SimExplorer.getRemoteStorageService().findApplicationsCount(token, false); - } else { - size = SimExplorer.getStorageService().findApplicationsCount(token, false); - } + size = getStorageService(remote).findApplicationsCount(token, false); } else { - if (remote) { - size = SimExplorer.getRemoteStorageService().findFullTextCount(token, query, false); - } else { - size = SimExplorer.getStorageService().findFullTextCount(token, query, false); - } + size = getStorageService(remote).findFullTextCount(token, query, false); } return size; } @@ -137,10 +129,14 @@ protected StorageService getStorageService(boolean remote) { StorageService service; - service = remote ? SimExplorer.getRemoteStorageService() : SimExplorer.getStorageService(); + service = remote ? getContext().getRemoteStorageService() : getContext().getStorageService(); return service; } + protected AuthenticationService getAuthenticationService() { + return getContext().getAuthenticationService(); + } + protected LoggableElement getElement(boolean remote, String uuid, String version) throws Exception { StorageService service = getStorageService(remote); LoggableElement data;