Added logoff option to username menu
authorChristos Stathis <chstath@ebs.gr>
Wed, 5 Oct 2011 15:15:43 +0000 (18:15 +0300)
committerChristos Stathis <chstath@ebs.gr>
Wed, 5 Oct 2011 15:15:43 +0000 (18:15 +0300)
src/gr/grnet/pithos/web/client/Pithos.java
src/gr/grnet/pithos/web/client/TopPanel.java

index 5e2e59f..24a39b6 100644 (file)
@@ -1112,4 +1112,10 @@ public class Pithos implements EntryPoint, ResizeHandler {
                        }
                });
        }
+
+       public void logoff() {
+        Configuration conf = (Configuration) GWT.create(Configuration.class);
+               Cookies.removeCookie(conf.authCookie());
+               Window.Location.assign(Window.Location.getHost());
+       }
 }
index 131f062..21341c7 100644 (file)
@@ -35,6 +35,8 @@
 package gr.grnet.pithos.web.client;
 
 import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.Cookies;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.HTML;
@@ -54,7 +56,7 @@ public class TopPanel extends Composite {
         */
        public static final boolean DONE = false;
 
-    private Pithos app;
+    Pithos app;
 
        /**
         * An image bundle for this widgets images.
@@ -83,9 +85,19 @@ public class TopPanel extends Composite {
                outer.add(logos);
 
         MenuBar username = new MenuBar();
+//        username.setWidth("120px");
         username.setStyleName("pithos-usernameMenu");
-        MenuItem userItem = new MenuItem(_app.getUsername(), new MenuBar(true));
+        MenuBar userItemMenu = new MenuBar(true);
+        userItemMenu.addItem(new MenuItem("Log off", new Command() {
+                       
+                       @Override
+                       public void execute() {
+                               app.logoff();
+                       }
+               }));
+        MenuItem userItem = new MenuItem(_app.getUsername(), userItemMenu);
         userItem.addStyleName("pithos-usernameMenu");
+        userItem.setWidth("68px");
         username.addItem(userItem);
         outer.add(username);
                outer.setCellHorizontalAlignment(username, HasHorizontalAlignment.ALIGN_RIGHT);