Author: dongxu
Date: Thu Sep 12 04:17:07 2013
New Revision: 1522322

URL: http://svn.apache.org/r1522322
Log:
add style to popup menu

Added:
    
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/RightCellTree.java
Modified:
    
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java
    
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssFolderListView.css

Modified: 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java
URL: 
http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java?rev=1522322&r1=1522321&r2=1522322&view=diff
==============================================================================
--- 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java
 (original)
+++ 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/FolderListView.java
 Thu Sep 12 04:17:07 2013
@@ -224,7 +224,6 @@ import org.apache.hupa.client.place.Comp
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.place.shared.Place;
-import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.cellview.client.CellTree;
@@ -237,7 +236,7 @@ import com.google.inject.assistedinject.
 public class FolderListView extends Composite implements
                FolderListActivity.Displayable {
        @UiField SimplePanel thisView;
-       private FolderCellTree cellTree;
+       private RightCellTree cellTree;
        // FIXME here we can not support another cell tree, since both of their
        // style
        // would not be cleared.
@@ -255,7 +254,7 @@ public class FolderListView extends Comp
                        }
                        thisView.add(contactPanel);
                } else {
-                       cellTree = new FolderCellTree(viewModel, null, 
Resources.INSTANCE);
+                       cellTree = new RightCellTree(viewModel);
                        cellTree.setAnimationEnabled(true);
                        if (thisView.getWidget() != null
                                        && thisView.getWidget() instanceof 
HTMLPanel) {
@@ -271,17 +270,6 @@ public class FolderListView extends Comp
 >>>>>>> make compose panel left another widget rather than cell tree
        }
 
-       public interface Resources extends CellTree.Resources {
-
-               Resources INSTANCE = GWT.create(Resources.class);
-
-               @Source("res/CssFolderListView.css")
-               public CellTree.Style cellTreeStyle();
-
-               @Source("res/listicons.png")
-               public ImageResource listicons();
-       }
-
        interface FolderListUiBinder extends UiBinder<SimplePanel, 
FolderListView> {
        }
 

Added: 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/RightCellTree.java
URL: 
http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/RightCellTree.java?rev=1522322&view=auto
==============================================================================
--- 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/RightCellTree.java
 (added)
+++ 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/RightCellTree.java
 Thu Sep 12 04:17:07 2013
@@ -0,0 +1,104 @@
+package org.apache.hupa.client.ui;
+
+import com.google.gwt.core.shared.GWT;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.user.cellview.client.CellTree;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.DecoratedPopupPanel;
+import com.google.gwt.user.client.ui.MenuBar;
+import com.google.gwt.user.client.ui.MenuItem;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.view.client.TreeViewModel;
+
+/**
+ * CellTree with right click event menu drop down
+ */
+public class RightCellTree extends CellTree {
+       final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
+
+       public <T> RightCellTree(TreeViewModel viewModel, T rootValue, 
Resources resources) {
+               super(viewModel, rootValue, resources);
+               this.sinkEvents(Event.ONMOUSEUP | Event.ONDBLCLICK | 
Event.ONCONTEXTMENU);
+               MenuBar popup = new MenuBar(true);
+               MenuItem newItem = new MenuItem("New subfolder", true, 
newSubfolderCommand);
+               MenuItem markItem = new MenuItem("Mark all as read", true, 
markAllReadCommand);
+               
newItem.addStyleName(Resources.INSTANCE.cellTreeStyle().menuItem());
+               
markItem.addStyleName(Resources.INSTANCE.cellTreeStyle().menuItem());
+               popup.addItem(newItem);
+               popup.addItem(markItem);
+               popup.setVisible(true);
+               simplePopup.add(popup);
+               
simplePopup.addStyleName(Resources.INSTANCE.cellTreeStyle().popup());
+       }
+
+       public RightCellTree(FoldersTreeViewModel viewModel) {
+               this(viewModel, null, Resources.INSTANCE);
+       }
+
+       Command newSubfolderCommand = new Command() {
+               public void execute() {
+                       Window.alert("//TODO New subfolder");
+               }
+       };
+
+       Command markAllReadCommand = new Command() {
+               public void execute() {
+                       Window.alert("//TODO Mark all as read");
+               }
+       };
+
+       @Override
+       public void onBrowserEvent(Event event) {
+               GWT.log("onBrowserEvent", null);
+               event.stopPropagation(); // propagated
+               event.preventDefault();
+               super.onBrowserEvent(event);
+               switch (DOM.eventGetType(event)) {
+               case Event.ONMOUSEUP:
+                       if (DOM.eventGetButton(event) == Event.BUTTON_LEFT) {
+                               GWT.log("left clicked.", null);
+                       }
+                       if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {
+                               GWT.log("right clicked.", null);
+                               int x = DOM.eventGetClientX(event);
+                               int y = DOM.eventGetClientY(event);
+                               simplePopup.setPopupPosition(x, y);
+                               simplePopup.show();
+                       }
+                       break;
+               case Event.ONDBLCLICK:
+                       break;
+
+               case Event.ONCONTEXTMENU:
+                       GWT.log("Event.ONCONTEXTMENU", null);
+                       break;
+
+               default:
+                       break; // Do nothing
+               }
+       }
+
+       public interface RightClickHandler extends ClickHandler {
+               void onRightClick(Widget sender, Event event);
+       }
+
+       public interface Css extends Style {
+               String popup();
+               String menuItem();
+       }
+
+       public interface Resources extends CellTree.Resources {
+
+               Resources INSTANCE = GWT.create(Resources.class);
+
+               @Source("res/CssFolderListView.css")
+               public Css cellTreeStyle();
+
+               @Source("res/listicons.png")
+               public ImageResource listicons();
+       }
+}

Modified: 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssFolderListView.css
URL: 
http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssFolderListView.css?rev=1522322&r1=1522321&r2=1522322&view=diff
==============================================================================
--- 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssFolderListView.css
 (original)
+++ 
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssFolderListView.css
 Thu Sep 12 04:17:07 2013
@@ -82,4 +82,13 @@ div:focus { outline: none; }
 }
 
 .cellTreeShowMoreButton {
+}
+
+.popup{
+       border:1px solid black;
+       background-color:rgba(250, 250, 250, 0.5);
+}
+
+.menuItem{
+       cursor: pointer;
 }
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to