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

vjrj vjrj at ourproject.org
Tue May 26 18:04:51 CEST 2009


Author: vjrj
Date: 2009-05-26 18:04:44 +0200 (Tue, 26 May 2009)
New Revision: 1114

Added:
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenu.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparatorDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIElement.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BaseAction.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenu.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultSubMenu.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioItemDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparatorDescriptor.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorDescriptor.java
Removed:
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparator.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
Modified:
   trunk/
   trunk/TODO
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButton.java
   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/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/DefaultButton.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/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/TestButton.java
   trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparator.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java
Log:
Incomplete - task New Action class (adapted from Swing) to replace ActionDescription


Property changes on: trunk
___________________________________________________________________
Name: svn:ignore
   - www-test
screenlog.0
bin
client
public
target
Main-compile
bin
.settings
.gwt-cache
repository
derby.log
star-yellow-grey.png
run.sh
tomcat
.classpath
gwt-out
synccss.sh
.externalToolBuilders
.project
.wtpmodules
www
testRepository
kune-OLD-jcr
KuneApp.launch
KuneApp NOSERVER.launch
old_src
org.ourproject.kune.app.Kune
org.ourproject.kune.iml
org.ourproject.kune.ipr
org.ourproject.kune.iws
nbproject
hibernate.reveng.xml
.gwt-tmp
target-eclipse
.checkstyle

   + .pmd
www-test
screenlog.0
bin
client
public
target
Main-compile
bin
.settings
.gwt-cache
repository
derby.log
star-yellow-grey.png
run.sh
tomcat
.classpath
gwt-out
synccss.sh
.externalToolBuilders
.project
.wtpmodules
www
testRepository
kune-OLD-jcr
KuneApp.launch
KuneApp NOSERVER.launch
old_src
org.ourproject.kune.app.Kune
org.ourproject.kune.iml
org.ourproject.kune.ipr
org.ourproject.kune.iws
nbproject
hibernate.reveng.xml
.gwt-tmp
target-eclipse
.checkstyle


Modified: trunk/TODO
===================================================================
--- trunk/TODO	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/TODO	2009-05-26 16:04:44 UTC (rev 1114)
@@ -128,6 +128,11 @@
 ** vjrj <v> IconHyperlink.java and IconLabel.java to gwt1.5
 
 * MID-TERM
+** TODO <v> use guice 2.0
+   http://google-code-updates.blogspot.com/2009/05/guice-deuce.html
+   http://code.google.com/docreader/#p=google-guice&s=google-guice
+   http://groups.google.com/group/warp-core
+   when warp-persist also support it
 ** 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

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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButton.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -13,8 +13,13 @@
     private transient final Button button;
 
     public AbstractButton(final ButtonDescriptor buttonDescriptor) {
+        this(buttonDescriptor, false);
+    }
+
+    public AbstractButton(final ButtonDescriptor buttonDescriptor, final boolean enableTongle) {
         super();
         button = new Button();
+        button.setEnableToggle(enableTongle);
         initWidget(button);
         button.addListener(new ButtonListenerAdapter() {
             @Override
@@ -36,10 +41,6 @@
         }
     }
 
-    public void setEnableToggle(final boolean enableToggle) {
-        button.setEnableToggle(enableToggle);
-    }
-
     @Override
     public void setIcon(final ImageResource imageResource) {
         if (imageResource != null) {

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,5 +1,6 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
+import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.Action;
 import org.ourproject.kune.platf.client.actions.PropertyChangeEvent;
 import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
@@ -7,7 +8,7 @@
 import com.google.gwt.libideas.resources.client.ImageResource;
 import com.google.gwt.user.client.ui.Composite;
 
-public abstract class AbstractGuiItem extends Composite {
+public abstract class AbstractGuiItem extends Composite implements View {
 
     protected transient Action action;
 

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenu.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenu.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenu.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,28 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import com.gwtext.client.widgets.menu.BaseItem;
+import com.gwtext.client.widgets.menu.Menu;
+
+public abstract class AbstractMenu extends AbstractGuiItem {
+
+    protected final transient Menu menu;
+
+    public AbstractMenu() {
+        super();
+        menu = new Menu();
+        menu.setShadow(true);
+    }
+
+    public void add(final BaseItem item) {
+        menu.addItem(item);
+    }
+
+    public void addSeparator() {
+        menu.addSeparator();
+    }
+
+    public void insert(final int position, final BaseItem item) {
+        menu.insert(position, item);
+    }
+
+}
\ No newline at end of file

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItem.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -4,31 +4,48 @@
 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.Widget;
 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.CheckItem;
+import com.gwtext.client.widgets.menu.Item;
 import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
 
 public abstract class AbstractMenuItem extends AbstractGuiItem {
 
-    private transient final MenuItem item;
+    private transient Item item;
 
     public AbstractMenuItem(final MenuItemDescriptor descriptor) {
         super();
-        item = new MenuItem();
-        initWidget(item);
-        item.addListener(new BaseItemListenerAdapter() {
+        if (descriptor instanceof MenuRadioItemDescriptor) {
+            final CheckItem checkItem = createCheckItem(descriptor);
+            checkItem.setGroup(((MenuRadioItemDescriptor) descriptor).getGroup());
+            item = checkItem;
+        } else if (descriptor instanceof MenuCheckItemDescriptor) {
+            final CheckItem checkItem = createCheckItem(descriptor);
+            item = checkItem;
+        } else {
+            item = new Item();
+        }
+        // initWidget(item);
+        final BaseItemListenerAdapter clickListener = new BaseItemListenerAdapter() {
             @Override
             public void onClick(final BaseItem item, final EventObject event) {
                 if (action != null) {
                     action.actionPerformed(new ActionEvent(item, event.getBrowserEvent()));
                 }
             }
-        });
+        };
+        item.addListener(clickListener);
         setAction(descriptor.action);
     }
 
     @Override
+    protected Widget getWidget() {
+        return item;
+    }
+
+    @Override
     protected void setEnabled(final boolean enabled) {
         if (enabled) {
             item.enable();
@@ -47,11 +64,21 @@
 
     @Override
     protected void setText(final String text) {
-        item.setText(text);
+        if (text != null) {
+            item.setText(text);
+        }
     }
 
     @Override
     protected void setToolTipText(final String text) {
-        item.setTitle(text);
+        if (text != null) {
+            item.setTitle(text);
+        }
     }
+
+    private CheckItem createCheckItem(final MenuItemDescriptor descriptor) {
+        final CheckItem checkItem = new CheckItem();
+        checkItem.setChecked(((MenuCheckItemDescriptor) descriptor).isChecked());
+        return checkItem;
+    }
 }

Deleted: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparator.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,16 +0,0 @@
-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
-            }
-        });
-    }
-
-}

Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparatorDescriptor.java (from rev 1113, 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparatorDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -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 abstract class AbstractSeparatorDescriptor extends AbstractUIActionDescriptor {
+
+    public AbstractSeparatorDescriptor() {
+        super(new AbstractAction() {
+            public void actionPerformed(final ActionEvent event) {
+                // No action
+            }
+        });
+    }
+
+}

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIActionDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,13 +1,20 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
+import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 
-// TODO: Auto-generated Javadoc
 /**
  * The Class AbstractUIActionDescriptor.
  */
-public abstract class AbstractUIActionDescriptor {
+public class AbstractUIActionDescriptor {
 
+    protected static final int NO_POSITION = -1;
+    protected static final View NO_VIEW = null;
+    protected static final AbstractUIActionDescriptor NO_PARENT = new AbstractUIActionDescriptor(null);
+
+    protected transient View view;
+    protected AbstractUIActionDescriptor parent;
+
     /** The action. */
     protected transient AbstractAction action;
 
@@ -35,6 +42,8 @@
      */
     public AbstractUIActionDescriptor(final AbstractAction action) {
         this.action = action;
+        position = NO_POSITION;
+        parent = NO_PARENT;
     }
 
     /**
@@ -65,6 +74,10 @@
         return location;
     }
 
+    public AbstractUIActionDescriptor getParent() {
+        return parent;
+    }
+
     /**
      * Gets the position.
      * 
@@ -74,6 +87,14 @@
         return position;
     }
 
+    public View getView() {
+        return view;
+    }
+
+    public boolean isChild() {
+        return !parent.equals(NO_PARENT);
+    }
+
     /**
      * Checks if is confirm required previous to do the action.
      * 
@@ -125,6 +146,10 @@
         this.location = location;
     }
 
+    public void setParent(final AbstractUIActionDescriptor parent) {
+        this.parent = parent;
+    }
+
     /**
      * Sets the position (where the UI element will be positioned, for instance
      * in a toolbar or in a menu).

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIElement.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIElement.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractUIElement.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,42 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import java.util.List;
+
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.InputMap;
+import org.ourproject.kune.platf.client.actions.KeyStroke;
+
+import com.google.gwt.user.client.ui.Composite;
+
+public abstract class AbstractUIElement extends Composite {
+
+    private transient GuiActionCollection guiItems;
+    private transient InputMap inputMap;
+
+    public void add(final AbstractUIActionDescriptor descriptor) {
+        getGuiItems().add(descriptor);
+    }
+
+    public void addAction(final KeyStroke key, final Action action) {
+        getInputMap().put(key, action);
+    }
+
+    public void addAll(final List<AbstractUIActionDescriptor> moreDescriptor) {
+        getGuiItems().addAll(moreDescriptor);
+    }
+
+    public GuiActionCollection getGuiItems() {
+        if (guiItems == null) {
+            guiItems = new GuiActionCollection();
+        }
+        return guiItems;
+    }
+
+    private InputMap getInputMap() {
+        if (inputMap == null) {
+            inputMap = new InputMap();
+        }
+        return inputMap;
+    }
+
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BaseAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BaseAction.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BaseAction.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,20 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
+
+import com.google.gwt.libideas.resources.client.ImageResource;
+
+public class BaseAction extends AbstractAction {
+    public BaseAction(final String text, final String tooltip, final ImageResource icon) {
+        super();
+        super.putValue(Action.NAME, text);
+        super.putValue(Action.SHORT_DESCRIPTION, tooltip);
+        super.putValue(Action.SMALL_ICON, icon);
+    }
+
+    public void actionPerformed(final ActionEvent actionEvent) {
+        // Nothing to do
+    }
+}

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,5 +1,6 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
+import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 
 public class ButtonDescriptor extends AbstractUIActionDescriptor {
@@ -7,4 +8,13 @@
     public ButtonDescriptor(final AbstractAction action) {
         super(action);
     }
+
+    @Override
+    public View getView() {
+        if (view == null) {
+            final DefaultButton defaultButton = new DefaultButton(this);
+            view = defaultButton;
+        }
+        return view;
+    }
 }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,39 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import java.util.List;
+
+import org.ourproject.kune.workspace.client.skel.Toolbar;
+
+import com.google.gwt.user.client.ui.Widget;
+
+public class ComplexToolbar extends AbstractUIElement {
+
+    private final transient Toolbar toolbar;
+
+    public ComplexToolbar() {
+        super();
+        toolbar = new Toolbar();
+        initWidget(toolbar.getPanel());
+    }
+
+    @Override
+    public void add(final AbstractUIActionDescriptor descrip) {
+        super.add(descrip);
+        addWidget(descrip);
+    }
+
+    @Override
+    public void addAll(final List<AbstractUIActionDescriptor> moreItems) {
+        super.addAll(moreItems);
+        for (AbstractUIActionDescriptor item : moreItems) {
+            addWidget(item);
+        }
+    }
+
+    private void addWidget(final AbstractUIActionDescriptor descrip) {
+        final Widget view = (Widget) descrip.getView();
+        if (!descrip.isChild()) {
+            toolbar.add(view);
+        }
+    }
+}

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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultButton.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,10 +1,12 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
-
 public class DefaultButton extends AbstractButton {
 
-    public DefaultButton(final ButtonDescriptor btn) {
-        super(btn);
+    public DefaultButton(final ButtonDescriptor buttonDescriptor) {
+        super(buttonDescriptor);
     }
 
+    public DefaultButton(final ButtonDescriptor buttonDescriptor, final boolean enableTongle) {
+        super(buttonDescriptor, enableTongle);
+    }
 }

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenu.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenu.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultMenu.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,63 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+
+import com.google.gwt.libideas.resources.client.ImageResource;
+import com.gwtext.client.widgets.ToolbarButton;
+
+public class DefaultMenu extends AbstractMenu {
+
+    // @PMD:REVIEWED:AtLeastOneConstructor: by vjrj on 26/05/09 15:56
+    public class MenuButton extends ToolbarButton implements View {
+    }
+
+    private transient final MenuButton button;
+
+    public DefaultMenu(final AbstractUIActionDescriptor descriptor) {
+        super();
+        button = new MenuButton();
+        button.setMenu(menu);
+        setAction(descriptor.action);
+        initWidget(menu);
+    }
+
+    public void add(final DefaultSubMenu submenu) {
+        menu.addItem(submenu.getMenuItem());
+    };
+
+    public MenuButton getButton() {
+        return button;
+    }
+
+    public void insert(final int position, final DefaultSubMenu submenu) {
+        menu.insert(position, submenu.getMenuItem());
+    }
+
+    @Override
+    public void setEnabled(final boolean enabled) {
+        if (enabled) {
+            button.enable();
+        } else {
+            button.disable();
+        }
+    }
+
+    @Override
+    public void setIcon(final ImageResource imageResource) {
+        if (imageResource != null) {
+            // FIXME
+            button.setIconCls(RTEImgResources.SUFFIX + imageResource.getName());
+        }
+    }
+
+    @Override
+    public void setText(final String text) {
+        button.setText(text);
+    }
+
+    @Override
+    public void setToolTipText(final String tooltip) {
+        button.setTooltip(tooltip);
+    }
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultSubMenu.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultSubMenu.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/DefaultSubMenu.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,50 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+
+import com.google.gwt.libideas.resources.client.ImageResource;
+import com.gwtext.client.widgets.menu.MenuItem;
+
+public class DefaultSubMenu extends AbstractMenu {
+
+    private transient final MenuItem item;
+
+    public DefaultSubMenu(final AbstractUIActionDescriptor descriptor) {
+        super();
+        item = new MenuItem();
+        item.setMenu(menu);
+        initWidget(menu);
+        setAction(descriptor.action);
+    }
+
+    public MenuItem getMenuItem() {
+        return item;
+    }
+
+    @Override
+    public void setEnabled(final boolean enabled) {
+        if (enabled) {
+            item.enable();
+        } else {
+            item.disable();
+        }
+    }
+
+    @Override
+    public void setIcon(final ImageResource imageResource) {
+        if (imageResource != null) {
+            // FIXME
+            item.setIconCls(RTEImgResources.SUFFIX + imageResource.getName());
+        }
+    }
+
+    @Override
+    public void setText(final String text) {
+        item.setText(text);
+    }
+
+    @Override
+    public void setToolTipText(final String tooltip) {
+        item.setTitle(tooltip);
+    }
+}

Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import java.util.ArrayList;
+
+// @PMD:REVIEWED:AtLeastOneConstructor: by vjrj on 26/05/09 12:31
+public class GuiActionCollection extends ArrayList<AbstractUIActionDescriptor> {
+
+    private static final long serialVersionUID = 6759723760404227737L;
+
+}

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-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -5,7 +5,7 @@
 public class MenuCheckItemDescriptor extends MenuItemDescriptor {
     private static final String CHECKED = "checked";
 
-    protected transient boolean checked = false;
+    private transient boolean checked = false;
 
     public MenuCheckItemDescriptor(final MenuDescriptor parent, final AbstractAction action) {
         super(parent, action);

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,23 +1,56 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
+import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 
+import com.google.gwt.libideas.resources.client.ImageResource;
+
 public class MenuDescriptor extends AbstractUIActionDescriptor {
 
-    private static final MenuDescriptor NO_PARENT = null;
-    private transient final MenuDescriptor parent;
+    private transient AbstractMenu menu;
 
     public MenuDescriptor(final AbstractAction action) {
         this(NO_PARENT, action);
     }
 
-    public MenuDescriptor(final MenuDescriptor parent, final AbstractAction action) {
+    public MenuDescriptor(final AbstractUIActionDescriptor parent, final AbstractAction action) {
         super(action);
-        this.parent = parent;
+        setParent(parent);
     }
 
-    public MenuDescriptor getParent() {
-        return parent;
+    public MenuDescriptor(final String text, final String tooltip, final ImageResource icon) {
+        this(new BaseAction(text, tooltip, icon));
     }
 
+    public AbstractMenu getMenu() {
+        createIfNeeded();
+        return menu;
+    }
+
+    @Override
+    public View getView() {
+        createIfNeeded();
+        return view;
+    }
+
+    private void createIfNeeded() {
+        if (view == NO_VIEW) {
+            if (isChild()) {
+                final DefaultSubMenu submenu = new DefaultSubMenu(this);
+                final AbstractMenu parentMenu = ((MenuDescriptor) parent).getMenu();
+                final int position = getPosition();
+                if (position == NO_POSITION) {
+                    parentMenu.add(submenu.getMenuItem());
+                } else {
+                    parentMenu.insert(position, submenu.getMenuItem());
+                }
+                view = menu = submenu;
+            } else {
+                // Is main parent menu
+                final DefaultMenu newMenu = new DefaultMenu(this);
+                menu = newMenu;
+                view = newMenu.getButton();
+            }
+        }
+    }
 }

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,17 +1,32 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
+import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 
+import com.gwtext.client.widgets.menu.Item;
+
 public class MenuItemDescriptor extends AbstractUIActionDescriptor {
 
-    private transient final MenuDescriptor parent;
-
     public MenuItemDescriptor(final MenuDescriptor parent, final AbstractAction action) {
         super(action);
-        this.parent = parent;
+        setParent(parent);
     }
 
-    public MenuDescriptor getParent() {
-        return parent;
+    @Override
+    public View getView() {
+        if (view == NO_VIEW) {
+            final DefaultMenuItem item = new DefaultMenuItem(this);
+            final int position = getPosition();
+            final Item menuItem = (Item) item.getWidget();
+            final AbstractMenu menu = ((MenuDescriptor) parent).getMenu();
+            if (position == NO_POSITION) {
+                menu.add(menuItem);
+            } else {
+                menu.insert(position, menuItem);
+            }
+            view = item;
+        }
+        return view;
     }
+
 }

Deleted: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,17 +0,0 @@
-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;
-    }
-}

Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioItemDescriptor.java (from rev 1113, 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuRadioItemDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,17 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+
+public class MenuRadioItemDescriptor extends MenuCheckItemDescriptor {
+
+    private transient final String group;
+
+    public MenuRadioItemDescriptor(final MenuDescriptor parent, final AbstractAction action, final String group) {
+        super(parent, action);
+        this.group = group;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+}

Deleted: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparator.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,5 +0,0 @@
-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/MenuSeparatorDescriptor.java (from rev 1113, 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparatorDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,21 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.View;
+
+public class MenuSeparatorDescriptor extends AbstractSeparatorDescriptor {
+
+    public MenuSeparatorDescriptor(final MenuDescriptor parent) {
+        super();
+        setParent(parent);
+    }
+
+    @Override
+    public View getView() {
+        if (view == NO_VIEW) {
+            final AbstractMenu menu = ((MenuDescriptor) getParent()).getMenu();
+            menu.addSeparator();
+            view = menu;
+        }
+        return view;
+    }
+}
\ No newline at end of file

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButton.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButton.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -6,8 +6,7 @@
 public class PushButton extends DefaultButton {
 
     public PushButton(final PushButtonDescriptor btn) {
-        super(btn);
-        setEnableToggle(true);
+        super(btn, true);
         setPressed(btn.isPushed());
         action.addPropertyChangeListener(new PropertyChangeListener() {
             public void propertyChange(final PropertyChangeEvent event) {

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,5 +1,6 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
+import org.ourproject.kune.platf.client.View;
 import org.ourproject.kune.platf.client.actions.AbstractAction;
 
 public class PushButtonDescriptor extends ButtonDescriptor {
@@ -17,6 +18,15 @@
         pushed = button.pushed;
     }
 
+    @Override
+    public View getView() {
+        if (view == null) {
+            final PushButton button = new PushButton(this);
+            view = button;
+        }
+        return view;
+    }
+
     public boolean isPushed() {
         return 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -27,21 +27,45 @@
     public TestButton(final WorkspaceSkeleton wksp) {
         final NotiAction noti = new NotiAction();
 
-        final PushButtonDescriptor descriptor = new PushButtonDescriptor(noti);
+        final PushButtonDescriptor btn = new PushButtonDescriptor(noti);
 
-        final DefaultButton btn = new DefaultButton(descriptor);
+        final MenuDescriptor menu = new MenuDescriptor("File", "File menu tooltip", null);
+        final MenuItemDescriptor item = new MenuItemDescriptor(menu, noti);
+        final MenuItemDescriptor item2 = new MenuItemDescriptor(menu, noti);
+        final MenuDescriptor submenu = new MenuDescriptor("Options", "submenu tooltip", null);
+        submenu.setParent(menu);
+        final MenuItemDescriptor item3 = new MenuItemDescriptor(submenu, noti);
+        final MenuCheckItemDescriptor item4 = new MenuCheckItemDescriptor(submenu, noti);
+        item4.setChecked(true);
+        final MenuRadioItemDescriptor item5 = new MenuRadioItemDescriptor(submenu, noti, "new");
+        final MenuRadioItemDescriptor item6 = new MenuRadioItemDescriptor(submenu, noti, "new");
+        item5.setChecked(true);
+        final ComplexToolbar toolbar = new ComplexToolbar();
 
-        wksp.getEntityWorkspace().getBottomTitle().add(btn);
+        toolbar.add(btn);
+        toolbar.add(menu);
+        toolbar.add(item);
+        toolbar.add(new MenuSeparatorDescriptor(menu));
+        toolbar.add(item2);
+        toolbar.add(item3);
+        toolbar.add(item4);
+        toolbar.add(new MenuSeparatorDescriptor(submenu));
+        toolbar.add(item5);
+        toolbar.add(item6);
+        // toolbar.add(new ToolbarSeparatorDescriptor(Type.separator));
+
+        wksp.getEntityWorkspace().getBottomTitle().add(toolbar);
+
         new Timer() {
             @Override
             public void run() {
                 noti.putValue(Action.NAME, "test2");
                 noti.putValue(Action.SHORT_DESCRIPTION, "test2 button");
-                descriptor.setPushed(false);
+                btn.setPushed(false);
             }
         }.schedule(10000);
 
-        descriptor.setPushed(true);
+        btn.setPushed(true);
 
     }
 }

Modified: 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparator.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -1,20 +1,7 @@
 package org.ourproject.kune.platf.client.actions.ui;
 
-public class ToolbarSeparator extends AbstractSeparator {
+public class ToolbarSeparator {
 
-    public enum Type {
-        spacer, separator, fill
+    public ToolbarSeparator(final ToolbarSeparatorDescriptor descriptor) {
     }
-
-    private transient final Type type;
-
-    public ToolbarSeparator(final Type type) {
-        super();
-        this.type = type;
-    }
-
-    public Type getType() {
-        return type;
-    }
-
 }

Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorDescriptor.java (from rev 1113, 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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorDescriptor.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -0,0 +1,28 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.View;
+
+public class ToolbarSeparatorDescriptor extends AbstractSeparatorDescriptor {
+
+    public enum Type {
+        spacer, separator, fill
+    }
+
+    private transient final Type type;
+
+    public ToolbarSeparatorDescriptor(final Type type) {
+        super();
+        // setParent(parent);
+        this.type = type;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    @Override
+    public View getView() {
+        return null;
+    }
+
+}

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-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -529,7 +529,7 @@
             }
         });
 
-        //$(TestButton.class);
+        // $(TestButton.class);
 
         $(ApplicationComponentGroup.class).createAll();
         $(ToolGroup.class).createAll();

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java	2009-05-24 18:56:49 UTC (rev 1113)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java	2009-05-26 16:04:44 UTC (rev 1114)
@@ -27,15 +27,16 @@
 import com.gwtext.client.widgets.Panel;
 
 public class Toolbar {
-    private final Panel container;
-    private final HorizontalPanel childPanel;
+    private static final String _100PC = "100%";
+    private transient final Panel container;
+    private transient final HorizontalPanel childPanel;
 
     public Toolbar() {
         container = new Panel();
         container.setBorder(false);
         container.setBodyBorder(false);
         container.setHeight(WorkspaceSkeleton.DEF_TOOLBAR_HEIGHT);
-        container.setWidth("100%");
+        container.setWidth(_100PC);
         container.setHeader(false);
         container.setBaseCls("x-toolbar");
         container.addClass("x-panel");
@@ -46,8 +47,8 @@
     public void add(final Widget widget) {
         childPanel.add(widget);
         if (widget instanceof SimpleToolbar) {
-            widget.setWidth("100%");
-            childPanel.setCellWidth(widget, "100%");
+            widget.setWidth(_100PC);
+            childPanel.setCellWidth(widget, _100PC);
         }
         doLayoutIfNeeded();
     }
@@ -55,7 +56,7 @@
     public Widget addFill() {
         final Label emptyLabel = new Label("");
         this.add(emptyLabel);
-        childPanel.setCellWidth(emptyLabel, "100%");
+        childPanel.setCellWidth(emptyLabel, _100PC);
         return emptyLabel;
     }
 




More information about the kune-commits mailing list