Merge branch 'release-0.15' into debian-release-0.15
[pithos-web-client] / src / gr / grnet / pithos / web / client / TopPanel.java
index 9c4e1ec..6dd0bde 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2013 GRNET S.A. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or
  * without modification, are permitted provided that the following
  */
 package gr.grnet.pithos.web.client;
 
+import com.google.gwt.i18n.client.Dictionary;
 import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
-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;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.MenuItem;
+import com.google.gwt.user.client.ui.*;
 
 /**
  * The top panel, which contains the menu bar icons and the user name.
  */
 public class TopPanel extends Composite {
 
-       /**
-        * A constant that denotes the completion of an IncrementalCommand.
-        */
-       public static final boolean DONE = false;
+    /**
+     * A constant that denotes the completion of an IncrementalCommand.
+     */
+    public static final boolean DONE = false;
 
     Pithos app;
 
-       /**
-        * An image bundle for this widgets images.
-        */
-       public interface Images extends FilePropertiesDialog.Images {
+    /**
+     * An image bundle for this widgets images.
+     */
+    public interface Images extends FilePermissionsDialog.Images {
+        @Source("gr/grnet/pithos/resources/pithos2-logo.png")
+        ImageResource pithosLogo();
 
-               @Source("gr/grnet/pithos/resources/pithos2-logo.png")
-               ImageResource pithosLogo();
-               
-               @Source("gr/grnet/pithos/resources/desc.png")
-               ImageResource downArrow();
-       }
+        @Source("gr/grnet/pithos/resources/desc.png")
+        ImageResource downArrow();
+    }
 
-       /**
-        * The constructor for the top panel.
-        *
-        * @param images the supplied images
-        */
-       public TopPanel(Pithos _app, final Images images) {
+    /**
+     * The constructor for the top panel.
+     *
+     * @param images the supplied images
+     */
+    public TopPanel(Pithos _app, final Images images) {
         this.app = _app;
-               HorizontalPanel outer = new HorizontalPanel();
-               outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
+        HorizontalPanel outer = new HorizontalPanel();
+        outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
 
-               outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
-               outer.setStyleName("pithos-topPanel");
+        outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+        outer.setStyleName("pithos-topPanel");
 
-               HTML logos = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.pithosLogo()).getHTML() + "</td></tr></table>");
-               outer.add(logos);
+        HorizontalPanel inner = new HorizontalPanel();
+        inner.setWidth("75%");
+        inner.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
 
-        MenuBar username = new MenuBar();
-        username.setStyleName("pithos-usernameMenu");
-        username.setAutoOpen(true);
-        
-        MenuBar userItemMenu = new MenuBar(true);
-        userItemMenu.addItem(new MenuItem("API token", new Command() {
-                       
-                       @Override
-                       public void execute() {
-                               new CredentialsDialog(app, images).center();
-                       }
-               }));
-        userItemMenu.addItem(new MenuItem("Log off", new Command() {
-                       
-                       @Override
-                       public void execute() {
-                               app.logoff();
-                       }
-               }));
-
-        SafeHtmlBuilder sb = new SafeHtmlBuilder();
-        sb.append(SafeHtmlUtils.fromSafeConstant(_app.getUsername()));
-        sb.appendHtmlConstant(AbstractImagePrototype.create(images.downArrow()).getHTML());
-        MenuItem userItem = new MenuItem(_app.getUsername(), userItemMenu);
-//        userItem.setWidth("68px");
-        username.addItem(userItem);
-        outer.add(username);
-               outer.setCellHorizontalAlignment(username, HasHorizontalAlignment.ALIGN_RIGHT);
-               Image downArrow = AbstractImagePrototype.create(images.downArrow()).createImage();
-               outer.add(downArrow);
-               outer.setCellHorizontalAlignment(downArrow, HasHorizontalAlignment.ALIGN_LEFT);
-               initWidget(outer);
-       }
+        Dictionary otherProperties = Dictionary.getDictionary("otherProperties");
+        final String STORAGE_LOGO_URL = otherProperties.get("STORAGE_LOGO_URL");
+        final Image logo = new Image(STORAGE_LOGO_URL);
+        Pithos.LOG("Pithos Logo = ", logo.getUrl());
+        inner.add(logo);
+        outer.add(inner);
+        outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
+        outer.setCellVerticalAlignment(inner, HasVerticalAlignment.ALIGN_BOTTOM);
+        initWidget(outer);
+    }
 }