X-Git-Url: https://code.grnet.gr/git/pithos-web-client/blobdiff_plain/5fab761b804924c2ed767658f63e7c04d962e58a..ebead1b508364bfa1154e40773c659bc61dc87cf:/src/gr/grnet/pithos/web/client/Pithos.java diff --git a/src/gr/grnet/pithos/web/client/Pithos.java b/src/gr/grnet/pithos/web/client/Pithos.java index 83fd0fd..fc3d955 100644 --- a/src/gr/grnet/pithos/web/client/Pithos.java +++ b/src/gr/grnet/pithos/web/client/Pithos.java @@ -34,6 +34,8 @@ */ package gr.grnet.pithos.web.client; +import gr.grnet.pithos.web.client.commands.NewFolderCommand; +import gr.grnet.pithos.web.client.commands.PropertiesCommand; import gr.grnet.pithos.web.client.commands.UploadFileCommand; import gr.grnet.pithos.web.client.foldertree.AccountResource; import gr.grnet.pithos.web.client.foldertree.File; @@ -54,8 +56,6 @@ import gr.grnet.pithos.web.client.rest.HeadRequest; import gr.grnet.pithos.web.client.rest.PutRequest; import gr.grnet.pithos.web.client.rest.RestException; import gr.grnet.pithos.web.client.tagtree.Tag; -import gr.grnet.pithos.web.client.tagtree.TagTreeView; -import gr.grnet.pithos.web.client.tagtree.TagTreeViewModel; import java.util.ArrayList; import java.util.HashMap; @@ -67,6 +67,7 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Style.Display; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.ResizeEvent; @@ -84,13 +85,17 @@ import com.google.gwt.json.client.JSONParser; 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.History; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.AbstractImagePrototype; +import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HasVerticalAlignment; @@ -137,6 +142,10 @@ public class Pithos implements EntryPoint, ResizeHandler { groupTreeView.updateGroupNode(group); } + public void updateMySharedRoot() { + mysharedTreeView.updateRoot(); + } + public void updateSharedFolder(Folder f, boolean showfiles) { mysharedTreeView.updateFolder(f, showfiles); } @@ -169,9 +178,12 @@ public class Pithos implements EntryPoint, ResizeHandler { ImageResource folders(); @Source("gr/grnet/pithos/resources/advancedsettings.png") + @ImageOptions(width=32, height=32) ImageResource tools(); } + private Throwable error; + /** * The Application Clipboard implementation; */ @@ -185,7 +197,7 @@ public class Pithos implements EntryPoint, ResizeHandler { /** * 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. @@ -240,17 +252,17 @@ public class Pithos implements EntryPoint, ResizeHandler { GroupTreeViewModel groupTreeViewModel; private GroupTreeView groupTreeView; - private TreeView selectedTree; + TreeView selectedTree; protected AccountResource account; Folder trash; + + List treeViews = new ArrayList(); @SuppressWarnings("rawtypes") List selectionModels = new ArrayList(); Button upload; - private HTML totalFiles; - private HTML usedBytes; private HTML totalBytes; @@ -259,7 +271,9 @@ public class Pithos implements EntryPoint, ResizeHandler { private HTML numOfFiles; - private Button toolsButton; + private Anchor refreshButton; + + private Anchor toolsButton; @Override public void onModuleLoad() { @@ -268,29 +282,113 @@ public class Pithos implements EntryPoint, ResizeHandler { } private void initialize() { - VerticalPanel outer = new VerticalPanel(); + boolean bareContent = Window.Location.getParameter("noframe") != null; + String contentWidth = bareContent ? "100%" : "75%"; + + VerticalPanel outer = new VerticalPanel(); outer.setWidth("100%"); + if (!bareContent) { + outer.addStyleName("pithos-outer"); + } - topPanel = new TopPanel(this, Pithos.images); - topPanel.setWidth("100%"); - outer.add(topPanel); - outer.setCellHorizontalAlignment(topPanel, HasHorizontalAlignment.ALIGN_CENTER); + if (!bareContent) { + topPanel = new TopPanel(this, Pithos.images); + topPanel.setWidth("100%"); + outer.add(topPanel); + outer.setCellHorizontalAlignment(topPanel, HasHorizontalAlignment.ALIGN_CENTER); + } - messagePanel.setWidth("75%"); - messagePanel.setVisible(false); - outer.add(messagePanel); - outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); + HorizontalPanel header = new HorizontalPanel(); + header.addStyleName("pithos-header"); + header.setWidth(contentWidth); + if (bareContent) + header.addStyleName("pithos-header-noframe"); + upload = new Button("Upload File", new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + new UploadFileCommand(Pithos.this, null, getSelection()).execute(); + } + }); + upload.addStyleName("pithos-uploadButton"); + header.add(upload); + header.setCellHorizontalAlignment(upload, HasHorizontalAlignment.ALIGN_LEFT); + header.setCellVerticalAlignment(upload, HasVerticalAlignment.ALIGN_MIDDLE); + messagePanel.setVisible(false); + header.add(messagePanel); + header.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); + header.setCellVerticalAlignment(messagePanel, HasVerticalAlignment.ALIGN_MIDDLE); + + FlowPanel toolbar = new FlowPanel(); + toolbar.getElement().setId("toolbar"); + toolbar.addStyleName("clearfix"); + toolbar.getElement().getStyle().setDisplay(Display.BLOCK); + + Anchor newFolderButton = new Anchor("New folder", true); + newFolderButton.getElement().setId("newfolder-button"); + newFolderButton.addStyleName("pithos-toolbarItem"); + newFolderButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + Folder folder = getSelectedTree().getSelection(); + if (folder != null) { + Boolean[] permissions = folder.getPermissions().get(getUsername()); + boolean canWrite = folder.getOwner().equals(getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]); + + if (!folder.isInTrash() && canWrite) + new NewFolderCommand(Pithos.this, null, folder).execute(); + } + } + }); + toolbar.add(newFolderButton); - // Inner contains the various lists. - inner.sinkEvents(Event.ONCONTEXTMENU); - inner.setWidth("100%"); + Anchor shareFolderButton = new Anchor("Share folder", true); + shareFolderButton.getElement().setId("sharefolder-button"); + shareFolderButton.addStyleName("pithos-toolbarItem"); + shareFolderButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + Folder folder = getSelectedTree().getSelection(); + if (folder != null) { + Boolean[] permissions = folder.getPermissions().get(getUsername()); + boolean canWrite = folder.getOwner().equals(getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]); + boolean isFolderTreeSelected = selectedTree.equals(getFolderTreeView()); + + if (!folder.isInTrash() && canWrite && isFolderTreeSelected && !folder.isContainer()) + new PropertiesCommand(Pithos.this, null, folder, PropertiesCommand.PERMISSIONS).execute(); + } + } + }); + toolbar.add(shareFolderButton); - HorizontalPanel rightside = new HorizontalPanel(); - rightside.addStyleName("pithos-rightSide"); - rightside.setSpacing(5); + refreshButton = new Anchor("Refresh", true); + refreshButton.getElement().setId("refresh-button"); + refreshButton.addStyleName("pithos-toolbarItem"); + refreshButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(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(); + } + }); + } + }); + toolbar.add(refreshButton); - toolsButton = new Button(AbstractImagePrototype.create(images.tools()).getHTML()); + toolsButton = new Anchor("More...", true); + toolsButton.getElement().setId("tools-button"); + toolsButton.addStyleName("pithos-toolbarItem"); toolsButton.addClickHandler(new ClickHandler() { @Override @@ -302,31 +400,45 @@ public class Pithos implements EntryPoint, ResizeHandler { } } }); - rightside.add(toolsButton); - rightside.setCellHorizontalAlignment(toolsButton, HasHorizontalAlignment.ALIGN_LEFT); + toolbar.add(toolsButton); + + header.add(toolbar); + header.setCellHorizontalAlignment(toolbar, HasHorizontalAlignment.ALIGN_CENTER); + header.setCellVerticalAlignment(toolbar, HasVerticalAlignment.ALIGN_MIDDLE); HorizontalPanel folderStatistics = new HorizontalPanel(); folderStatistics.addStyleName("pithos-folderStatistics"); numOfFiles = new HTML(); folderStatistics.add(numOfFiles); + folderStatistics.setCellVerticalAlignment(numOfFiles, HasVerticalAlignment.ALIGN_MIDDLE); HTML numOfFilesLabel = new HTML(" Files"); folderStatistics.add(numOfFilesLabel); - rightside.add(folderStatistics); - rightside.setCellHorizontalAlignment(folderStatistics, HasHorizontalAlignment.ALIGN_RIGHT); - - inner.add(rightside); - inner.setCellVerticalAlignment(rightside, HasVerticalAlignment.ALIGN_MIDDLE); - inner.setCellHeight(rightside, "60px"); + folderStatistics.setCellVerticalAlignment(numOfFilesLabel, HasVerticalAlignment.ALIGN_MIDDLE); + header.add(folderStatistics); + header.setCellHorizontalAlignment(folderStatistics, HasHorizontalAlignment.ALIGN_RIGHT); + header.setCellVerticalAlignment(folderStatistics, HasVerticalAlignment.ALIGN_MIDDLE); + header.setCellWidth(folderStatistics, "40px"); + outer.add(header); + outer.setCellHorizontalAlignment(header, HasHorizontalAlignment.ALIGN_CENTER); + // Inner contains the various lists.nner + inner.sinkEvents(Event.ONCONTEXTMENU); + inner.setWidth("100%"); folderTreeSelectionModel = new SingleSelectionModel(); folderTreeSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override - public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) { + public void onSelectionChange(SelectionChangeEvent event) { if (folderTreeSelectionModel.getSelectedObject() != null) { deselectOthers(folderTreeView, folderTreeSelectionModel); applyPermissions(folderTreeSelectionModel.getSelectedObject()); Folder f = folderTreeSelectionModel.getSelectedObject(); - updateFolder(f, true, null); + updateFolder(f, true, new Command() { + + @Override + public void execute() { + updateStatistics(); + } + }); } } }); @@ -334,40 +446,26 @@ public class Pithos implements EntryPoint, ResizeHandler { folderTreeViewModel = new FolderTreeViewModel(this, folderTreeSelectionModel); folderTreeView = new FolderTreeView(folderTreeViewModel); - + treeViews.add(folderTreeView); + fileList = new FileList(this, images, folderTreeView); inner.add(fileList); groupTreeViewModel = new GroupTreeViewModel(this); groupTreeView = new GroupTreeView(groupTreeViewModel); - + treeViews.add(groupTreeView); + trees = new VerticalPanel(); trees.setWidth("100%"); - VerticalPanel uploadButtonPanel = new VerticalPanel(); - upload = new Button("Upload File", new ClickHandler() { - @Override - public void onClick(@SuppressWarnings("unused") ClickEvent event) { - new UploadFileCommand(Pithos.this, null, getSelection()).execute(); - } - }); - uploadButtonPanel.add(upload); - uploadButtonPanel.setWidth("100%"); - uploadButtonPanel.setHeight("60px"); - uploadButtonPanel.setCellHorizontalAlignment(upload, HasHorizontalAlignment.ALIGN_CENTER); - uploadButtonPanel.setCellVerticalAlignment(upload, HasVerticalAlignment.ALIGN_MIDDLE); - upload.addStyleName("pithos-uploadButton"); - trees.add(uploadButtonPanel); HorizontalPanel treeHeader = new HorizontalPanel(); treeHeader.addStyleName("pithos-treeHeader"); - treeHeader.setWidth("100%"); treeHeader.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + treeHeader.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); HorizontalPanel statistics = new HorizontalPanel(); - statistics.add(new HTML("Total Objects: ")); - totalFiles = new HTML(); - statistics.add(totalFiles); - statistics.add(new HTML(" | Used: ")); + statistics.addStyleName("pithos-statistics"); + statistics.add(new HTML("Used: ")); usedBytes = new HTML(); statistics.add(usedBytes); statistics.add(new HTML(" of ")); @@ -389,14 +487,18 @@ public class Pithos implements EntryPoint, ResizeHandler { splitPanel.setSplitPosition("35%"); splitPanel.setSize("100%", "100%"); splitPanel.addStyleName("pithos-splitPanel"); - splitPanel.setWidth("75%"); + splitPanel.setWidth(contentWidth); outer.add(splitPanel); outer.setCellHorizontalAlignment(splitPanel, HasHorizontalAlignment.ALIGN_CENTER); - statusPanel = new StatusPanel(); - statusPanel.setWidth("100%"); - outer.add(statusPanel); - outer.setCellHorizontalAlignment(statusPanel, HasHorizontalAlignment.ALIGN_CENTER); + if (!bareContent) { + statusPanel = new StatusPanel(); + statusPanel.setWidth("100%"); + outer.add(statusPanel); + outer.setCellHorizontalAlignment(statusPanel, HasHorizontalAlignment.ALIGN_CENTER); + } + else + splitPanel.addStyleName("pithos-splitPanel-noframe"); // Hook the window resize event, so that we can adjust the UI. Window.addResizeHandler(this); @@ -448,6 +550,15 @@ public class Pithos implements EntryPoint, ResizeHandler { }); } }); + +// Scheduler.get().scheduleDeferred(new Command() { +// +// @Override +// public void execute() { +// displayError("lalala"); +// +// } +// }); } public void applyPermissions(Folder f) { @@ -470,19 +581,24 @@ public class Pithos implements EntryPoint, ResizeHandler { @SuppressWarnings({ "rawtypes", "unchecked" }) public void deselectOthers(TreeView _selectedTree, SingleSelectionModel model) { selectedTree = _selectedTree; + + for (Composite c : treeViews) + if (c.equals(selectedTree)) + c.addStyleName("cellTreeWidget-selectedTree"); + else + c.removeStyleName("cellTreeWidget-selectedTree"); + for (SingleSelectionModel s : selectionModels) if (!s.equals(model)) s.setSelected(s.getSelectedObject(), false); } - public void showFiles(Folder f) { + public void showFiles(final Folder f) { Set files = f.getFiles(); showFiles(files); } public void showFiles(Set files) { - //Iterator iter = files.iterator(); - //fetchFile(iter, files); fileList.setFiles(new ArrayList(files)); } @@ -492,13 +608,14 @@ public class Pithos implements EntryPoint, ResizeHandler { String path = file.getUri() + "?format=json"; GetRequest getFile = new GetRequest(File.class, getApiPath(), username, path, file) { @Override - public void onSuccess(@SuppressWarnings("unused") File _result) { + public void onSuccess(File _result) { fetchFile(iter, files); } @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 @@ -531,6 +648,10 @@ public class Pithos implements EntryPoint, ResizeHandler { 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(); @@ -540,7 +661,8 @@ public class Pithos implements EntryPoint, ResizeHandler { 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; } @@ -566,6 +688,7 @@ public class Pithos implements EntryPoint, ResizeHandler { @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 @@ -585,13 +708,14 @@ public class Pithos implements EntryPoint, ResizeHandler { HeadRequest headAccount = new HeadRequest(AccountResource.class, getApiPath(), username, "", account) { @Override - public void onSuccess(@SuppressWarnings("unused") AccountResource _result) { + public void onSuccess(AccountResource _result) { showStatistics(); } @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 @@ -608,7 +732,6 @@ public class Pithos implements EntryPoint, ResizeHandler { } 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(); @@ -619,7 +742,7 @@ public class Pithos implements EntryPoint, ResizeHandler { String path = "/" + Pithos.HOME_CONTAINER; PutRequest createPithos = new PutRequest(getApiPath(), getUsername(), path) { @Override - public void onSuccess(@SuppressWarnings("unused") Resource result) { + public void onSuccess(Resource result) { if (!_account.hasTrashContainer()) createTrashContainer(callback); else @@ -629,6 +752,7 @@ public class Pithos implements EntryPoint, ResizeHandler { @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 @@ -648,13 +772,14 @@ public class Pithos implements EntryPoint, ResizeHandler { String path = "/" + Pithos.TRASH_CONTAINER; PutRequest createPithos = new PutRequest(getApiPath(), getUsername(), path) { @Override - public void onSuccess(@SuppressWarnings("unused") Resource result) { + public void onSuccess(Resource result) { fetchAccount(callback); } @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 @@ -688,7 +813,7 @@ public class Pithos implements EntryPoint, ResizeHandler { protected void onWindowResized(int height) { // Adjust the split panel to take up the available room in the window. - int newHeight = height - splitPanel.getAbsoluteTop() - 60; + int newHeight = height - splitPanel.getAbsoluteTop(); if (newHeight < 1) newHeight = 1; splitPanel.setHeight("" + newHeight); @@ -801,7 +926,7 @@ public class Pithos implements EntryPoint, ResizeHandler { try { builder.sendRequest("", new RequestCallback() { @Override - public void onResponseReceived(@SuppressWarnings("unused") Request request, Response response) { + public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { JSONValue json = JSONParser.parseStrict(response.getText()); JSONArray array = json.isArray(); @@ -813,7 +938,8 @@ public class Pithos implements EntryPoint, ResizeHandler { } @Override - public void onError(@SuppressWarnings("unused") Request request, Throwable exception) { + public void onError(Request request, Throwable exception) { + setError(exception); displayError("System error unable to delete folder: " + exception.getMessage()); } }); @@ -830,13 +956,14 @@ public class Pithos implements EntryPoint, ResizeHandler { String path = "/" + folder.getContainer() + "/" + name.stringValue(); DeleteRequest delete = new DeleteRequest(getApiPath(), folder.getOwner(), path) { @Override - public void onSuccess(@SuppressWarnings("unused") Resource result) { + public void onSuccess(Resource result) { deleteObject(folder, i + 1, array); } @Override public void onError(Throwable t) { GWT.log("", t); + setError(t); displayError("System error unable to delete folder: " + t.getMessage()); } @@ -857,7 +984,7 @@ public class Pithos implements EntryPoint, ResizeHandler { try { builder.sendRequest("", new RequestCallback() { @Override - public void onResponseReceived(@SuppressWarnings("unused") Request request, Response response) { + public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { JSONValue json = JSONParser.parseStrict(response.getText()); JSONArray array2 = json.isArray(); @@ -872,7 +999,8 @@ public class Pithos implements EntryPoint, ResizeHandler { } @Override - public void onError(@SuppressWarnings("unused") Request request, Throwable exception) { + public void onError(Request request, Throwable exception) { + setError(exception); displayError("System error unable to delete folder: " + exception.getMessage()); } }); @@ -885,7 +1013,7 @@ public class Pithos implements EntryPoint, ResizeHandler { String path = folder.getUri(); DeleteRequest deleteFolder = new DeleteRequest(getApiPath(), getUsername(), path) { @Override - public void onSuccess(@SuppressWarnings("unused") Resource result) { + public void onSuccess(Resource result) { updateFolder(folder.getParent(), true, new Command() { @Override @@ -898,6 +1026,7 @@ public class Pithos implements EntryPoint, ResizeHandler { @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()); @@ -928,13 +1057,14 @@ public class Pithos implements EntryPoint, ResizeHandler { String path = targetUri + "/" + file.getName(); PutRequest copyFile = new PutRequest(getApiPath(), targetUsername, path) { @Override - public void onSuccess(@SuppressWarnings("unused") Resource result) { + public void onSuccess(Resource result) { copyFiles(iter, targetUsername, targetUri, callback); } @Override public void onError(Throwable t) { GWT.log("", t); + setError(t); if (t instanceof RestException) { displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText()); } @@ -948,9 +1078,10 @@ public class Pithos implements EntryPoint, ResizeHandler { } }; 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) { @@ -978,7 +1109,7 @@ public class Pithos implements EntryPoint, ResizeHandler { String path = targetUri + "/" + f.getName(); PutRequest createFolder = new PutRequest(getApiPath(), targetUsername, path) { @Override - public void onSuccess(@SuppressWarnings("unused") Resource result) { + public void onSuccess(Resource result) { GetRequest getFolder = new GetRequest(Folder.class, getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) { @Override @@ -996,6 +1127,7 @@ public class Pithos implements EntryPoint, ResizeHandler { @Override public void onError(Throwable t) { GWT.log("", t); + setError(t); if (t instanceof RestException) { displayError("Unable to get folder: " + ((RestException) t).getHttpStatusText()); } @@ -1015,7 +1147,8 @@ public class Pithos implements EntryPoint, ResizeHandler { @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 @@ -1089,13 +1222,13 @@ public class Pithos implements EntryPoint, ResizeHandler { mysharedTreeSelectionModel = new SingleSelectionModel(); mysharedTreeSelectionModel.addSelectionChangeHandler(new Handler() { @Override - public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) { + public void onSelectionChange(SelectionChangeEvent event) { if (mysharedTreeSelectionModel.getSelectedObject() != null) { deselectOthers(mysharedTreeView, mysharedTreeSelectionModel); upload.setEnabled(false); updateSharedFolder(mysharedTreeSelectionModel.getSelectedObject(), true); } - } + } }); selectionModels.add(mysharedTreeSelectionModel); mysharedTreeViewModel = new MysharedTreeViewModel(Pithos.this, mysharedTreeSelectionModel); @@ -1104,7 +1237,8 @@ public class Pithos implements EntryPoint, ResizeHandler { @Override public void execute() { mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel); - trees.insert(mysharedTreeView, 3); + trees.insert(mysharedTreeView, 2); + treeViews.add(mysharedTreeView); createOtherSharedTree(); } }); @@ -1114,13 +1248,14 @@ public class Pithos implements EntryPoint, ResizeHandler { otherSharedTreeSelectionModel = new SingleSelectionModel(); otherSharedTreeSelectionModel.addSelectionChangeHandler(new Handler() { @Override - public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) { + public void onSelectionChange(SelectionChangeEvent event) { if (otherSharedTreeSelectionModel.getSelectedObject() != null) { deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel); + otherSharedTreeView.addStyleName("cellTreeWidget-selectedTree"); applyPermissions(otherSharedTreeSelectionModel.getSelectedObject()); updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true); } - } + } }); selectionModels.add(otherSharedTreeSelectionModel); otherSharedTreeViewModel = new OtherSharedTreeViewModel(Pithos.this, otherSharedTreeSelectionModel); @@ -1129,18 +1264,29 @@ public class Pithos implements EntryPoint, ResizeHandler { @Override public void execute() { otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel); - trees.insert(otherSharedTreeView, 4); + trees.insert(otherSharedTreeView, 3); + treeViews.add(otherSharedTreeView); } }); } 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; + } }