[kune-commits] r1834 - in trunk: . src/main/java/cc/kune/events/client/viewer src/main/java/cc/kune/gspace/client/viewers

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Tue Apr 10 18:13:35 CEST 2012


Author: vjrj_
Date: 2012-04-10 18:13:34 +0200 (Tue, 10 Apr 2012)
New Revision: 1834

Modified:
   trunk/TODO
   trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerPanel.java
   trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerView.java
   trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerUtils.java
   trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.java
   trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.ui.xml
Log:
NEW - # 193: Add a tool intro tutorial instead of the sample contents 
http://kune.ourproject.org/issues/ticket/193

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/TODO	2012-04-10 16:13:34 UTC (rev 1834)
@@ -28,8 +28,27 @@
 2012-04-09 00:14:34 AuthenticatedMethodInterceptor [INFO] Userhash received: null
 2012-04-09 00:14:34 AuthenticatedMethodInterceptor [INFO] --------------------------------------------------------------------------------
 
-** Central Deck
+** Views and Subviews
+|----------+-----------------+------------------+--------------------------+----------|
+| View     | Subview         | Set              | Show                     | Hide     |
+|----------+-----------------+------------------+--------------------------+----------|
+| Folder   | Tutorial        | onToolChange     | onBtn / onEmpty & logged | closeBtn |
+|          | Empty           | onStateChange    | onEmpty                  | (1)      |
+|          | Folder list     | onStateChange    | onNotEmpty               | (1)      |
+|----------+-----------------+------------------+--------------------------+----------|
+| Content  | Tutorial        | onToolChange     | onBtn & logged           | closeBtn |
+|          | Not logged view | onStateChange    | onBtn                    | (1)      |
+|          | Def lang        | onStateChange    | onStateChange            | (1)      |
+|          | lang 1          | onBtn(LangClick) | onBtn                    | (1)      |
+|          | lang 2          | onBtn(LangClick) | onBtn                    | (1)      |
+|          | ...             |                  |                          |          |
+|----------+-----------------+------------------+--------------------------+----------|
+| Calendar | Tutorial        | onToolChange     | onBtn                    | closeBtn |
+|          | Calendar view   | onStateChange    | onBtn(calendar tool)     | (1)      |
+|----------+-----------------+------------------+--------------------------+----------|
 
+(1) when move to other #url
+
 ** Permission tables
 
 |---------------------------+-------------+--------------|

Modified: trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java	2012-04-10 16:13:34 UTC (rev 1834)
@@ -42,6 +42,7 @@
 import cc.kune.events.shared.EventsToolConstants;
 import cc.kune.gspace.client.viewers.AbstractFolderViewerView;
 import cc.kune.gspace.client.viewers.FolderViewerUtils;
+import cc.kune.gspace.client.viewers.TutorialViewer.OnTutorialClose;
 
 import com.bradrydzewski.gwt.calendar.client.Appointment;
 import com.bradrydzewski.gwt.calendar.client.AppointmentStyle;
@@ -304,6 +305,12 @@
   @Override
   public void setContent(@Nonnull final HasContent state) {
     folderViewerUtils.setContent(getView(), state);
+    folderViewerUtils.setTutorialCloseHandler(new OnTutorialClose() {
+      @Override
+      public void onClose() {
+        folderViewerUtils.setContent(getView(), state);
+      }
+    });
     getView().showFolder();
     final StateEventContainerDTO eventState = (StateEventContainerDTO) state;
     updateMenuItems();

Modified: trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerPanel.java	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerPanel.java	2012-04-10 16:13:34 UTC (rev 1834)
@@ -32,6 +32,7 @@
 import cc.kune.gspace.client.armor.GSpaceArmor;
 import cc.kune.gspace.client.armor.GSpaceCenter;
 import cc.kune.gspace.client.viewers.FolderViewerPresenter.FolderViewerView;
+import cc.kune.gspace.client.viewers.TutorialViewer.OnTutorialClose;
 
 import com.google.gwt.event.logical.shared.ResizeEvent;
 import com.google.gwt.event.logical.shared.ResizeHandler;
@@ -174,13 +175,12 @@
   }
 
   @Override
-  public void showTutorial(final String tool) {
+  public void showTutorial(final OnTutorialClose onTutorialClose) {
     gsArmor.enableCenterScroll(false);
     final GSpaceCenter docContainer = gsArmor.getDocContainer();
-    // docContainer.clear();
-    final Widget tutorial = tutorialViewer.show(tool);
     resizeTutorialFrame();
-    docContainer.add(tutorial);
-    docContainer.showWidget(tutorial);
+    docContainer.add(tutorialViewer);
+    docContainer.showWidget(tutorialViewer);
+    tutorialViewer.setTutorialCloseHandler(onTutorialClose);
   }
 }

Modified: trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerView.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerView.java	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/src/main/java/cc/kune/gspace/client/viewers/AbstractFolderViewerView.java	2012-04-10 16:13:34 UTC (rev 1834)
@@ -22,6 +22,7 @@
 import cc.kune.common.client.actions.ui.descrip.GuiActionDescCollection;
 import cc.kune.common.client.ui.HasEditHandler;
 import cc.kune.core.shared.dto.StateContainerDTO;
+import cc.kune.gspace.client.viewers.TutorialViewer.OnTutorialClose;
 import cc.kune.gspace.client.viewers.items.FolderItemDescriptor;
 
 import com.google.gwt.event.dom.client.ClickHandler;
@@ -56,5 +57,5 @@
 
   void showFolder();
 
-  void showTutorial(String tool);
+  void showTutorial(OnTutorialClose onTutorialClose);
 }

Modified: trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerPresenter.java	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerPresenter.java	2012-04-10 16:13:34 UTC (rev 1834)
@@ -29,6 +29,7 @@
 import cc.kune.gspace.client.actions.RenameAction;
 import cc.kune.gspace.client.actions.RenameListener;
 import cc.kune.gspace.client.tool.ContentViewer;
+import cc.kune.gspace.client.viewers.TutorialViewer.OnTutorialClose;
 
 import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.event.shared.HandlerRegistration;
@@ -120,5 +121,11 @@
   @Override
   public void setContent(@Nonnull final HasContent state) {
     folderViewerUtils.setContent(getView(), state);
+    folderViewerUtils.setTutorialCloseHandler(new OnTutorialClose() {
+      @Override
+      public void onClose() {
+        folderViewerUtils.setContent(getView(), state);
+      }
+    });
   }
 }
\ No newline at end of file

Modified: trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerUtils.java	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/src/main/java/cc/kune/gspace/client/viewers/FolderViewerUtils.java	2012-04-10 16:13:34 UTC (rev 1834)
@@ -44,6 +44,7 @@
 import cc.kune.gspace.client.actions.ActionGroups;
 import cc.kune.gspace.client.actions.ShowHelpContainerEvent;
 import cc.kune.gspace.client.viewers.FolderViewerPresenter.FolderViewerView;
+import cc.kune.gspace.client.viewers.TutorialViewer.OnTutorialClose;
 import cc.kune.gspace.client.viewers.items.FolderItemDescriptor;
 import cc.kune.trash.shared.TrashToolConstants;
 
@@ -62,6 +63,7 @@
   private final Provider<ClientFileDownloadUtils> downloadUtilsProvider;
   private final I18nTranslationService i18n;
   private final IconsRegistry iconsRegistry;
+  private OnTutorialClose onTutorialClose;
   private final PathToolbarUtils pathToolbarUtils;
   private final Session session;
   private final StateManager stateManager;
@@ -87,7 +89,7 @@
           public void onShowHelpContainer(final ShowHelpContainerEvent event) {
             final AbstractFolderViewerView currentView = getView();
             if (currentView != null) {
-              currentView.showTutorial(event.getTool());
+              currentView.showTutorial(onTutorialClose);
             }
           }
         });
@@ -139,14 +141,15 @@
       // No elements here, so, we show a empty message (or a tutorial)
       if (session.isLogged() && capabReg.getTutorialRegistry().hasTutorial(typeId)) {
         // If we have a tutorial, we show it.
-        getView().showTutorial(container.getStateToken().getTool());
+        getView().showTutorial(new OnTutorialClose() {
+          @Override
+          public void onClose() {
+            showEmptyMsg(typeId);
+          }
+        });
       } else {
         // If not, we show the empty message
-        // msg is already translated
-        final String msg = session.isLogged() ? capabReg.getEmptyMessagesRegistry().getContentTypeIcon(
-            typeId) : capabReg.getEmptyMessagesRegistryNotLogged().getContentTypeIcon(typeId);
-        final String emptyMessage = TextUtils.empty(msg) ? i18n.t("This is empty.") : msg;
-        getView().showEmptyMsg(emptyMessage);
+        showEmptyMsg(typeId);
       }
     } else {
       // Folders
@@ -218,4 +221,16 @@
     getView().setFooterActions(bottomActions);
     createChildItems(container, stateContainer.getContainerRights());
   }
+
+  public void setTutorialCloseHandler(final OnTutorialClose onTutorialClose) {
+    this.onTutorialClose = onTutorialClose;
+  }
+
+  private void showEmptyMsg(final String typeId) {
+    // msg is already translated
+    final String msg = session.isLogged() ? capabReg.getEmptyMessagesRegistry().getContentTypeIcon(
+        typeId) : capabReg.getEmptyMessagesRegistryNotLogged().getContentTypeIcon(typeId);
+    final String emptyMessage = TextUtils.empty(msg) ? i18n.t("This is empty.") : msg;
+    getView().showEmptyMsg(emptyMessage);
+  }
 }

Modified: trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.java	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.java	2012-04-10 16:13:34 UTC (rev 1834)
@@ -23,12 +23,16 @@
 
 import cc.kune.common.client.log.Log;
 import cc.kune.common.client.ui.dialogs.CloseDialogButton;
+import cc.kune.core.client.events.ToolChangedEvent;
+import cc.kune.core.client.events.ToolChangedEvent.ToolChangedHandler;
 import cc.kune.core.client.i18n.I18nUITranslationService;
 import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.StateManager;
 import cc.kune.core.shared.FileConstants;
 
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.HasClickHandlers;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.Composite;
@@ -40,6 +44,9 @@
 @Singleton
 public class TutorialViewer extends Composite {
 
+  public interface OnTutorialClose {
+    void onClose();
+  }
   interface TutorialViewerUiBinder extends UiBinder<Widget, TutorialViewer> {
   }
 
@@ -52,19 +59,31 @@
   public Frame frame;
   private final I18nUITranslationService i18n;
   private List<String> langs;
+  private OnTutorialClose onTutorialClose;
   private final Session session;
 
   @Inject
-  public TutorialViewer(final I18nUITranslationService i18n, final Session session) {
+  public TutorialViewer(final I18nUITranslationService i18n, final Session session,
+      final StateManager stateManager) {
     this.i18n = i18n;
     this.session = session;
     initWidget(uiBinder.createAndBindUi(this));
+    stateManager.onToolChanged(true, new ToolChangedHandler() {
+      @Override
+      public void onToolChanged(final ToolChangedEvent event) {
+        setTool(event.getNewTool());
+      }
+    });
+    closeBtn.addClickHandler(new ClickHandler() {
+      @Override
+      public void onClick(final ClickEvent event) {
+        if (onTutorialClose != null) {
+          onTutorialClose.onClose();
+        }
+      }
+    });
   }
 
-  public HasClickHandlers getCloseBtn() {
-    return closeBtn;
-  }
-
   private String getTutorialLang() {
     if (langs == null) {
       langs = session.getInitData().getTutorialLanguages();
@@ -85,10 +104,13 @@
     }
   }
 
-  public Widget show(final String tool) {
+  private void setTool(final String tool) {
     final String currentLang = getTutorialLang();
     frame.setUrl(FileConstants.TUTORIALS_PREFIX + tool + ".svg" + "#" + currentLang);
-    return this;
   }
 
+  public void setTutorialCloseHandler(final OnTutorialClose onTutorialClose) {
+    this.onTutorialClose = onTutorialClose;
+  }
+
 }

Modified: trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.ui.xml
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.ui.xml	2012-04-10 14:53:28 UTC (rev 1833)
+++ trunk/src/main/java/cc/kune/gspace/client/viewers/TutorialViewer.ui.xml	2012-04-10 16:13:34 UTC (rev 1834)
@@ -16,7 +16,7 @@
   </ui:style>
   <g:FlowPanel styleName="{style.flow}">
     <d:CloseDialogButton ui:field="closeBtn"
-      addStyleNames="k-dialog-close-btn-normal" visible="false"/>
+      addStyleNames="k-dialog-close-btn-normal" visible="true"/>
     <g:Frame styleName="{style.frame}" ui:field="frame"/>
   </g:FlowPanel>
 </ui:UiBinder>
\ No newline at end of file




More information about the kune-commits mailing list