import gr.grnet.pithos.web.client.tagtree.TagTreeViewModel;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.HorizontalSplitPanel;
+import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.SelectionChangeEvent;
groupTreeView.updateGroupNode(group);
}
+ public void updateMySharedRoot() {
+ mysharedTreeView.updateRoot();
+ }
+
public void updateSharedFolder(Folder f, boolean showfiles) {
mysharedTreeView.updateFolder(f, showfiles);
}
ImageResource folders();
@Source("gr/grnet/pithos/resources/advancedsettings.png")
+ @ImageOptions(width=32, height=32)
ImageResource tools();
}
+ private Throwable error;
+
/**
* The Application Clipboard implementation;
*/
/**
* The panel that contains the various system messages.
*/
- private MessagePanel messagePanel = new MessagePanel(Pithos.images);
+ private MessagePanel messagePanel = new MessagePanel(this, Pithos.images);
/**
* The bottom panel that contains the status bar.
GroupTreeViewModel groupTreeViewModel;
private GroupTreeView groupTreeView;
- private TreeView selectedTree;
+ TreeView selectedTree;
protected AccountResource account;
Folder trash;
Button upload;
- private HTML totalFiles;
-
private HTML usedBytes;
private HTML totalBytes;
private HTML numOfFiles;
- private Button toolsButton;
+ private Image refreshButton;
+
+ private Image toolsButton;
@Override
public void onModuleLoad() {
header.add(upload);
header.setCellHorizontalAlignment(upload, HasHorizontalAlignment.ALIGN_LEFT);
header.setCellVerticalAlignment(upload, HasVerticalAlignment.ALIGN_MIDDLE);
- header.setCellWidth(upload, "146px");
+// header.setCellWidth(upload, "146px");
messagePanel.setVisible(false);
header.add(messagePanel);
header.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER);
header.setCellVerticalAlignment(messagePanel, HasVerticalAlignment.ALIGN_MIDDLE);
-
- toolsButton = new Button(AbstractImagePrototype.create(images.tools()).getHTML());
+ refreshButton = new Image(images.refresh());
+ refreshButton.addStyleName("pithos-toolsButton");
+ refreshButton.setWidth("32px");
+ refreshButton.setHeight("32px");
+ refreshButton.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(@SuppressWarnings("unused") ClickEvent event) {
+ boolean isFolderTreeSelected = selectedTree.equals(getFolderTreeView());
+ boolean otherSharedTreeSelected = selectedTree.equals(getOtherSharedTreeView());
+ Folder folder = getSelectedTree().getSelection();
+
+ if (folder != null && (isFolderTreeSelected || otherSharedTreeSelected))
+ updateFolder(folder, true, new Command() {
+
+ @Override
+ public void execute() {
+ updateStatistics();
+ }
+ });
+ }
+ });
+ header.add(refreshButton);
+ header.setCellHorizontalAlignment(refreshButton, HasHorizontalAlignment.ALIGN_CENTER);
+ header.setCellVerticalAlignment(refreshButton, HasVerticalAlignment.ALIGN_MIDDLE);
+ header.setCellWidth(refreshButton, "40px");
+
+ toolsButton = new Image(images.tools());
+ toolsButton.addStyleName("pithos-toolsButton");
toolsButton.addClickHandler(new ClickHandler() {
@Override
}
});
header.add(toolsButton);
- header.setCellHorizontalAlignment(toolsButton, HasHorizontalAlignment.ALIGN_RIGHT);
+ header.setCellHorizontalAlignment(toolsButton, HasHorizontalAlignment.ALIGN_CENTER);
header.setCellVerticalAlignment(toolsButton, HasVerticalAlignment.ALIGN_MIDDLE);
- header.setCellWidth(toolsButton, "30px");
-
+ header.setCellWidth(toolsButton, "40px");
+
HorizontalPanel folderStatistics = new HorizontalPanel();
folderStatistics.addStyleName("pithos-folderStatistics");
numOfFiles = new HTML();
header.add(folderStatistics);
header.setCellHorizontalAlignment(folderStatistics, HasHorizontalAlignment.ALIGN_RIGHT);
header.setCellVerticalAlignment(folderStatistics, HasVerticalAlignment.ALIGN_MIDDLE);
- header.setCellWidth(folderStatistics, "60px");
+ header.setCellWidth(folderStatistics, "40px");
outer.add(header);
outer.setCellHorizontalAlignment(header, HasHorizontalAlignment.ALIGN_CENTER);
// Inner contains the various lists.nner
treeHeader.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
HorizontalPanel statistics = new HorizontalPanel();
statistics.addStyleName("pithos-statistics");
- statistics.add(new HTML("Total Objects: "));
- totalFiles = new HTML();
- statistics.add(totalFiles);
- statistics.add(new HTML(" | Used: "));
+ statistics.add(new HTML("Used: "));
usedBytes = new HTML();
statistics.add(usedBytes);
statistics.add(new HTML(" of "));
@Override
public void onError(Throwable t) {
GWT.log("Error getting file", t);
+ setError(t);
if (t instanceof RestException)
displayError("Error getting file: " + ((RestException) t).getHttpStatusText());
else
authenticateUser();
return false;
}
+ if (auth.startsWith("\""))
+ auth = auth.substring(1);
+ if (auth.endsWith("\""))
+ auth = auth.substring(0, auth.length() - 1);
String[] authSplit = auth.split("\\" + conf.cookieSeparator(), 2);
if (authSplit.length != 2) {
authenticateUser();
token = authSplit[1];
return true;
}
- Cookies.setCookie(conf.authCookie(), username + conf.cookieSeparator() + token);
+
+ Cookies.setCookie(conf.authCookie(), username + conf.cookieSeparator() + token, null, "", "/", false);
return true;
}
@Override
public void onError(Throwable t) {
GWT.log("Error getting account", t);
+ setError(t);
if (t instanceof RestException)
displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
else
@Override
public void onError(Throwable t) {
GWT.log("Error getting account", t);
+ setError(t);
if (t instanceof RestException)
displayError("Error getting account: " + ((RestException) t).getHttpStatusText());
else
}
protected void showStatistics() {
- totalFiles.setHTML(String.valueOf(account.getNumberOfObjects()));
usedBytes.setHTML(String.valueOf(account.getFileSizeAsString()));
totalBytes.setHTML(String.valueOf(account.getQuotaAsString()));
NumberFormat nf = NumberFormat.getPercentFormat();
@Override
public void onError(Throwable t) {
GWT.log("Error creating pithos", t);
+ setError(t);
if (t instanceof RestException)
displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText());
else
@Override
public void onError(Throwable t) {
GWT.log("Error creating pithos", t);
+ setError(t);
if (t instanceof RestException)
displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText());
else
@Override
public void onError(@SuppressWarnings("unused") Request request, Throwable exception) {
+ setError(exception);
displayError("System error unable to delete folder: " + exception.getMessage());
}
});
@Override
public void onError(Throwable t) {
GWT.log("", t);
+ setError(t);
displayError("System error unable to delete folder: " + t.getMessage());
}
@Override
public void onError(@SuppressWarnings("unused") Request request, Throwable exception) {
+ setError(exception);
displayError("System error unable to delete folder: " + exception.getMessage());
}
});
@Override
public void onError(Throwable t) {
GWT.log("", t);
+ setError(t);
if (t instanceof RestException) {
if (((RestException) t).getHttpStatusCode() != Response.SC_NOT_FOUND)
displayError("Unable to delete folder: "+((RestException) t).getHttpStatusText());
@Override
public void onError(Throwable t) {
GWT.log("", t);
+ setError(t);
if (t instanceof RestException) {
displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
}
}
};
copyFile.setHeader("X-Auth-Token", getToken());
- copyFile.setHeader("X-Copy-From", file.getUri());
+ copyFile.setHeader("X-Copy-From", URL.encodePathSegment(file.getUri()));
if (!file.getOwner().equals(targetUsername))
- copyFile.setHeader("X-Source-Account", file.getOwner());
+ copyFile.setHeader("X-Source-Account", URL.encodePathSegment(file.getOwner()));
+ copyFile.setHeader("Content-Type", file.getContentType());
Scheduler.get().scheduleDeferred(copyFile);
}
else if (callback != null) {
@Override
public void onError(Throwable t) {
GWT.log("", t);
+ setError(t);
if (t instanceof RestException) {
displayError("Unable to get folder: " + ((RestException) t).getHttpStatusText());
}
@Override
public void onError(Throwable t) {
GWT.log("", t);
- if (t instanceof RestException) {
+ setError(t);
+ if (t instanceof RestException) {
displayError("Unable to create folder: " + ((RestException) t).getHttpStatusText());
}
else
public void logoff() {
Configuration conf = (Configuration) GWT.create(Configuration.class);
- Cookies.removeCookie(conf.authCookie());
+ Cookies.removeCookie(conf.authCookie(), "/");
Cookies.removeCookie(conf.authTokenCookie(), "/");
for (String s: Cookies.getCookieNames())
if (s.startsWith(conf.shibSessionCookiePrefix()))
Cookies.removeCookie(s, "/");
Window.Location.assign(Window.Location.getPath());
}
+
+ public String getErrorData() {
+ if (error != null)
+ return error.toString();
+ return "";
+ }
+
+ public void setError(Throwable t) {
+ error = t;
+ }
}