[kune-commits] r773 - in trunk/src/main/java/org/ourproject/kune: docs/client docs/client/cnt docs/client/ctx docs/client/ui platf/client platf/client/actions platf/client/app platf/client/services

vjrj vjrj at ourproject.org
Sun Jun 1 19:25:08 CEST 2008


Author: vjrj
Date: 2008-06-01 19:25:04 +0200 (Sun, 01 Jun 2008)
New Revision: 773

Added:
   trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationDefault.java
Removed:
   trunk/src/main/java/org/ourproject/kune/platf/client/app/DefaultApplication.java
Modified:
   trunk/src/main/java/org/ourproject/kune/docs/client/DocToolComponents.java
   trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java
   trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentComponents.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java
   trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextComponents.java
   trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java
   trunk/src/main/java/org/ourproject/kune/docs/client/ui/DocumentFactory.java
   trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java
   trunk/src/main/java/org/ourproject/kune/platf/client/PlatformClientModule.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoAction.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoContainerAction.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/services/Kune.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
Log:
more modules...

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocToolComponents.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocToolComponents.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocToolComponents.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -28,21 +28,23 @@
     private DocumentContent content;
     private DocumentContext context;
     private final DocumentClientTool documentClientTool;
+    private final DocumentFactory documentFactory;
 
-    public DocToolComponents(final DocumentClientTool documentClientTool) {
+    public DocToolComponents(final DocumentFactory documentFactory, final DocumentClientTool documentClientTool) {
+        this.documentFactory = documentFactory;
         this.documentClientTool = documentClientTool;
     }
 
     public DocumentContent getContent() {
         if (content == null) {
-            content = DocumentFactory.createDocumentContent(documentClientTool);
+            content = documentFactory.createDocumentContent(documentClientTool);
         }
         return content;
     }
 
     public DocumentContext getContext() {
         if (context == null) {
-            context = DocumentFactory.createDocumentContext();
+            context = documentFactory.createDocumentContext();
         }
         return context;
     }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientNewModule.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -1,5 +1,6 @@
 package org.ourproject.kune.docs.client;
 
+import org.ourproject.kune.docs.client.ui.DocumentFactory;
 import org.ourproject.kune.platf.client.KunePlatform;
 import org.ourproject.kune.platf.client.app.Application;
 import org.ourproject.kune.platf.client.state.Session;
@@ -22,11 +23,19 @@
     }
 
     public void onLoad(final ModuleBuilder builder) {
+        builder.registerProvider(DocumentFactory.class, new Provider<DocumentFactory>() {
+            public DocumentFactory get() {
+                return new DocumentFactory(builder.getInstance(I18nUITranslationService.class));
+            }
+        }, Scopes.SINGLETON);
+
         builder.registerProvider(DocumentClientTool.class, new Provider<DocumentClientTool>() {
             public DocumentClientTool get() {
-                return new DocumentClientTool(builder.getInstance(I18nUITranslationService.class));
+                DocumentFactory factory = builder.getInstance(DocumentFactory.class);
+                return new DocumentClientTool(factory, builder.getInstance(I18nUITranslationService.class));
             }
         }, Scopes.SINGLETON_EAGER);
+
         KunePlatform platform = builder.getInstance(KunePlatform.class);
         DocumentClientTool docClientTool = getDocumentClientTool(builder);
         platform.addTool(docClientTool);

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -23,6 +23,7 @@
 import org.ourproject.kune.docs.client.cnt.DocumentContent;
 import org.ourproject.kune.docs.client.cnt.DocumentContentListener;
 import org.ourproject.kune.docs.client.ctx.DocumentContext;
+import org.ourproject.kune.docs.client.ui.DocumentFactory;
 import org.ourproject.kune.platf.client.dto.StateDTO;
 import org.ourproject.kune.platf.client.tool.AbstractClientTool;
 import org.ourproject.kune.workspace.client.component.WorkspaceComponent;
@@ -35,9 +36,9 @@
     public static final String NAME = "docs";
     private final DocToolComponents components;
 
-    public DocumentClientTool(final I18nUITranslationService i18n) {
+    public DocumentClientTool(final DocumentFactory documentFactory, final I18nUITranslationService i18n) {
         super(i18n.t("documents"));
-        components = new DocToolComponents(this);
+        components = new DocToolComponents(documentFactory, this);
     }
 
     public WorkspaceComponent getContent() {

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentComponents.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentComponents.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentComponents.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -35,44 +35,47 @@
     private FolderViewer folderViewer;
     private FolderEditor folderEditor;
     private DocumentReaderControl readerControl;
+    private final DocumentFactory documentFactory;
 
-    public DocumentContentComponents(final DocumentContentPresenter documentContentPresenter) {
+    public DocumentContentComponents(final DocumentFactory documentFactory,
+            final DocumentContentPresenter documentContentPresenter) {
+        this.documentFactory = documentFactory;
         this.documentContentPresenter = documentContentPresenter;
     }
 
+    public TextEditor getDocumentEditor() {
+        if (editor == null) {
+            editor = WorkspaceFactory.createDocumentEditor(documentContentPresenter);
+        }
+        return editor;
+    }
+
     public DocumentReader getDocumentReader() {
         if (reader == null) {
-            reader = DocumentFactory.createDocumentReader(documentContentPresenter);
+            reader = documentFactory.createDocumentReader(documentContentPresenter);
         }
         return reader;
     }
 
     public DocumentReaderControl getDocumentReaderControl() {
         if (readerControl == null) {
-            readerControl = DocumentFactory.createDocumentReaderControl(documentContentPresenter);
+            readerControl = documentFactory.createDocumentReaderControl(documentContentPresenter);
         }
         return readerControl;
     }
 
-    public TextEditor getDocumentEditor() {
-        if (editor == null) {
-            editor = WorkspaceFactory.createDocumentEditor(documentContentPresenter);
+    public FolderEditor getFolderEditor() {
+        if (folderEditor == null) {
+            folderEditor = documentFactory.createFolderEditor();
         }
-        return editor;
+        return folderEditor;
     }
 
     public FolderViewer getFolderViewer() {
         if (folderViewer == null) {
-            folderViewer = DocumentFactory.createFolderViewer();
+            folderViewer = documentFactory.createFolderViewer();
         }
         return folderViewer;
     }
 
-    public FolderEditor getFolderEditor() {
-        if (folderEditor == null) {
-            folderEditor = DocumentFactory.createFolderEditor();
-        }
-        return folderEditor;
-    }
-
 }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -26,6 +26,7 @@
 import org.ourproject.kune.docs.client.cnt.reader.DocumentReader;
 import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderControl;
 import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderListener;
+import org.ourproject.kune.docs.client.ui.DocumentFactory;
 import org.ourproject.kune.platf.client.PlatformEvents;
 import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.dispatch.DefaultDispatcher;
@@ -47,27 +48,36 @@
     private final DocumentReader reader;
     private final DocumentReaderControl readerControl;
 
-    public DocumentContentPresenter(final DocumentContentListener listener, final WorkspaceDeckView view) {
+    public DocumentContentPresenter(final DocumentFactory documentFactory, final DocumentContentListener listener,
+            final WorkspaceDeckView view) {
         this.listener = listener;
         this.view = view;
-        this.components = new DocumentContentComponents(this);
+        this.components = new DocumentContentComponents(documentFactory, this);
         reader = components.getDocumentReader();
         readerControl = components.getDocumentReaderControl();
     }
 
-    public void setContent(final StateDTO content) {
-        this.content = content;
-        showContent();
+    public void attach() {
     }
 
-    public void onSaved() {
-        components.getDocumentEditor().onSaved();
+    public void detach() {
     }
 
-    public void onSaveFailed() {
-        components.getDocumentEditor().onSaveFailed();
+    public View getView() {
+        return view;
     }
 
+    public void onCancel() {
+        showContent();
+        listener.onCancel();
+        // Re-enable rateIt widget
+        DefaultDispatcher.getInstance().fire(WorkspaceEvents.ENABLE_RATEIT, null);
+    }
+
+    public void onDelete() {
+        DefaultDispatcher.getInstance().fire(DocsEvents.DEL_CONTENT, content.getDocumentId());
+    }
+
     public void onEdit() {
         DefaultDispatcher.getInstance().fire(WorkspaceEvents.ONLY_CHECK_USER_SESSION,
                 new AsyncCallbackSimple<Object>() {
@@ -80,8 +90,10 @@
                             view.show(editor.getView());
                             DefaultDispatcher.getInstance().fire(PlatformEvents.CLEAR_EXTENSIBLE_WIDGET,
                                     ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT);
-                            DefaultDispatcher.getInstance().fire(PlatformEvents.ATTACH_TO_EXTENSIBLE_WIDGET,
-                                    new ExtensibleWidgetChild(ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT, editor.getToolBar()));
+                            DefaultDispatcher.getInstance().fire(
+                                    PlatformEvents.ATTACH_TO_EXTENSIBLE_WIDGET,
+                                    new ExtensibleWidgetChild(ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT, editor
+                                            .getToolBar()));
                             DefaultDispatcher.getInstance().fire(WorkspaceEvents.RECALCULATE_WORKSPACE_SIZE, null);
                         } else {
                             FolderEditor editor = components.getFolderEditor();
@@ -101,43 +113,37 @@
         DefaultDispatcher.getInstance().fire(WorkspaceEvents.RECALCULATE_WORKSPACE_SIZE, null);
     }
 
-    public void onCancel() {
-        showContent();
-        listener.onCancel();
-        // Re-enable rateIt widget
-        DefaultDispatcher.getInstance().fire(WorkspaceEvents.ENABLE_RATEIT, null);
+    public void onSaved() {
+        components.getDocumentEditor().onSaved();
     }
 
-    public void onDelete() {
-        DefaultDispatcher.getInstance().fire(DocsEvents.DEL_CONTENT, content.getDocumentId());
+    public void onSaveFailed() {
+        components.getDocumentEditor().onSaveFailed();
     }
 
-    public View getView() {
-        return view;
+    public void onTranslate() {
     }
 
-    public void attach() {
+    public void setContent(final StateDTO content) {
+        this.content = content;
+        showContent();
     }
 
-    public void detach() {
-    }
-
-    public void onTranslate() {
-    }
-
     private void showContent() {
         if (content.hasDocument()) {
             reader.showDocument(content.getContent());
             components.getDocumentEditor().reset();
             readerControl.setRights(content.getContentRights());
-            DefaultDispatcher.getInstance().fire(PlatformEvents.CLEAR_EXTENSIBLE_WIDGET, ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT);
+            DefaultDispatcher.getInstance().fire(PlatformEvents.CLEAR_EXTENSIBLE_WIDGET,
+                    ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT);
             DefaultDispatcher.getInstance().fire(PlatformEvents.ATTACH_TO_EXTENSIBLE_WIDGET,
                     new ExtensibleWidgetChild(ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT, readerControl.getView()));
             view.show(reader.getView());
         } else {
             FolderViewer viewer = components.getFolderViewer();
             viewer.setFolder(content.getFolder());
-            DefaultDispatcher.getInstance().fire(PlatformEvents.CLEAR_EXTENSIBLE_WIDGET, ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT);
+            DefaultDispatcher.getInstance().fire(PlatformEvents.CLEAR_EXTENSIBLE_WIDGET,
+                    ExtensibleWidgetId.CONTENT_TOOLBAR_LEFT);
             view.show(viewer.getView());
         }
     }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextComponents.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextComponents.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextComponents.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -28,22 +28,24 @@
 
     private FolderContext folderContext;
     private AdminContext adminContext;
+    private final DocumentFactory documentFactory;
 
-    public DocumentContextComponents(final DocumentContextPresenter listener) {
+    public DocumentContextComponents(final DocumentFactory documentFactory, final DocumentContextPresenter listener) {
+        this.documentFactory = documentFactory;
     }
 
+    public AdminContext getAdminContext() {
+        if (adminContext == null) {
+            adminContext = documentFactory.createAdminContext();
+        }
+        return adminContext;
+    }
+
     public FolderContext getFolderContext() {
         if (folderContext == null) {
-            folderContext = DocumentFactory.createFolderContext();
+            folderContext = documentFactory.createFolderContext();
         }
         return folderContext;
     }
 
-    public AdminContext getAdminContext() {
-        if (adminContext == null) {
-            adminContext = DocumentFactory.createAdminContext();
-        }
-        return adminContext;
-    }
-
 }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -22,6 +22,7 @@
 
 import org.ourproject.kune.docs.client.ctx.admin.AdminContext;
 import org.ourproject.kune.docs.client.ctx.folder.FolderContext;
+import org.ourproject.kune.docs.client.ui.DocumentFactory;
 import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.dto.StateDTO;
 import org.ourproject.kune.platf.client.dto.StateToken;
@@ -31,9 +32,9 @@
     private final WorkspaceDeckView view;
     private final DocumentContextComponents components;
 
-    public DocumentContextPresenter(final WorkspaceDeckView view) {
+    public DocumentContextPresenter(final DocumentFactory documentFactory, final WorkspaceDeckView view) {
         this.view = view;
-        this.components = new DocumentContextComponents(this);
+        this.components = new DocumentContextComponents(documentFactory, this);
     }
 
     public void attach() {

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/ui/DocumentFactory.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/ui/DocumentFactory.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/ui/DocumentFactory.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -54,59 +54,59 @@
 
 public class DocumentFactory {
 
-    private static I18nTranslationService i18n;
+    private final I18nTranslationService i18n;
 
-    public static AdminContext createAdminContext() {
+    public DocumentFactory(final I18nTranslationService i18n) {
+        this.i18n = i18n;
+    }
+
+    public AdminContext createAdminContext() {
         AdminContextPresenter presenter = new AdminContextPresenter();
         AdminContextView view = new AdminContextPanel(presenter, i18n);
         presenter.init(view);
         return presenter;
     }
 
-    public static DocumentContent createDocumentContent(final DocumentContentListener listener) {
+    public DocumentContent createDocumentContent(final DocumentContentListener listener) {
         WorkspaceDeckPanel panel = new WorkspaceDeckPanel();
-        DocumentContentPresenter presenter = new DocumentContentPresenter(listener, panel);
+        DocumentContentPresenter presenter = new DocumentContentPresenter(this, listener, panel);
         return presenter;
     }
 
-    public static DocumentContext createDocumentContext() {
+    public DocumentContext createDocumentContext() {
         WorkspaceDeckPanel view = new WorkspaceDeckPanel();
-        DocumentContextPresenter presenter = new DocumentContextPresenter(view);
+        DocumentContextPresenter presenter = new DocumentContextPresenter(this, view);
         return presenter;
     }
 
-    public static DocumentReader createDocumentReader(final DocumentReaderListener listener) {
+    public DocumentReader createDocumentReader(final DocumentReaderListener listener) {
         DocumentReaderView view = new DocumentReaderPanel();
         DocumentReaderPresenter presenter = new DocumentReaderPresenter(view);
         return presenter;
     }
 
-    public static DocumentReaderControl createDocumentReaderControl(final DocumentReaderListener listener) {
+    public DocumentReaderControl createDocumentReaderControl(final DocumentReaderListener listener) {
         DocumentReaderControlView view = new DocumentReaderControlPanel(listener, i18n);
         DocumentReaderControlPresenter presenter = new DocumentReaderControlPresenter(view);
         return presenter;
     }
 
-    public static FolderContext createFolderContext() {
+    public FolderContext createFolderContext() {
         ContextItems contextItems = WorkspaceFactory.createContextItems();
         FolderContextPresenter presenter = new FolderContextPresenter(contextItems, i18n);
         return presenter;
     }
 
-    public static FolderEditor createFolderEditor() {
+    public FolderEditor createFolderEditor() {
         FolderEditorPanel view = new FolderEditorPanel();
         FolderEditorPresenter presenter = new FolderEditorPresenter(view);
         return presenter;
     }
 
-    public static FolderViewer createFolderViewer() {
+    public FolderViewer createFolderViewer() {
         FolderViewerView view = new FolderViewerPanel();
         FolderViewerPresenter presenter = new FolderViewerPresenter(view);
         return presenter;
     }
 
-    public DocumentFactory(final I18nTranslationService i18n) {
-        DocumentFactory.i18n = i18n;
-    }
-
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/KunePlatform.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -53,13 +53,11 @@
     }
 
     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);
+        final HashMap<String, ClientTool> toolsIndexed = new HashMap<String, ClientTool>();
+        for (ClientTool tool : this.tools) {
+            toolsIndexed.put(tool.getName(), tool);
         }
-        return tools;
+        return toolsIndexed;
     }
 
     public List<ClientTool> getTools() {

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/PlatformClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/PlatformClientModule.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/PlatformClientModule.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -27,12 +27,14 @@
 import org.ourproject.kune.platf.client.state.Session;
 import org.ourproject.kune.platf.client.state.StateManager;
 
+import com.calclab.emite.client.modular.Provider;
+
 public class PlatformClientModule implements ClientModule {
-    private final StateManager stateManager;
+    private final Provider<StateManager> stateManager;
     private final Session session;
 
-    public PlatformClientModule(final Session session, final StateManager stateManager) {
-        this.stateManager = stateManager;
+    public PlatformClientModule(final Session session, final Provider<StateManager> provider) {
+        this.stateManager = provider;
         this.session = session;
     }
 

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoAction.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoAction.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -23,11 +23,13 @@
 import org.ourproject.kune.platf.client.dto.StateToken;
 import org.ourproject.kune.platf.client.state.StateManager;
 
+import com.calclab.emite.client.modular.Provider;
+
 public class GotoAction implements Action<String> {
 
-    private final StateManager stateManager;
+    private final Provider<StateManager> stateManager;
 
-    public GotoAction(final StateManager stateManager) {
+    public GotoAction(final Provider<StateManager> stateManager) {
         this.stateManager = stateManager;
     }
 
@@ -36,6 +38,6 @@
     }
 
     private void onGoto(final String token) {
-        stateManager.setState(new StateToken(token));
+        stateManager.get().setState(new StateToken(token));
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoContainerAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoContainerAction.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/GotoContainerAction.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -24,12 +24,14 @@
 import org.ourproject.kune.platf.client.state.Session;
 import org.ourproject.kune.platf.client.state.StateManager;
 
+import com.calclab.emite.client.modular.Provider;
+
 public class GotoContainerAction implements Action<Long> {
 
     private final Session session;
-    private final StateManager stateManager;
+    private final Provider<StateManager> stateManager;
 
-    public GotoContainerAction(final StateManager stateManager, final Session session) {
+    public GotoContainerAction(final Provider<StateManager> stateManager, final Session session) {
         this.stateManager = stateManager;
         this.session = session;
     }
@@ -42,6 +44,6 @@
         StateToken newStateToken = session.getCurrentState().getStateToken();
         newStateToken.setDocument(null);
         newStateToken.setFolder(folderId.toString());
-        stateManager.setState(newStateToken);
+        stateManager.get().setState(newStateToken);
     }
 }

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-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -20,23 +20,20 @@
 
 package org.ourproject.kune.platf.client.app;
 
+import java.util.HashMap;
+
 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;
 import org.ourproject.kune.workspace.client.workspace.Workspace;
 
 public interface Application {
 
-    Dispatcher getDispatcher();
-
-    StateManager getStateManager();
-
     ClientTool getTool(String toolName);
 
     Workspace getWorkspace();
 
-    void init(DefaultDispatcher dispatcher, StateManager stateManager);
+    void init(DefaultDispatcher dispatcher, StateManager stateManager, HashMap<String, ClientTool> tools);
 
     /**
      * 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-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationBuilder.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -24,18 +24,22 @@
 import java.util.HashMap;
 import java.util.Iterator;
 
+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.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.services.Kune;
+import org.ourproject.kune.platf.client.services.KuneModule;
 import org.ourproject.kune.platf.client.state.Session;
 import org.ourproject.kune.platf.client.state.StateManager;
 import org.ourproject.kune.workspace.client.WorkspaceClientModule;
 import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
 import org.ourproject.kune.workspace.client.sitebar.Site;
 
+import com.calclab.emiteuimodule.client.EmiteUIModule;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.WindowCloseListener;
 
@@ -45,7 +49,8 @@
     }
 
     public void build(final I18nLanguageDTO initialLang, final HashMap<String, String> lexicon) {
-        final Kune kune = Kune.create(initialLang, lexicon);
+        final Kune kune = Kune.create(new KuneModule(initialLang, lexicon), new EmiteUIModule(),
+                new DocumentClientNewModule(), new ChatClientNewModule());
         final Session session = kune.getSession();
 
         Site.showProgressLoading();
@@ -56,12 +61,13 @@
         final Application application = kune.getInstance(Application.class);
         I18nUITranslationService i18n = kune.getI18N();
 
-        platform.install(new PlatformClientModule(session, stateManager));
+        // Testing providers:
+        platform.install(new PlatformClientModule(session, kune.getProvider(StateManager.class)));
         platform.install(new WorkspaceClientModule(session, stateManager, application.getWorkspace(), i18n));
 
         final DefaultDispatcher dispatcher = DefaultDispatcher.getInstance();
 
-        application.init(dispatcher, stateManager);
+        application.init(dispatcher, stateManager, platform.getIndexedTools());
         subscribeActions(dispatcher, platform.getActions());
 
         Window.addWindowCloseListener(new WindowCloseListener() {

Copied: trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationDefault.java (from rev 772, trunk/src/main/java/org/ourproject/kune/platf/client/app/DefaultApplication.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/app/DefaultApplication.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationDefault.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -0,0 +1,96 @@
+/*
+ *
+ * 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.app;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.ourproject.kune.platf.client.dispatch.DefaultDispatcher;
+import org.ourproject.kune.platf.client.dispatch.Dispatcher;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.extend.ExtensibleWidgetsManager;
+import org.ourproject.kune.platf.client.services.ColorTheme;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.tool.ClientTool;
+import org.ourproject.kune.workspace.client.WorkspaceEvents;
+import org.ourproject.kune.workspace.client.WorkspaceFactory;
+import org.ourproject.kune.workspace.client.sitebar.bar.SiteBarListener;
+import org.ourproject.kune.workspace.client.workspace.Workspace;
+
+public class ApplicationDefault implements Application {
+    private final Workspace workspace;
+    private Map<String, ClientTool> tools;
+    private Dispatcher dispatcher;
+    private StateManager stateManager;
+
+    public ApplicationDefault(final Session session, final ExtensibleWidgetsManager extensionPointManager,
+            final I18nTranslationService i18n, final ColorTheme colorTheme, final KuneErrorHandler errorHandler) {
+        workspace = WorkspaceFactory.createWorkspace(session, extensionPointManager, i18n, colorTheme, errorHandler);
+        tools = new HashMap<String, ClientTool>();
+        DesktopView desktop = WorkspaceFactory.createDesktop(workspace, new SiteBarListener() {
+            public void onChangeState(StateToken token) {
+                stateManager.setState(token);
+            }
+
+            public void onUserLoggedOut() {
+                dispatcher.fire(WorkspaceEvents.USER_LOGGED_OUT, null);
+            }
+        }, session);
+        desktop.attach();
+
+    }
+
+    public ClientTool getTool(final String toolName) {
+        return tools.get(toolName);
+    }
+
+    public Workspace getWorkspace() {
+        return workspace;
+    }
+
+    public void init(final DefaultDispatcher dispatcher, final StateManager stateManager,
+            final HashMap<String, ClientTool> tools) {
+        this.dispatcher = dispatcher;
+        this.stateManager = stateManager;
+        this.tools = tools;
+        workspace.attachTools(tools.values().iterator());
+    }
+
+    public void setGroupState(final String groupShortName) {
+        Iterator<ClientTool> iterator = tools.values().iterator();
+        while (iterator.hasNext()) {
+            ClientTool tool = iterator.next();
+            tool.setGroupState(groupShortName);
+        }
+    }
+
+    public void start() {
+        dispatcher.fireDeferred(WorkspaceEvents.START_APP, null);
+    }
+
+    public void stop() {
+        dispatcher.fire(WorkspaceEvents.STOP_APP, null);
+    }
+}

Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/app/DefaultApplication.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/app/DefaultApplication.java	2008-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/DefaultApplication.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -1,103 +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.app;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.ourproject.kune.platf.client.dispatch.DefaultDispatcher;
-import org.ourproject.kune.platf.client.dispatch.Dispatcher;
-import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.extend.ExtensibleWidgetsManager;
-import org.ourproject.kune.platf.client.services.ColorTheme;
-import org.ourproject.kune.platf.client.services.I18nTranslationService;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
-import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.tool.ClientTool;
-import org.ourproject.kune.workspace.client.WorkspaceEvents;
-import org.ourproject.kune.workspace.client.WorkspaceFactory;
-import org.ourproject.kune.workspace.client.sitebar.bar.SiteBarListener;
-import org.ourproject.kune.workspace.client.workspace.Workspace;
-
-public class DefaultApplication implements Application {
-    private final Workspace workspace;
-    private final Map<String, ClientTool> tools;
-    private Dispatcher dispatcher;
-    private StateManager stateManager;
-
-    public DefaultApplication(final Map<String, ClientTool> tools, final Session session,
-            final ExtensibleWidgetsManager extensionPointManager, final I18nTranslationService i18n,
-            final ColorTheme colorTheme, final KuneErrorHandler errorHandler) {
-        this.tools = tools;
-        workspace = WorkspaceFactory.createWorkspace(session, extensionPointManager, i18n, colorTheme, errorHandler);
-        workspace.attachTools(tools.values().iterator());
-
-        DesktopView desktop = WorkspaceFactory.createDesktop(workspace, new SiteBarListener() {
-            public void onChangeState(StateToken token) {
-                stateManager.setState(token);
-            }
-
-            public void onUserLoggedOut() {
-                dispatcher.fire(WorkspaceEvents.USER_LOGGED_OUT, null);
-            }
-        }, session);
-        desktop.attach();
-
-    }
-
-    public Dispatcher getDispatcher() {
-        return dispatcher;
-    }
-
-    public StateManager getStateManager() {
-        return stateManager;
-    }
-
-    public ClientTool getTool(final String toolName) {
-        return tools.get(toolName);
-    }
-
-    public Workspace getWorkspace() {
-        return workspace;
-    }
-
-    public void init(final DefaultDispatcher dispatcher, final StateManager stateManager) {
-        this.dispatcher = dispatcher;
-        this.stateManager = stateManager;
-    }
-
-    public void setGroupState(final String groupShortName) {
-        Iterator<ClientTool> iterator = tools.values().iterator();
-        while (iterator.hasNext()) {
-            ClientTool tool = iterator.next();
-            tool.setGroupState(groupShortName);
-        }
-    }
-
-    public void start() {
-        dispatcher.fireDeferred(WorkspaceEvents.START_APP, null);
-    }
-
-    public void stop() {
-        dispatcher.fire(WorkspaceEvents.STOP_APP, null);
-    }
-}

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-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/Kune.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -20,13 +20,8 @@
 
 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;
@@ -37,16 +32,10 @@
 import com.calclab.emite.client.modular.Module;
 import com.calclab.emite.client.modular.ModuleBuilder;
 import com.calclab.emiteuimodule.client.EmiteUIDialog;
-import com.calclab.emiteuimodule.client.EmiteUIModule;
 
 public class Kune extends DelegatedContainer {
 
-    public static Kune create(final I18nLanguageDTO initialLang, final HashMap<String, String> lexicon) {
-        return create(new KuneModule(initialLang, lexicon), new EmiteUIModule(), new DocumentClientNewModule(),
-                new ChatClientNewModule());
-    }
-
-    private static Kune create(final Module... modules) {
+    public static Kune create(final Module... modules) {
         final ModuleBuilder container = new ModuleBuilder();
         container.add(modules);
         return container.getInstance(Kune.class);

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-06-01 14:44:36 UTC (rev 772)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java	2008-06-01 17:25:04 UTC (rev 773)
@@ -4,7 +4,7 @@
 
 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.ApplicationDefault;
 import org.ourproject.kune.platf.client.app.HistoryWrapper;
 import org.ourproject.kune.platf.client.app.HistoryWrapperImpl;
 import org.ourproject.kune.platf.client.dto.I18nLanguageDTO;
@@ -15,11 +15,9 @@
 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 org.ourproject.kune.workspace.client.sitebar.Site;
 
-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;
@@ -28,11 +26,6 @@
 import com.google.gwt.user.client.History;
 
 public class KuneModule implements Module {
-
-    public static Kune getKune(final Container container) {
-        return container.getInstance(Kune.class);
-    }
-
     private final I18nLanguageDTO initialLang;
     private final HashMap<String, String> lexicon;
 
@@ -74,7 +67,7 @@
                 return new KuneErrorHandler(builder.getInstance(Session.class), builder
                         .getInstance(I18nUITranslationService.class));
             }
-        });
+        }, Scopes.SINGLETON);
 
         builder.registerProvider(ColorTheme.class, new Provider<ColorTheme>() {
             public ColorTheme get() {
@@ -92,18 +85,17 @@
             public ExtensibleWidgetsManager get() {
                 return new ExtensibleWidgetsManager();
             }
-        });
+        }, Scopes.SINGLETON);
 
         builder.registerProvider(Application.class, new Provider<Application>() {
             public Application get() {
                 Session session = builder.getInstance(Session.class);
-                HashMap<String, ClientTool> tools = builder.getInstance(KunePlatform.class).getIndexedTools();
                 ExtensibleWidgetsManager extensionPointManager = builder.getInstance(ExtensibleWidgetsManager.class);
-                return new DefaultApplication(tools, session, extensionPointManager, builder
+                return new ApplicationDefault(session, extensionPointManager, builder
                         .getInstance(I18nUITranslationService.class), builder.getInstance(ColorTheme.class), builder
                         .getInstance(KuneErrorHandler.class));
             }
-        });
+        }, Scopes.SINGLETON);
 
         builder.registerProvider(StateManager.class, new Provider<StateManager>() {
             public StateManager get() {
@@ -116,7 +108,7 @@
                 History.addHistoryListener(stateManager);
                 return stateManager;
             }
-        });
+        }, Scopes.SINGLETON);
 
     }
 }




More information about the kune-commits mailing list