[kune-commits] r1045 - in trunk: . src/main/java/org/ourproject/kune/chat/client src/main/java/org/ourproject/kune/platf/client/actions src/main/java/org/ourproject/kune/platf/client/actions/toolbar src/main/java/org/ourproject/kune/platf/client/services src/main/java/org/ourproject/kune/platf/client/ui/rte src/main/java/org/ourproject/kune/workspace/client src/main/java/org/ourproject/kune/workspace/client/editor src/main/java/org/ourproject/kune/workspace/client/i18n src/main/java/org/ourproject/kune/workspace/client/socialnet src/main/java/org/ourproject/kune/workspace/client/title src/test/java/org/ourproject/kune/platf/client/actions src/test/java/org/ourproject/kune/workspace/client/editor

vjrj vjrj at ourproject.org
Tue Feb 3 11:15:41 CET 2009


Author: vjrj
Date: 2009-02-03 11:15:36 +0100 (Tue, 03 Feb 2009)
New Revision: 1045

Added:
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentEditorActionRegistry.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.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/ui/rte/RTEditorView.java
   trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
Removed:
   trunk/src/main/java/org/ourproject/kune/workspace/client/licensechoose/
Modified:
   trunk/TODO
   trunk/pom.xml
   trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionAddCondition.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionEnableCondition.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonAndItemDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuAndItemDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuCheckItemDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/MenuItemsContainer.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneRegistryModule.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java
   trunk/src/test/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenterTest.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support 



Modified: trunk/TODO
===================================================================
--- trunk/TODO	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/TODO	2009-02-03 10:15:36 UTC (rev 1045)
@@ -81,6 +81,7 @@
 ** 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
@@ -93,7 +94,7 @@
       - youtube videos
     + Edit HTML
     + Easy extensible for new actions
-    + Try to be a reausable module (like emite)
+    + 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

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/pom.xml	2009-02-03 10:15:36 UTC (rev 1045)
@@ -60,7 +60,7 @@
     <dependency>
       <groupId>com.allen_sauer.gwt.log.gwt-log</groupId>
       <artifactId>gwt-log</artifactId>
-      <version>2.5.2</version>
+      <version>2.5.3</version>
     </dependency>
     <dependency>
       <groupId>com.allen_sauer.gwt.voices.gwt-voices</groupId>

Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -112,7 +112,7 @@
 
     private ActionEnableCondition<StateToken> notDeleted() {
         return new ActionEnableCondition<StateToken>() {
-            public boolean mustBeEnabled(final StateToken itemToken) {
+            public boolean mustBeEnabled(StateToken token) {
                 final boolean isNotDeleted = !(session.isCurrentStateAContent() && session.getContentState().getStatus().equals(
                         ContentStatusDTO.inTheDustbin));
                 return isNotDeleted;

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionAddCondition.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionAddCondition.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionAddCondition.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -20,5 +20,5 @@
 package org.ourproject.kune.platf.client.actions;
 
 public interface ActionAddCondition<T> {
-    boolean mustBeAdded(T item);
+    boolean mustBeAdded(T param);
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -23,6 +23,7 @@
 import org.ourproject.kune.platf.client.services.ImageDescriptor;
 
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 /**
  * The Class ActionDescriptor.
@@ -71,14 +72,8 @@
     /** The id. */
     private String id;
 
-    /**
-     * Instantiates a new action descriptor.
-     * 
-     * @param accessRolDTO
-     *            the access rol dto
-     * @param onPerformCall
-     *            the on perform call
-     */
+    private ActionShortcut shortcut;
+
     public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener<T> onPerformCall) {
         this.accessRol = accessRolDTO;
         this.onPerformCall = onPerformCall;
@@ -110,6 +105,35 @@
     }
 
     /**
+     * Instantiates a new action descriptor.
+     * 
+     * @param accessRolDTO
+     *            the access rol dto
+     * @param onPerformCall
+     *            the on perform call
+     */
+
+    public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener0 onPerformCall) {
+        this(accessRolDTO, new Listener<T>() {
+            public void onEvent(T parameter) {
+                onPerformCall.onEvent();
+            }
+        });
+    }
+
+    public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener0 onPerformCall,
+            final ActionAddCondition<T> addCondition) {
+        this(accessRolDTO, onPerformCall);
+        this.addCondition = addCondition;
+    }
+
+    public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener0 onPerformCall,
+            final ActionEnableCondition<T> enableCondition) {
+        this(accessRolDTO, onPerformCall);
+        this.enableCondition = enableCondition;
+    }
+
+    /**
      * Fire on not confirmed.
      * 
      * @param parameter
@@ -143,15 +167,6 @@
     }
 
     /**
-     * Gets the add condition.
-     * 
-     * @return the add condition
-     */
-    public ActionAddCondition<T> getAddCondition() {
-        return addCondition;
-    }
-
-    /**
      * Gets the confirmation text.
      * 
      * @return the confirmation text
@@ -170,15 +185,6 @@
     }
 
     /**
-     * Gets the enable condition.
-     * 
-     * @return the enable condition
-     */
-    public ActionEnableCondition<T> getEnableCondition() {
-        return enableCondition;
-    }
-
-    /**
      * Gets the icon descriptor.
      * 
      * @return the icon descriptor
@@ -205,6 +211,10 @@
         return id;
     }
 
+    public ActionShortcut getShortcut() {
+        return shortcut;
+    }
+
     /**
      * Gets the text.
      * 
@@ -232,6 +242,10 @@
         return mustBeConfirmed;
     }
 
+    public boolean mustBeAdded(T item) {
+        return addCondition != null ? addCondition.mustBeAdded(item) : true;
+    }
+
     /**
      * Must be authenticated.
      * 
@@ -241,6 +255,10 @@
         return mustBeAuthenticated;
     }
 
+    public boolean mustBeEnabled(T item) {
+        return enableCondition != null ? enableCondition.mustBeEnabled(item) : true;
+    }
+
     /**
      * Sets the access rol.
      * 
@@ -341,6 +359,10 @@
         this.mustBeConfirmed = mustBeConfirmed;
     }
 
+    public void setShortcut(ActionShortcut shortcut) {
+        this.shortcut = shortcut;
+    }
+
     /**
      * Sets the text description.
      * 

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionEnableCondition.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionEnableCondition.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionEnableCondition.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -20,5 +20,5 @@
 package org.ourproject.kune.platf.client.actions;
 
 public interface ActionEnableCondition<T> {
-    boolean mustBeEnabled(T item);
+    boolean mustBeEnabled(T param);
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -35,16 +35,6 @@
         this.item = item;
     }
 
-    public boolean checkAdded() {
-        final ActionAddCondition<T> addCondition = action.getAddCondition();
-        return addCondition != null ? addCondition.mustBeAdded(getItem()) : true;
-    }
-
-    public boolean checkEnabling() {
-        final ActionEnableCondition<T> enableCondition = action.getEnableCondition();
-        return enableCondition != null ? enableCondition.mustBeEnabled(getItem()) : true;
-    }
-
     public ActionDescriptor<T> getAction() {
         return action;
     }
@@ -52,4 +42,12 @@
     public T getItem() {
         return item;
     }
+
+    public boolean mustBeAdded() {
+        return action.mustBeAdded(getItem());
+    }
+
+    public boolean mustBeEnabled() {
+        return action.mustBeEnabled(getItem());
+    }
 }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -0,0 +1,52 @@
+package org.ourproject.kune.platf.client.actions;
+
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+
+import com.google.gwt.user.client.ui.KeyboardListener;
+
+public class ActionShortcut {
+
+    final boolean alt;
+    final boolean ctrl;
+    final boolean shift;
+    final char key;
+
+    public ActionShortcut(boolean alt, boolean ctrl, boolean shift, char key) {
+        this.alt = alt;
+        this.ctrl = ctrl;
+        this.shift = shift;
+        this.key = key;
+    }
+
+    public ActionShortcut(boolean ctrl, boolean shift, char key) {
+        this(false, ctrl, shift, key);
+    }
+
+    public ActionShortcut(boolean ctrl, char key) {
+        this(false, ctrl, false, key);
+    }
+
+    public boolean is(char keyCode, int modifiers) {
+        return (keyCode == keyCode && same(modifiers, KeyboardListener.MODIFIER_ALT, alt)
+                && same(modifiers, KeyboardListener.MODIFIER_CTRL, ctrl) && same(modifiers,
+                KeyboardListener.MODIFIER_SHIFT, shift));
+    }
+
+    public boolean same(int modifiers, int modifier, boolean keyValue) {
+        return (((modifiers & modifier) == modifier) == keyValue);
+    }
+
+    public String toString(I18nTranslationService i18n) {
+        String s = " (";
+        s += sKey(alt, "Alt", i18n);
+        s += sKey(ctrl, "Ctrl", i18n);
+        s += sKey(shift, "Shift", i18n);
+        s += String.valueOf(key).toUpperCase() + ")";
+        return s;
+    }
+
+    private String sKey(boolean key, String keyName, I18nTranslationService i18n) {
+        return key ? i18n.tWithNT(keyName, "The '" + keyName + "' keyboard key") + "+" : "";
+    }
+
+}

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonAndItemDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonAndItemDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonAndItemDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -22,6 +22,7 @@
 import org.ourproject.kune.platf.client.dto.AccessRolDTO;
 
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 public class ActionToolbarButtonAndItemDescriptor<T> extends ActionToolbarButtonDescriptor<T> {
 
@@ -36,4 +37,15 @@
         super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
     }
 
+    public ActionToolbarButtonAndItemDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall);
+    }
+
+    public ActionToolbarButtonAndItemDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall,
+            final ActionEnableCondition<T> enableCondition) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
+    }
+
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarButtonDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -22,6 +22,7 @@
 import org.ourproject.kune.platf.client.dto.AccessRolDTO;
 
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 public class ActionToolbarButtonDescriptor<T> extends ActionToolbarDescriptor<T> {
 
@@ -45,6 +46,23 @@
         super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
     }
 
+    public ActionToolbarButtonDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall);
+    }
+
+    public ActionToolbarButtonDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall,
+            final ActionAddCondition<T> addCondition) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall, addCondition);
+    }
+
+    public ActionToolbarButtonDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall,
+            final ActionEnableCondition<T> enableCondition) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
+    }
+
     public ActionToolbarButtonSeparator getLeftSeparator() {
         return leftSeparator;
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -22,6 +22,7 @@
 import org.ourproject.kune.platf.client.dto.AccessRolDTO;
 
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 public abstract class ActionToolbarDescriptor<T> extends ActionDescriptor<T> {
 
@@ -45,6 +46,24 @@
         this.actionToolbarPosition = actionToolbarPosition;
     }
 
+    public ActionToolbarDescriptor(final AccessRolDTO accessRolDTO, final ActionToolbarPosition actionToolbarPosition,
+            final Listener0 onPerformCall) {
+        super(accessRolDTO, onPerformCall);
+        this.actionToolbarPosition = actionToolbarPosition;
+    }
+
+    public ActionToolbarDescriptor(final AccessRolDTO accessRolDTO, final ActionToolbarPosition actionToolbarPosition,
+            final Listener0 onPerformCall, final ActionAddCondition<T> addCondition) {
+        super(accessRolDTO, onPerformCall, addCondition);
+        this.actionToolbarPosition = actionToolbarPosition;
+    }
+
+    public ActionToolbarDescriptor(final AccessRolDTO accessRolDTO, final ActionToolbarPosition actionToolbarPosition,
+            final Listener0 onPerformCall, final ActionEnableCondition<T> enableCondition) {
+        super(accessRolDTO, onPerformCall, enableCondition);
+        this.actionToolbarPosition = actionToolbarPosition;
+    }
+
     public ActionToolbarPosition getActionPosition() {
         return actionToolbarPosition;
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuAndItemDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuAndItemDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuAndItemDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -22,6 +22,7 @@
 import org.ourproject.kune.platf.client.dto.AccessRolDTO;
 
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 public class ActionToolbarMenuAndItemDescriptor<T> extends ActionToolbarMenuDescriptor<T> {
 
@@ -36,4 +37,15 @@
         super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
     }
 
+    public ActionToolbarMenuAndItemDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall);
+    }
+
+    public ActionToolbarMenuAndItemDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall,
+            final ActionEnableCondition<T> enableCondition) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
+    }
+
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuCheckItemDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuCheckItemDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuCheckItemDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -22,6 +22,7 @@
 import org.ourproject.kune.platf.client.dto.AccessRolDTO;
 
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 public class ActionToolbarMenuCheckItemDescriptor<T> extends ActionToolbarMenuDescriptor<T> {
 
@@ -33,6 +34,12 @@
         this.mustBeChecked = mustBeChecked;
     }
 
+    public ActionToolbarMenuCheckItemDescriptor(AccessRolDTO accessRol, ActionToolbarPosition toolbarPosition,
+            Listener0 onPerformCall, ActionCheckedCondition mustBeChecked) {
+        super(accessRol, toolbarPosition, onPerformCall);
+        this.mustBeChecked = mustBeChecked;
+    }
+
     public ActionCheckedCondition getMustBeChecked() {
         return mustBeChecked;
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -23,6 +23,7 @@
 
 import com.allen_sauer.gwt.log.client.Log;
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 public class ActionToolbarMenuDescriptor<T> extends ActionToolbarDescriptor<T> {
 
@@ -41,6 +42,17 @@
         super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
     }
 
+    public ActionToolbarMenuDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall);
+    }
+
+    public ActionToolbarMenuDescriptor(final AccessRolDTO accessRolDTO,
+            final ActionToolbarPosition actionToolbarPosition, final Listener0 onPerformCall,
+            final ActionEnableCondition<T> enableCondition) {
+        super(accessRolDTO, actionToolbarPosition, onPerformCall, enableCondition);
+    }
+
     public String getParentMenuIconUrl() {
         return parentMenuIconUrl;
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarMenuRadioDescriptor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -23,6 +23,7 @@
 import org.ourproject.kune.workspace.client.socialnet.RadioMustBeChecked;
 
 import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
 
 public class ActionToolbarMenuRadioDescriptor<T> extends ActionToolbarMenuDescriptor<T> {
     private final String group;
@@ -35,6 +36,13 @@
         this.mustBeChecked = mustBeChecked;
     }
 
+    public ActionToolbarMenuRadioDescriptor(AccessRolDTO accessRol, ActionToolbarPosition toolbarPosition,
+            Listener0 onPerformCall, String group, RadioMustBeChecked mustBeChecked) {
+        super(accessRol, toolbarPosition, onPerformCall);
+        this.group = group;
+        this.mustBeChecked = mustBeChecked;
+    }
+
     public String getGroup() {
         return group;
     }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentEditorActionRegistry.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentEditorActionRegistry.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentEditorActionRegistry.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -0,0 +1,6 @@
+package org.ourproject.kune.platf.client.actions;
+
+import org.ourproject.kune.platf.client.dto.StateToken;
+
+public class ContentEditorActionRegistry extends ActionRegistry<StateToken> {
+}
\ No newline at end of file

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/MenuItemsContainer.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/MenuItemsContainer.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/MenuItemsContainer.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -51,7 +51,7 @@
                     // Remove if when retrieved rights of siblings
                     for (final ActionItem<T> actionItem : actionCollection) {
                         final ActionDescriptor<T> action = actionItem.getAction();
-                        if (actionItem.checkEnabling()) {
+                        if (actionItem.mustBeEnabled()) {
                             final Item item = new Item(action.getText());
                             item.setIcon(action.getIconUrl());
                             menu.addItem(item);

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -20,7 +20,6 @@
 package org.ourproject.kune.platf.client.actions.toolbar;
 
 import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionToolbarDescriptor;
 
 public interface ActionToolbar<T> {
 
@@ -36,6 +35,4 @@
 
     void setActions(ActionItemCollection<T> actionItemCollection);
 
-    void setEnableAction(ActionToolbarDescriptor<T> action, boolean enable);
-
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -163,15 +163,6 @@
         }
     }
 
-    public void setMenuEnable(final ActionDescriptor<T> action, final boolean enable) {
-        final Item item = menuItems.get(genMenuKey((ActionToolbarMenuDescriptor<T>) action));
-        if (item != null) {
-            setEnableMenuItem(item, enable);
-        } else {
-            Log.error("Tryng to enable/disable a non existent toolbar menu item");
-        }
-    }
-
     private void add(final ActionToolbarPosition toolbar, final Widget widget) {
         getToolbar(toolbar).add(widget);
     }
@@ -193,18 +184,18 @@
         final ActionToolbarMenuDescriptor<T> action = (ActionToolbarMenuDescriptor<T>) actionItem.getAction();
         final Item item;
         if (action instanceof ActionToolbarMenuRadioDescriptor) {
-            CheckItem checkItem = new CheckItem(action.getText());
+            CheckItem checkItem = new CheckItem(action.getText() + action.getShortcut());
             ActionToolbarMenuRadioDescriptor<T> radioDescriptor = (ActionToolbarMenuRadioDescriptor<T>) action;
             checkItem.setGroup(radioDescriptor.getGroup());
             checkItem.setChecked(radioDescriptor.mustBeChecked());
             item = checkItem;
         } else if (action instanceof ActionToolbarMenuCheckItemDescriptor) {
-            CheckItem checkItem = new CheckItem(action.getText());
+            CheckItem checkItem = new CheckItem(action.getText() + action.getShortcut());
             ActionToolbarMenuCheckItemDescriptor<T> checkItemDescriptor = (ActionToolbarMenuCheckItemDescriptor<T>) action;
             checkItem.setChecked(checkItemDescriptor.getMustBeChecked().mustBeChecked());
             item = checkItem;
         } else {
-            item = new Item(action.getText());
+            item = new Item(action.getText() + action.getShortcut());
         }
         BaseItemListenerAdapter clickListener = new BaseItemListenerAdapter() {
             @Override
@@ -259,19 +250,14 @@
     }
 
     private String genButtonKey(final ActionToolbarPosition pos, final String actionText) {
-        final String basePart = "km-ctx-btn-" + pos.toString().substring(0, 2) + "-" + actionText;
+        final String basePart = "km-act-btn-" + pos.toString().substring(0, 2) + "-" + actionText;
         return basePart;
     }
 
-    private String genMenuKey(final ActionToolbarMenuDescriptor<T> action) {
-        return genMenuKey(action.getActionPosition(), action.getParentMenuTitle(), action.getParentSubMenuTitle(),
-                action.getText());
-    }
-
     private String genMenuKey(final ActionToolbarPosition pos, final String menuTitle, final String menuSubTitle,
             final String actionText) {
 
-        final String basePart = "km-ctx-menu-" + pos.toString().substring(0, 2) + "-" + menuTitle;
+        final String basePart = "km-atp-menu-" + pos.toString().substring(0, 2) + "-" + menuTitle;
         final String subMenuPart = menuSubTitle != null ? "-subm-" + menuSubTitle : "";
         final String itemPart = actionText != null ? "-item-" + actionText : "";
         return basePart + subMenuPart + itemPart;

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -24,7 +24,6 @@
 import org.ourproject.kune.platf.client.actions.ActionItemCollection;
 import org.ourproject.kune.platf.client.actions.ActionToolbarButtonAndItemDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarMenuAndItemDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
 
@@ -60,12 +59,12 @@
     public void setActions(final ActionItemCollection<T> actions) {
         for (final ActionItem<T> actionItem : actions) {
             final ActionDescriptor<T> action = actionItem.getAction();
-            if (actionItem.checkAdded()) {
+            if (actionItem.mustBeAdded()) {
                 if (isToolbarMenu(action)) {
-                    view.addMenuAction(actionItem, actionItem.checkEnabling());
+                    view.addMenuAction(actionItem, actionItem.mustBeEnabled());
                 } else {
                     if (isToolbarButton(action)) {
-                        view.addButtonAction(actionItem, actionItem.checkEnabling());
+                        view.addButtonAction(actionItem, actionItem.mustBeEnabled());
                     } else {
                         Log.error("Code error: Not an ActionMenuDescriptor or ActionButtonDescriptor: "
                                 + action.getText());
@@ -75,17 +74,6 @@
         }
     }
 
-    public void setEnableAction(final ActionToolbarDescriptor<T> action, final boolean enable) {
-        if (isToolbarMenu(action)) {
-            view.setMenuEnable(action, enable);
-        } else {
-            if (isToolbarButton(action)) {
-                view.setButtonEnable(action, enable);
-            }
-        }
-
-    }
-
     private boolean isToolbarButton(final ActionDescriptor<T> action) {
         return action instanceof ActionToolbarButtonDescriptor
                 || action instanceof ActionToolbarButtonAndItemDescriptor;

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -39,6 +39,4 @@
 
     void setButtonEnable(ActionDescriptor<T> action, boolean enable);
 
-    void setMenuEnable(ActionDescriptor<T> action, boolean enable);
-
 }

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-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -19,10 +19,14 @@
  \*/
 package org.ourproject.kune.platf.client.services;
 
+import org.ourproject.kune.platf.client.actions.ContentEditorActionRegistry;
 import org.ourproject.kune.platf.client.state.Session;
 import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
 import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePanel;
 import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePresenter;
+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.RTEditorPresenter;
 import org.ourproject.kune.platf.client.ui.upload.FileUploader;
 import org.ourproject.kune.platf.client.ui.upload.FileUploaderDialog;
 import org.ourproject.kune.platf.client.ui.upload.FileUploaderPresenter;
@@ -64,5 +68,15 @@
             }
         });
 
+        register(Singleton.class, new Factory<RTEditor>(RTEditor.class) {
+            @Override
+            public RTEditor create() {
+                final RTEditorPresenter presenter = new RTEditorPresenter($(ContentEditorActionRegistry.class),
+                        $(I18nTranslationService.class), $(Session.class));
+                final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class));
+                presenter.init(panel);
+                return presenter;
+            }
+        });
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneRegistryModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneRegistryModule.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneRegistryModule.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -20,6 +20,7 @@
 package org.ourproject.kune.platf.client.services;
 
 import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
+import org.ourproject.kune.platf.client.actions.ContentEditorActionRegistry;
 import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
 import org.ourproject.kune.platf.client.actions.ContextActionRegistry;
 import org.ourproject.kune.platf.client.actions.GroupActionRegistry;
@@ -188,6 +189,13 @@
             }
         });
 
+        register(Singleton.class, new Factory<ContentEditorActionRegistry>(ContentEditorActionRegistry.class) {
+            @Override
+            public ContentEditorActionRegistry create() {
+                return new ContentEditorActionRegistry();
+            }
+        });
+
         register(Singleton.class, new Factory<ContentActionRegistry>(ContentActionRegistry.class) {
             @Override
             public ContentActionRegistry create() {

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	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -316,8 +316,7 @@
             @Override
             public EntitySubTitle create() {
                 final EntitySubTitlePresenter presenter = new EntitySubTitlePresenter(
-                        $(I18nUITranslationService.class), $(StateManager.class), $(Session.class), false,
-                        $(AuthorableRegistry.class));
+                        $(I18nUITranslationService.class), $(StateManager.class), false, $(AuthorableRegistry.class));
                 final EntitySubTitlePanel panel = new EntitySubTitlePanel(presenter, $(WorkspaceSkeleton.class));
                 presenter.init(panel);
                 return presenter;

Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -0,0 +1,32 @@
+package org.ourproject.kune.platf.client.ui.rte;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ActionCollection;
+import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+
+public interface RTEditor {
+
+    void addAction(ActionDescriptor<StateToken> action);
+
+    void addActions(ActionCollection<StateToken> actions);
+
+    void editContent(String content, Listener<String> onSave, Listener0 onEditCancelled);
+
+    View getView();
+
+    void onSavedSuccessful();
+
+    void onSaveFailed();
+
+    void setAccessRol(AccessRolDTO accessRol);
+
+    void setAutosave(boolean autosave);
+
+    void setExtended(boolean extended);
+
+}

Added: 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-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -0,0 +1,48 @@
+package org.ourproject.kune.platf.client.ui.rte;
+
+import java.util.Date;
+
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.DOM;
+
+public class RTEditorPanel implements RTEditorView {
+
+    private final I18nUITranslationService i18n;
+
+    public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n) {
+        this.i18n = i18n;
+    }
+
+    public void addComment(String userName) {
+        String time = i18n.formatDateWithLocale(new Date());
+        Element span = DOM.createSpan();
+        span.setInnerText(i18n.t("type here") + " -" + userName + time);
+        DOM.setElementAttribute((com.google.gwt.user.client.Element) span, "backgroundColor", "rgb(255,255,215");
+        // addCustomStyle
+        // insertHtml
+    }
+
+    public boolean canBeExtended() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void insertHR() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void redo() {
+        // TODO Auto-generated method stub
+    }
+
+    public void selectAll() {
+        // TODO Auto-generated method stub
+    }
+
+    public void undo() {
+        // TODO Auto-generated method stub
+    }
+}

Added: 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-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -0,0 +1,149 @@
+package org.ourproject.kune.platf.client.ui.rte;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ActionCollection;
+import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
+import org.ourproject.kune.platf.client.actions.ActionShortcut;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
+import org.ourproject.kune.platf.client.actions.ContentEditorActionRegistry;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.services.I18nTranslationService;
+import org.ourproject.kune.platf.client.state.Session;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+
+public class RTEditorPresenter implements RTEditor {
+
+    private static final String EDIT_MENU = "Edit";
+    private static final String INSERT_MENU = "Insert";
+    private RTEditorView view;
+    private boolean autosave;
+    private boolean extended;
+    private AccessRolDTO accessRol;
+    private final I18nTranslationService i18n;
+    private final Session session;
+
+    public RTEditorPresenter(ContentEditorActionRegistry contentEditorActionRegistry, I18nTranslationService i18n,
+            Session session) {
+        this.i18n = i18n;
+        this.session = session;
+        createDefActions();
+        autosave = false;
+        extended = true;
+        accessRol = AccessRolDTO.Editor;
+    }
+
+    public void addAction(ActionDescriptor<StateToken> action) {
+        // TODO Auto-generated method stub
+    }
+
+    public void addActions(ActionCollection<StateToken> actions) {
+        // TODO Auto-generated method stub
+    }
+
+    public void editContent(String content, Listener<String> onSave, Listener0 onEditCancelled) {
+        // TODO Auto-generated method stub
+    }
+
+    public View getView() {
+        return view;
+    }
+
+    public void init(RTEditorView view) {
+        this.view = view;
+    }
+
+    public void onSavedSuccessful() {
+        // TODO Auto-generated method stub
+    }
+
+    public void onSaveFailed() {
+        // TODO Auto-generated method stub
+    }
+
+    public void setAccessRol(AccessRolDTO accessRol) {
+        this.accessRol = accessRol;
+    }
+
+    public void setAutosave(boolean autosave) {
+        this.autosave = autosave;
+    }
+
+    public void setExtended(boolean extended) {
+        this.extended = extended;
+    }
+
+    private void createDefActions() {
+        ActionToolbarMenuDescriptor<StateToken> undo = new ActionToolbarMenuDescriptor<StateToken>(accessRol,
+                ActionToolbarPosition.topbar, new Listener0() {
+                    public void onEvent() {
+                        view.undo();
+                    }
+                });
+        undo.setShortcut(new ActionShortcut(true, 'Z'));
+        undo.setTextDescription(i18n.t("Undo"));
+        undo.setParentMenuTitle(i18n.t(EDIT_MENU));
+
+        ActionToolbarMenuDescriptor<StateToken> redo = new ActionToolbarMenuDescriptor<StateToken>(accessRol,
+                ActionToolbarPosition.topbar, new Listener0() {
+                    public void onEvent() {
+                        view.redo();
+                    }
+                });
+        redo.setShortcut(new ActionShortcut(true, 'Y'));
+        redo.setTextDescription(i18n.t("Redo"));
+        redo.setParentMenuTitle(i18n.t(EDIT_MENU));
+
+        ActionToolbarMenuDescriptor<StateToken> selectAll = new ActionToolbarMenuDescriptor<StateToken>(accessRol,
+                ActionToolbarPosition.topbar, new Listener0() {
+                    public void onEvent() {
+                        view.selectAll();
+                    }
+                });
+        selectAll.setShortcut(new ActionShortcut(true, 'A'));
+        selectAll.setTextDescription(i18n.t("Select all"));
+        selectAll.setParentMenuTitle(i18n.t(EDIT_MENU));
+
+        ActionToolbarMenuDescriptor<Object> comment = new ActionToolbarMenuDescriptor<Object>(accessRol,
+                ActionToolbarPosition.topbar, new Listener0() {
+                    public void onEvent() {
+                        view.addComment(session.getCurrentUser().getShortName());
+                    }
+                });
+        comment.setShortcut(new ActionShortcut(true, 'M'));
+        comment.setTextDescription(i18n.t("Comment..."));
+        comment.setParentMenuTitle(i18n.t(INSERT_MENU));
+        comment.setEnableCondition(isInsertHtmlSupported());
+
+        ActionToolbarMenuDescriptor<Object> hr = new ActionToolbarMenuDescriptor<Object>(accessRol,
+                ActionToolbarPosition.topbar, new Listener0() {
+                    public void onEvent() {
+                        view.insertHR();
+                    }
+                });
+        hr.setShortcut(new ActionShortcut(true, 'M'));
+        hr.setTextDescription(i18n.t("Horizontal line"));
+        hr.setParentMenuTitle(i18n.t(INSERT_MENU));
+        hr.setEnableCondition(isExtended());
+    }
+
+    private ActionEnableCondition<Object> isExtended() {
+        return new ActionEnableCondition<Object>() {
+            public boolean mustBeEnabled(Object param) {
+                return extended && view.canBeExtended();
+            }
+        };
+    }
+
+    private ActionEnableCondition<Object> isInsertHtmlSupported() {
+        return new ActionEnableCondition<Object>() {
+            public boolean mustBeEnabled(Object param) {
+                return true;
+            }
+        };
+    }
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -0,0 +1,18 @@
+package org.ourproject.kune.platf.client.ui.rte;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface RTEditorView extends View {
+
+    void addComment(String userName);
+
+    boolean canBeExtended();
+
+    void insertHR();
+
+    void redo();
+
+    void selectAll();
+
+    void undo();
+}

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -263,7 +263,7 @@
                                                     public void onSuccess(Object param) {
                                                         Site.hideProgress();
                                                         session.getContentState().setContent(html);
-                                                        editor.onSaved();
+                                                        editor.onSavedSuccessful();
                                                     }
                                                 });
                                     }
@@ -305,11 +305,6 @@
         go.setMustBeAuthenticated(false);
         go.setTextDescription(i18n.t("Open"));
         go.setIconUrl("images/nav/go.png");
-        go.setEnableCondition(new ActionEnableCondition<StateToken>() {
-            public boolean mustBeEnabled(final StateToken itemToken) {
-                return !contextNavigator.isSelected(itemToken);
-            }
-        });
         contextActionRegistry.addAction(go, registerInTypes);
         return go;
     }
@@ -324,9 +319,9 @@
         goGroupHome.setMustBeAuthenticated(false);
         goGroupHome.setIconUrl("images/group-home.png");
         goGroupHome.setEnableCondition(new ActionEnableCondition<StateToken>() {
-            public boolean mustBeEnabled(final StateToken itemToken) {
+            public boolean mustBeEnabled(StateToken token) {
                 final StateToken defContentToken = session.getCurrentState().getGroup().getDefaultContent().getStateToken();
-                return !itemToken.equals(defContentToken);
+                return !session.getCurrentStateToken().equals(defContentToken);
             }
         });
         goGroupHome.setLeftSeparator(ActionToolbarButtonSeparator.fill);
@@ -362,8 +357,8 @@
             String iconUrl, final String description, final String parentMenuTitle, Position position,
             String... registerInTypes) {
         final ActionToolbarMenuAndItemDescriptor<StateToken> addContent = new ActionToolbarMenuAndItemDescriptor<StateToken>(
-                AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
-                    public void onEvent(final StateToken token) {
+                AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener0() {
+                    public void onEvent() {
                         Site.showProgressProcessing();
                         contentServiceProvider.get().addContent(session.getUserHash(),
                                 session.getCurrentState().getStateToken(), description, typeId,
@@ -394,7 +389,7 @@
                         setContentStatus(status, stateToken);
                     }
                 }, new ActionAddCondition<StateToken>() {
-                    public boolean mustBeAdded(StateToken param) {
+                    public boolean mustBeAdded(StateToken token) {
                         if (session.isCurrentStateAContent()
                                 && session.getContentState().getStatus().equals(ContentStatusDTO.submittedForEvaluation)) {
                             return true;
@@ -505,8 +500,8 @@
 
     protected void createShowDeletedItems(String parentMenuTitle, String... registerInTypes) {
         ActionToolbarMenuCheckItemDescriptor<StateToken> showDeletedItems = new ActionToolbarMenuCheckItemDescriptor<StateToken>(
-                AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
-                    public void onEvent(StateToken parameter) {
+                AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener0() {
+                    public void onEvent() {
                         boolean mustShow = !session.getCurrentUserInfo().getShowDeletedContent();
                         session.getCurrentUserInfo().setShowDeletedContent(mustShow);
                         if (!mustShow && session.isCurrentStateAContent()
@@ -547,8 +542,8 @@
             final String iconUrl, final String toolTip, final String permitedExtensions, String... registerInTypes) {
         final ActionToolbarButtonAndItemDescriptor<StateToken> uploadFile;
         uploadFile = new ActionToolbarButtonAndItemDescriptor<StateToken>(AccessRolDTO.Editor,
-                ActionToolbarPosition.bottombar, new Listener<StateToken>() {
-                    public void onEvent(final StateToken token) {
+                ActionToolbarPosition.bottombar, new Listener0() {
+                    public void onEvent() {
                         if (permitedExtensions != null) {
                             // FIXME: can't be reset ...
                             // fileUploaderProvider.get().setPermittedExtensions(permitedExtensions);
@@ -604,7 +599,7 @@
         setGroupLogo.setTextDescription(i18n.t("Set this as the group logo"));
         setGroupLogo.setIconUrl("images/nav/picture.png");
         setGroupLogo.setEnableCondition(new ActionEnableCondition<StateToken>() {
-            public boolean mustBeEnabled(final StateToken itemToken) {
+            public boolean mustBeEnabled(StateToken token) {
                 final BasicMimeTypeDTO mime = session.getContentState().getMimeType();
                 return mime != null && mime.getType().equals("image");
             }
@@ -614,19 +609,17 @@
 
     private ActionEnableCondition<StateToken> notDefAndNotDeleted() {
         return new ActionEnableCondition<StateToken>() {
-            public boolean mustBeEnabled(final StateToken itemToken) {
+            public boolean mustBeEnabled(StateToken token) {
                 final boolean isNotDefContentToken = !session.getCurrentState().getGroup().getDefaultContent().getStateToken().equals(
-                        itemToken);
-                final boolean isNotDeleted = !(session.isCurrentStateAContent() && session.getContentState().getStatus().equals(
-                        ContentStatusDTO.inTheDustbin));
-                return isNotDefContentToken && isNotDeleted;
+                        session.getCurrentStateToken());
+                return isNotDefContentToken && notDeleted().mustBeEnabled(token);
             }
         };
     }
 
     private ActionEnableCondition<StateToken> notDeleted() {
         return new ActionEnableCondition<StateToken>() {
-            public boolean mustBeEnabled(final StateToken itemToken) {
+            public boolean mustBeEnabled(StateToken token) {
                 final boolean isNotDeleted = !(session.isCurrentStateAContent() && session.getContentState().getStatus().equals(
                         ContentStatusDTO.inTheDustbin));
                 return isNotDeleted;

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -26,10 +26,8 @@
 
     void editContent(String content, Listener<String> onSave, Listener0 onEditCancelled);
 
-    void onSaved();
+    void onSavedSuccessful();
 
     void onSaveFailed();
 
-    void reset();
-
 }

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -99,14 +99,12 @@
 
     public void init(final TextEditorView view) {
         this.view = view;
-        toolbar.setEnableAction(save, false);
         this.view.setEnabled(true);
     }
 
     public void onEdit() {
         if (!savePending) {
             savePending = true;
-            toolbar.setEnableAction(save, true);
             if (autoSave) {
                 view.scheduleSave(AUTOSAVE_IN_MILLISECONDS);
             }
@@ -118,7 +116,7 @@
         onSave();
     }
 
-    public void onSaved() {
+    public void onSavedSuccessful() {
         if (saveAndCloseConfirmed) {
             onCancelConfirmed();
         } else {
@@ -133,13 +131,6 @@
         }
     }
 
-    public void reset() {
-        view.saveTimerCancel();
-        savePending = false;
-        saveAndCloseConfirmed = false;
-        toolbar.setEnableAction(save, false);
-    }
-
     protected void onCancel() {
         if (savePending) {
             view.saveTimerCancel();
@@ -221,6 +212,12 @@
         toolbar.setActions(collection);
     }
 
+    private void reset() {
+        view.saveTimerCancel();
+        savePending = false;
+        saveAndCloseConfirmed = false;
+    }
+
     private void setContent(final String html) {
         this.view.setHTML(html);
     }

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nUITranslationService.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -19,6 +19,7 @@
  */
 package org.ourproject.kune.workspace.client.i18n;
 
+import java.util.Date;
 import java.util.HashMap;
 
 import org.ourproject.kune.platf.client.dto.I18nLanguageDTO;
@@ -31,13 +32,14 @@
 
 import com.allen_sauer.gwt.log.client.Log;
 import com.calclab.suco.client.events.Listener0;
+import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
 public class I18nUITranslationService extends I18nTranslationService {
     private HashMap<String, String> lexicon;
     private String currentLanguageCode;
     private I18nChangeListenerCollection i18nChangeListeners;
-    private I18nLanguageDTO initialLang;
+    private I18nLanguageDTO currentLang;
     private I18nServiceAsync i18nService;
     private Session session;
 
@@ -60,14 +62,25 @@
         }
     }
 
+    public String formatDateWithLocale(final Date date) {
+        String dateFormat = currentLang.getDateFormat();
+        final DateTimeFormat fmt;
+        if (dateFormat == null) {
+            fmt = DateTimeFormat.getFormat("M/d/yyyy h:mm a");
+        } else {
+            String abrevMonthInEnglish = DateTimeFormat.getFormat("MMM").format(date);
+            String monthToTranslate = abrevMonthInEnglish + " [%NT abbreviated month]";
+            dateFormat = dateFormat.replaceFirst("MMM", "'" + t(monthToTranslate) + "'");
+            fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
+        }
+        String dateFormated = fmt.format(date);
+        return dateFormated;
+    }
+
     public String getCurrentLanguage() {
         return currentLanguageCode;
     }
 
-    public I18nLanguageDTO getInitialLang() {
-        return initialLang;
-    }
-
     public HashMap<String, String> getLexicon() {
         return lexicon;
     }
@@ -83,10 +96,10 @@
             }
 
             public void onSuccess(final I18nLanguageDTO result) {
-                initialLang = result;
-                currentLanguageCode = initialLang.getCode();
-                session.setCurrentLanguage(initialLang);
-                i18nService.getLexicon(initialLang.getCode(), new AsyncCallback<HashMap<String, String>>() {
+                currentLang = result;
+                currentLanguageCode = currentLang.getCode();
+                session.setCurrentLanguage(currentLang);
+                i18nService.getLexicon(currentLang.getCode(), new AsyncCallback<HashMap<String, String>>() {
                     public void onFailure(final Throwable caught) {
                         Log.error("Workspace adaptation to your language failed");
                     }

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -23,10 +23,8 @@
 
 import org.ourproject.kune.chat.client.ChatEngine;
 import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
 import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
 import org.ourproject.kune.platf.client.actions.ActionMenuItemDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonAndItemDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor;
 import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
@@ -191,8 +189,8 @@
     }
 
     private void registerActions() {
-        final ActionToolbarButtonAndItemDescriptor<UserSimpleDTO> addAsBuddie = new ActionToolbarButtonAndItemDescriptor<UserSimpleDTO>(
-                AccessRolDTO.Viewer, ActionToolbarPosition.bottombar, new Listener<UserSimpleDTO>() {
+        final ActionMenuItemDescriptor<UserSimpleDTO> addAsBuddie = new ActionMenuItemDescriptor<UserSimpleDTO>(
+                AccessRolDTO.Viewer, new Listener<UserSimpleDTO>() {
                     public void onEvent(final UserSimpleDTO user) {
                         chatEngineProvider.get().addNewBuddie(user.getShortName());
                     }
@@ -200,14 +198,9 @@
         addAsBuddie.setMustBeAuthenticated(true);
         addAsBuddie.setTextDescription(i18n.t("Add as a buddie"));
         addAsBuddie.setIconUrl("images/add-green.png");
-        addAsBuddie.setAddCondition(new ActionAddCondition<UserSimpleDTO>() {
-            public boolean mustBeAdded(UserSimpleDTO item) {
-                return !session.getCurrentUserInfo().getShortName().equals(item.getShortName());
-            }
-        });
         addAsBuddie.setEnableCondition(new ActionEnableCondition<UserSimpleDTO>() {
-            public boolean mustBeEnabled(UserSimpleDTO item) {
-                return !session.getCurrentUserInfo().getShortName().equals(item.getShortName());
+            public boolean mustBeEnabled(UserSimpleDTO user) {
+                return !chatEngineProvider.get().isBuddie(user.getShortName());
             }
         });
         actionRegistry.addAction(addAsBuddie);

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -170,7 +170,7 @@
         participate.setToolTip(i18n.t("Request to participate in this group"));
         participate.setMustBeAuthenticated(false);
         participate.setAddCondition(new ActionAddCondition<StateToken>() {
-            public boolean mustBeAdded(StateToken param) {
+            public boolean mustBeAdded(StateToken token) {
                 return !isMember(session.getCurrentState().getGroupRights());
             }
         });

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntitySubTitlePresenter.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -26,25 +26,21 @@
 import org.ourproject.kune.platf.client.dto.StateContainerDTO;
 import org.ourproject.kune.platf.client.dto.StateContentDTO;
 import org.ourproject.kune.platf.client.registry.AuthorableRegistry;
-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.workspace.client.i18n.I18nUITranslationService;
 
 import com.calclab.suco.client.events.Listener;
-import com.google.gwt.i18n.client.DateTimeFormat;
 
 public class EntitySubTitlePresenter implements EntitySubTitle {
 
     private EntitySubTitleView view;
-    private final I18nTranslationService i18n;
+    private final I18nUITranslationService i18n;
     private final boolean showLanguage;
-    private final Session session;
     private final AuthorableRegistry authorableRegistry;
 
-    public EntitySubTitlePresenter(final I18nTranslationService i18n, final StateManager stateManager, Session session,
+    public EntitySubTitlePresenter(final I18nUITranslationService i18n, final StateManager stateManager,
             boolean showLanguage, AuthorableRegistry authorableRegistry) {
         this.i18n = i18n;
-        this.session = session;
         this.showLanguage = showLanguage;
         this.authorableRegistry = authorableRegistry;
         stateManager.onStateChanged(new Listener<StateAbstractDTO>() {
@@ -71,17 +67,8 @@
 
     public void setContentDate(final Date publishedOn) {
         if (publishedOn != null) {
-            String dateFormat = session.getCurrentLanguage().getDateFormat();
-            final DateTimeFormat fmt;
-            if (dateFormat == null) {
-                fmt = DateTimeFormat.getFormat("M/d/yyyy h:mm a");
-            } else {
-                String abrevMonthInEnglish = DateTimeFormat.getFormat("MMM").format(publishedOn);
-                String monthToTranslate = abrevMonthInEnglish + " [%NT abbreviated month]";
-                dateFormat = dateFormat.replaceFirst("MMM", "'" + i18n.t(monthToTranslate) + "'");
-                fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
-            }
-            view.setContentSubTitleRight(i18n.t("Published on: [%s]", fmt.format(publishedOn)));
+            String dateFormated = i18n.formatDateWithLocale(publishedOn);
+            view.setContentSubTitleRight(i18n.t("Published on: [%s]", dateFormated));
             setContentDateVisible(true);
         } else {
             setContentDateVisible(false);

Added: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java	2009-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -0,0 +1,55 @@
+package org.ourproject.kune.platf.client.actions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.ourproject.kune.platf.client.services.I18nTranslationServiceMocked;
+
+import com.google.gwt.user.client.ui.KeyboardListener;
+
+public class ActionShortcutTest {
+
+    private I18nTranslationServiceMocked i18n;
+
+    @Test
+    public void altS() {
+        ActionShortcut shortcut = new ActionShortcut(true, false, false, 'S');
+        assertEquals(" (Alt+S)", shortcut.toString(i18n));
+        assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_ALT));
+        assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_CTRL));
+        assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_SHIFT));
+    }
+
+    @Before
+    public void before() {
+        i18n = new I18nTranslationServiceMocked();
+    }
+
+    @Test
+    public void ctrl_s() {
+        ActionShortcut shortcut = new ActionShortcut(true, 's');
+        assertEquals(" (Ctrl+S)", shortcut.toString(i18n));
+        assertTrue(shortcut.is('s', KeyboardListener.MODIFIER_CTRL));
+        assertTrue(!shortcut.is('s', KeyboardListener.MODIFIER_ALT));
+        assertTrue(!shortcut.is('s', KeyboardListener.MODIFIER_SHIFT));
+    }
+
+    @Test
+    public void ctrlS() {
+        ActionShortcut shortcut = new ActionShortcut(true, 'S');
+        assertEquals(" (Ctrl+S)", shortcut.toString(i18n));
+        assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_CTRL));
+        assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_ALT));
+        assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_SHIFT));
+    }
+
+    @Test
+    public void ctrlShiftS() {
+        ActionShortcut shortcut = new ActionShortcut(false, true, true, 'S');
+        assertEquals(" (Ctrl+Shift+S)", shortcut.toString(i18n));
+        assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_ALT));
+        assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_SHIFT | KeyboardListener.MODIFIER_CTRL));
+    }
+}

Modified: 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-02-01 14:46:12 UTC (rev 1044)
+++ trunk/src/test/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenterTest.java	2009-02-03 10:15:36 UTC (rev 1045)
@@ -63,7 +63,7 @@
     public void historyChangeWithPendingSaveMustPosponeIt() {
         editAndChangeHistoryToken();
         presenter.onSaveAndClose();
-        presenter.onSaved();
+        presenter.onSavedSuccessful();
         assertTrue(saveListener.isCalledOnce());
         Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
     }




More information about the kune-commits mailing list