[kune-commits] r943 - in trunk/src/main/java/org/ourproject/kune: chat/client chat/client/cnt/room chat/client/ctx docs/client docs/client/cnt docs/client/cnt/folder/viewer docs/client/cnt/viewer platf/client/services workspace/client/cnt

vjrj vjrj at ourproject.org
Mon Nov 10 20:00:13 CET 2008


Author: vjrj
Date: 2008-11-10 20:00:10 +0100 (Mon, 10 Nov 2008)
New Revision: 943

Added:
   trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java
Removed:
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContent.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPanel.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentView.java
Modified:
   trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java
   trunk/src/main/java/org/ourproject/kune/chat/client/cnt/room/ChatRoomPanel.java
   trunk/src/main/java/org/ourproject/kune/chat/client/ctx/ChatContextPresenter.java
   trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
   trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/viewer/DocFolderContentPanel.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewer.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPanel.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPresenter.java
   trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerView.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentPanel.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
Log:
Incomplete - task UI tools & workspace refactorization 


Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -33,6 +33,7 @@
 import org.ourproject.kune.platf.client.app.Application;
 import org.ourproject.kune.platf.client.app.ToolGroup;
 import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
 import org.ourproject.kune.platf.client.state.Session;
 import org.ourproject.kune.platf.client.state.StateManager;
 import org.ourproject.kune.platf.client.tool.ToolSelector;
@@ -71,7 +72,8 @@
         register(Singleton.class, new Factory<ChatContext>(ChatContext.class) {
             @Override
             public ChatContext create() {
-                final ChatContextPresenter presenter = new ChatContextPresenter($$(RoomAdmin.class));
+                final ChatContextPresenter presenter = new ChatContextPresenter($(StateManager.class),
+                        $$(ContextNavigator.class), $$(RoomAdmin.class));
                 return presenter;
             }
         });
@@ -90,7 +92,8 @@
                 final ChatRoomPresenter presenter = new ChatRoomPresenter($(StateManager.class), $(Session.class),
                         $(I18nUITranslationService.class), $(ActionContentToolbar.class),
                         $(ContentActionRegistry.class));
-                final ChatRoomPanel panel = new ChatRoomPanel($(WorkspaceSkeleton.class));
+                final ChatRoomPanel panel = new ChatRoomPanel($(WorkspaceSkeleton.class),
+                        $(I18nTranslationService.class));
                 presenter.init(panel);
                 return presenter;
             }

Modified: trunk/src/main/java/org/ourproject/kune/chat/client/cnt/room/ChatRoomPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/cnt/room/ChatRoomPanel.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/cnt/room/ChatRoomPanel.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -19,24 +19,17 @@
  */
 package org.ourproject.kune.chat.client.cnt.room;
 
-import org.ourproject.kune.workspace.client.cnt.AbstractContentPanel;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.workspace.client.cnt.FoldableContentPanel;
 import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
 
-import com.google.gwt.user.client.ui.Label;
+public class ChatRoomPanel extends FoldableContentPanel implements ChatRoomView {
 
-public class ChatRoomPanel extends AbstractContentPanel implements ChatRoomView {
-
-    private final Label label;
-
-    public ChatRoomPanel(final WorkspaceSkeleton ws) {
-        super(ws);
-        label = new Label();
-        label.setStyleName("kune-Content-Main");
-        label.addStyleName("kune-Margin-7-trbl");
-        initWidget(label);
+    public ChatRoomPanel(final WorkspaceSkeleton ws, I18nTranslationService i18n) {
+        super(ws, i18n);
     }
 
     public void setInfo(String info) {
-        label.setText(info);
+        setLabel(info);
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ctx/ChatContextPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ctx/ChatContextPresenter.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ctx/ChatContextPresenter.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -21,6 +21,8 @@
 
 import org.ourproject.kune.chat.client.ctx.room.RoomAdmin;
 import org.ourproject.kune.platf.client.dto.StateContainerDTO;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
 
 import com.calclab.suco.client.ioc.Provider;
 
@@ -28,7 +30,8 @@
 
     private final Provider<RoomAdmin> roomAdminsProvider;
 
-    public ChatContextPresenter(final Provider<RoomAdmin> roomAdminsProvider) {
+    public ChatContextPresenter(final StateManager stateManager,
+            final Provider<ContextNavigator> contextNavigatorProvider, final Provider<RoomAdmin> roomAdminsProvider) {
         this.roomAdminsProvider = roomAdminsProvider;
     }
 

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -28,7 +28,7 @@
 import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_WIKI;
 import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_WIKIPAGE;
 
-import org.ourproject.kune.docs.client.cnt.DocumentContent;
+import org.ourproject.kune.docs.client.cnt.viewer.DocumentViewer;
 import org.ourproject.kune.docs.client.ctx.admin.DocContextEditor;
 import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
 import org.ourproject.kune.platf.client.actions.ActionMenuItemDescriptor;
@@ -86,7 +86,7 @@
     private final EntityLogo entityLogo;
     private final Provider<TextEditor> textEditorProvider;
     private final KuneErrorHandler errorHandler;
-    private final DocumentContent documentContent;
+    private final DocumentViewer documentViewer;
     private final Provider<DocContextEditor> adminContextProvider;
 
     public DocumentClientActions(final I18nUITranslationService i18n, final ContextNavigator contextNavigator,
@@ -96,7 +96,7 @@
             final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry,
             final Provider<FileDownloadUtils> fileDownloadProvider, final EntityLogo entityLogo,
             final Provider<TextEditor> textEditorProvider, final KuneErrorHandler errorHandler,
-            final DocumentContent documentContent, final Provider<DocContextEditor> adminContextProvider) {
+            final DocumentViewer documentViewer, final Provider<DocContextEditor> adminContextProvider) {
         this.i18n = i18n;
         this.contextNavigator = contextNavigator;
         this.session = session;
@@ -110,7 +110,7 @@
         this.entityLogo = entityLogo;
         this.textEditorProvider = textEditorProvider;
         this.errorHandler = errorHandler;
-        this.documentContent = documentContent;
+        this.documentViewer = documentViewer;
         this.adminContextProvider = adminContextProvider;
         createActions();
     }
@@ -337,7 +337,7 @@
                         session.check(new AsyncCallbackSimple<Object>() {
                             public void onSuccess(final Object result) {
                                 final TextEditor editor = textEditorProvider.get();
-                                documentContent.detach();
+                                documentViewer.detach();
                                 contextNavigator.detach();
                                 adminContextProvider.get().attach();
                                 editor.editContent(session.getContentState().getContent(), new Listener<String>() {
@@ -370,11 +370,11 @@
                                         // onClose
                                         DeferredCommand.addCommand(new Command() {
                                             public void execute() {
-                                                documentContent.attach();
+                                                documentViewer.attach();
                                                 adminContextProvider.get().detach();
                                                 contextNavigator.attach();
                                                 if (session.getCurrentStateToken().equals(stateToken)) {
-                                                    documentContent.refreshState();
+                                                    documentViewer.refreshState();
                                                 }
                                             }
                                         });

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -18,9 +18,6 @@
  *
  */package org.ourproject.kune.docs.client;
 
-import org.ourproject.kune.docs.client.cnt.DocumentContent;
-import org.ourproject.kune.docs.client.cnt.DocumentContentPanel;
-import org.ourproject.kune.docs.client.cnt.DocumentContentPresenter;
 import org.ourproject.kune.docs.client.cnt.folder.viewer.DocFolderContent;
 import org.ourproject.kune.docs.client.cnt.folder.viewer.DocFolderContentPanel;
 import org.ourproject.kune.docs.client.cnt.folder.viewer.DocFolderContentPresenter;
@@ -86,23 +83,11 @@
                         $(Session.class), $(StateManager.class), $$(ContentServiceAsync.class),
                         $$(GroupServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class),
                         $(ContextActionRegistry.class), $$(FileDownloadUtils.class), $(EntityLogo.class),
-                        $$(TextEditor.class), $(KuneErrorHandler.class), $(DocumentContent.class),
+                        $$(TextEditor.class), $(KuneErrorHandler.class), $(DocumentViewer.class),
                         $$(DocContextEditor.class));
             }
         });
 
-        register(ToolGroup.class, new Factory<DocumentContent>(DocumentContent.class) {
-            @Override
-            public DocumentContent create() {
-                final DocumentContentPresenter presenter = new DocumentContentPresenter($(StateManager.class),
-                        $(Session.class), $$(DocumentViewer.class), $$(TextEditor.class),
-                        $(ActionContentToolbar.class), $(ContentActionRegistry.class));
-                final DocumentContentPanel panel = new DocumentContentPanel($(WorkspaceSkeleton.class));
-                presenter.init(panel);
-                return presenter;
-            }
-        });
-
         register(Singleton.class, new Factory<DocContextEditor>(DocContextEditor.class) {
             @Override
             public DocContextEditor create() {
@@ -128,9 +113,12 @@
         register(Singleton.class, new Factory<DocumentViewer>(DocumentViewer.class) {
             @Override
             public DocumentViewer create() {
+                final DocumentViewerPresenter presenter = new DocumentViewerPresenter($(StateManager.class),
+                        $(Session.class), $(I18nUITranslationService.class), $(ActionContentToolbar.class),
+                        $(ContentActionRegistry.class), $$(FileDownloadUtils.class));
                 final DocumentViewerView view = new DocumentViewerPanel($(WorkspaceSkeleton.class),
                         $(I18nTranslationService.class));
-                final DocumentViewerPresenter presenter = new DocumentViewerPresenter(view, $$(FileDownloadUtils.class));
+                presenter.init(view);
                 return presenter;
             }
         });
@@ -140,7 +128,8 @@
             public DocFolderContent create() {
                 final DocFolderContentPresenter presenter = new DocFolderContentPresenter($(StateManager.class),
                         $(Session.class), $(ActionContentToolbar.class), $(ContentActionRegistry.class));
-                final DocFolderContentView view = new DocFolderContentPanel($(WorkspaceSkeleton.class));
+                final DocFolderContentView view = new DocFolderContentPanel($(WorkspaceSkeleton.class),
+                        $(I18nTranslationService.class));
                 presenter.init(view);
                 return presenter;
             }

Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContent.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContent.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContent.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -1,30 +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.docs.client.cnt;
-
-public interface DocumentContent {
-
-    void attach();
-
-    void detach();
-
-    void refreshState();
-
-}

Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPanel.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPanel.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -1,37 +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.docs.client.cnt;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.google.gwt.user.client.ui.Widget;
-
-public class DocumentContentPanel implements DocumentContentView {
-
-    private final WorkspaceSkeleton ws;
-
-    public DocumentContentPanel(final WorkspaceSkeleton ws) {
-        this.ws = ws;
-    }
-
-    public void setContent(final View view) {
-        ws.getEntityWorkspace().setContent((Widget) view);
-    }
-}

Deleted: 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-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -1,113 +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.docs.client.cnt;
-
-import org.ourproject.kune.docs.client.DocumentClientTool;
-import org.ourproject.kune.docs.client.cnt.viewer.DocumentViewer;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionRegistry;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.dto.StateAbstractDTO;
-import org.ourproject.kune.platf.client.dto.StateContainerDTO;
-import org.ourproject.kune.platf.client.dto.StateContentDTO;
-import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.workspace.client.editor.TextEditor;
-
-import com.calclab.suco.client.ioc.Provider;
-import com.calclab.suco.client.listener.Listener;
-import com.calclab.suco.client.listener.Listener2;
-
-public class DocumentContentPresenter implements DocumentContent {
-    private DocumentContentView view;
-    private final Session session;
-    private final Provider<DocumentViewer> docReaderProvider;
-    private final Provider<TextEditor> textEditorProvider;
-    private final ActionToolbar<StateToken> toolbar;
-    private final ActionRegistry<StateToken> actionRegistry;
-
-    public DocumentContentPresenter(final StateManager stateManager, final Session session,
-            final Provider<DocumentViewer> docReaderProvider, final Provider<TextEditor> textEditorProvider,
-            final ActionToolbar<StateToken> toolbar, final ActionRegistry<StateToken> actionRegistry) {
-        this.session = session;
-        this.docReaderProvider = docReaderProvider;
-        this.textEditorProvider = textEditorProvider;
-        this.toolbar = toolbar;
-        this.actionRegistry = actionRegistry;
-        stateManager.onStateChanged(new Listener<StateAbstractDTO>() {
-            public void onEvent(final StateAbstractDTO state) {
-                setState(state);
-            }
-        });
-        stateManager.onToolChanged(new Listener2<String, String>() {
-            public void onEvent(final String oldTool, final String newTool) {
-                if (oldTool != null && oldTool.equals(DocumentClientTool.NAME)) {
-                    toolbar.detach();
-                }
-            }
-        });
-    }
-
-    public void attach() {
-        toolbar.attach();
-    }
-
-    public void detach() {
-        toolbar.detach();
-    }
-
-    public void init(final DocumentContentView view) {
-        this.view = view;
-    }
-
-    public void refreshState() {
-        setState(session.getCurrentState());
-    }
-
-    private void setState(final StateAbstractDTO state) {
-        if (state instanceof StateContainerDTO) {
-            StateContainerDTO stateCntCtx = (StateContainerDTO) state;
-            if (stateCntCtx.getToolName().equals(DocumentClientTool.NAME)) {
-                // This tool
-                if (stateCntCtx instanceof StateContentDTO) {
-                    setState((StateContentDTO) stateCntCtx);
-                } else if (stateCntCtx instanceof StateContainerDTO) {
-                    // FIXME setState(stateCntCtx);
-                }
-            }
-        }
-    }
-
-    private void setState(final StateContentDTO state) {
-        ActionItemCollection<StateToken> collection = actionRegistry.getCurrentActions(state.getStateToken(),
-                state.getTypeId(), session.isLogged(), state.getContentRights(), true);
-        setToolbar(collection);
-        docReaderProvider.get().showDocument(state.getStateToken(), state.getContent(), state.getTypeId(),
-                state.getMimeType());
-        textEditorProvider.get().reset();
-    }
-
-    private void setToolbar(ActionItemCollection<StateToken> collection) {
-        toolbar.disableMenusAndClearButtons();
-        toolbar.setActions(collection);
-        toolbar.attach();
-    }
-}

Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentView.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentView.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -1,27 +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.docs.client.cnt;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface DocumentContentView {
-
-    void setContent(View view);
-
-}

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/viewer/DocFolderContentPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/viewer/DocFolderContentPanel.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/viewer/DocFolderContentPanel.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -19,19 +19,15 @@
  */
 package org.ourproject.kune.docs.client.cnt.folder.viewer;
 
-import org.ourproject.kune.workspace.client.cnt.AbstractContentPanel;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.workspace.client.cnt.FoldableContentPanel;
 import org.ourproject.kune.workspace.client.site.Site;
 import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
 
-import com.google.gwt.user.client.ui.Label;
+public class DocFolderContentPanel extends FoldableContentPanel implements DocFolderContentView {
 
-public class DocFolderContentPanel extends AbstractContentPanel implements DocFolderContentView {
-
-    public DocFolderContentPanel(WorkspaceSkeleton ws) {
-        super(ws);
-        Label label = new Label("Folder properties, translations ..." + Site.IN_DEVELOPMENT);
-        label.setStyleName("kune-Content-Main");
-        label.addStyleName("kune-Margin-7-trbl");
-        initWidget(label);
+    public DocFolderContentPanel(WorkspaceSkeleton ws, I18nTranslationService i18n) {
+        super(ws, i18n);
+        super.setLabel("Folder properties, translations ..." + Site.IN_DEVELOPMENT);
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewer.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewer.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewer.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -19,13 +19,12 @@
  */
 package org.ourproject.kune.docs.client.cnt.viewer;
 
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO;
-import org.ourproject.kune.platf.client.dto.StateToken;
-
 public interface DocumentViewer {
 
-    View getView();
+    void attach();
 
-    void showDocument(StateToken token, String text, String typeId, BasicMimeTypeDTO mimeType);
+    void detach();
+
+    void refreshState();
+
 }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPanel.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPanel.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -20,54 +20,11 @@
 package org.ourproject.kune.docs.client.cnt.viewer;
 
 import org.ourproject.kune.platf.client.services.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.KuneUiUtils;
+import org.ourproject.kune.workspace.client.cnt.FoldableContentPanel;
 import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
 
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Widget;
-
-public class DocumentViewerPanel implements DocumentViewerView {
-
-    private final WorkspaceSkeleton ws;
-    private final I18nTranslationService i18n;
-
+public class DocumentViewerPanel extends FoldableContentPanel implements DocumentViewerView {
     public DocumentViewerPanel(final WorkspaceSkeleton ws, I18nTranslationService i18n) {
-        this.ws = ws;
-        this.i18n = i18n;
+        super(ws, i18n);
     }
-
-    public void setContent(final String content) {
-        final HTML html = new HTML(content);
-        setDefStyle(html);
-        ws.getEntityWorkspace().setContent(html);
-    }
-
-    public void showImage(String imageUrl, String imageResizedUrl) {
-        final Image imgOrig = new Image(imageUrl);
-        final Image imgResized = new Image(imageResizedUrl);
-        KuneUiUtils.setQuickTip(imgOrig, i18n.t("Click to zoom out"));
-        KuneUiUtils.setQuickTip(imgResized, i18n.t("Click to zoom in"));
-        setDefStyle(imgOrig);
-        setDefStyle(imgResized);
-        imgOrig.addStyleName("kune-pointer");
-        imgResized.addStyleName("kune-pointer");
-        imgResized.addClickListener(new ClickListener() {
-            public void onClick(Widget sender) {
-                ws.getEntityWorkspace().setContent(imgOrig);
-            }
-        });
-        imgOrig.addClickListener(new ClickListener() {
-            public void onClick(Widget sender) {
-                ws.getEntityWorkspace().setContent(imgResized);
-            }
-        });
-        ws.getEntityWorkspace().setContent(imgResized);
-    }
-
-    private void setDefStyle(final Widget widget) {
-        widget.setStyleName("kune-Content-Main");
-        widget.addStyleName("kune-Margin-7-trbl");
-    }
 }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPresenter.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerPresenter.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -20,29 +20,47 @@
 package org.ourproject.kune.docs.client.cnt.viewer;
 
 import org.ourproject.kune.docs.client.DocumentClientTool;
-import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionContentToolbar;
 import org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO;
+import org.ourproject.kune.platf.client.dto.StateContentDTO;
 import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
 import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
 import org.ourproject.kune.platf.client.ui.download.ImageSize;
+import org.ourproject.kune.workspace.client.cnt.FoldableContentPresenter;
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
 
 import com.calclab.suco.client.ioc.Provider;
 
-public class DocumentViewerPresenter implements DocumentViewer {
-    private final DocumentViewerView view;
+public class DocumentViewerPresenter extends FoldableContentPresenter implements DocumentViewer {
+    private DocumentViewerView view;
     private final Provider<FileDownloadUtils> downloadProvider;
 
-    public DocumentViewerPresenter(final DocumentViewerView view, final Provider<FileDownloadUtils> downloadProvider) {
-        this.view = view;
+    public DocumentViewerPresenter(StateManager stateManager, Session session, I18nUITranslationService i18n,
+            ActionContentToolbar toolbar, ContentActionRegistry actionRegistry,
+            Provider<FileDownloadUtils> downloadProvider) {
+        super(DocumentClientTool.NAME, stateManager, session, toolbar, actionRegistry);
         this.downloadProvider = downloadProvider;
     }
 
-    public View getView() {
-        return view;
+    public void init(DocumentViewerView view) {
+        super.init(view);
+        this.view = view;
     }
 
-    public void showDocument(final StateToken token, final String text, final String typeId,
-            final BasicMimeTypeDTO mimeType) {
+    public void refreshState() {
+        setState(session.getContentState());
+    }
+
+    @Override
+    protected void setState(StateContentDTO state) {
+        super.setState(state);
+        String typeId = state.getTypeId();
+        String text = state.getContent();
+        StateToken token = state.getStateToken();
+        BasicMimeTypeDTO mimeType = state.getMimeType();
         if (typeId.equals(DocumentClientTool.TYPE_UPLOADEDFILE)) {
             if (mimeType != null) {
                 FileDownloadUtils fileDownloadUtils = downloadProvider.get();
@@ -58,5 +76,6 @@
         } else {
             view.setContent(text);
         }
+        view.attach();
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerView.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/viewer/DocumentViewerView.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -19,9 +19,9 @@
  */
 package org.ourproject.kune.docs.client.cnt.viewer;
 
-import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.workspace.client.cnt.AbstractContentView;
 
-public interface DocumentViewerView extends View {
+public interface DocumentViewerView extends AbstractContentView {
 
     void setContent(String content);
 

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -253,7 +253,8 @@
                 final EntityLogoPresenter presenter = new EntityLogoPresenter($(StateManager.class),
                         $(WsThemePresenter.class), $(Session.class));
                 final EntityLogoPanel panel = new EntityLogoPanel($(I18nUITranslationService.class),
-                        $(WorkspaceSkeleton.class), $$(FileDownloadUtils.class), $$(EntityLogoSelector.class), $(Images.class));
+                        $(WorkspaceSkeleton.class), $$(FileDownloadUtils.class), $$(EntityLogoSelector.class),
+                        $(Images.class));
                 presenter.init(panel);
                 return presenter;
             }

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentPanel.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/AbstractContentPanel.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -13,18 +13,18 @@
     }
 
     public void attach() {
-        if (!widget.isAttached()) {
+        if (widget != null && !widget.isAttached()) {
             ws.getEntityWorkspace().setContent(widget);
         }
     }
 
     public void detach() {
-        if (widget.isAttached()) {
+        if (widget != null && widget.isAttached()) {
             widget.removeFromParent();
         }
     }
 
-    public void initWidget(Widget widget) {
+    public void setWidget(Widget widget) {
         this.widget = widget;
     }
 }

Added: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPanel.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -0,0 +1,66 @@
+package org.ourproject.kune.workspace.client.cnt;
+
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.KuneUiUtils;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Widget;
+
+public class FoldableContentPanel extends AbstractContentPanel {
+
+    private final I18nTranslationService i18n;
+
+    public FoldableContentPanel(final WorkspaceSkeleton ws, I18nTranslationService i18n) {
+        super(ws);
+        this.i18n = i18n;
+    }
+
+    public void setContent(final String content) {
+        final HTML html = new HTML(content);
+        setDefStyle(html);
+        setWidget(html);
+        attach();
+    }
+
+    public void setLabel(String text) {
+        Label label = new Label(text);
+        setDefStyle(label);
+        setWidget(label);
+    }
+
+    public void showImage(String imageUrl, String imageResizedUrl) {
+        final Image imgOrig = new Image(imageUrl);
+        final Image imgResized = new Image(imageResizedUrl);
+        KuneUiUtils.setQuickTip(imgOrig, i18n.t("Click to zoom out"));
+        KuneUiUtils.setQuickTip(imgResized, i18n.t("Click to zoom in"));
+        setDefStyle(imgOrig);
+        setDefStyle(imgResized);
+        imgOrig.addStyleName("kune-pointer");
+        imgResized.addStyleName("kune-pointer");
+        imgResized.addClickListener(new ClickListener() {
+            public void onClick(Widget sender) {
+                detach();
+                setWidget(imgOrig);
+                attach();
+            }
+        });
+        imgOrig.addClickListener(new ClickListener() {
+            public void onClick(Widget sender) {
+                detach();
+                setWidget(imgResized);
+                attach();
+            }
+        });
+        setWidget(imgResized);
+        attach();
+    }
+
+    private void setDefStyle(final Widget widget) {
+        widget.setStyleName("kune-Content-Main");
+        widget.addStyleName("kune-Margin-7-trbl");
+    }
+}

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java	2008-11-06 21:03:52 UTC (rev 942)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java	2008-11-10 19:00:10 UTC (rev 943)
@@ -3,6 +3,7 @@
 import org.ourproject.kune.platf.client.actions.ActionItemCollection;
 import org.ourproject.kune.platf.client.actions.ActionRegistry;
 import org.ourproject.kune.platf.client.actions.toolbar.ActionContentToolbar;
+import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
 import org.ourproject.kune.platf.client.dto.StateAbstractDTO;
 import org.ourproject.kune.platf.client.dto.StateContainerDTO;
 import org.ourproject.kune.platf.client.dto.StateContentDTO;
@@ -16,7 +17,7 @@
 
     private final String toolName;
     private final ActionRegistry<StateToken> actionRegistry;
-    private final Session session;
+    protected final Session session;
     private final ActionContentToolbar toolbar;
 
     public FoldableContentPresenter(final String toolName, StateManager stateManager, Session session,
@@ -52,15 +53,21 @@
     }
 
     protected void setState(StateContainerDTO state) {
-        ActionItemCollection<StateToken> collection = actionRegistry.getCurrentActions(state.getStateToken(),
-                state.getTypeId(), session.isLogged(), state.getContainerRights(), true);
+        ActionItemCollection<StateToken> collection = getActionCollection(state, state.getContainerRights());
         setToolbar(collection);
         attach();
     }
 
     protected void setState(StateContentDTO state) {
+        ActionItemCollection<StateToken> collection = getActionCollection(state, state.getContentRights());
+        setToolbar(collection);
     }
 
+    private ActionItemCollection<StateToken> getActionCollection(StateContainerDTO state, AccessRightsDTO rights) {
+        return actionRegistry.getCurrentActions(state.getStateToken(), state.getTypeId(), session.isLogged(), rights,
+                true);
+    }
+
     private void setToolbar(ActionItemCollection<StateToken> collection) {
         toolbar.disableMenusAndClearButtons();
         toolbar.setActions(collection);




More information about the kune-commits mailing list