[kune-commits] r1066 - in trunk: . src/main/java/org/ourproject/kune/blogs/client src/main/java/org/ourproject/kune/docs/client src/main/java/org/ourproject/kune/platf/client/services src/main/java/org/ourproject/kune/platf/client/ui src/main/java/org/ourproject/kune/platf/client/ui/rte src/main/java/org/ourproject/kune/platf/client/utils src/main/java/org/ourproject/kune/wiki/client src/main/java/org/ourproject/kune/workspace/client src/main/java/org/ourproject/kune/workspace/client/editor src/test/java/org/ourproject/kune/platf/client/ui src/test/java/org/ourproject/kune/platf/client/ui/rte src/test/java/org/ourproject/kune/workspace/client/editor

vjrj vjrj at ourproject.org
Tue Mar 10 14:43:46 CET 2009


Author: vjrj
Date: 2009-03-10 14:43:43 +0100 (Tue, 10 Mar 2009)
New Revision: 1066

Added:
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java
   trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/
   trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java
Removed:
   trunk/src/test/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenterTest.java
Modified:
   trunk/DEV-GUIDE
   trunk/TODO
   trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java
   trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/FlowToolbar.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java
   trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java
   trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support 


Modified: trunk/DEV-GUIDE
===================================================================
--- trunk/DEV-GUIDE	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/DEV-GUIDE	2009-03-10 13:43:43 UTC (rev 1066)
@@ -18,6 +18,14 @@
 
  svn checkout svn+ssh://[email protected]/svnroot/kune/trunk
 
+== Mailing lists==
+
+We use mainly two lists:
+* [https://lists.ourproject.org/cgi-bin/mailman/listinfo/kune-devel kune-devel] for all development related topics
+* [https://lists.ourproject.org/cgi-bin/mailman/listinfo/kune-commits kune-commits] where the svn sends the commit logs and summaries
+
+It's recommended to be subscribed to both if you want to participate in the development.
+
 ==Some relevant docs for kune development==
 
 See this files in trunk directory:

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/TODO	2009-03-10 13:43:43 UTC (rev 1066)
@@ -78,55 +78,16 @@
    http://en.wikipedia.org/wiki/Fragment_identifier
    http://www.w3.org/DesignIssues/Fragment.html
 ** vjrj <v> better RTE
-*** Functionality
-    + We can have several RTE in use 
-      - with different menus (File/Blog ...)
-      - with different save/close actions
-      - with different capabilities depending on:
-        - the browser
-        - the functionality
-    + bidi support
-    + shortcuts (for insert comments, italic, bold, and soon).
-    + Add new capabilities (based on InsertHTML):
-      - Insert tables
-      - Insert special chars (for table or from unicode).
-      - youtube videos
-    + Edit HTML
-    + Easy extensible for new actions
-    + Try (yes, only try) to be a reusable module (like emite)
-    + autosave on/off
-*** Charactericts 
-    + Builded over gwt RTE (or any similar RTE) and based in gwt mouse/keyboard events
-*** Menus
-**** File
-     + Save (Ctrl+S) [Always active?]
-     + Save as new copy ...
-     + Rename... (F2)
-     + Delete...
-**** Edit
-     + Undo (Ctrl+Z)
-     + Redo (Ctrl+Y)
-     ---------------
-     + Copy
-     + Cut
-     + Paste
-     ---------------
-     + Select all (Ctrl+A)
-     + Edit HTML
-**** Insert
-     + Picture...
-     + Link... (Ctrl+K)
-     + Table...
-     ----------------
-     + Comment...(Ctrl+M)
-     + Special char
-     + Horizontal line
-     + Page break (for printing)
-*** Buttons
-*** Elements
-    + A register of actions (menus/buttons)
-    + Every RTE instance selects the actions to use
-    + Two topbars, one for menus, other for buttons, font/color selections      
+*** Pending
+**** with different menus (File/Blog ...)
+**** bidi support
+**** Insert special chars (for table or from unicode).
+**** images (local/remote) with preview
+**** youtube videos/podcasts
+**** Edit HTML
+**** File > Rename (F2)
+**** Insert > Special char
+**** Insert > Page break (for printing)
 *** Links
    http://www.ongwt.com/post/2009/01/08/XWiki-:-Wysiwyg-editor-based-on-GWT
    http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/ie55/EditRegions/default.asp

Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -79,6 +79,7 @@
                 Position.ctx, TYPE_BLOG);
 
         createContentRenameAction(parentMenuTitle, i18n.t("Rename"), contents);
+        createEditAction(TYPE_POST);
         createContentModeratedActions(parentMenuTitle, contentsModerated);
         createRenameContentInCtxAction(parentMenuTitleCtx, i18n.t("Rename"), containersNoRoot);
 
@@ -95,7 +96,6 @@
 
         createGoAction(all);
         createGoHomeAction(containers);
-        createEditAction(TYPE_POST);
 
         // ContentRPC Authorized must permit folders
         // contentActionRegistry.addAction(setAsDefGroupCxt, TYPE_BLOG);

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -80,6 +80,7 @@
                 Position.ctx, TYPE_ROOT, TYPE_FOLDER);
 
         createContentRenameAction(parentMenuTitle, i18n.t("Rename"), contents);
+        createEditAction(TYPE_DOCUMENT);
         createContentModeratedActions(parentMenuTitle, contentsModerated);
         createRenameContentInCtxAction(parentMenuTitleCtx, i18n.t("Rename"), containersNoRoot);
 
@@ -100,8 +101,6 @@
 
         createGoHomeAction(containers);
 
-        createEditAction(TYPE_DOCUMENT);
-
         createTranslateAction(TYPE_DOCUMENT, TYPE_FOLDER);
 
         createDelContainerAction("Delete folder", parentMenuTitleCtx, containersNoRoot);

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -53,6 +53,7 @@
 import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbar;
 import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbarPresenter;
 import org.ourproject.kune.platf.client.ui.rte.RTESavingEditor;
+import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPanel;
 import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter;
 import org.ourproject.kune.platf.client.ui.rte.RTEditor;
 import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel;
@@ -60,6 +61,7 @@
 import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
 import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
 import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
 import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElement;
 import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
 
@@ -240,6 +242,13 @@
             }
         });
 
+        register(Singleton.class, new Factory<TimerWrapper>(TimerWrapper.class) {
+            @Override
+            public TimerWrapper create() {
+                return new TimerWrapper();
+            }
+        });
+
         register(NoDecoration.class, new Factory<RTEditor>(RTEditor.class) {
             @Override
             public RTEditor create() {
@@ -256,9 +265,12 @@
         }, new Factory<RTESavingEditor>(RTESavingEditor.class) {
             @Override
             public RTESavingEditor create() {
-                return new RTESavingEditorPresenter($(RTEditor.class), true, $(I18nTranslationService.class),
-                        $(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class),
-                        $(RTEImgResources.class));
+                RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditor.class), true,
+                        $(I18nTranslationService.class), $(StateManager.class), $(SiteSignOutLink.class),
+                        $(DeferredCommandWrapper.class), $(RTEImgResources.class), $(TimerWrapper.class));
+                RTESavingEditorPanel panel = new RTESavingEditorPanel();
+                presenter.init(panel);
+                return presenter;
             }
         });
 

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/FlowToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/FlowToolbar.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/FlowToolbar.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -48,6 +48,7 @@
 
     public Widget addFill() {
         final Label emptyLabel = new Label("");
+        emptyLabel.addStyleName("kune-floatleft");
         this.add(emptyLabel);
         return emptyLabel;
     }
@@ -56,6 +57,7 @@
         final Label emptyLabel = new Label("");
         emptyLabel.setStyleName("ytb-sep");
         emptyLabel.addStyleName("k-toolbar-sep");
+        emptyLabel.addStyleName("kune-floatleft");
         this.add(emptyLabel);
         return emptyLabel;
     }
@@ -63,6 +65,7 @@
     public Widget addSpacer() {
         final Label emptyLabel = new Label("");
         emptyLabel.setStyleName("ytb-spacer");
+        emptyLabel.addStyleName("kune-floatleft");
         this.add(emptyLabel);
         return emptyLabel;
     }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -0,0 +1,14 @@
+package org.ourproject.kune.platf.client.ui.rte;
+
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
+
+import com.calclab.suco.client.events.Listener0;
+
+public class RTESavingEditorPanel implements RTESavingEditorView {
+
+    public void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm,
+            Listener0 onCancel) {
+        NotifyUser.askConfirmation(confirmationTitle, confirmationText, onConfirm, onCancel);
+    }
+
+}

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -8,7 +8,6 @@
 import org.ourproject.kune.platf.client.dto.AccessRolDTO;
 import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
 import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
 import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
 import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
 import org.ourproject.kune.platf.client.utils.TimerWrapper;
@@ -38,11 +37,12 @@
     private final BeforeActionListener beforeStateChangeListener;
     @Deprecated
     private final SiteSignOutLink siteSignOutLink;
-    private ActionToolbarButtonDescriptor<Object> saveBtn;
+    ActionToolbarButtonDescriptor<Object> saveBtn;
+    private RTESavingEditorView view;
 
     public RTESavingEditorPresenter(RTEditor editor, final boolean autoSave, final I18nTranslationService i18n,
             StateManager stateManager, SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper,
-            RTEImgResources imgResources) {
+            RTEImgResources imgResources, TimerWrapper timer) {
         this.editor = editor;
         this.autoSave = autoSave;
         this.i18n = i18n;
@@ -53,7 +53,9 @@
         this.savePending = false;
         this.saveAndCloseConfirmed = false;
         createActions();
-        this.timer = new TimerWrapper(new Listener0() {
+        this.timer =  timer;
+        timer.configure(new Listener0() {;
+
             public void onEvent() {
                 onAutoSave();
             }
@@ -84,6 +86,10 @@
         return editor;
     }
 
+    public void init(RTESavingEditorView view) {
+        this.view = view;
+    }
+
     public void onDoSaveAndClose() {
         saveAndCloseConfirmed = true;
         onDoSave();
@@ -121,7 +127,7 @@
                     onCancelConfirmed();
                 }
             };
-            NotifyUser.askConfirmation(i18n.t("Save confirmation"),
+            view.askConfirmation(i18n.t("Save confirmation"),
                     i18n.t("Do you want to save before closing the editor?"), onYes, onCancel);
         } else {
             onCancelConfirmed();
@@ -155,23 +161,34 @@
         }
     }
 
+    void onEdit() {
+        if (!savePending) {
+            savePending = true;
+            if (autoSave) {
+                timer.schedule(AUTOSAVE_IN_MILLISECONDS);
+            }
+            enableSaveBtn(true);
+        }
+    }
+
     private void createActions() {
         Listener0 onPerformSaveCall = new Listener0() {
             public void onEvent() {
                 onDoSave();
             }
         };
-        saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveCall);
+        saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.sndbar, onPerformSaveCall);
         saveBtn.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
         saveBtn.setToolTip(i18n.t("Save"));
         saveBtn.setShortcut(new ActionShortcut(true, 'S'));
-        saveBtn.setPosition(20);
+        saveBtn.setPosition(0);
 
         ActionToolbarMenuDescriptor<Object> save = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
                 RTEditor.topbar, onPerformSaveCall);
         save.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
         save.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
         save.setTextDescription(i18n.t("Save"));
+        save.setShortcut(new ActionShortcut(true, 'S'));
         save.setPosition(0);
 
         ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
@@ -185,7 +202,12 @@
 
         Listener0 onPerformSaveAndCloseCall = new Listener0() {
             public void onEvent() {
-                onDoSaveAndClose();
+                if (savePending) {
+                    timer.cancel();
+                    onDoSaveAndClose();
+                } else {
+                    onCancelConfirmed();
+                }
             }
         };
         ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
@@ -208,23 +230,13 @@
     }
 
     private void enableSaveBtn(boolean enable) {
-        editor.getTopBar().setButtonEnable(saveBtn, enable);
+        editor.getSndBar().setButtonEnable(saveBtn, enable);
     }
 
     private void onDoEditCancelled() {
         onEditCancelled.onEvent();
     }
 
-    private void onEdit() {
-        if (!savePending) {
-            savePending = true;
-            if (autoSave) {
-                timer.schedule(AUTOSAVE_IN_MILLISECONDS);
-            }
-            enableSaveBtn(true);
-        }
-    }
-
     private void reset() {
         timer.cancel();
         savePending = false;

Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.platf.client.ui.rte;
+
+import org.ourproject.kune.platf.client.View;
+
+import com.calclab.suco.client.events.Listener0;
+
+public interface RTESavingEditorView extends View {
+
+    void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm, Listener0 onCancel);
+}

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -115,7 +115,7 @@
     public void addComment(String userName) {
         String time = i18n.formatDateWithLocale(new Date(), true);
         Element span = DOM.createSpan();
-        span.setInnerHTML("<em>" + i18n.t("type your commment here") + "</em> -" + userName + " " + time);
+        span.setInnerHTML("<em>" + i18n.t("type your comment here") + "</em> -" + userName + " " + time);
         DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
         insertHtml("&nbsp;" + span.getString() + "&nbsp;");
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -297,7 +297,6 @@
         justifyRight.setIconCls(getCssName(imgResources.alignright()));
         justifyRight.setToolTip(i18n.t("Right Justify"));
         justifyRight.setShortcut(new ActionShortcut(true, 'R'));
-        // justifyRight.setRightSeparator(ActionToolbarButtonSeparator.spacer);
         justifyRight.setAddCondition(canBeBasic);
 
         ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
@@ -327,7 +326,7 @@
         redo.setBottomSeparator(true);
         redo.setIconCls(getCssName(imgResources.redo()));
 
-        ActionToolbarButtonDescriptor<Object> undoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, topbar,
+        ActionToolbarButtonDescriptor<Object> undoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
                 new Listener0() {
                     public void onEvent() {
                         view.undo();
@@ -337,8 +336,9 @@
         undoBtn.setToolTip(i18n.t("Undo"));
         undoBtn.setAddCondition(canBeExtended);
         undoBtn.setIconCls(getCssName(imgResources.undo()));
+        undoBtn.setPosition(0);
 
-        ActionToolbarButtonDescriptor<Object> redoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, topbar,
+        ActionToolbarButtonDescriptor<Object> redoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
                 new Listener0() {
                     public void onEvent() {
                         view.redo();
@@ -348,6 +348,7 @@
         redoBtn.setToolTip(i18n.t("Redo"));
         redoBtn.setAddCondition(canBeExtended);
         redoBtn.setIconCls(getCssName(imgResources.redo()));
+        redoBtn.setPosition(1);
         redoBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
 
         ActionToolbarMenuDescriptor<Object> copy = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
@@ -454,7 +455,7 @@
         });
         strikethrough.setIconCls(getCssName(imgResources.strikeout()));
         strikethrough.setToolTip(i18n.t("Strikethrough"));
-        // strikethrough.setRightSeparator(ActionToolbarButtonSeparator.separator);
+        strikethrough.setRightSeparator(ActionToolbarButtonSeparator.separator);
         strikethrough.setAddCondition(canBeExtended);
 
         ActionToolbarButtonDescriptor<Object> decreaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
@@ -477,7 +478,6 @@
                 });
         increaseIndent.setIconCls(getCssName(imgResources.incrementindent()));
         increaseIndent.setToolTip(i18n.t("Increase Indent"));
-        // increaseIndent.setRightSeparator(ActionToolbarButtonSeparator.spacer);
         increaseIndent.setAddCondition(canBeExtended);
 
         ActionToolbarButtonDescriptor<Object> ol = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
@@ -502,7 +502,7 @@
         ul.setIconCls(getCssName(imgResources.defaultbullet()));
         ul.setToolTip(i18n.t("Bullet List"));
         ul.setShortcut(new ActionShortcut(true, '8'));
-        // ul.setRightSeparator(ActionToolbarButtonSeparator.separator);
+        ul.setRightSeparator(ActionToolbarButtonSeparator.separator);
         ul.setAddCondition(canBeExtended);
 
         ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
@@ -559,17 +559,12 @@
         removeFormat.setToolTip(i18n.t("Clear Formatting"));
         removeFormat.setShortcut(new ActionShortcut(true, ' ', "Space"));
         removeFormat.setAddCondition(canBeExtended);
-        // removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator);
+        removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator);
 
         final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol,
                 topbar, new Listener0() {
                     public void onEvent() {
-                        view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n"
-                                + "<tbody>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
-                                + "<td width=\"50%\"><br>\n" + "</td>\n" + "</tr>\n" + "<tr>\n"
-                                + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
-                                + "</tr>\n</tbody>\n</table>");
-                        fireOnEdit();
+                        insertSimpleTable();
                     }
                 });
         insertTable.setIconCls(getCssName(imgResources.inserttable()));
@@ -577,6 +572,17 @@
         insertTable.setAddCondition(canBeExtended);
         insertTable.setParentMenuTitle(i18n.t(INSERT_MENU));
 
+        final ActionToolbarButtonDescriptor<Object> insertTableBtn = new ActionToolbarButtonDescriptor<Object>(
+                accessRol, sndbar, new Listener0() {
+                    public void onEvent() {
+                        insertSimpleTable();
+                    }
+                });
+        insertTableBtn.setIconCls(getCssName(imgResources.inserttable()));
+        insertTableBtn.setToolTip(i18n.t("Insert Table"));
+        insertTableBtn.setAddCondition(canBeExtended);
+        insertTableBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
+
         final ActionToolbarButtonDescriptor<Object> fontColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
                 sndbar, new Listener0() {
                     public void onEvent() {
@@ -639,6 +645,7 @@
         actions.add(withNoItem(img));
         actions.add(withNoItem(createLink));
         actions.add(withNoItem(removeLink));
+        actions.add(withNoItem(insertTableBtn));
         actions.add(withNoItem(insertTable));
         actions.add(withNoItem(comment));
         actions.add(withNoItem(undoBtn));
@@ -701,6 +708,14 @@
         return RTEImgResources.SUFFIX + imageResource.getName();
     }
 
+    private void insertSimpleTable() {
+        view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n" + "<tbody>\n"
+                + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
+                + "</tr>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n"
+                + "</td>\n" + "</tr>\n</tbody>\n</table>");
+        fireOnEdit();
+    }
+
     private boolean isExtended() {
         return extended && view.canBeExtended();
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -4,9 +4,16 @@
 import com.google.gwt.user.client.Timer;
 
 public class TimerWrapper {
-    private final Timer timer;
+    private Timer timer;
 
-    public TimerWrapper(final Listener0 onTime) {
+    public TimerWrapper() {
+    }
+
+    public void cancel() {
+        timer.cancel();
+    }
+
+    public void configure(final Listener0 onTime) {
         timer = new Timer() {
             @Override
             public void run() {
@@ -15,10 +22,6 @@
         };
     }
 
-    public void cancel() {
-        timer.cancel();
-    }
-
     public void run() {
         timer.run();
     }

Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -83,6 +83,7 @@
 
         createContentRenameAction(parentMenuTitle, i18n.t("Rename"), contents);
         createRenameContentInCtxAction(parentMenuTitleCtx, i18n.t("Rename"), containersNoRoot);
+        createEditAction(TYPE_WIKIPAGE);
 
         // final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupCxt =
         // createSetAsDefContent(parentMenuTitleCtx);
@@ -101,8 +102,6 @@
 
         createGoHomeAction(containers);
 
-        createEditAction(TYPE_WIKIPAGE);
-
         createTranslateAction(TYPE_FOLDER, TYPE_WIKIPAGE);
 
         createDelContainerAction("Delete folder", parentMenuTitleCtx, containersNoRoot);

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -46,10 +46,12 @@
 import org.ourproject.kune.platf.client.state.StateManager;
 import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
 import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
+import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPanel;
 import org.ourproject.kune.platf.client.ui.rte.RTEditor;
 import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
 import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
 import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
 import org.ourproject.kune.workspace.client.cnt.ActionContentToolbar;
 import org.ourproject.kune.workspace.client.cnt.ActionContentToolbarPresenter;
 import org.ourproject.kune.workspace.client.cnt.ContentIconsRegistry;
@@ -912,7 +914,8 @@
             public ContentEditor create() {
                 return new ContentEditor($(RTEditor.class), true, $(I18nTranslationService.class),
                         $(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class),
-                        $(RTEImgResources.class), $(WorkspaceSkeleton.class));
+                        $(RTEImgResources.class), $(WorkspaceSkeleton.class), $(TimerWrapper.class),
+                        new RTESavingEditorPanel());
             }
         });
         register(NoDecoration.class, new Factory<ActionContextTopToolbar>(ActionContextTopToolbar.class) {

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -5,10 +5,12 @@
 import org.ourproject.kune.platf.client.state.StateManager;
 import org.ourproject.kune.platf.client.ui.AbstractToolbar;
 import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter;
+import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorView;
 import org.ourproject.kune.platf.client.ui.rte.RTEditor;
 import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel;
 import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
 import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
 import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
 import org.ourproject.kune.workspace.client.skel.Toolbar;
 import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
@@ -30,8 +32,9 @@
 
     public ContentEditor(RTEditor editor, boolean autoSave, I18nTranslationService i18n, StateManager stateManager,
             SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper,
-            RTEImgResources imgResources, WorkspaceSkeleton ws) {
-        super(editor, autoSave, i18n, stateManager, siteSignOutLink, deferredCommandWrapper, imgResources);
+            RTEImgResources imgResources, WorkspaceSkeleton ws, TimerWrapper timer, RTESavingEditorView view) {
+        super(editor, autoSave, i18n, stateManager, siteSignOutLink, deferredCommandWrapper, imgResources, timer);
+        super.init(view);
         this.ws = ws;
 
         vp = new VerticalPanel();

Added: trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -0,0 +1,161 @@
+package org.ourproject.kune.platf.client.ui.rte;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.internal.verification.api.VerificationMode;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
+import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
+
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.testing.events.MockedListener;
+import com.calclab.suco.testing.events.MockedListener0;
+import com.google.gwt.libideas.resources.client.ImageResource;
+
+public class RTESavingEditorPresenterTest {
+
+    private RTESavingEditorPresenter presenter;
+    private MockedListener<String> saveListener;
+    private MockedListener0 cancelListener;
+    private StateManager stateManager;
+    private SiteSignOutLink signOutLink;
+    private DeferredCommandWrapper deferredCommandWrapper;
+    private RTEditor rteEditor;
+    private TimerWrapper timer;
+    @SuppressWarnings("unchecked")
+    private ActionToolbar sndbar;
+    private RTESavingEditorView view;
+
+    @SuppressWarnings("unchecked")
+    @Before
+    public void createObjects() {
+        I18nUITranslationService i18n = Mockito.mock(I18nUITranslationService.class);
+        stateManager = Mockito.mock(StateManager.class);
+        signOutLink = Mockito.mock(SiteSignOutLink.class);
+        deferredCommandWrapper = Mockito.mock(DeferredCommandWrapper.class);
+        rteEditor = Mockito.mock(RTEditor.class);
+        RTEImgResources imgResources = Mockito.mock(RTEImgResources.class);
+        ImageResource imageResource = Mockito.mock(ImageResource.class);
+        Mockito.when(imageResource.getName()).thenReturn("save");
+        Mockito.when(imgResources.save()).thenReturn(imageResource);
+        sndbar = Mockito.mock(ActionToolbar.class);
+        Mockito.when(rteEditor.getSndBar()).thenReturn(sndbar);
+        timer = Mockito.mock(TimerWrapper.class);
+        view = Mockito.mock(RTESavingEditorView.class);
+        presenter = new RTESavingEditorPresenter(rteEditor, true, i18n, stateManager, signOutLink,
+                deferredCommandWrapper, imgResources, timer);
+        presenter.init(view);
+        saveListener = new MockedListener<String>();
+        cancelListener = new MockedListener0();
+    }
+
+    @Test
+    public void historyChangeWithoutPendingMustAccept() {
+        presenter.edit("Text to edit", saveListener, cancelListener);
+        boolean change = presenter.beforeTokenChange();
+        assertTrue(change);
+        verifyAskConfirmationCalled(Mockito.never());
+        Mockito.verify(deferredCommandWrapper, Mockito.times(1)).addCommand((Listener0) Mockito.anyObject());
+    }
+
+    @Test
+    public void historyChangeWithPendingSaveAndCancelMustPosponeIt() {
+        editAndChangeHistoryToken();
+        presenter.onCancelConfirmed();
+        assertTrue(saveListener.isNotCalled());
+        Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
+    }
+
+    @Test
+    public void historyChangeWithPendingSaveMustPosponeIt() {
+        editAndChangeHistoryToken();
+        presenter.onDoSaveAndClose();
+        presenter.onSavedSuccessful();
+        assertTrue(saveListener.isCalledOnce());
+        Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
+    }
+
+    @Test
+    public void initialEditWithCancel() {
+        presenter.edit("Text to edit", saveListener, cancelListener);
+        presenter.onCancel();
+        assertTrue(saveListener.isNotCalled());
+        assertTrue(cancelListener.isCalledOnce());
+    }
+
+    @Test
+    public void initialEditWithEditionAndSave() {
+        presenter.edit("Text to edit", saveListener, cancelListener);
+        String textModified = "Text modified";
+        Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+        presenter.onEdit();
+        presenter.onDoSave();
+        checkSaveBtnDisabled();
+        assertTrue(saveListener.isCalledWithEquals(textModified));
+        assertTrue(cancelListener.isNotCalled());
+    }
+
+    @Test
+    public void initialEditWithSave() {
+        presenter.edit("Text to edit", saveListener, cancelListener);
+        presenter.onDoSave();
+        checkSaveBtnDisabled();
+        assertTrue(saveListener.isCalledOnce());
+        assertTrue(cancelListener.isNotCalled());
+    }
+
+    @Test
+    public void testSavePendingAndCancel() {
+        presenter.edit("Text to edit", saveListener, cancelListener);
+        String textModified = "Text modified";
+        Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+        presenter.onEdit();
+        presenter.onCancel();
+        presenter.onCancelConfirmed();
+        assertTrue(saveListener.isNotCalled());
+        assertTrue(cancelListener.isCalledOnce());
+    }
+
+    @Test
+    public void testSavePendingAndSaveFails() {
+        presenter.edit("Text to edit", saveListener, cancelListener);
+        String textModified = "Text modified";
+        Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+        presenter.onEdit();
+        presenter.onDoSave();
+        presenter.onSaveFailed();
+        presenter.onDoSave();
+        Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_IN_MILLISECONDS);
+        Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
+        assertTrue(saveListener.isCalled(2));
+    }
+
+    @SuppressWarnings("unchecked")
+    private void checkSaveBtnDisabled() {
+        Mockito.verify(sndbar, Mockito.times(1)).setButtonEnable(presenter.saveBtn, false);
+    }
+
+    private String editAndChangeHistoryToken() {
+        presenter.edit("Text to edit", saveListener, cancelListener);
+        presenter.onEdit();
+        String newToken = "somegroup";
+        boolean change = presenter.beforeTokenChange();
+        assertFalse(change);
+        verifyAskConfirmationCalled(Mockito.times(1));
+        return newToken;
+    }
+
+    private void verifyAskConfirmationCalled(VerificationMode mode) {
+        Mockito.verify(view, mode).askConfirmation(Mockito.anyString(), Mockito.anyString(),
+                (Listener0) Mockito.anyObject(), (Listener0) Mockito.anyObject());
+    }
+
+}

Deleted: trunk/src/test/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenterTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenterTest.java	2009-03-10 03:17:33 UTC (rev 1065)
+++ trunk/src/test/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenterTest.java	2009-03-10 13:43:43 UTC (rev 1066)
@@ -1,134 +0,0 @@
-package org.ourproject.kune.workspace.client.editor;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
-
-import com.calclab.suco.client.events.Listener0;
-import com.calclab.suco.testing.events.MockedListener;
-import com.calclab.suco.testing.events.MockedListener0;
-
-public class TextEditorPresenterTest {
-    private TextEditorPresenter presenter;
-    private TextEditorView view;
-    private MockedListener<String> saveListener;
-    private MockedListener0 cancelListener;
-    @SuppressWarnings("unchecked")
-    private ActionToolbar toolbar;
-    private StateManager stateManager;
-    private SiteSignOutLink signOutLink;
-    private DeferredCommandWrapper deferredCommandWrapper;
-
-    @SuppressWarnings("unchecked")
-    @Before
-    public void createObjects() {
-        I18nUITranslationService i18n = Mockito.mock(I18nUITranslationService.class);
-        stateManager = Mockito.mock(StateManager.class);
-        toolbar = Mockito.mock(ActionToolbar.class);
-        signOutLink = Mockito.mock(SiteSignOutLink.class);
-        deferredCommandWrapper = Mockito.mock(DeferredCommandWrapper.class);
-        presenter = new TextEditorPresenter(true, toolbar, i18n, stateManager, signOutLink, deferredCommandWrapper);
-        view = Mockito.mock(TextEditorView.class);
-        presenter.init(view);
-        saveListener = new MockedListener<String>();
-        cancelListener = new MockedListener0();
-    }
-
-    @Test
-    public void historyChangeWithoutPendingMustAccept() {
-        presenter.editContent("Text to edit", saveListener, cancelListener);
-        boolean change = presenter.beforeTokenChange();
-        assertTrue(change);
-        Mockito.verify(view, Mockito.never()).showSaveBeforeDialog();
-        Mockito.verify(deferredCommandWrapper, Mockito.times(1)).addCommand((Listener0) Mockito.anyObject());
-    }
-
-    @Test
-    public void historyChangeWithPendingSaveAndCancelMustPosponeIt() {
-        editAndChangeHistoryToken();
-        presenter.onCancelConfirmed();
-        assertTrue(saveListener.isNotCalled());
-        Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
-    }
-
-    @Test
-    public void historyChangeWithPendingSaveMustPosponeIt() {
-        editAndChangeHistoryToken();
-        presenter.onSaveAndClose();
-        presenter.onSavedSuccessful();
-        assertTrue(saveListener.isCalledOnce());
-        Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
-    }
-
-    @Test
-    public void initialEditWithCancel() {
-        presenter.editContent("Text to edit", saveListener, cancelListener);
-        presenter.onCancel();
-        assertTrue(saveListener.isNotCalled());
-        assertTrue(cancelListener.isCalledOnce());
-    }
-
-    @Test
-    public void initialEditWithEditionAndSave() {
-        presenter.editContent("Text to edit", saveListener, cancelListener);
-        String textModified = "Text modified";
-        Mockito.when(view.getHTML()).thenReturn(textModified);
-        presenter.onEdit();
-        presenter.onSave();
-        assertTrue(saveListener.isCalledWithEquals(textModified));
-        assertTrue(cancelListener.isNotCalled());
-    }
-
-    @Test
-    public void initialEditWithSave() {
-        presenter.editContent("Text to edit", saveListener, cancelListener);
-        presenter.onSave();
-        assertTrue(saveListener.isCalledOnce());
-        assertTrue(cancelListener.isNotCalled());
-    }
-
-    @Test
-    public void testSavePendingAndCancel() {
-        presenter.editContent("Text to edit", saveListener, cancelListener);
-        String textModified = "Text modified";
-        Mockito.when(view.getHTML()).thenReturn(textModified);
-        presenter.onEdit();
-        presenter.onCancel();
-        presenter.onCancelConfirmed();
-        assertTrue(saveListener.isNotCalled());
-        assertTrue(cancelListener.isCalledOnce());
-    }
-
-    @Test
-    public void testSavePendingAndSaveFails() {
-        presenter.editContent("Text to edit", saveListener, cancelListener);
-        String textModified = "Text modified";
-        Mockito.when(view.getHTML()).thenReturn(textModified);
-        presenter.onEdit();
-        presenter.onSave();
-        presenter.onSaveFailed();
-        presenter.onSave();
-        Mockito.verify(view, Mockito.times(1)).scheduleSave(TextEditorPresenter.AUTOSAVE_IN_MILLISECONDS);
-        Mockito.verify(view, Mockito.times(1)).scheduleSave(TextEditorPresenter.AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
-        assertTrue(saveListener.isCalled(2));
-    }
-
-    private String editAndChangeHistoryToken() {
-        presenter.editContent("Text to edit", saveListener, cancelListener);
-        presenter.onEdit();
-        String newToken = "somegroup";
-        boolean change = presenter.beforeTokenChange();
-        assertFalse(change);
-        Mockito.verify(view, Mockito.times(1)).showSaveBeforeDialog();
-        return newToken;
-    }
-
-}




More information about the kune-commits mailing list