[kune-commits] r1124 - in trunk/src/main/java/org/ourproject/kune: platf/client/actions platf/client/actions/ui platf/client/services platf/client/ui/rte platf/client/ui/rte/basic workspace/client/sitebar/siteoptions

vjrj vjrj at ourproject.org
Wed Jun 10 16:37:57 CEST 2009


Author: vjrj
Date: 2009-06-10 16:37:53 +0200 (Wed, 10 Jun 2009)
New Revision: 1124

Modified:
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
Log:
Complete - task Font selectors with show current font in RTE

and lot of improvements and fixes in new RTE actions



Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -89,7 +89,8 @@
      *            the name (<code>null</code> permitted).
      */
     public AbstractAction(final String name) {
-        // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09 15:19
+        // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09
+        // 15:19
         putValue(NAME, name);
     }
 
@@ -105,9 +106,11 @@
      *            the icon (<code>null</code> permitted).
      */
     public AbstractAction(final String name, final ImageResource icon) {
-        // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09 15:19
+        // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09
+        // 15:19
         putValue(NAME, name);
-        // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09 15:19
+        // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09
+        // 15:19
         putValue(SMALL_ICON, icon);
     }
 

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -96,7 +96,8 @@
     public PropertyChangeSupport(final Object source) {
         this.source = source;
         if (source == null) {
-            // @PMD:REVIEWED:AvoidThrowingNullPointerException: by vjrj on 21/05/09 14:12
+            // @PMD:REVIEWED:AvoidThrowingNullPointerException: by vjrj on
+            // 21/05/09 14:12
             throw new NullPointerException();
         }
     }
@@ -119,7 +120,7 @@
         }
 
         if (l instanceof PropertyChangeListenerProxy) {
-            PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+            final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
             addPropertyChangeListener(p.propertyName, (PropertyChangeListener) p.getListener());
         } else {
             if (listeners == null) {
@@ -156,7 +157,7 @@
         }
 
         while (l instanceof PropertyChangeListenerProxy) {
-            PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+            final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
             if (propertyName == null ? p.propertyName != null : !propertyName.equals(p.propertyName)) {
                 return;
             }
@@ -238,10 +239,10 @@
                 (v.get(i)).propertyChange(event);
             }
         }
-        HashMap<String, PropertyChangeSupport> h = children; // Be
+        final HashMap<String, PropertyChangeSupport> h = children; // Be
         // thread-safe.
         if (h != null && event.propertyName != null) {
-            PropertyChangeSupport s = h.get(event.propertyName);
+            final PropertyChangeSupport s = h.get(event.propertyName);
             if (s != null) {
                 v = s.listeners; // Be thread-safe.
                 int i = v == null ? 0 : v.size();
@@ -320,17 +321,17 @@
      * @since 1.4
      */
     public PropertyChangeListener[] getPropertyChangeListeners() {
-        ArrayList<PropertyChangeListener> list = new ArrayList<PropertyChangeListener>();
+        final ArrayList<PropertyChangeListener> list = new ArrayList<PropertyChangeListener>();
         if (listeners != null) {
             list.addAll(listeners);
         }
         if (children != null) {
             int i = children.size();
-            Iterator<Entry<String, PropertyChangeSupport>> iter = children.entrySet().iterator();
+            final Iterator<Entry<String, PropertyChangeSupport>> iter = children.entrySet().iterator();
             while (--i >= 0) {
-                Entry<String, PropertyChangeSupport> e = iter.next();
-                String name = e.getKey();
-                Vector<PropertyChangeListener> v = (e.getValue()).listeners;
+                final Entry<String, PropertyChangeSupport> e = iter.next();
+                final String name = e.getKey();
+                final Vector<PropertyChangeListener> v = (e.getValue()).listeners;
                 int j = v.size();
                 while (--j >= 0) {
                     list.add(new PropertyChangeListenerProxy(name, v.get(j)));
@@ -352,7 +353,7 @@
         if (children == null || propertyName == null) {
             return new PropertyChangeListener[0];
         }
-        PropertyChangeSupport s = children.get(propertyName);
+        final PropertyChangeSupport s = children.get(propertyName);
         if (s == null) {
             return new PropertyChangeListener[0];
         }
@@ -387,7 +388,7 @@
      */
     public void removePropertyChangeListener(final PropertyChangeListener l) {
         if (l instanceof PropertyChangeListenerProxy) {
-            PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+            final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
             removePropertyChangeListener(p.propertyName, (PropertyChangeListener) p.getListener());
         } else if (listeners != null) {
             listeners.remove(l);
@@ -417,12 +418,12 @@
         if (children == null) {
             return;
         }
-        PropertyChangeSupport s = children.get(propertyName);
+        final PropertyChangeSupport s = children.get(propertyName);
         if (s == null) {
             return;
         }
         while (l instanceof PropertyChangeListenerProxy) {
-            PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+            final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
             if (propertyName == null ? p.propertyName != null : !propertyName.equals(p.propertyName)) {
                 return;
             }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -3,6 +3,8 @@
 import org.ourproject.kune.platf.client.actions.Action;
 import org.ourproject.kune.platf.client.actions.ActionEvent;
 import org.ourproject.kune.platf.client.actions.KeyStroke;
+import org.ourproject.kune.platf.client.actions.PropertyChangeEvent;
+import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
 import org.ourproject.kune.platf.client.ui.img.ImgConstants;
 
 import com.google.gwt.libideas.resources.client.ImageResource;
@@ -24,9 +26,11 @@
         if (descriptor instanceof MenuRadioItemDescriptor) {
             final CheckItem checkItem = createCheckItem(descriptor);
             checkItem.setGroup(((MenuRadioItemDescriptor) descriptor).getGroup());
+            confCheckListener(descriptor, checkItem);
             item = checkItem;
         } else if (descriptor instanceof MenuCheckItemDescriptor) {
             final CheckItem checkItem = createCheckItem(descriptor);
+            confCheckListener(descriptor, checkItem);
             item = checkItem;
         } else {
             item = new Item();
@@ -66,7 +70,6 @@
     @Override
     protected void setIcon(final ImageResource imageResource) {
         if (imageResource != null) {
-            // FIXME
             item.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
         }
     }
@@ -90,6 +93,16 @@
         }
     }
 
+    private void confCheckListener(final MenuItemDescriptor descriptor, final CheckItem checkItem) {
+        descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
+            public void propertyChange(final PropertyChangeEvent event) {
+                if (event.getPropertyName().equals(MenuCheckItemDescriptor.CHECKED)) {
+                    checkItem.setChecked((Boolean) event.getNewValue());
+                }
+            }
+        });
+    }
+
     private CheckItem createCheckItem(final MenuItemDescriptor descriptor) {
         final CheckItem checkItem = new CheckItem();
         checkItem.setChecked(((MenuCheckItemDescriptor) descriptor).isChecked());

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -9,8 +9,8 @@
         bindings.register(MenuCheckItemDescriptor.class, menuItemBinding);
         bindings.register(MenuItemDescriptor.class, menuItemBinding);
         bindings.register(MenuSeparatorDescriptor.class, new MenuSeparatorBinding());
+        bindings.register(PushButtonDescriptor.class, new PushButtonBinding());
         bindings.register(ButtonDescriptor.class, new ButtonBinding());
-        bindings.register(PushButtonDescriptor.class, new PushButtonBinding());
         bindings.register(ToolbarSeparatorDescriptor.class, new ToolbarSeparatorBinding());
     }
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -1,11 +1,9 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
 
 /**
  * The Class AbstractUIActionDescriptor.
@@ -20,7 +18,6 @@
     private GuiVisibleCondition visibleCondition = new GuiVisibleConditionAdapter();
 
     protected GuiActionDescrip parent;
-    private final Map<String, Object> store;
 
     /** The action. */
     protected AbstractAction action;
@@ -42,9 +39,12 @@
         this.action = action;
         position = NO_POSITION;
         parent = NO_PARENT;
-        store = new HashMap<String, Object>();
     }
 
+    public void fire(final ActionEvent event) {
+        action.actionPerformed(event);
+    }
+
     public GuiAddCondition getAddCondition() {
         return addCondition;
     }
@@ -86,7 +86,7 @@
      * @see #putValue(String, Object)
      */
     public Object getValue(final String key) {
-        return store.get(key);
+        return action.getValue(key);
     }
 
     public GuiVisibleCondition getVisibleCondition() {
@@ -109,7 +109,7 @@
      *            the value (<code>null</code> permitted).
      */
     public void putValue(final String key, final Object value) {
-        store.put(key, value);
+        action.putValue(key, value);
     }
 
     public void setAddCondition(final GuiAddCondition addCondition) {

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -3,7 +3,7 @@
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 
 public class MenuCheckItemDescriptor extends MenuItemDescriptor {
-    private static final String CHECKED = "checked";
+    public static final String CHECKED = "checked";
 
     private boolean checked = false;
 

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -6,6 +6,8 @@
 
 import com.google.gwt.libideas.resources.client.ImageResource;
 import com.gwtext.client.widgets.ToolbarButton;
+import com.gwtext.client.widgets.menu.Menu;
+import com.gwtext.client.widgets.menu.event.MenuListenerAdapter;
 
 public class MenuGui extends AbstractMenuGui {
 
@@ -18,13 +20,18 @@
         setAction(descriptor.action);
         initWidget(button);
         descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
-            public void propertyChange(final PropertyChangeEvent e) {
-                if (e.getPropertyName().equals(MenuDescriptor.MENU_HIDE) && e.getNewValue().equals(true)) {
+            public void propertyChange(final PropertyChangeEvent event) {
+                if (event.getPropertyName().equals(MenuDescriptor.MENU_HIDE) && event.getNewValue().equals(true)) {
                     menu.hide(true);
-                    descriptor.action.putValue(MenuDescriptor.MENU_HIDE, false);
                 }
             }
         });
+        menu.addListener(new MenuListenerAdapter() {
+            @Override
+            public void onShow(final Menu menu) {
+                descriptor.action.putValue(MenuDescriptor.MENU_HIDE, false);
+            }
+        });
     }
 
     public void add(final SubMenuGui submenu) {

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -4,7 +4,7 @@
 
     @Override
     public AbstractGuiItem create(final GuiActionDescrip descriptor) {
-        return new ButtonGui((ButtonDescriptor) descriptor, true);
+        return new PushButtonGui((PushButtonDescriptor) descriptor);
     }
 
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -8,7 +8,7 @@
     public PushButtonGui(final PushButtonDescriptor btn) {
         super(btn, true);
         setPressed(btn.isPushed());
-        action.addPropertyChangeListener(new PropertyChangeListener() {
+        btn.action.addPropertyChangeListener(new PropertyChangeListener() {
             public void propertyChange(final PropertyChangeEvent event) {
                 if (event.getPropertyName().equals(PushButtonDescriptor.PUSHED)) {
                     setPressed(btn.isPushed());

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -59,11 +59,8 @@
 import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
 import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionSndToolbar;
 import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbar;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
 import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
 import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanelNew;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenter;
 import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenterNew;
 import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
 import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPanel;
@@ -337,22 +334,8 @@
             }
         });
 
-        register(NoDecoration.class, new Factory<RTEditor>(RTEditor.class) {
+        register(NoDecoration.class,new Factory<RTEditorNew>(RTEditorNew.class) {
             @Override
-            public RTEditor create() {
-                final RTEActionTopToolbar topBar = $(RTEActionTopToolbar.class);
-                final RTEActionSndToolbar sndBar = $(RTEActionSndToolbar.class);
-                final RTEditorPresenter presenter = new RTEditorPresenter($(I18nTranslationService.class),
-                        $(Session.class), topBar, sndBar, $(RTEImgResources.class), $$(InsertLinkDialog.class),
-                        $$(ColorWebSafePalette.class), $$(EditHtmlDialog.class), $$(InsertImageDialog.class),
-                        $$(InsertMediaDialog.class),   $$(InsertTableDialog.class), $$(InsertSpecialCharDialog.class), $(DeferredCommandWrapper.class));
-                final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class),
-                        $(ActionManager.class), $(GlobalShortcutRegister.class));
-                presenter.init(panel);
-                return presenter;
-            }
-        },new Factory<RTEditorNew>(RTEditorNew.class) {
-            @Override
             public RTEditorNew create() {
                 final RTEditorPresenterNew presenter = new RTEditorPresenterNew($(I18nTranslationService.class),
                         $(Session.class),  $(RTEImgResources.class), $$(InsertLinkDialog.class),

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -3,7 +3,7 @@
 import org.ourproject.kune.platf.client.actions.ui.ComplexToolbar;
 import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog;
 import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanelNew;
 import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
 
 import com.google.gwt.user.client.ui.VerticalPanel;
@@ -23,9 +23,8 @@
         final RTEditorNew basicEditor = editor.getBasicEditor();
         vp.add((ComplexToolbar) basicEditor.getTopBar());
         vp.add((ComplexToolbar) basicEditor.getSndBar());
-        final RTEditorPanel editorPanel = (RTEditorPanel) basicEditor.getEditorArea();
+        final RTEditorPanelNew editorPanel = (RTEditorPanelNew) basicEditor.getEditorArea();
         vp.add(editorPanel);
-        basicEditor.setExtended(true);
         vp.setWidth("100%");
         dialog.add(vp);
         dialog.addListener(new WindowListenerAdapter() {

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -1,5 +1,7 @@
 package org.ourproject.kune.platf.client.ui.rte.basic;
 
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
 import org.ourproject.kune.platf.client.actions.ActionItem;
 import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
 import org.ourproject.kune.platf.client.services.Images;
@@ -9,6 +11,7 @@
 import com.calclab.suco.client.events.Listener0;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.Label;
@@ -32,7 +35,16 @@
     }
 
     public void add(final GuiActionDescrip item) {
-        // TODO
+        final Label actionLabel = new Label();
+        actionLabel.setText((String) item.getValue(Action.NAME));
+        actionLabel.addStyleName("k-rte-changelink");
+        KuneUiUtils.setUnselectable(actionLabel.getElement());
+        actionLabel.addClickHandler(new ClickHandler() {
+            public void onClick(final ClickEvent event) {
+                item.fire(new ActionEvent(actionLabel, (Event) event.getNativeEvent()));
+            }
+        });
+        hpanel.insert(actionLabel, 0);
     }
 
     @Deprecated

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -2,6 +2,7 @@
 
 import java.util.Date;
 
+import org.cobogw.gwt.user.client.CSS;
 import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 import org.ourproject.kune.platf.client.actions.ActionEvent;
@@ -27,6 +28,7 @@
 
 import com.allen_sauer.gwt.log.client.Log;
 import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Node;
 import com.google.gwt.event.dom.client.BlurEvent;
 import com.google.gwt.event.dom.client.BlurHandler;
 import com.google.gwt.event.dom.client.FocusEvent;
@@ -39,6 +41,7 @@
 
 public class RTEditorPanelNew extends AbstractComplexGuiItem implements RTEditorViewNew, FocusHandler, BlurHandler {
 
+    private static final Element NO_ELEMENT = null;
     private final I18nUITranslationService i18n;
     private final BasicFormatter basic;
     private final ExtendedFormatter extended;
@@ -120,6 +123,16 @@
         setFocus(true);
     }
 
+    public String getFont() {
+        final Element currentElement = getCurrentElement();
+        return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty(CSS.A.FONT_FAMILY);
+    }
+
+    public String getFontSize() {
+        final Element currentElement = getCurrentElement();
+        return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty("size");
+    }
+
     public String getHTML() {
         return rta.getHTML();
     }
@@ -292,7 +305,6 @@
             // globalShortcutReg.get(event) : rtaActionItem;
             final AbstractAction actionItem = rtaActionItem == null ? null : rtaActionItem;
             if (actionItem == null) {
-                Log.warn("rte action key null");
                 super.onBrowserEvent(event);
                 updateStatus();
                 updateLinkInfo();
@@ -420,6 +432,17 @@
         presenter.fireOnEdit();
     }
 
+    protected Element getElement(final Node inputNode) {
+        Node node = inputNode;
+        if (node.getNodeType() != Node.ELEMENT_NODE) {
+            node = node.getParentNode();
+        }
+        if (node == null || node.getNodeType() != Node.ELEMENT_NODE) {
+            return null;
+        }
+        return Element.as(node);
+    }
+
     private void createCommentAndSelectIt(final String author, final String comment) {
         final Element commentEl = createCommentElement(author, comment);
         final Range innerCommentRange = rta.getDocument().createRange();
@@ -439,6 +462,14 @@
         return span;
     }
 
+    private Element getCurrentElement() {
+        if (getSelection().getRangeCount() > 0) {
+            return getElement(getSelection().getRangeAt(0).getStartContainer());
+        } else {
+            return NO_ELEMENT;
+        }
+    }
+
     private Range getFstRange() {
         return getSelection().getRangeAt(0);
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -4,7 +4,9 @@
 import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_TEXT;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
@@ -16,8 +18,10 @@
 import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection;
 import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
 import org.ourproject.kune.platf.client.actions.ui.GuiAddCondition;
+import org.ourproject.kune.platf.client.actions.ui.MenuCheckItemDescriptor;
 import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
 import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuRadioItemDescriptor;
 import org.ourproject.kune.platf.client.actions.ui.MenuSeparatorDescriptor;
 import org.ourproject.kune.platf.client.actions.ui.PushButtonDescriptor;
 import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor;
@@ -248,18 +252,23 @@
     }
 
     public class FontAction extends AbstractRTEAction {
-        private final String fontName;
+        public static final String FONT_NAME = "fontname";
 
         public FontAction(final String fontName, final String tooltip, final ImageResource icon) {
             super("<span style=\"font-family: " + fontName + "\">" + fontName + "</span>", tooltip, icon);
-            this.fontName = fontName;
+            super.putValue(FONT_NAME, fontName);
         }
 
         public void actionPerformed(final ActionEvent actionEvent) {
+            final String fontName = getFontName();
             view.setFontName(fontName);
             fontMenu.setText(fontName);
             fireOnEdit();
         }
+
+        private String getFontName() {
+            return (String) super.getValue(FONT_NAME);
+        }
     }
 
     public class FontColorAction extends AbstractRTEAction {
@@ -282,20 +291,18 @@
     }
 
     public class FontSizeAction extends AbstractRTEAction {
-        private final String fontSizeName;
         private final int fontSize;
 
         public FontSizeAction(final String fontSizeName, final int fontSize, final String tooltip,
                 final ImageResource icon) {
             super("<font size=\"" + (fontSize + 1) + "\">" + fontSizeName + "</font>", tooltip, icon);
-            this.fontSizeName = fontSizeName;
             this.fontSize = fontSize;
         }
 
         public void actionPerformed(final ActionEvent actionEvent) {
             view.setFontSize(FONT_SIZES[fontSize]);
             fireOnEdit();
-            fontSizeMenu.setText(fontSizeName);
+            // fontSizeMenu.setText(fontSizeName);
         }
     }
 
@@ -623,6 +630,8 @@
             RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
             RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
             RichTextArea.FontSize.XX_LARGE };
+    private static final String FONT_GROUP = "fontgroup";
+    private static final String FONT_SIZEGROUP = "fontsizegroup";
 
     private RTEditorViewNew view;
     private boolean extended;
@@ -662,6 +671,8 @@
     private MenuDescriptor fileMenu;
     private final List<MenuDescriptor> menus;
     private boolean attached;
+    private final Map<String, MenuCheckItemDescriptor> fontActions;
+    private MenuCheckItemDescriptor currentFontItem;
 
     public RTEditorPresenterNew(final I18nTranslationService i18n, final Session session,
             final RTEImgResources imgResources, final Provider<InsertLinkDialog> insLinkDialog,
@@ -683,11 +694,10 @@
         menus = new ArrayList<MenuDescriptor>();
 
         this.imgResources = imgResources;
-        extended = true;
         this.onEdit = new Event0("onRTEEdit");
         extendedAddCond = new GuiAddCondition() {
             public boolean mustBeAdded() {
-                return isExtended();
+                return isAndCanBeExtended();
             }
         };
         basicAddCond = new GuiAddCondition() {
@@ -696,6 +706,7 @@
             }
         };
         attached = false;
+        fontActions = new HashMap<String, MenuCheckItemDescriptor>();
     }
 
     public void addAction(final GuiActionDescrip descriptor) {
@@ -814,8 +825,8 @@
         }
     }
 
-    public void setExtended(final boolean extended) {
-        this.extended = extended;
+    public void setExtended(final boolean newValue) {
+        this.extended = newValue;
     }
 
     public void setFocus(final boolean focus) {
@@ -835,7 +846,7 @@
     public void updateLinkInfo() {
         deferred.addCommand(new Listener0() {
             public void onEvent() {
-                if (isExtended() && view.isLink()) {
+                if (isAndCanBeExtended() && view.isLink()) {
                     view.showLinkCtxMenu();
                 } else {
                     hideLinkCtxMenu();
@@ -849,8 +860,14 @@
             bold.setPushed(view.isBold());
             italic.setPushed(view.isItalic());
             underline.setPushed(view.isUnderlined());
+            deferred.addCommand(new Listener0() {
+                public void onEvent() {
+                    updateFont();
+                    // Log.warn(view.getFontSize());
+                }
+            });
         }
-        if (isExtended()) {
+        if (isAndCanBeExtended()) {
             strikethrough.setPushed(view.isStrikethrough());
         }
     }
@@ -866,8 +883,11 @@
         final MenuSeparatorDescriptor editMenuSep = new MenuSeparatorDescriptor(editMenu);
         final MenuSeparatorDescriptor insertMenuSep = new MenuSeparatorDescriptor(insertMenu);
         final MenuSeparatorDescriptor formatMenuSep = new MenuSeparatorDescriptor(formatMenu);
+        insertMenuSep.setAddCondition(extendedAddCond);
 
         final ToolbarSeparatorDescriptor sndbarSep = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
+        final ToolbarSeparatorDescriptor sndbarSepExt = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
+        sndbarSepExt.setAddCondition(extendedAddCond);
 
         final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), AbstractRTEAction.NO_TEXT,
                 imgResources.selectall());
@@ -1051,7 +1071,7 @@
         final FontColorAction fontColorAction = new FontColorAction(NO_TEXT, i18n.t("Text Colour"),
                 imgResources.fontcolor());
         final ButtonDescriptor fontColor = new ButtonDescriptor(fontColorAction);
-        fontColor.setAddCondition(extendedAddCond);
+        fontColor.setAddCondition(basicAddCond);
 
         final BackgroundColorAction backColorAction = new BackgroundColorAction(NO_TEXT,
                 i18n.t("Text Background Colour"), imgResources.backcolor());
@@ -1069,20 +1089,20 @@
                 select, editMenuSep, editHtml, editLink, img, insertTable, insertMedia, insertMenuSep,
                 insertSpecialChar, comment, hline, removeFormat, formatMenuSep, insertMenuSep, undoBtn, redoBtn,
                 sndbarSep, bold, italic, underline, strikethrough, sndbarSep, justifyLeft, justifyCentre, justifyRight,
-                decreaseIndent, increaseIndent, olist, ulist, sndbarSep, removeFormatBtn, sndbarSep, hlineBtn, imgBtn,
-                editLinkBtn, removeLinkBtn, insertTableBtn, sndbarSep, subscript, superscript, blockquote, fontMenu,
-                fontSizeMenu, fontColor, backgroundColor);
+                decreaseIndent, increaseIndent, olist, ulist, sndbarSep, removeFormatBtn, sndbarSepExt, hlineBtn,
+                imgBtn, editLinkBtn, removeLinkBtn, insertTableBtn, sndbarSepExt, subscript, superscript, blockquote,
+                fontColor, backgroundColor, fontSizeMenu, fontMenu, editLinkCtx, removeLinkCtx);
         // actions.add(devInfo);
 
         setLocation(TOPBAR, new GuiActionDescrip[] { fileMenu, editMenu, insertMenu, formatMenu, editMenuSep,
                 subscript, superscript, undo, redo, editMenuSep, copy, cut, paste, editMenuSep, select, editMenuSep,
                 editHtml, comment, hline, blockquote, img, insertTable, insertMedia, editLink, removeFormat,
                 formatMenuSep, insertMenuSep, insertSpecialChar, insertTable, devInfo });
-        setLocation(SNDBAR, new GuiActionDescrip[] { undoBtn, redoBtn, sndbarSep, bold, italic, underline,
-                strikethrough, justifyLeft, justifyCentre, justifyRight, undoBtn, redoBtn, hlineBtn, decreaseIndent,
-                increaseIndent, olist, ulist, hlineBtn, imgBtn, editLinkBtn, removeLinkBtn, removeFormatBtn,
-                insertTableBtn, fontColor, backgroundColor, fontMenu, fontSizeMenu });
-        setLocation(LINKCTX, new GuiActionDescrip[] { editLinkCtx, removeLinkCtx });
+        setLocation(SNDBAR, new GuiActionDescrip[] { undoBtn, redoBtn, sndbarSep, sndbarSepExt, bold, italic,
+                underline, strikethrough, justifyLeft, justifyCentre, justifyRight, undoBtn, redoBtn, hlineBtn,
+                decreaseIndent, increaseIndent, olist, ulist, hlineBtn, imgBtn, editLinkBtn, removeLinkBtn,
+                removeFormatBtn, insertTableBtn, fontColor, backgroundColor, fontMenu, fontSizeMenu });
+        setLocation(LINKCTX, new GuiActionDescrip[] { removeLinkCtx, editLinkCtx });
 
         for (final String fontName : FONT_NAMES) {
             createFontAction(fontMenu, fontName);
@@ -1095,22 +1115,22 @@
 
     private void createFontAction(final MenuDescriptor fontMenu, final String fontName) {
         final FontAction fontAction = new FontAction(fontName, NO_TEXT, NO_ICON);
-        final MenuItemDescriptor font = new MenuItemDescriptor(fontMenu, fontAction);
+        final MenuRadioItemDescriptor font = new MenuRadioItemDescriptor(fontMenu, fontAction, FONT_GROUP);
         font.setAddCondition(basicAddCond);
         font.setLocation(SNDBAR);
-        fontMenu.setText(fontName);
+        fontActions.put(fontName.toLowerCase(), font);
         actions.add(font);
     }
 
     private void createFontSizeAction(final MenuDescriptor fontSizeMenu, final int fontSize) {
         final String fontSizeName = i18n.t(FONT_SIZE_NAMES[fontSize]);
         final FontSizeAction fontSizeAction = new FontSizeAction(fontSizeName, fontSize, NO_TEXT, NO_ICON);
-        final MenuItemDescriptor fontSizeItem = new MenuItemDescriptor(fontSizeMenu, fontSizeAction);
+        final MenuRadioItemDescriptor fontSizeItem = new MenuRadioItemDescriptor(fontSizeMenu, fontSizeAction,
+                FONT_SIZEGROUP);
         fontSizeItem.setAddCondition(basicAddCond);
         setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char) (48 + fontSize))), Keyboard.MODIFIER_CTRL),
                 fontSizeAction);
         fontSizeItem.setLocation(SNDBAR);
-        fontSizeMenu.setText(fontSizeName);
         actions.add(fontSizeItem);
     }
 
@@ -1122,6 +1142,7 @@
         menus.add(linkCtxMenu = new MenuDescriptor(i18n.t("Change Link")));
         menus.add(fontMenu = new MenuDescriptor(NO_TEXT, i18n.t("Font"), imgResources.charfontname()));
         menus.add(fontSizeMenu = new MenuDescriptor(NO_TEXT, i18n.t("Font size"), imgResources.fontheight()));
+        insertMenu.setAddCondition(extendedAddCond);
     }
 
     private void createPalette() {
@@ -1145,7 +1166,7 @@
         }
     }
 
-    private boolean isExtended() {
+    private boolean isAndCanBeExtended() {
         return extended && view.canBeExtended();
     }
 
@@ -1155,4 +1176,18 @@
         }
     }
 
+    private void updateFont() {
+        final String currentFont = view.getFont();
+        final MenuCheckItemDescriptor item = fontActions.get(currentFont);
+        if (currentFontItem != null && item != currentFontItem) {
+            currentFontItem.setChecked(false);
+        }
+        if (item != null) {
+            item.setChecked(true);
+            currentFontItem = item;
+            fontMenu.setText((String) item.getValue(FontAction.FONT_NAME));
+        } else {
+            fontMenu.setText("&nbsp;");
+        }
+    }
 }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -26,6 +26,10 @@
 
     void focus();
 
+    String getFont();
+
+    String getFontSize();
+
     String getHTML();
 
     LinkInfo getLinkInfoIfHref();
@@ -133,5 +137,4 @@
     void undo();
 
     void unlink();
-
 }

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java	2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java	2009-06-10 14:37:53 UTC (rev 1124)
@@ -58,24 +58,24 @@
             }
         });
 
-        // final Item testRTE = new Item(i18n.t("Test new RTE"), new
-        // BaseItemListenerAdapter() {
-        // @Override
-        // public void onClick(final BaseItem item, final EventObject e) {
-        // editor.get().show();
-        // }
-        // }, "");
-        //
-        // final Item testRTEbasic = new
-        // Item(i18n.t("Test new RTE (basic mode)"), new
-        // BaseItemListenerAdapter() {
-        // @Override
-        // public void onClick(final BaseItem item, final EventObject e) {
-        // editor.get().setExtended(false);
-        // editor.get().show();
-        // }
-        // }, "");
+        final Item testRTE = new Item(i18n.t("Test new RTE"), new BaseItemListenerAdapter() {
+            @Override
+            public void onClick(final BaseItem item, final EventObject e) {
+                final TestRTEDialog testRTEDialog = editor.get();
+                testRTEDialog.setExtended(true);
+                testRTEDialog.show();
+            }
+        }, "");
 
+        final Item testRTEbasic = new Item(i18n.t("Test new RTE (basic mode)"), new BaseItemListenerAdapter() {
+            @Override
+            public void onClick(final BaseItem item, final EventObject e) {
+                final TestRTEDialog testRTEDialog = editor.get();
+                testRTEDialog.setExtended(false);
+                testRTEDialog.show();
+            }
+        }, "");
+
         final Item linkHelpInTrans = new Item(i18n.t("Help with the translation"), new BaseItemListenerAdapter() {
             @Override
             public void onClick(final BaseItem item, final EventObject e) {
@@ -91,6 +91,8 @@
                 KuneWindowUtils.open("http://ourproject.org/tracker/?group_id=407");
             }
         }, "images/kuneicon16.gif");
+        optionsMenu.addItem(testRTEbasic);
+        optionsMenu.addItem(testRTE);
         optionsMenu.addItem(linkHelpInTrans);
         optionsMenu.addItem(linkKuneBugs);
     }




More information about the kune-commits mailing list