import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.cell.client.ImageResourceCell;
else if (callback != null)
callback.execute();
}
+
+ public void selectByUrl(List<String> selectedUrls) {
+ Set<File> previous = selectionModel.getSelectedSet();
+ for (File f : previous)
+ selectionModel.setSelected(f, false);
+
+ int i = 0;
+ for (File f : files) {
+ if (selectedUrls.contains(app.getApiPath() + f.getOwner() + f.getUri())) {
+ selectionModel.setSelected(f, true);
+ celltable.getRowElement(i).scrollIntoView();
+ }
+ i++;
+ }
+ }
}
}
}, true);
else
- app.updateOtherSharedFolder(folder, true);
+ app.updateOtherSharedFolder(folder, true, null);
}
native void setupUpload(FileUploadDialog dlg, Pithos app, String token) /*-{
var uri = folder.@gr.grnet.pithos.web.client.foldertree.Folder::getUri()();
var path = api + owner + uri;
for (var j=0; j<files.length; j++)
- files[j].url = path + "/" + files[j].name + "?X-Auth-Token=" + encodeURIComponent(token);
+ files[j].url = path + "/" + files[j].name;
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::setInProgress(Z)(true);
up.start();
app.@gr.grnet.pithos.web.client.Pithos::showUploadIndicator()();
+ app.@gr.grnet.pithos.web.client.Pithos::showUploadAlert(I)(files.length);
},
FilesRemoved: function(up, files) {
BeforeUpload: function(up, file) {
if ($wnd.console && $wnd.console.log)
$wnd.console.log('About to upload ' + file.url);
- up.settings.url = file.url;
+ up.settings.url = file.url + + "?X-Auth-Token=" + encodeURIComponent(token);
},
FileUploaded: function(up, file, response) {
$wnd.console.log('All files finished');
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::setInProgress(Z)(false);
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::hideUploadIndicator()();
+ app.@gr.grnet.pithos.web.client.Pithos::hideUploadAlert()();
+ var uris = [];
+ for (var i = 0; i<files.length; i++)
+ uris.push(files[i].url);
+ app.@gr.grnet.pithos.web.client.Pithos::updateUploadFolder(Lcom/google/gwt/core/client/JsArrayString;)(uris);
},
Error: function(up, error) {
var uploader = $wnd.$("#uploader").pluploadQueue();
if (uploader.runtime == 'html5') {
uploader.settings.drop_element = 'rightPanel';
- var dropElm = $wnd.document.getElementById(uploader.settings.drop_element);
uploader.trigger('PostInit');
}
}-*/;
.statistics .gwt-HTML {
font-size: 80%;
}
+
+.uploadAlert {
+ background-color: #4085a5;
+ border: none;
+ width: 350px;
+}
+
+.uploadAlertLink {
+ text-decoration: underline;
+ position: absolute;
+ left: 200px;
+ top: 2px;
+}
+
+.uploadAlertClose {
+ cursor: pointer;
+ position: absolute;
+ right: 1px;
+ top: 2px;
+}
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArray;
+import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.RepeatingCommand;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
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.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.SelectionChangeEvent;
@ClassName("gwt-HTML")
String html();
+
+ String uploadAlert();
+
+ String uploadAlertLink();
+
+ String uploadAlertClose();
}
public interface Resources extends ClientBundle {
@Source("Pithos.css")
Style pithosCss();
+
+ @Source("gr/grnet/pithos/resources/close-popup.png")
+ ImageResource closePopup();
}
public static Resources resources = GWT.create(Resources.class);
updateSharedFolder(f, showfiles, null);
}
- public void updateOtherSharedFolder(Folder f, boolean showfiles) {
- otherSharedTreeView.updateFolder(f, showfiles);
+ public void updateOtherSharedFolder(Folder f, boolean showfiles, Command callback) {
+ otherSharedTreeView.updateFolder(f, showfiles, callback);
}
public MysharedTreeView getMySharedTreeView() {
private Toolbar toolbar;
private FileUploadDialog fileUploadDialog = new FileUploadDialog(this);
-
+
+ UploadAlert uploadAlert;
+
@Override
public void onModuleLoad() {
if (parseUserCredentials())
if (otherSharedTreeSelectionModel.getSelectedObject() != null) {
deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel);
applyPermissions(otherSharedTreeSelectionModel.getSelectedObject());
- updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true);
+ updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true, null);
showRelevantToolbarButtons();
}
else {
}
private void updateUploadFolder() {
+ updateUploadFolder(null);
+ }
+
+ private void updateUploadFolder(final JsArrayString urls) {
if (folderTreeView.equals(getSelectedTree()) || otherSharedTreeView.equals(getSelectedTree())) {
Folder f = getSelection();
if (getSelectedTree().equals(getFolderTreeView()))
@Override
public void execute() {
updateStatistics();
+ if (urls != null)
+ selectUploadedFiles(urls);
}
}, false);
else
- updateOtherSharedFolder(f, true);
+ updateOtherSharedFolder(f, true, null);
}
}
public native void enableUploadArea() /*-{
var uploader = $wnd.$("#uploader").pluploadQueue();
+ var dropElm = $wnd.document.getElementById('rightPanel');
+ $wnd.plupload.removeAllEvents(dropElm, uploader.id);
if (uploader.runtime == 'html5') {
uploader.settings.drop_element = 'rightPanel';
- var dropElm = $wnd.document.getElementById(uploader.settings.drop_element);
uploader.trigger('PostInit');
}
}-*/;
+
+ public void showUploadAlert(int numOfFiles) {
+ uploadAlert = new UploadAlert(this, numOfFiles);
+ uploadAlert.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
+
+ @Override
+ public void setPosition(int offsetWidth, int offsetHeight) {
+ uploadAlert.setPopupPosition((Window.getClientWidth() - offsetWidth)/2, Window.getClientHeight() - offsetHeight);
+ }
+ });
+ }
+
+ public void hideUploadAlert() {
+ uploadAlert.hide();
+ }
+
+ public void selectUploadedFiles(JsArrayString urls) {
+ List<String> selectedUrls = new ArrayList<String>();
+ for (int i=0; i<urls.length(); i++)
+ selectedUrls.add(urls.get(i));
+ fileList.selectByUrl(selectedUrls);
+ }
}
--- /dev/null
+/*
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+package gr.grnet.pithos.web.client;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.PopupPanel;
+
+/**
+ * The 'Folder Context' menu implementation.
+ */
+public class UploadAlert extends PopupPanel {
+
+ /**
+ * The widget's constructor.
+ */
+ public UploadAlert(final Pithos app, int numOfFiles) {
+ // The popup's constructor's argument is a boolean specifying that it
+ // auto-close itself when the user clicks outside of it.
+ super(false);
+ setAnimationEnabled(true);
+ addStyleName(Pithos.resources.pithosCss().uploadAlert());
+ FlowPanel content = new FlowPanel();
+ String label = String.valueOf(numOfFiles) + " " + (numOfFiles > 1 ? "files are" : "file is") + " being uploaded";
+ content.add(new HTML(label));
+ Anchor a = new Anchor("Click for details");
+ a.addStyleName(Pithos.resources.pithosCss().uploadAlertLink());
+ a.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ app.getFileUploadDialog().center();
+ }
+ });
+ content.add(a);
+ Image close = new Image(Pithos.resources.closePopup());
+ close.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ hide();
+ }
+ });
+ close.addStyleName(Pithos.resources.pithosCss().uploadAlertClose());
+ content.add(close);
+ add(content);
+ }
+}
import com.google.gwt.user.cellview.client.CellTree;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.cellview.client.TreeNode;
+import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Tree;
return model.getSelection();
}
- public void updateFolder(Folder folder, boolean showfiles) {
- model.updateFolder(folder, showfiles);
+ public void updateFolder(Folder folder, boolean showfiles, Command callback) {
+ model.updateFolder(folder, showfiles, callback);
}
}
dataProviderMap.put(f, new ListDataProvider<Folder>());
}
final ListDataProvider<Folder> dataProvider = dataProviderMap.get(f);
- fetchFolder(f, dataProvider, false);
+ fetchFolder(f, dataProvider, false, null);
return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null);
}
}
return selectionModel.getSelectedObject();
}
- public void updateFolder(Folder folder, boolean showfiles) {
+ public void updateFolder(Folder folder, boolean showfiles, Command callback) {
if (dataProviderMap.get(folder) == null) {
dataProviderMap.put(folder, new ListDataProvider<Folder>());
}
final ListDataProvider<Folder> dataProvider = dataProviderMap.get(folder);
- fetchFolder(folder, dataProvider, showfiles);
+ fetchFolder(folder, dataProvider, showfiles, callback);
}
- public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles) {
+ public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles, final Command callback) {
String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
@Override
dataProvider.getList().clear();
dataProvider.getList().addAll(_result.getSubfolders());
app.getOtherSharedTreeView().updateChildren(f);
+ if (callback != null)
+ callback.execute();
}
});
}