[kune-commits] r1113 - in trunk: . src/main/java/org/ourproject/kune/platf/client/actions src/main/java/org/ourproject/kune/platf/client/actions/ui src/main/java/org/ourproject/kune/platf/client/services

vjrj vjrj at ourproject.org
Sun May 24 20:56:54 CEST 2009


Author: vjrj
Date: 2009-05-24 20:56:49 +0200 (Sun, 24 May 2009)
New Revision: 1113

Added:
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItem.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparator.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIActionDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuCheckItem.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuItem.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/MenuDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparator.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButton.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparator.java
Removed:
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionMap.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/CheckButton.java
Modified:
   trunk/DEV-GUIDE
   trunk/TODO
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButton.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultButton.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
Log:
Incomplete - task New Action class (adapted from Swing) to replace ActionDescription 


Modified: trunk/DEV-GUIDE
===================================================================
--- trunk/DEV-GUIDE	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/DEV-GUIDE	2009-05-24 18:56:49 UTC (rev 1113)
@@ -172,6 +172,10 @@
 
 Also you have to set the variable M2_REPO (Eclipse Preferences > Java > Build Path > Classpath Variables > New) to the location of your local maven repo (in our case /home/ouruser/.m2/repository).
 
+Is recommended that you use the PMD plugin:
+http://pmd.sourceforge.net/
+http://pmd.sourceforge.net/eclipse/
+
 Useful info about gwt and Eclipse:
 http://code.google.com/p/gwt-examples/wiki/gwtEclipseFaqs
 
@@ -214,6 +218,10 @@
 
 http://docs.codehaus.org/display/PICO/Good+Citizen
 
+Is recommended that you use the PMD plugin in eclipse:
+http://pmd.sourceforge.net/
+http://pmd.sourceforge.net/eclipse/
+
 ==Use of mylyn in eclipse==
 
 To use mylyn and to track the kune issues from eclipse, you have to add a "Web Repository" and select "ASM (gforge" with server: http://ourproject.org. 

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/TODO	2009-05-24 18:56:49 UTC (rev 1113)
@@ -13,14 +13,13 @@
 * SHORT-TERM (URGENT)
 ** New Action class
 *** Things to support
-**** menu and toolbars separators (space, bar, expand)
-**** index position insertion (for buttons added by other plugins)
-**** menu button property change (icon, text). If we select a menu option, maybe this require a change in the menu button.
-**** confirmation of actions yes, no.... (confirmation title, text, and onNotConfirmed)
-**** tongle/push buttons with isPressed (initially and later)...
-**** position id, that is, if we have some toolbars and a list of actions, how to select which action in which toolbar.
-**** radio menu (with group) and check menu item
-
+**** [X] menu and toolbars separators (space, bar, expand)
+**** [X] index position insertion (for buttons added by other plugins)
+**** [X] menu button property change (icon, text). If we select a menu option, maybe this require a change in the menu button.
+**** [X] confirmation of actions yes, no.... (confirmation title, text, and onNotConfirmed)
+**** [X] tongle/push buttons with isPressed (initially and later)...
+**** [X] position id, that is, if we have some toolbars and a list of actions, how to select which action in which toolbar.
+**** [X] radio menu (with group) and check menu item
 ** maven-gwt problem (using another plugin from codehaus)
    mvn com.totsp.gwt:maven-googlewebtoolkit2-plugin:compile
    and so on.
@@ -129,6 +128,7 @@
 ** vjrj <v> IconHyperlink.java and IconLabel.java to gwt1.5
 
 * MID-TERM
+** TODO <v> encourage use of free formats
 ** TODO <v> study opensocial, openstack and related
    http://developer.yahoo.net/blog/archives/2008/12/the_open_stack.html
 ** TODO <v> Use of command key ⌘ for Mac shortcuts

Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionMap.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionMap.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionMap.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -1,194 +0,0 @@
-/* ActionMap.java --
-   Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package org.ourproject.kune.platf.client.actions;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Maps arbitrary keys (usually Strings) to {@link Action} instances. This is
- * used in combination with {@link InputMap}s.
- * 
- * If a component receives an input event, this is looked up in the component's
- * <code>InputMap</code>. The result is an object which serves as a key to the
- * components <code>ActionMap</code>. Finally the <code>Action</code> that is
- * stored is executed.
- * 
- * @author Andrew Selkirk
- * @author Adapted version for GWT (C) The kune development team
- * @author Michael Koch
- */
-public class ActionMap {
-
-    /**
-     * actionMap
-     */
-    private final Map<Object, Action> actionMap = new HashMap<Object, Action>();
-
-    /**
-     * parent
-     */
-    private ActionMap parent;
-
-    /**
-     * Creates a new <code>ActionMap</code> instance.
-     */
-    public ActionMap() {
-        // Nothing to do here.
-    }
-
-    /**
-     * Returns all keys of entries in this <code>ActionMap</code> and all its
-     * parents.
-     * 
-     * @return an array of keys
-     */
-    // @PMD:REVIEWED:ReturnEmptyArrayRatherThanNull: by vjrj on 21/05/09 15:03
-    public Object[] allKeys() {
-        Set<Object> set = new HashSet<Object>();
-
-        if (parent != null) {
-            set.addAll(Arrays.asList(parent.allKeys()));
-        }
-
-        set.addAll(actionMap.keySet());
-        if (set.size() != 0) {
-            return set.toArray();
-        }
-        return null;
-    }
-
-    /**
-     * Clears the <code>ActionMap</code>.
-     */
-    public void clear() {
-        actionMap.clear();
-    }
-
-    /**
-     * Returns an action associated with an object.
-     * 
-     * @param key
-     *            the key of the enty
-     * 
-     * @return the action associated with key, may be null
-     */
-    public Action get(final Object key) {
-        Object result = actionMap.get(key);
-
-        if (result == null && parent != null) {
-            result = parent.get(key);
-        }
-
-        return (Action) result;
-    }
-
-    /**
-     * Returns the parent of this <code>ActionMap</code>.
-     * 
-     * @return the parent, may be null.
-     */
-    public ActionMap getParent() {
-        return parent;
-    }
-
-    /**
-     * Returns all keys of entries in this <code>ActionMap</code>.
-     * 
-     * @return an array of keys
-     */
-    // @PMD:REVIEWED:ReturnEmptyArrayRatherThanNull: by vjrj on 21/05/09 15:03
-    public Object[] keys() {
-        if (size() != 0) {
-            return actionMap.keySet().toArray();
-        }
-        return null;
-    }
-
-    /**
-     * Puts a new <code>Action</code> into the <code>ActionMap</code>. If action
-     * is null an existing entry will be removed.
-     * 
-     * @param key
-     *            the key for the entry
-     * @param action
-     *            the action.
-     */
-    public void put(final Object key, final Action action) {
-        if (action == null) {
-            actionMap.remove(key);
-        } else {
-            actionMap.put(key, action);
-        }
-    }
-
-    /**
-     * Remove an entry from the <code>ActionMap</code>.
-     * 
-     * @param key
-     *            the key of the entry to remove
-     */
-    public void remove(final Object key) {
-        actionMap.remove(key);
-    }
-
-    /**
-     * Sets a parent for this <code>ActionMap</code>.
-     * 
-     * @param parentMap
-     *            the new parent
-     */
-    public void setParent(final ActionMap parentMap) {
-        if (parentMap != this) {
-            parent = parentMap;
-        }
-    }
-
-    /**
-     * Returns the number of entries in this <code>ActionMap</code>.
-     * 
-     * @return the number of entries
-     */
-    public int size() {
-        return actionMap.size();
-    }
-
-}

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -85,10 +85,10 @@
      * @return An array of keys (may be <code>null</code> or have zero length).
      */
     public KeyStroke[] allKeys() {
-        Set<KeyStroke> set = new HashSet<KeyStroke>();
+        final Set<KeyStroke> set = new HashSet<KeyStroke>();
 
         if (parent != null) {
-            KeyStroke[] parentKeys = parent.allKeys();
+            final KeyStroke[] parentKeys = parent.allKeys();
             if (parentKeys != null) {
                 set.addAll(Arrays.asList(parentKeys));
             }
@@ -96,10 +96,10 @@
         if (inputMap != null) {
             set.addAll(inputMap.keySet());
         }
-        if (set.size() == 0) {
+        if (set.isEmpty()) {
             return null;
         }
-        KeyStroke[] array = new KeyStroke[set.size()];
+        final KeyStroke[] array = new KeyStroke[set.size()];
         return set.toArray(array);
     }
 
@@ -122,8 +122,8 @@
      * @return The binding associated with the specified keystroke (or
      *         <code>null</code>).
      */
-    public Object get(final KeyStroke keystroke) {
-        Object result = null;
+    public Action get(final KeyStroke keystroke) {
+        Action result = null;
         if (inputMap != null) {
             result = inputMap.get(keystroke);
         }
@@ -161,7 +161,7 @@
     // @PMD:REVIEWED:ReturnEmptyArrayRatherThanNull: by vjrj on 21/05/09 15:33
     public KeyStroke[] keys() {
         if (inputMap != null) {
-            KeyStroke[] array = new KeyStroke[size()];
+            final KeyStroke[] array = new KeyStroke[size()];
             return inputMap.keySet().toArray(array);
         }
         return null;

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButton.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButton.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -1,59 +1,33 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
-import org.ourproject.kune.platf.client.actions.Action;
 import org.ourproject.kune.platf.client.actions.ActionEvent;
-import org.ourproject.kune.platf.client.actions.PropertyChangeEvent;
-import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
 import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
 
 import com.google.gwt.libideas.resources.client.ImageResource;
-import com.google.gwt.user.client.ui.Composite;
 import com.gwtext.client.core.EventObject;
 import com.gwtext.client.widgets.Button;
 import com.gwtext.client.widgets.event.ButtonListenerAdapter;
 
-public abstract class AbstractButton extends Composite {
+public abstract class AbstractButton extends AbstractGuiItem {
 
-    private Action action;
-    private final Button button;
+    private transient final Button button;
 
-    /**
-     * Listener the button uses to receive PropertyChangeEvents from its Action.
-     */
-    PropertyChangeListener actionPropertyChangeListener;
-
-    public AbstractButton() {
+    public AbstractButton(final ButtonDescriptor buttonDescriptor) {
+        super();
         button = new Button();
         initWidget(button);
         button.addListener(new ButtonListenerAdapter() {
             @Override
-            public void onClick(final Button button, final EventObject e) {
+            public void onClick(final Button button, final EventObject event) {
                 if (action != null) {
-                    action.actionPerformed(new ActionEvent(button, e.getBrowserEvent()));
+                    action.actionPerformed(new ActionEvent(button, event.getBrowserEvent()));
                 }
             }
         });
+        setAction(buttonDescriptor.action);
     }
 
-    public void setAction(final Action a) {
-        if (action != null) {
-            action.removePropertyChangeListener(actionPropertyChangeListener);
-            // removeActionListener(action);
-            if (actionPropertyChangeListener != null) {
-                action.removePropertyChangeListener(actionPropertyChangeListener);
-                actionPropertyChangeListener = null;
-            }
-        }
-
-        action = a;
-        configurePropertiesFromAction(action);
-        if (action != null) {
-            actionPropertyChangeListener = createActionPropertyChangeListener(a);
-            action.addPropertyChangeListener(actionPropertyChangeListener);
-            // addActionListener(action);
-        }
-    }
-
+    @Override
     public void setEnabled(final boolean enabled) {
         if (enabled) {
             button.enable();
@@ -62,6 +36,11 @@
         }
     }
 
+    public void setEnableToggle(final boolean enableToggle) {
+        button.setEnableToggle(enableToggle);
+    }
+
+    @Override
     public void setIcon(final ImageResource imageResource) {
         if (imageResource != null) {
             // FIXME
@@ -69,68 +48,20 @@
         }
     }
 
+    public void setPressed(final boolean pressed) {
+        if (button.isPressed() != pressed) {
+            button.toggle();
+        }
+    }
+
+    @Override
     public void setText(final String text) {
         button.setText(text);
     }
 
+    @Override
     public void setToolTipText(final String tooltip) {
         button.setTooltip(tooltip);
     }
 
-    protected void configurePropertiesFromAction(final Action a) {
-        if (a == null) {
-            setText(null);
-            setIcon(null);
-            setEnabled(true);
-            setToolTipText(null);
-        } else {
-            setText((String) (a.getValue(Action.NAME)));
-            setIcon((ImageResource) (a.getValue(Action.SMALL_ICON)));
-            setEnabled(a.isEnabled());
-            setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION)));
-            // if (a.getValue(Action.MNEMONIC_KEY) != null) {
-            // setMnemonic(((Integer)
-            // (a.getValue(Action.MNEMONIC_KEY))).intValue());
-            // }
-            // String actionCommand = (String)
-            // (a.getValue(Action.ACTION_COMMAND_KEY));
-            //
-            // // Set actionCommand to button's text by default if it is not
-            // // specified
-            // if (actionCommand != null) {
-            // setActionCommand((String)
-            // (a.getValue(Action.ACTION_COMMAND_KEY)));
-            // } else {
-            // setActionCommand(getText());
-            // }
-        }
-    }
-
-    protected PropertyChangeListener createActionPropertyChangeListener(final Action a) {
-        return new PropertyChangeListener() {
-            public void propertyChange(final PropertyChangeEvent e) {
-                Action act = (Action) (e.getSource());
-                if (e.getPropertyName().equals(Action.ENABLED)) {
-                    setEnabled(act.isEnabled());
-                } else if (e.getPropertyName().equals(Action.NAME)) {
-                    setText((String) (act.getValue(Action.NAME)));
-                } else if (e.getPropertyName().equals(Action.SMALL_ICON)) {
-                    setIcon((ImageResource) (act.getValue(Action.SMALL_ICON)));
-                } else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION)) {
-                    setToolTipText((String) (act.getValue(Action.SHORT_DESCRIPTION)));
-                }
-                // else if (e.getPropertyName().equals(Action.MNEMONIC_KEY)) {
-                // if (act.getValue(Action.MNEMONIC_KEY) != null) {
-                // setMnemonic(((Integer) (act.getValue(Action.MNEMONIC_KEY)))
-                // .intValue());
-                // } else if
-                // (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY)) {
-                // setActionCommand((String)
-                // (act.getValue(Action.ACTION_COMMAND_KEY)));
-                // }
-                // }
-            }
-        };
-    }
-
 }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,107 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.PropertyChangeEvent;
+import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
+
+import com.google.gwt.libideas.resources.client.ImageResource;
+import com.google.gwt.user.client.ui.Composite;
+
+public abstract class AbstractGuiItem extends Composite {
+
+    protected transient Action action;
+
+    /**
+     * Listener the button uses to receive PropertyChangeEvents from its Action.
+     */
+    protected transient PropertyChangeListener changeListener;
+
+    public void setAction(final Action newaction) {
+        if (action != null) {
+            action.removePropertyChangeListener(changeListener);
+            // removeActionListener(action);
+            if (changeListener != null) {
+                action.removePropertyChangeListener(changeListener);
+                // @PMD:REVIEWED:NullAssignment: by vjrj on 24/05/09 20:05
+                changeListener = null;
+            }
+        }
+
+        action = newaction;
+        configurePropertiesFromAction(action);
+        if (action != null) {
+            changeListener = createActionPropertyChangeListener(newaction);
+            action.addPropertyChangeListener(changeListener);
+            // addActionListener(action);
+        }
+    }
+
+    protected void configurePropertiesFromAction(final Action action) {
+        configurePropertiesFromActionImpl(action);
+    }
+
+    protected PropertyChangeListener createActionPropertyChangeListener(final Action action) {
+        return new PropertyChangeListener() {
+            public void propertyChange(final PropertyChangeEvent event) {
+                final Action act = (Action) (event.getSource());
+                if (event.getPropertyName().equals(Action.ENABLED)) {
+                    setEnabled(act.isEnabled());
+                } else if (event.getPropertyName().equals(Action.NAME)) {
+                    setText((String) (act.getValue(Action.NAME)));
+                } else if (event.getPropertyName().equals(Action.SMALL_ICON)) {
+                    setIcon((ImageResource) (act.getValue(Action.SMALL_ICON)));
+                } else if (event.getPropertyName().equals(Action.SHORT_DESCRIPTION)) {
+                    setToolTipText((String) (act.getValue(Action.SHORT_DESCRIPTION)));
+                }
+                // else if (e.getPropertyName().equals(Action.MNEMONIC_KEY)) {
+                // if (act.getValue(Action.MNEMONIC_KEY) != null) {
+                // setMnemonic(((Integer) (act.getValue(Action.MNEMONIC_KEY)))
+                // .intValue());
+                // } else if
+                // (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY)) {
+                // setActionCommand((String)
+                // (act.getValue(Action.ACTION_COMMAND_KEY)));
+                // }
+                // }
+            }
+        };
+    }
+
+    protected abstract void setEnabled(boolean enabled);
+
+    protected abstract void setIcon(ImageResource imageResource);
+
+    protected abstract void setText(String text);
+
+    protected abstract void setToolTipText(String text);
+
+    private void configurePropertiesFromActionImpl(final Action action) {
+        if (action == null) {
+            setText(null);
+            setIcon(null);
+            setEnabled(true);
+            setToolTipText(null);
+        } else {
+            setText((String) (action.getValue(Action.NAME)));
+            setIcon((ImageResource) (action.getValue(Action.SMALL_ICON)));
+            setEnabled(action.isEnabled());
+            setToolTipText((String) (action.getValue(Action.SHORT_DESCRIPTION)));
+            // if (a.getValue(Action.MNEMONIC_KEY) != null) {
+            // setMnemonic(((Integer)
+            // (a.getValue(Action.MNEMONIC_KEY))).intValue());
+            // }
+            // String actionCommand = (String)
+            // (a.getValue(Action.ACTION_COMMAND_KEY));
+            //
+            // // Set actionCommand to button's text by default if it is not
+            // // specified
+            // if (actionCommand != null) {
+            // setActionCommand((String)
+            // (a.getValue(Action.ACTION_COMMAND_KEY)));
+            // } else {
+            // setActionCommand(getText());
+            // }
+        }
+    }
+
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItem.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItem.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,57 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.ActionEvent;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+
+import com.google.gwt.libideas.resources.client.ImageResource;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.menu.BaseItem;
+import com.gwtext.client.widgets.menu.MenuItem;
+import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
+
+public abstract class AbstractMenuItem extends AbstractGuiItem {
+
+    private transient final MenuItem item;
+
+    public AbstractMenuItem(final MenuItemDescriptor descriptor) {
+        super();
+        item = new MenuItem();
+        initWidget(item);
+        item.addListener(new BaseItemListenerAdapter() {
+            @Override
+            public void onClick(final BaseItem item, final EventObject event) {
+                if (action != null) {
+                    action.actionPerformed(new ActionEvent(item, event.getBrowserEvent()));
+                }
+            }
+        });
+        setAction(descriptor.action);
+    }
+
+    @Override
+    protected void setEnabled(final boolean enabled) {
+        if (enabled) {
+            item.enable();
+        } else {
+            item.disable();
+        }
+    }
+
+    @Override
+    protected void setIcon(final ImageResource imageResource) {
+        if (imageResource != null) {
+            // FIXME
+            item.setIconCls(RTEImgResources.SUFFIX + imageResource.getName());
+        }
+    }
+
+    @Override
+    protected void setText(final String text) {
+        item.setText(text);
+    }
+
+    @Override
+    protected void setToolTipText(final String text) {
+        item.setTitle(text);
+    }
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparator.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparator.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparator.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,16 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
+
+public class AbstractSeparator extends AbstractUIActionDescriptor {
+
+    public AbstractSeparator() {
+        super(new AbstractAction() {
+            public void actionPerformed(final ActionEvent event) {
+                // No action
+            }
+        });
+    }
+
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIActionDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIActionDescriptor.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIActionDescriptor.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,138 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class AbstractUIActionDescriptor.
+ */
+public abstract class AbstractUIActionDescriptor {
+
+    /** The action. */
+    protected transient AbstractAction action;
+
+    /** The position where the item will be inserted. */
+    private int position;
+
+    /** If the action must be confirmed. */
+    private boolean confirmRequired;
+
+    /** The confirmation dialog title. */
+    private String confirmationTitle;
+
+    /** The confirmation dialog text. */
+    private String confirmationText;
+
+    /** The item location. */
+    private String location;
+
+    /**
+     * Instantiates a new abstract ui action descriptor. This is used for
+     * describe UI button, menus, menu items and so on
+     * 
+     * @param action
+     *            the action
+     */
+    public AbstractUIActionDescriptor(final AbstractAction action) {
+        this.action = action;
+    }
+
+    /**
+     * Gets the dialog confirmation text.
+     * 
+     * @return the confirmation text
+     */
+    public String getConfirmationText() {
+        return confirmationText;
+    }
+
+    /**
+     * Gets the dialog confirmation title.
+     * 
+     * @return the confirmation title
+     */
+    public String getConfirmationTitle() {
+        return confirmationTitle;
+    }
+
+    /**
+     * Gets the location, a string used to group actions with locations (top
+     * bar, bottom bar, user bar...).
+     * 
+     * @return the location
+     */
+    public String getLocation() {
+        return location;
+    }
+
+    /**
+     * Gets the position.
+     * 
+     * @return the position
+     */
+    public int getPosition() {
+        return position;
+    }
+
+    /**
+     * Checks if is confirm required previous to do the action.
+     * 
+     * @return true, if is confirm required
+     */
+    public boolean isConfirmRequired() {
+        return confirmRequired;
+    }
+
+    /**
+     * Sets the confirmation text.
+     * 
+     * @param confirmationText
+     *            the new confirmation text
+     */
+    public void setConfirmationText(final String confirmationText) {
+        this.confirmationText = confirmationText;
+    }
+
+    /**
+     * Sets the confirmation title.
+     * 
+     * @param confirmationTitle
+     *            the new confirmation title
+     */
+    public void setConfirmationTitle(final String confirmationTitle) {
+        this.confirmationTitle = confirmationTitle;
+    }
+
+    /**
+     * Sets the confirm required.
+     * 
+     * @param isConfirmRequired
+     *            the new confirm required
+     */
+    public void setConfirmRequired(final boolean isConfirmRequired) {
+        this.confirmRequired = isConfirmRequired;
+    }
+
+    /**
+     * If we have several toolbars, we can group with the "location" string key
+     * actions that must be in the same location (ex: top bar, bottom bar, and
+     * so on).
+     * 
+     * @param location
+     *            the new location
+     */
+    public void setLocation(final String location) {
+        this.location = location;
+    }
+
+    /**
+     * Sets the position (where the UI element will be positioned, for instance
+     * in a toolbar or in a menu).
+     * 
+     * @param position
+     *            the new position
+     */
+    public void setPosition(final int position) {
+        this.position = position;
+    }
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+public class ButtonDescriptor extends AbstractUIActionDescriptor {
+
+    public ButtonDescriptor(final AbstractAction action) {
+        super(action);
+    }
+}

Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/CheckButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/CheckButton.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/CheckButton.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -1,5 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-public class CheckButton {
-
-}

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultButton.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultButton.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -1,28 +1,10 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
-import org.ourproject.kune.platf.client.actions.Action;
 
-import com.google.gwt.libideas.resources.client.ImageResource;
-
 public class DefaultButton extends AbstractButton {
-    public DefaultButton() {
-    }
 
-    public DefaultButton(final Action action) {
-        configurePropertiesFromAction(action);
+    public DefaultButton(final ButtonDescriptor btn) {
+        super(btn);
     }
 
-    public DefaultButton(final ImageResource icon) {
-        setIcon(icon);
-    }
-
-    public DefaultButton(final String text) {
-        setText(text);
-    }
-
-    public DefaultButton(final String text, final ImageResource icon) {
-        setText(text);
-        setIcon(icon);
-    }
-
 }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuCheckItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuCheckItem.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuCheckItem.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,9 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+public class DefaultMenuCheckItem extends AbstractMenuItem {
+
+    public DefaultMenuCheckItem(final MenuCheckItemDescriptor descriptor) {
+        super(descriptor);
+    }
+
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuItem.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenuItem.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,9 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+public class DefaultMenuItem extends AbstractMenuItem {
+
+    public DefaultMenuItem(final MenuItemDescriptor descriptor) {
+        super(descriptor);
+    }
+
+}

Added: 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-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,25 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+public class MenuCheckItemDescriptor extends MenuItemDescriptor {
+    private static final String CHECKED = "checked";
+
+    protected transient boolean checked = false;
+
+    public MenuCheckItemDescriptor(final MenuDescriptor parent, final AbstractAction action) {
+        super(parent, action);
+    }
+
+    public boolean isChecked() {
+        return checked;
+    }
+
+    public void setChecked(final boolean checked) {
+        if (checked != this.checked) {
+            this.checked = checked;
+            action.putValue(CHECKED, this.checked);
+        }
+    }
+
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,23 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+public class MenuDescriptor extends AbstractUIActionDescriptor {
+
+    private static final MenuDescriptor NO_PARENT = null;
+    private transient final MenuDescriptor parent;
+
+    public MenuDescriptor(final AbstractAction action) {
+        this(NO_PARENT, action);
+    }
+
+    public MenuDescriptor(final MenuDescriptor parent, final AbstractAction action) {
+        super(action);
+        this.parent = parent;
+    }
+
+    public MenuDescriptor getParent() {
+        return parent;
+    }
+
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,17 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+public class MenuItemDescriptor extends AbstractUIActionDescriptor {
+
+    private transient final MenuDescriptor parent;
+
+    public MenuItemDescriptor(final MenuDescriptor parent, final AbstractAction action) {
+        super(action);
+        this.parent = parent;
+    }
+
+    public MenuDescriptor getParent() {
+        return parent;
+    }
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioDescriptor.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioDescriptor.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,17 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+public class MenuRadioDescriptor extends MenuCheckItemDescriptor {
+
+    private transient final String group;
+
+    public MenuRadioDescriptor(final MenuDescriptor parent, final AbstractAction action, final String group) {
+        super(parent, action);
+        this.group = group;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparator.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparator.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparator.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+// @PMD:REVIEWED:AtLeastOneConstructor: by vjrj on 24/05/09 15:59
+public class MenuSeparator extends AbstractSeparator {
+}
\ No newline at end of file

Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButton.java (from rev 1112, trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/CheckButton.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/CheckButton.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButton.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,21 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.PropertyChangeEvent;
+import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
+
+public class PushButton extends DefaultButton {
+
+    public PushButton(final PushButtonDescriptor btn) {
+        super(btn);
+        setEnableToggle(true);
+        setPressed(btn.isPushed());
+        action.addPropertyChangeListener(new PropertyChangeListener() {
+            public void propertyChange(final PropertyChangeEvent event) {
+                if (event.getPropertyName().equals(PushButtonDescriptor.PUSHED)) {
+                    setPressed(btn.isPushed());
+                }
+            }
+        });
+    }
+
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonDescriptor.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonDescriptor.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,30 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+public class PushButtonDescriptor extends ButtonDescriptor {
+
+    public static final String PUSHED = "pushed";
+
+    protected transient boolean pushed = false;
+
+    public PushButtonDescriptor(final AbstractAction action) {
+        super(action);
+    }
+
+    public PushButtonDescriptor(final PushButtonDescriptor button) {
+        super(button.action);
+        pushed = button.pushed;
+    }
+
+    public boolean isPushed() {
+        return pushed;
+    }
+
+    public void setPushed(final boolean pushed) {
+        if (pushed != this.pushed) {
+            this.pushed = pushed;
+            action.putValue(PUSHED, this.pushed);
+        }
+    }
+}

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -8,9 +8,10 @@
 
 import com.google.gwt.user.client.Timer;
 
-public class TestButton extends DefaultButton {
+public class TestButton {
     public class NotiAction extends AbstractAction {
         public NotiAction() {
+            super();
             super.putValue(Action.NAME, "test");
             super.putValue(Action.SHORT_DESCRIPTION, "test button");
         }
@@ -21,24 +22,26 @@
             }
             NotifyUser.info("Button clicked");
         }
-
-        @Override
-        public boolean isEnabled() {
-            return super.isEnabled();
-        }
     }
 
-    public TestButton(final WorkspaceSkeleton ws) {
-        super();
-        ws.getEntityWorkspace().getBottomTitle().add(this);
+    public TestButton(final WorkspaceSkeleton wksp) {
         final NotiAction noti = new NotiAction();
-        super.setAction(noti);
+
+        final PushButtonDescriptor descriptor = new PushButtonDescriptor(noti);
+
+        final DefaultButton btn = new DefaultButton(descriptor);
+
+        wksp.getEntityWorkspace().getBottomTitle().add(btn);
         new Timer() {
             @Override
             public void run() {
                 noti.putValue(Action.NAME, "test2");
                 noti.putValue(Action.SHORT_DESCRIPTION, "test2 button");
+                descriptor.setPushed(false);
             }
-        }.schedule(5000);
+        }.schedule(10000);
+
+        descriptor.setPushed(true);
+
     }
 }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparator.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparator.java	2009-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparator.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -0,0 +1,20 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+public class ToolbarSeparator extends AbstractSeparator {
+
+    public enum Type {
+        spacer, separator, fill
+    }
+
+    private transient final Type type;
+
+    public ToolbarSeparator(final Type type) {
+        super();
+        this.type = type;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+}

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-05-21 18:31:14 UTC (rev 1112)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java	2009-05-24 18:56:49 UTC (rev 1113)
@@ -258,10 +258,6 @@
             public Application create() {
                 return new ApplicationDefault($(Session.class));
             }
-
-            @Override
-            public void onAfterCreated(final Application instance) {
-            }
         });
 
         register(Singleton.class, new Factory<DeferredCommandWrapper>(DeferredCommandWrapper.class) {
@@ -338,8 +334,8 @@
         register(NoDecoration.class, new Factory<RTEditor>(RTEditor.class) {
             @Override
             public RTEditor create() {
-                RTEActionTopToolbar topBar = $(RTEActionTopToolbar.class);
-                RTEActionSndToolbar sndBar = $(RTEActionSndToolbar.class);
+                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),
@@ -352,10 +348,10 @@
         }, new Factory<RTESavingEditor>(RTESavingEditor.class) {
             @Override
             public RTESavingEditor create() {
-                RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditor.class), true,
+                final RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditor.class), true,
                         $(I18nTranslationService.class), $(StateManager.class), $(DeferredCommandWrapper.class),
                         $(RTEImgResources.class), $(TimerWrapper.class));
-                RTESavingEditorPanel panel = new RTESavingEditorPanel();
+                final RTESavingEditorPanel panel = new RTESavingEditorPanel();
                 presenter.init(panel);
                 return presenter;
             }
@@ -378,7 +374,7 @@
         register(Singleton.class, new Factory<RTEImgResources>(RTEImgResources.class) {
             @Override
             public RTEImgResources create() {
-                RTEImgResources instance = GWT.create(RTEImgResources.class);
+                final RTEImgResources instance = GWT.create(RTEImgResources.class);
                 StyleInjector.injectStylesheet(instance.css().getText());
                 return instance;
             }




More information about the kune-commits mailing list