Author: vjrj Date: 2008-06-01 06:01:10 +0200 (Sun, 01 Jun 2008) New Revision: 771 Added: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientNewModule.java trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java Removed: trunk/src/main/java/org/ourproject/kune/platf/client/Services.java trunk/src/main/java/org/ourproject/kune/platf/client/extend/HelloWorldPlugin.java trunk/src/main/java/org/ourproject/kune/platf/client/extend/Plugin.java trunk/src/main/java/org/ourproject/kune/platf/client/extend/PluginManager.java trunk/src/test/java/org/ourproject/kune/platf/client/stubs/ Modified: trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientTool.java trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineXmpp.java trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationBuilder.java trunk/src/main/java/org/ourproject/kune/platf/client/extend/ClientModule.java trunk/src/main/java/org/ourproject/kune/platf/client/services/Kune.java trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java trunk/src/main/java/org/ourproject/kune/platf/client/state/ContentProviderImpl.java trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionImpl.java trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java trunk/src/main/java/org/ourproject/kune/workspace/client/actions/LoggedInAction.java trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java trunk/src/test/java/org/ourproject/kune/sitebar/client/ui/LoginPresenterTest.java Log: more modules... Modified: trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2008-06-01 04:01:10 UTC (rev 771) @@ -23,12 +23,14 @@ import org.ourproject.kune.platf.client.app.ApplicationBuilder; import org.ourproject.kune.platf.client.dto.I18nLanguageDTO; -import org.ourproject.kune.platf.client.services.Kune; +import org.ourproject.kune.platf.client.rpc.I18nService; +import org.ourproject.kune.platf.client.rpc.I18nServiceAsync; +import org.ourproject.kune.platf.client.ui.Location; +import org.ourproject.kune.platf.client.ui.WindowUtils; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -51,22 +53,23 @@ } public void onModuleLoadCont() { - final String userHash = Cookies.getCookie("userHash"); - Kune.I18N.getInitialLanguage(new AsyncCallback<I18nLanguageDTO>() { + Location loc = WindowUtils.getLocation(); + String locale = loc.getParameter("locale"); + final I18nServiceAsync server = I18nService.App.getInstance(); + server.getInitialLanguage(locale, new AsyncCallback<I18nLanguageDTO>() { public void onFailure(final Throwable caught) { Log.debug("Workspace adaptation to your language failed"); } public void onSuccess(final I18nLanguageDTO result) { final I18nLanguageDTO initialLang = result; - Kune.I18N.getInitialLexicon(initialLang.getCode(), new AsyncCallback<HashMap<String, String>>() { + server.getLexicon(initialLang.getCode(), new AsyncCallback<HashMap<String, String>>() { public void onFailure(final Throwable caught) { Log.debug("Workspace adaptation to your language failed"); } public void onSuccess(final HashMap<String, String> lexicon) { - Kune.I18N.setLexicon(lexicon); - new ApplicationBuilder().build(userHash, initialLang); + new ApplicationBuilder().build(initialLang, lexicon); } }); } Added: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientNewModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientNewModule.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientNewModule.java 2008-06-01 04:01:10 UTC (rev 771) @@ -0,0 +1,40 @@ +package org.ourproject.kune.chat.client; + +import org.ourproject.kune.platf.client.KunePlatform; +import org.ourproject.kune.platf.client.state.Session; +import org.ourproject.kune.platf.client.state.StateManager; +import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; + +import com.calclab.emite.client.modular.Container; +import com.calclab.emite.client.modular.Module; +import com.calclab.emite.client.modular.ModuleBuilder; +import com.calclab.emite.client.modular.Provider; +import com.calclab.emite.client.modular.Scopes; +import com.calclab.emiteuimodule.client.EmiteUIDialog; + +public class ChatClientNewModule implements Module { + public static ChatClientTool getChatClientTool(final Container components) { + return components.getInstance(ChatClientTool.class); + } + + public Class<? extends Module> getType() { + return ChatClientNewModule.class; + } + + public void onLoad(final ModuleBuilder builder) { + builder.registerProvider(ChatClientTool.class, new Provider<ChatClientTool>() { + public ChatClientTool get() { + return new ChatClientTool(builder.getInstance(I18nUITranslationService.class), builder + .getInstance(EmiteUIDialog.class)); + } + }, Scopes.SINGLETON_EAGER); + + KunePlatform platform = builder.getInstance(KunePlatform.class); + ChatClientTool chatClientTool = getChatClientTool(builder); + platform.addTool(chatClientTool); + + Session session = builder.getInstance(Session.class); + StateManager stateManager = builder.getInstance(StateManager.class); + platform.install(new ChatClientModule(session, stateManager, chatClientTool)); + } +} Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientTool.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientTool.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientTool.java 2008-06-01 04:01:10 UTC (rev 771) @@ -21,10 +21,12 @@ package org.ourproject.kune.chat.client; import org.ourproject.kune.platf.client.dto.StateDTO; -import org.ourproject.kune.platf.client.services.Kune; +import org.ourproject.kune.platf.client.services.I18nTranslationService; import org.ourproject.kune.platf.client.tool.AbstractClientTool; import org.ourproject.kune.workspace.client.component.WorkspaceComponent; +import com.calclab.emiteuimodule.client.EmiteUIDialog; + public class ChatClientTool extends AbstractClientTool implements ChatProvider { public static final String NAME = "chats"; public static final String TYPE_ROOT = "chat.root"; @@ -33,12 +35,12 @@ private final ChatToolComponents components; private ChatEngine chat; - private final Kune kune; + private final EmiteUIDialog emiteUIDialog; - public ChatClientTool(final Kune kune) { - super(Kune.I18N.t("chat rooms")); - this.kune = kune; - components = new ChatToolComponents(kune.getEmiteUIDialog()); + public ChatClientTool(final I18nTranslationService i18n, final EmiteUIDialog emiteUIDialog) { + super(i18n.t("chat rooms")); + this.emiteUIDialog = emiteUIDialog; + components = new ChatToolComponents(emiteUIDialog); } public ChatEngine getChat() { @@ -58,7 +60,7 @@ } public void initEngine(final ChatOptions options) { - this.chat = new ChatEngineXmpp(kune.getEmiteUIDialog(), options); + this.chat = new ChatEngineXmpp(emiteUIDialog, options); } public void setContent(final StateDTO state) { Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineXmpp.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineXmpp.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineXmpp.java 2008-06-01 04:01:10 UTC (rev 771) @@ -23,14 +23,12 @@ import org.ourproject.kune.platf.client.services.Kune; -import com.allen_sauer.gwt.log.client.Log; import com.calclab.emite.client.core.signal.Listener; import com.calclab.emite.client.im.roster.RosterManager.SubscriptionMode; import com.calclab.emite.client.xmpp.stanzas.XmppURI; import com.calclab.emiteuimodule.client.EmiteUIDialog; import com.calclab.emiteuimodule.client.UserChatOptions; import com.calclab.emiteuimodule.client.params.AvatarProvider; -import com.calclab.emiteuimodule.client.params.MultiChatCreationParam; import com.calclab.emiteuimodule.client.status.OwnPresence.OwnStatus; import com.google.gwt.user.client.Window; @@ -67,6 +65,11 @@ }; final String initialWindowTitle = Window.getTitle(); + chatOptions.userOptions = userChatOptions; + emiteDialog.start(userChatOptions, chatOptions.httpBase, chatOptions.roomHost, avatarProvider, Kune.I18N + .t("Chat")); + emiteDialog.show(OwnStatus.online); + emiteDialog.hide(); emiteDialog.onConversationAttended(new Listener<String>() { public void onEvent(final String parameter) { Window.setTitle(initialWindowTitle); @@ -77,13 +80,6 @@ Window.setTitle("(* " + chatTitle + ") " + initialWindowTitle); } }); - chatOptions.userOptions = userChatOptions; - - emiteDialog.getChatDialog(new MultiChatCreationParam(Kune.I18N.t("Chat"), chatOptions.roomHost, avatarProvider, - chatOptions.userOptions)); - Log.debug("LOGIN CHAT: " + chatName + "[" + chatPassword + "]"); - emiteDialog.show(OwnStatus.online); - emiteDialog.hide(); } public void logout() { Added: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java 2008-06-01 04:01:10 UTC (rev 771) @@ -0,0 +1,40 @@ +package org.ourproject.kune.docs.client; + +import org.ourproject.kune.platf.client.KunePlatform; +import org.ourproject.kune.platf.client.app.Application; +import org.ourproject.kune.platf.client.state.Session; +import org.ourproject.kune.platf.client.state.StateManager; +import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; + +import com.calclab.emite.client.modular.Container; +import com.calclab.emite.client.modular.Module; +import com.calclab.emite.client.modular.ModuleBuilder; +import com.calclab.emite.client.modular.Provider; +import com.calclab.emite.client.modular.Scopes; + +public class DocumentClientNewModule implements Module { + public static DocumentClientTool getDocumentClientTool(final Container components) { + return components.getInstance(DocumentClientTool.class); + } + + public Class<? extends Module> getType() { + return DocumentClientNewModule.class; + } + + public void onLoad(final ModuleBuilder builder) { + builder.registerProvider(DocumentClientTool.class, new Provider<DocumentClientTool>() { + public DocumentClientTool get() { + return new DocumentClientTool(builder.getInstance(I18nUITranslationService.class)); + } + }, Scopes.SINGLETON_EAGER); + KunePlatform platform = builder.getInstance(KunePlatform.class); + DocumentClientTool docClientTool = getDocumentClientTool(builder); + platform.addTool(docClientTool); + + Session session = builder.getInstance(Session.class); + StateManager stateManager = builder.getInstance(StateManager.class); + Application application = builder.getInstance(Application.class); + platform.install(new DocsClientModule(session, stateManager, application.getWorkspace())); + } + +} Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-06-01 04:01:10 UTC (rev 771) @@ -24,9 +24,9 @@ import org.ourproject.kune.docs.client.cnt.DocumentContentListener; import org.ourproject.kune.docs.client.ctx.DocumentContext; import org.ourproject.kune.platf.client.dto.StateDTO; -import org.ourproject.kune.platf.client.services.Kune; import org.ourproject.kune.platf.client.tool.AbstractClientTool; import org.ourproject.kune.workspace.client.component.WorkspaceComponent; +import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; public class DocumentClientTool extends AbstractClientTool implements DocumentContentListener { public static final String TYPE_ROOT = "docs.root"; @@ -35,8 +35,8 @@ public static final String NAME = "docs"; private final DocToolComponents components; - public DocumentClientTool() { - super(Kune.I18N.t("documents")); + public DocumentClientTool(final I18nUITranslationService i18n) { + super(i18n.t("documents")); components = new DocToolComponents(this); } @@ -52,6 +52,14 @@ return NAME; } + public void onCancel() { + components.getContext().showFolders(); + } + + public void onEdit() { + components.getContext().showAdmin(); + } + public void setContent(final StateDTO state) { DocumentContent docContent = components.getContent(); docContent.setContent(state); @@ -65,12 +73,4 @@ context.setContext(state); } - public void onEdit() { - components.getContext().showAdmin(); - } - - public void onCancel() { - components.getContext().showFolders(); - } - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java 2008-06-01 04:01:10 UTC (rev 771) @@ -21,6 +21,7 @@ package org.ourproject.kune.platf.client; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import org.ourproject.kune.platf.client.dispatch.Action; @@ -38,25 +39,35 @@ this.actions = new ArrayList<ActionEvent<?>>(); } + @SuppressWarnings("unchecked") + public void addAction(final String eventName, final Action<?> action) { + actions.add(new ActionEvent(eventName, action)); + } + public void addTool(final ClientTool clientTool) { tools.add(clientTool); } - @SuppressWarnings("unchecked") - public void addAction(final String eventName, final Action<?> action) { - actions.add(new ActionEvent(eventName, action)); + public ArrayList<ActionEvent<?>> getActions() { + return actions; } - public void install(final ClientModule module) { - module.configure(this); + public HashMap<String, ClientTool> getIndexedTools() { + final HashMap<String, ClientTool> tools = new HashMap<String, ClientTool>(); + final int total = tools.size(); + for (int index = 0; index < total; index++) { + final ClientTool clientTool = tools.get(index); + tools.put(clientTool.getName(), clientTool); + } + return tools; } public List<ClientTool> getTools() { return tools; } - public ArrayList<ActionEvent<?>> getActions() { - return actions; + public void install(final ClientModule module) { + module.configure(this); } } Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/Services.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/Services.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/Services.java 2008-06-01 04:01:10 UTC (rev 771) @@ -1,48 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.platf.client; - -import org.ourproject.kune.platf.client.app.Application; -import org.ourproject.kune.platf.client.dispatch.Dispatcher; -import org.ourproject.kune.platf.client.extend.ExtensibleWidgetsManager; -import org.ourproject.kune.platf.client.services.I18nTranslationService; -import org.ourproject.kune.platf.client.state.Session; -import org.ourproject.kune.platf.client.state.StateManager; - -public class Services { - public final Application app; - public final StateManager stateManager; - public final Dispatcher dispatcher; - public final Session session; - public final ExtensibleWidgetsManager extensionPointManager; - public final I18nTranslationService i18n; - - public Services(final Application application, final StateManager stateManager, final Dispatcher dispatcher, - final Session session, final ExtensibleWidgetsManager extensionPointManager, - final I18nTranslationService i18n) { - this.app = application; - this.stateManager = stateManager; - this.dispatcher = dispatcher; - this.session = session; - this.extensionPointManager = extensionPointManager; - this.i18n = i18n; - } - -} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java 2008-06-01 04:01:10 UTC (rev 771) @@ -20,6 +20,7 @@ package org.ourproject.kune.platf.client.app; +import org.ourproject.kune.platf.client.dispatch.DefaultDispatcher; import org.ourproject.kune.platf.client.dispatch.Dispatcher; import org.ourproject.kune.platf.client.state.StateManager; import org.ourproject.kune.platf.client.tool.ClientTool; @@ -27,14 +28,16 @@ public interface Application { - ClientTool getTool(String toolName); - Dispatcher getDispatcher(); StateManager getStateManager(); + ClientTool getTool(String toolName); + Workspace getWorkspace(); + void init(DefaultDispatcher dispatcher, StateManager stateManager); + /** * Communicates to every tool the current group * Modified: trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationBuilder.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationBuilder.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationBuilder.java 2008-06-01 04:01:10 UTC (rev 771) @@ -23,31 +23,17 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import java.util.List; -import org.ourproject.kune.chat.client.ChatClientModule; -import org.ourproject.kune.chat.client.ChatClientTool; -import org.ourproject.kune.docs.client.DocsClientModule; -import org.ourproject.kune.docs.client.DocumentClientTool; import org.ourproject.kune.platf.client.KunePlatform; import org.ourproject.kune.platf.client.PlatformClientModule; import org.ourproject.kune.platf.client.dispatch.ActionEvent; import org.ourproject.kune.platf.client.dispatch.DefaultDispatcher; import org.ourproject.kune.platf.client.dto.I18nLanguageDTO; -import org.ourproject.kune.platf.client.extend.ExtensibleWidgetsManager; -import org.ourproject.kune.platf.client.rpc.ContentService; import org.ourproject.kune.platf.client.services.Kune; -import org.ourproject.kune.platf.client.services.KuneErrorHandler; -import org.ourproject.kune.platf.client.state.ContentProvider; -import org.ourproject.kune.platf.client.state.ContentProviderImpl; import org.ourproject.kune.platf.client.state.Session; -import org.ourproject.kune.platf.client.state.SessionImpl; import org.ourproject.kune.platf.client.state.StateManager; -import org.ourproject.kune.platf.client.state.StateManagerDefault; -import org.ourproject.kune.platf.client.tool.ClientTool; import org.ourproject.kune.workspace.client.WorkspaceClientModule; import org.ourproject.kune.workspace.client.sitebar.Site; -import org.ourproject.kune.workspace.client.workspace.Workspace; import com.google.gwt.user.client.History; import com.google.gwt.user.client.Window; @@ -58,52 +44,27 @@ public ApplicationBuilder() { } - public void build(final String userHash, final I18nLanguageDTO initialLang) { - final Kune kune = Kune.getInstance(); + public void build(final I18nLanguageDTO initialLang, final HashMap<String, String> lexicon) { + final Kune kune = Kune.create(initialLang, lexicon); + final Session session = kune.getSession(); - final KunePlatform platform = new KunePlatform(); - final ChatClientTool chatClientTool = new ChatClientTool(kune); - platform.addTool(new DocumentClientTool()); - platform.addTool(chatClientTool); - // platform.addTool(new BlogClientTool()); - - final HashMap<String, ClientTool> tools = indexTools(platform.getTools()); - - final Session session = new SessionImpl(userHash, initialLang); - new KuneErrorHandler(session); - - final ExtensibleWidgetsManager extensionPointManager = new ExtensibleWidgetsManager(); - final DefaultApplication application = new DefaultApplication(tools, session, extensionPointManager); - final Workspace workspace = application.getWorkspace(); Site.showProgressLoading(); Site.mask(); - final ContentProvider provider = new ContentProviderImpl(ContentService.App.getInstance()); + final KunePlatform platform = kune.getPlatform(); + final StateManager stateManager = kune.getStateManager(); + final Application application = kune.getInstance(Application.class); - final HistoryWrapper historyWrapper = new HistoryWrapperImpl(); - final StateManager stateManager = new StateManagerDefault(provider, application, session, historyWrapper); History.addHistoryListener(stateManager); platform.install(new PlatformClientModule(session, stateManager)); - platform.install(new ChatClientModule(session, stateManager, chatClientTool)); - platform.install(new WorkspaceClientModule(session, stateManager, workspace)); - platform.install(new DocsClientModule(session, stateManager, workspace)); - // platform.install(new BlogsClientModule()); + platform.install(new WorkspaceClientModule(session, stateManager, application.getWorkspace())); final DefaultDispatcher dispatcher = DefaultDispatcher.getInstance(); - // Services services = new Services(application, stateManager, - // dispatcher, session, extensionPointManager, - // Kune.I18N); - application.init(dispatcher, stateManager); subscribeActions(dispatcher, platform.getActions()); - // final PluginManager pluginManager = new PluginManager(dispatcher, - // extensionPointManager, Kune.I18N); - // pluginManager.install(new HelloWorldPlugin()); - // pluginManager.install(new EmiteUIPlugin()); - Window.addWindowCloseListener(new WindowCloseListener() { public void onWindowClosed() { application.stop(); @@ -116,16 +77,6 @@ application.start(); } - private HashMap<String, ClientTool> indexTools(final List<ClientTool> toolList) { - final HashMap<String, ClientTool> tools = new HashMap<String, ClientTool>(); - final int total = toolList.size(); - for (int index = 0; index < total; index++) { - final ClientTool clientTool = toolList.get(index); - tools.put(clientTool.getName(), clientTool); - } - return tools; - } - private void subscribeActions(final DefaultDispatcher dispatcher, final ArrayList<ActionEvent<?>> actions) { ActionEvent<?> actionEvent; Modified: trunk/src/main/java/org/ourproject/kune/platf/client/extend/ClientModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/extend/ClientModule.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/extend/ClientModule.java 2008-06-01 04:01:10 UTC (rev 771) @@ -20,8 +20,9 @@ package org.ourproject.kune.platf.client.extend; -public interface ClientModule { +public interface ClientModule {// extends Module { + public void configure(Register register); } Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/extend/HelloWorldPlugin.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/extend/HelloWorldPlugin.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/extend/HelloWorldPlugin.java 2008-06-01 04:01:10 UTC (rev 771) @@ -1,126 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.platf.client.extend; - -import org.ourproject.kune.platf.client.PlatformEvents; -import org.ourproject.kune.platf.client.View; - -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Widget; - -public class HelloWorldPlugin extends Plugin { - - private HelloWorldPresenter helloWorld; - - public HelloWorldPlugin() { - super("HelloWorldPlugin"); - } - - @Override - protected void start() { - helloWorld = new HelloWorldPresenter(); - HelloWorldPanel panel = new HelloWorldPanel(helloWorld); - helloWorld.init(panel); - - getDispatcher().fire(PlatformEvents.ATTACH_TO_EXTENSIBLE_WIDGET, - new ExtensibleWidgetChild(ExtensibleWidgetId.CONTENT_BOTTOM_ICONBAR, helloWorld.getView())); - } - - @Override - protected void stop() { - getDispatcher().fire(PlatformEvents.DETACH_FROM_EXTENSIBLE_WIDGET, - new ExtensibleWidgetChild(ExtensibleWidgetId.CONTENT_BOTTOM_ICONBAR, helloWorld.getView())); - } - - class HelloWorldPresenter { - private HelloWorldView view; - - public HelloWorldPresenter() { - } - - void init(final HelloWorldView view) { - this.view = view; - } - - public View getView() { - return view; - } - - public void registerExtensibleWidget(final String id, final ExtensibleWidget extWidget) { - getExtensionPointManager().registerExtensibleWidget(id, extWidget); - } - - public void attachToExtensibleWidget(final ExtensibleWidgetChild child) { - getExtensionPointManager().attachToExtensible(child); - } - } - - interface HelloWorldView extends View { - } - - class HelloWorldPanel extends Composite implements HelloWorldView, ExtensibleWidget { - - private static final String HELLOWORLDPLUGIN_EXT_WIDGET = "helloworldplugin.extwidget"; - private final HorizontalPanel hp; - - public HelloWorldPanel(final HelloWorldPresenter presenter) { - hp = new HorizontalPanel(); - initWidget(hp); - hp.add(new Label("Hello")); - - // Registering a new extensible point - presenter.registerExtensibleWidget(HELLOWORLDPLUGIN_EXT_WIDGET, this); - - presenter.attachToExtensibleWidget(new ExtensibleWidgetChild(HELLOWORLDPLUGIN_EXT_WIDGET, new World())); - } - - public void attach(final ExtensibleWidgetChild child) { - if (child.getParentId().equals(HELLOWORLDPLUGIN_EXT_WIDGET)) { - hp.add((Widget) child.getView()); - } else { - // Other extension points in this widget here - } - } - - public void detach(final ExtensibleWidgetChild child) { - if (child.getParentId().equals(HELLOWORLDPLUGIN_EXT_WIDGET)) { - hp.remove((Widget) child.getView()); - } else { - // Other extension points in this widget here - } - } - - public void detachAll(final String id) { - if (id.equals(HELLOWORLDPLUGIN_EXT_WIDGET)) { - hp.clear(); - } - } - - private class World extends Label implements View { - public World() { - super("World"); - } - } - - } - -} Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/extend/Plugin.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/extend/Plugin.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/extend/Plugin.java 2008-06-01 04:01:10 UTC (rev 771) @@ -1,73 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.platf.client.extend; - -import org.ourproject.kune.platf.client.dispatch.Dispatcher; -import org.ourproject.kune.platf.client.services.I18nTranslationService; - -public abstract class Plugin { - private String name; - private final boolean started; - private ExtensibleWidgetsManager extensionPointManager; - private I18nTranslationService i18n; - private Dispatcher dispatcher; - - public Plugin(final String name) { - this.name = name; - this.started = false; - // InitDataDTO... - } - - protected void init(final Dispatcher dispatcher, final ExtensibleWidgetsManager extensionPointManager, - final I18nTranslationService i18n) { - this.dispatcher = dispatcher; - this.extensionPointManager = extensionPointManager; - this.i18n = i18n; - } - - public final boolean isActive() { - return started; - } - - public final Dispatcher getDispatcher() { - return dispatcher; - } - - public final I18nTranslationService getI18n() { - return i18n; - } - - public ExtensibleWidgetsManager getExtensionPointManager() { - return extensionPointManager; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - protected abstract void start(); - - protected abstract void stop(); - -} Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/extend/PluginManager.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/extend/PluginManager.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/extend/PluginManager.java 2008-06-01 04:01:10 UTC (rev 771) @@ -1,61 +0,0 @@ -/* - * - * Copyright (C) 2007-2008 The kune development team (see CREDITS for details) - * This file is part of kune. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.ourproject.kune.platf.client.extend; - -import java.util.HashMap; - -import org.ourproject.kune.platf.client.dispatch.Dispatcher; -import org.ourproject.kune.platf.client.services.I18nTranslationService; - -public class PluginManager { - - private final HashMap<String, Plugin> plugins; - private final Dispatcher dispacher; - private final ExtensibleWidgetsManager extensionPointManager; - private final I18nTranslationService i18n; - - public PluginManager(final Dispatcher dispacher, final ExtensibleWidgetsManager extensionPointManager, - final I18nTranslationService i18n) { - plugins = new HashMap<String, Plugin>(); - this.dispacher = dispacher; - this.extensionPointManager = extensionPointManager; - this.i18n = i18n; - } - - public void install(final Plugin plugin) { - String name = plugin.getName(); - if (plugins.containsKey(name)) { - throw new RuntimeException("Plugin with this name already installed"); - } - plugins.put(name, plugin); - plugin.init(dispacher, extensionPointManager, i18n); - plugin.start(); - } - - public void uninstall(final String name) { - if (!plugins.containsKey(name)) { - throw new RuntimeException("Plugin with this name not installed"); - } - Plugin plugin = plugins.get(name); - plugin.stop(); - plugins.remove(name); - } - -} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/Kune.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/services/Kune.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/services/Kune.java 2008-06-01 04:01:10 UTC (rev 771) @@ -20,7 +20,17 @@ package org.ourproject.kune.platf.client.services; +import java.util.HashMap; + +import org.ourproject.kune.chat.client.ChatClientNewModule; +import org.ourproject.kune.docs.client.DocumentClientNewModule; +import org.ourproject.kune.platf.client.KunePlatform; +import org.ourproject.kune.platf.client.app.Application; +import org.ourproject.kune.platf.client.dto.I18nLanguageDTO; +import org.ourproject.kune.platf.client.state.Session; +import org.ourproject.kune.platf.client.state.StateManager; import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; +import org.ourproject.kune.workspace.client.workspace.Workspace; import com.calclab.emite.client.modular.Container; import com.calclab.emite.client.modular.DelegatedContainer; @@ -37,8 +47,9 @@ private static Kune instance; - public static Kune create() { - return create(new KuneModule(), new EmiteUIModule()); + public static Kune create(final I18nLanguageDTO initialLang, final HashMap<String, String> lexicon) { + return instance = create(new KuneModule(initialLang, lexicon), new EmiteUIModule(), + new DocumentClientNewModule(), new ChatClientNewModule()); } public static Kune create(final Module... modules) { @@ -48,9 +59,6 @@ } public static Kune getInstance() { - if (instance == null) { - instance = create(); - } return instance; } @@ -70,4 +78,20 @@ return this.getInstance(I18nUITranslationService.class); } + public KunePlatform getPlatform() { + return this.getInstance(KunePlatform.class); + } + + public Session getSession() { + return this.getInstance(Session.class); + } + + public StateManager getStateManager() { + return this.getInstance(StateManager.class); + } + + public Workspace getWorkspace() { + return this.getInstance(Application.class).getWorkspace(); + } + } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2008-06-01 04:01:10 UTC (rev 771) @@ -36,6 +36,12 @@ public class KuneErrorHandler { private static KuneErrorHandler instance; + + @Deprecated + public static KuneErrorHandler getInstance() { + return instance; + } + private final Session session; public KuneErrorHandler(final Session session) { @@ -82,8 +88,4 @@ Site.showAlertMessage(Kune.I18N.t("Your session has expired. Please login again.")); } - public static KuneErrorHandler getInstance() { - return instance; - } - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-06-01 04:01:10 UTC (rev 771) @@ -1,5 +1,21 @@ package org.ourproject.kune.platf.client.services; +import java.util.HashMap; + +import org.ourproject.kune.platf.client.KunePlatform; +import org.ourproject.kune.platf.client.app.Application; +import org.ourproject.kune.platf.client.app.DefaultApplication; +import org.ourproject.kune.platf.client.app.HistoryWrapper; +import org.ourproject.kune.platf.client.app.HistoryWrapperImpl; +import org.ourproject.kune.platf.client.dto.I18nLanguageDTO; +import org.ourproject.kune.platf.client.extend.ExtensibleWidgetsManager; +import org.ourproject.kune.platf.client.rpc.ContentService; +import org.ourproject.kune.platf.client.state.ContentProviderImpl; +import org.ourproject.kune.platf.client.state.Session; +import org.ourproject.kune.platf.client.state.SessionImpl; +import org.ourproject.kune.platf.client.state.StateManager; +import org.ourproject.kune.platf.client.state.StateManagerDefault; +import org.ourproject.kune.platf.client.tool.ClientTool; import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService; import com.calclab.emite.client.modular.Container; @@ -7,6 +23,7 @@ import com.calclab.emite.client.modular.ModuleBuilder; import com.calclab.emite.client.modular.Provider; import com.calclab.emite.client.modular.Scopes; +import com.google.gwt.user.client.Cookies; public class KuneModule implements Module { @@ -14,30 +31,82 @@ return container.getInstance(Kune.class); } + private final I18nLanguageDTO initialLang; + private final HashMap<String, String> lexicon; + + public KuneModule(final I18nLanguageDTO initialLang, final HashMap<String, String> lexicon) { + this.initialLang = initialLang; + this.lexicon = lexicon; + } + public Class<? extends Module> getType() { return KuneModule.class; } public void onLoad(final ModuleBuilder builder) { - builder.add(new KuneModule()); builder.registerProvider(Kune.class, new Provider<Kune>() { public Kune get() { return new Kune(builder); } - }, Scopes.SINGLETON); builder.registerProvider(I18nUITranslationService.class, new Provider<I18nUITranslationService>() { public I18nUITranslationService get() { - return new I18nUITranslationService(); + I18nUITranslationService translationService = new I18nUITranslationService(); + translationService.setCurrentLanguage(initialLang.getCode()); + translationService.setLexicon(lexicon); + return translationService; } }, Scopes.SINGLETON); + builder.registerProvider(Session.class, new Provider<Session>() { + public Session get() { + return new SessionImpl(Cookies.getCookie("userHash"), initialLang); + } + }, Scopes.SINGLETON); + + builder.registerProvider(KuneErrorHandler.class, new Provider<KuneErrorHandler>() { + public KuneErrorHandler get() { + return new KuneErrorHandler(builder.getInstance(Session.class)); + } + }); + + builder.registerProvider(KunePlatform.class, new Provider<KunePlatform>() { + public KunePlatform get() { + return new KunePlatform(); + } + }, Scopes.SINGLETON); + builder.registerProvider(ColorTheme.class, new Provider<ColorTheme>() { public ColorTheme get() { return new ColorTheme(); } }, Scopes.SINGLETON); + + builder.registerProvider(ExtensibleWidgetsManager.class, new Provider<ExtensibleWidgetsManager>() { + public ExtensibleWidgetsManager get() { + return new ExtensibleWidgetsManager(); + } + }); + + final Session session = builder.getInstance(Session.class); + + builder.registerProvider(Application.class, new Provider<Application>() { + public Application get() { + HashMap<String, ClientTool> tools = builder.getInstance(KunePlatform.class).getIndexedTools(); + ExtensibleWidgetsManager extensionPointManager = builder.getInstance(ExtensibleWidgetsManager.class); + return new DefaultApplication(tools, session, extensionPointManager); + } + }); + + builder.registerProvider(StateManager.class, new Provider<StateManager>() { + public StateManager get() { + ContentProviderImpl provider = new ContentProviderImpl(ContentService.App.getInstance()); + final HistoryWrapper historyWrapper = new HistoryWrapperImpl(); + Application application = builder.getInstance(Application.class); + return new StateManagerDefault(provider, application, session, historyWrapper); + } + }); + } - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/state/ContentProviderImpl.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/state/ContentProviderImpl.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/state/ContentProviderImpl.java 2008-06-01 04:01:10 UTC (rev 771) @@ -39,6 +39,10 @@ this.cache = new HashMap<StateToken, StateDTO>(); } + public void cache(final StateToken encodeState, final StateDTO content) { + cache.put(encodeState, content); + } + public void getContent(final String user, final StateToken newState, final AsyncCallback<StateDTO> callback) { Site.showProgressProcessing(); StateDTO catched = getCached(newState); @@ -53,8 +57,4 @@ return cache.remove(newState); } - public void cache(final StateToken encodeState, final StateDTO content) { - cache.put(encodeState, content); - } - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionImpl.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionImpl.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionImpl.java 2008-06-01 04:01:10 UTC (rev 771) @@ -50,96 +50,112 @@ private String defaultWsTheme; private I18nLanguageDTO currentLanguage; - public SessionImpl(final String usersHash, final I18nLanguageDTO initialLang) { - this.userHash = usersHash; + public SessionImpl(final String userHash, final I18nLanguageDTO initialLanguage) { + this.userHash = userHash; + currentLanguage = initialLanguage; licenses = null; languages = null; languagesArray = null; countries = null; - currentLanguage = initialLang; } - public List<LicenseDTO> getLicenses() { - return licenses; + public List<I18nCountryDTO> getCountries() { + return countries; } - public void setLicenses(final List<LicenseDTO> licenses) { - this.licenses = licenses; + public Object[][] getCountriesArray() { + if (countriesArray == null) { + countriesArray = mapCountries(); + } + return countriesArray; } - public void setCurrent(final StateDTO currentState) { - this.currentState = currentState; + public I18nLanguageDTO getCurrentLanguage() { + return currentLanguage; } public StateDTO getCurrentState() { return currentState; } - public void setCurrentState(final StateDTO currentState) { - this.currentState = currentState; + public String getDefaultWsTheme() { + return defaultWsTheme; } - public void setDefaultWsTheme(final String defaultWsTheme) { - this.defaultWsTheme = defaultWsTheme; + public List<I18nLanguageSimpleDTO> getLanguages() { + return languages; } - public void setWsThemes(final String[] wsThemes) { - this.wsThemes = wsThemes; + public Object[][] getLanguagesArray() { + if (languagesArray == null) { + languagesArray = mapLangs(); + } + return languagesArray; } + public List<LicenseDTO> getLicenses() { + return licenses; + } + + public Object[][] getTimezones() { + if (timezonesArray == null) { + mapTimezones(); + } + return timezonesArray; + } + + public String getUserHash() { + return userHash; + } + public String[] getWsThemes() { return wsThemes; } - public String getDefaultWsTheme() { - return defaultWsTheme; - } - public boolean isLogged() { return userHash != null; } - public List<I18nLanguageSimpleDTO> getLanguages() { - return languages; + public void setCountries(final List<I18nCountryDTO> countries) { + this.countries = countries; } - public void setLanguages(final List<I18nLanguageSimpleDTO> languages) { - this.languages = languages; + public void setCurrent(final StateDTO currentState) { + this.currentState = currentState; } - public List<I18nCountryDTO> getCountries() { - return countries; + public void setCurrentLanguage(final I18nLanguageDTO currentLanguage) { + this.currentLanguage = currentLanguage; } - public void setCountries(final List<I18nCountryDTO> countries) { - this.countries = countries; + public void setCurrentState(final StateDTO currentState) { + this.currentState = currentState; } - public Object[][] getLanguagesArray() { - if (languagesArray == null) { - languagesArray = mapLangs(); - } - return languagesArray; + public void setDefaultWsTheme(final String defaultWsTheme) { + this.defaultWsTheme = defaultWsTheme; } - public Object[][] getCountriesArray() { - if (countriesArray == null) { - countriesArray = mapCountries(); - } - return countriesArray; + public void setLanguages(final List<I18nLanguageSimpleDTO> languages) { + this.languages = languages; } + public void setLicenses(final List<LicenseDTO> licenses) { + this.licenses = licenses; + } + public void setTimezones(final String[] timezones) { this.timezones = timezones; } - public Object[][] getTimezones() { - if (timezonesArray == null) { - mapTimezones(); - } - return timezonesArray; + public void setUserHash(final String userHash) { + this.userHash = userHash; } + public void setWsThemes(final String[] wsThemes) { + this.wsThemes = wsThemes; + } + private Object[][] mapCountries() { Object[][] objs = new Object[countries.size()][1]; int i = 0; @@ -170,20 +186,4 @@ } } - public void setCurrentLanguage(final I18nLanguageDTO currentLanguage) { - this.currentLanguage = currentLanguage; - } - - public I18nLanguageDTO getCurrentLanguage() { - return currentLanguage; - } - - public String getUserHash() { - return userHash; - } - - public void setUserHash(final String userHash) { - this.userHash = userHash; - } - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java 2008-06-01 04:01:10 UTC (rev 771) @@ -22,6 +22,7 @@ import org.ourproject.kune.platf.client.app.Application; import org.ourproject.kune.platf.client.app.HistoryWrapper; +import org.ourproject.kune.platf.client.dispatch.DefaultDispatcher; import org.ourproject.kune.platf.client.dto.GroupDTO; import org.ourproject.kune.platf.client.dto.ParticipationDataDTO; import org.ourproject.kune.platf.client.dto.SocialNetworkDTO; @@ -53,6 +54,28 @@ this.oldState = null; } + public void onHistoryChanged(final String historyToken) { + String oldStateEncoded = ""; + if (oldState != null) { + oldStateEncoded = oldState.getStateToken().getEncoded(); + } + if (historyToken.equals(Site.NEWGROUP_TOKEN)) { + Site.doNewGroup(oldStateEncoded); + } else if (historyToken.equals(Site.LOGIN_TOKEN)) { + Site.doLogin(oldStateEncoded); + } else if (historyToken.equals(Site.TRANSLATE_TOKEN)) { + DefaultDispatcher.getInstance().fire(WorkspaceEvents.SHOW_TRANSLATOR, null); + } else if (historyToken.equals(Site.FIXME_TOKEN)) { + if (oldState == null) { + onHistoryChanged(new StateToken()); + } else { + loadContent(oldState); + } + } else { + onHistoryChanged(new StateToken(historyToken)); + } + } + /** * <p> * Reload current state (using client cache if available) @@ -75,55 +98,30 @@ }); } - public void onHistoryChanged(final String historyToken) { - String oldStateEncoded = ""; - if (oldState != null) { - oldStateEncoded = oldState.getStateToken().getEncoded(); - } - if (historyToken.equals(Site.NEWGROUP_TOKEN)) { - Site.doNewGroup(oldStateEncoded); - } else if (historyToken.equals(Site.LOGIN_TOKEN)) { - Site.doLogin(oldStateEncoded); - } else if (historyToken.equals(Site.TRANSLATE_TOKEN)) { - app.getDispatcher().fire(WorkspaceEvents.SHOW_TRANSLATOR, null); - } else if (historyToken.equals(Site.FIXME_TOKEN)) { - if (oldState == null) { - onHistoryChanged(new StateToken()); - } else { - loadContent(oldState); - } - } else { - onHistoryChanged(new StateToken(historyToken)); - } - } - public void setRetrievedState(final StateDTO content) { final StateToken state = content.getStateToken(); provider.cache(state, content); setState(state); } + public void setSocialNetwork(final SocialNetworkResultDTO socialNet) { + StateDTO state; + if (session != null && (state = session.getCurrentState()) != null) { + // After a SN operation, usually returns a SocialNetworkResultDTO + // with new SN data and we refresh the state + // to avoid to reload() again the state + SocialNetworkDTO groupMembers = socialNet.getGroupMembers(); + ParticipationDataDTO userParticipation = socialNet.getUserParticipation(); + state.setGroupMembers(groupMembers); + state.setParticipation(userParticipation); + setSocialNetwork(state); + } + } + public void setState(final StateToken state) { history.newItem(state.getEncoded()); } - private void onHistoryChanged(final StateToken newState) { - provider.getContent(session.getUserHash(), newState, new AsyncCallbackSimple<StateDTO>() { - public void onSuccess(final StateDTO newStateDTO) { - loadContent(newStateDTO); - oldState = newStateDTO; - } - }); - } - - private void loadContextOnly(final StateDTO state) { - session.setCurrent(state); - final String toolName = state.getToolName(); - final ClientTool clientTool = app.getTool(toolName); - clientTool.setContext(state); - workspace.setContext(clientTool.getContext()); - } - private void loadContent(final StateDTO state) { session.setCurrent(state); final GroupDTO group = state.getGroup(); @@ -155,30 +153,33 @@ Site.hideProgress(); } - private void setWsTheme(final GroupDTO group) { - String nextTheme = group.getWorkspaceTheme(); - if (lastTheme == null || !lastTheme.equals(nextTheme)) { - workspace.setTheme(nextTheme); - } - lastTheme = nextTheme; + private void loadContextOnly(final StateDTO state) { + session.setCurrent(state); + final String toolName = state.getToolName(); + final ClientTool clientTool = app.getTool(toolName); + clientTool.setContext(state); + workspace.setContext(clientTool.getContext()); } - public void setSocialNetwork(final SocialNetworkResultDTO socialNet) { - StateDTO state; - if (session != null && (state = session.getCurrentState()) != null) { - // After a SN operation, usually returns a SocialNetworkResultDTO - // with new SN data and we refresh the state - // to avoid to reload() again the state - SocialNetworkDTO groupMembers = socialNet.getGroupMembers(); - ParticipationDataDTO userParticipation = socialNet.getUserParticipation(); - state.setGroupMembers(groupMembers); - state.setParticipation(userParticipation); - setSocialNetwork(state); - } + private void onHistoryChanged(final StateToken newState) { + provider.getContent(session.getUserHash(), newState, new AsyncCallbackSimple<StateDTO>() { + public void onSuccess(final StateDTO newStateDTO) { + loadContent(newStateDTO); + oldState = newStateDTO; + } + }); } private void setSocialNetwork(final StateDTO state) { workspace.getGroupMembersComponent().setGroupMembers(state); workspace.getParticipationComponent().setParticipation(state); } + + private void setWsTheme(final GroupDTO group) { + String nextTheme = group.getWorkspaceTheme(); + if (lastTheme == null || !lastTheme.equals(nextTheme)) { + workspace.setTheme(nextTheme); + } + lastTheme = nextTheme; + } } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/actions/LoggedInAction.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/actions/LoggedInAction.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/actions/LoggedInAction.java 2008-06-01 04:01:10 UTC (rev 771) @@ -50,7 +50,7 @@ Site.sitebar.showLoggedUser(userInfoDTO); I18nLanguageDTO language = userInfoDTO.getLanguage(); stateManager.reload(); - Kune.I18N.setCurrentLanguage(language.getCode()); + Kune.I18N.changeCurrentLanguage(language.getCode()); session.setCurrentLanguage(language); } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java 2008-06-01 04:01:10 UTC (rev 771) @@ -23,17 +23,11 @@ import org.ourproject.kune.platf.client.dispatch.DefaultDispatcher; import org.ourproject.kune.platf.client.dto.GetTranslationActionParams; -import org.ourproject.kune.platf.client.dto.I18nLanguageDTO; -import org.ourproject.kune.platf.client.rpc.I18nService; -import org.ourproject.kune.platf.client.rpc.I18nServiceAsync; import org.ourproject.kune.platf.client.services.I18nTranslationService; import org.ourproject.kune.platf.client.ui.KuneStringUtils; -import org.ourproject.kune.platf.client.ui.Location; -import org.ourproject.kune.platf.client.ui.WindowUtils; import org.ourproject.kune.workspace.client.WorkspaceEvents; import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.user.client.rpc.AsyncCallback; public class I18nUITranslationService extends I18nTranslationService { private HashMap<String, String> lexicon; @@ -53,23 +47,17 @@ i18nChangeListeners.add(listener); } + public void changeCurrentLanguage(final String newLanguage) { + if (!newLanguage.equals(this.currentLanguage)) { + setCurrentLanguage(newLanguage); + changeLocale(newLanguage); + } + } + public String getCurrentLanguage() { return currentLanguage; } - public void getInitialLanguage(final AsyncCallback<I18nLanguageDTO> callback) { - Location loc = WindowUtils.getLocation(); - String locale = loc.getParameter("locale"); - I18nServiceAsync server = I18nService.App.getInstance(); - server.getInitialLanguage(locale, callback); - } - - public void getInitialLexicon(final String initLanguage, final AsyncCallback<HashMap<String, String>> callback) { - currentLanguage = initLanguage; - I18nServiceAsync server = I18nService.App.getInstance(); - server.getLexicon(currentLanguage, callback); - } - public HashMap<String, String> getLexicon() { return lexicon; } @@ -81,12 +69,7 @@ } public void setCurrentLanguage(final String newLanguage) { - if (!newLanguage.equals(this.currentLanguage)) { - this.currentLanguage = newLanguage; - changeLocale(newLanguage); - // DefaultDispatcher.getInstance().fire(WorkspaceEvents.GET_LEXICON, - // newLanguage, null); - } + this.currentLanguage = newLanguage; } public void setLexicon(final HashMap<String, String> lexicon) { Modified: trunk/src/test/java/org/ourproject/kune/sitebar/client/ui/LoginPresenterTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/sitebar/client/ui/LoginPresenterTest.java 2008-05-31 20:03:25 UTC (rev 770) +++ trunk/src/test/java/org/ourproject/kune/sitebar/client/ui/LoginPresenterTest.java 2008-06-01 04:01:10 UTC (rev 771) @@ -3,7 +3,6 @@ import org.easymock.EasyMock; import org.junit.Before; import org.junit.Test; -import org.ourproject.kune.platf.client.dto.I18nLanguageDTO; import org.ourproject.kune.platf.client.state.SessionImpl; import org.ourproject.kune.workspace.client.sitebar.login.LoginListener; import org.ourproject.kune.workspace.client.sitebar.login.LoginPresenter; @@ -17,15 +16,18 @@ @Before public void createObjects() { listener = EasyMock.createStrictMock(LoginListener.class); - presenter = new LoginPresenter(new SessionImpl("foofoo", new I18nLanguageDTO()), listener); + presenter = new LoginPresenter(new SessionImpl("foo", null), listener); view = EasyMock.createStrictMock(LoginView.class); } @Test - public void testViewInitialization() { + public void nickPassTyped() { // view.setEnabledLoginButton(false); + // view.setEnabledLoginButton(true); EasyMock.replay(view); + presenter.init(view); + // presenter.onDataChanged("luther.b", "somepass"); EasyMock.verify(view); } @@ -40,13 +42,10 @@ } @Test - public void nickPassTyped() { + public void testViewInitialization() { // view.setEnabledLoginButton(false); - // view.setEnabledLoginButton(true); EasyMock.replay(view); - presenter.init(view); - // presenter.onDataChanged("luther.b", "somepass"); EasyMock.verify(view); } }