Added 'close' to all dialogs (issue #2377)
[pithos-web-client] / src / gr / grnet / pithos / web / client / FileVersionsDialog.java
index 1c3f40c..87d4398 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright 2011 GRNET S.A. All rights reserved.\r
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.\r
  *\r
  * Redistribution and use in source and binary forms, with or\r
  * without modification, are permitted provided that the following\r
@@ -36,32 +36,24 @@ package gr.grnet.pithos.web.client;
 \r
 import gr.grnet.pithos.web.client.foldertree.File;\r
 import gr.grnet.pithos.web.client.foldertree.FileVersions;\r
-import gr.grnet.pithos.web.client.foldertree.Resource;\r
 import gr.grnet.pithos.web.client.foldertree.Version;\r
 import gr.grnet.pithos.web.client.rest.GetRequest;\r
-import gr.grnet.pithos.web.client.rest.PostRequest;\r
-import gr.grnet.pithos.web.client.rest.PutRequest;\r
 import gr.grnet.pithos.web.client.rest.RestException;\r
 \r
-import java.util.HashMap;\r
 import java.util.List;\r
-import java.util.Map;\r
 \r
 import com.google.gwt.core.client.GWT;\r
 import com.google.gwt.core.client.Scheduler;\r
 import com.google.gwt.event.dom.client.ClickEvent;\r
 import com.google.gwt.event.dom.client.ClickHandler;\r
 import com.google.gwt.http.client.Response;\r
-import com.google.gwt.http.client.URL;\r
 import com.google.gwt.resources.client.ImageResource;\r
 import com.google.gwt.user.client.Command;\r
 import com.google.gwt.user.client.ui.Anchor;\r
 import com.google.gwt.user.client.ui.Button;\r
 import com.google.gwt.user.client.ui.CheckBox;\r
-import com.google.gwt.user.client.ui.DecoratedTabPanel;\r
 import com.google.gwt.user.client.ui.FocusPanel;\r
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
-import com.google.gwt.user.client.ui.TextBox;\r
 import com.google.gwt.user.client.ui.VerticalPanel;\r
 \r
 /**\r
@@ -70,10 +62,6 @@ import com.google.gwt.user.client.ui.VerticalPanel;
  */\r
 public class FileVersionsDialog extends AbstractPropertiesDialog {\r
 \r
-       protected PermissionsList permList;\r
-\r
-       protected CheckBox readForAll;\r
-\r
        /**\r
         * An image bundle for this widgets images.\r
         */\r
@@ -106,12 +94,12 @@ public class FileVersionsDialog extends AbstractPropertiesDialog {
         super(_app);\r
         file = _file;\r
 \r
-               Anchor close = new Anchor();\r
+               Anchor close = new Anchor("close");\r
                close.addStyleName("close");\r
                close.addClickHandler(new ClickHandler() {\r
                        \r
                        @Override\r
-                       public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
+                       public void onClick(ClickEvent event) {\r
                                hide();\r
                        }\r
                });\r
@@ -129,15 +117,13 @@ public class FileVersionsDialog extends AbstractPropertiesDialog {
                inner = new VerticalPanel();\r
                inner.addStyleName("inner");\r
 \r
-               fetchVersions();\r
-                       \r
-        outer.add(inner);\r
+               outer.add(inner);\r
 \r
                // Create the 'OK' button, along with a listener that hides the dialog\r
                // when the button is clicked.\r
                final Button ok = new Button("OK", new ClickHandler() {\r
                        @Override\r
-                       public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
+                       public void onClick(ClickEvent event) {\r
                                accept();\r
                                closeDialog();\r
                        }\r
@@ -151,6 +137,15 @@ public class FileVersionsDialog extends AbstractPropertiesDialog {
         setWidget(outer);\r
        }\r
 \r
+       void doCenter() {\r
+               super.center();\r
+       }\r
+       \r
+       @Override\r
+       public void center() {\r
+               fetchVersions();\r
+       }\r
+\r
     protected void fetchVersions() {\r
        String path = file.getUri() + "?format=json&version=list";\r
        GetRequest<FileVersions> getVersions = new GetRequest<FileVersions>(FileVersions.class, app.getApiPath(), file.getOwner(), path) {\r
@@ -158,6 +153,7 @@ public class FileVersionsDialog extends AbstractPropertiesDialog {
                        @Override\r
                        public void onSuccess(FileVersions _result) {\r
                        inner.add(createVersionPanel(_result.getVersions()));\r
+                               doCenter();\r
                        }\r
 \r
                        @Override\r
@@ -172,7 +168,7 @@ public class FileVersionsDialog extends AbstractPropertiesDialog {
                        }\r
 \r
                        @Override\r
-                       protected void onUnauthorized(@SuppressWarnings("unused") Response response) {\r
+                       protected void onUnauthorized(Response response) {\r
                                app.sessionExpired();\r
                        }\r
                };\r
@@ -189,21 +185,20 @@ public class FileVersionsDialog extends AbstractPropertiesDialog {
 \r
        /**\r
         * Accepts any change and updates the file\r
+        * @return \r
         *\r
         */\r
        @Override\r
-       protected void accept() {\r
-               updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=");\r
-       }\r
-\r
-       protected void updateMetaData(String api, String owner, String path) {\r
+       protected boolean accept() {\r
         app.updateFolder(file.getParent(), true, new Command() {\r
                        \r
                        @Override\r
                        public void execute() {\r
-                               if (file.isShared())\r
+                               if (file.isSharedOrPublished())\r
                                        app.updateMySharedRoot();\r
                        }\r
-               });\r
-    }\r
+               }, true);\r
+        \r
+        return true;\r
+       }\r
 }\r