Revision 3646552f
b/src/gr/grnet/pithos/web/client/FileList.java | ||
---|---|---|
44 | 44 |
import java.util.Comparator; |
45 | 45 |
import java.util.Iterator; |
46 | 46 |
import java.util.List; |
47 |
import java.util.Set; |
|
47 | 48 |
|
48 | 49 |
import com.google.gwt.cell.client.Cell.Context; |
49 | 50 |
import com.google.gwt.cell.client.ImageResourceCell; |
... | ... | |
665 | 666 |
else if (callback != null) |
666 | 667 |
callback.execute(); |
667 | 668 |
} |
669 |
|
|
670 |
public void selectByUrl(List<String> selectedUrls) { |
|
671 |
Set<File> previous = selectionModel.getSelectedSet(); |
|
672 |
for (File f : previous) |
|
673 |
selectionModel.setSelected(f, false); |
|
674 |
|
|
675 |
int i = 0; |
|
676 |
for (File f : files) { |
|
677 |
if (selectedUrls.contains(app.getApiPath() + f.getOwner() + f.getUri())) { |
|
678 |
selectionModel.setSelected(f, true); |
|
679 |
celltable.getRowElement(i).scrollIntoView(); |
|
680 |
} |
|
681 |
i++; |
|
682 |
} |
|
683 |
} |
|
668 | 684 |
} |
b/src/gr/grnet/pithos/web/client/FileUploadDialog.java | ||
---|---|---|
170 | 170 |
} |
171 | 171 |
}, true); |
172 | 172 |
else |
173 |
app.updateOtherSharedFolder(folder, true); |
|
173 |
app.updateOtherSharedFolder(folder, true, null);
|
|
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
native void setupUpload(FileUploadDialog dlg, Pithos app, String token) /*-{ |
... | ... | |
206 | 206 |
var uri = folder.@gr.grnet.pithos.web.client.foldertree.Folder::getUri()(); |
207 | 207 |
var path = api + owner + uri; |
208 | 208 |
for (var j=0; j<files.length; j++) |
209 |
files[j].url = path + "/" + files[j].name + "?X-Auth-Token=" + encodeURIComponent(token);
|
|
209 |
files[j].url = path + "/" + files[j].name; |
|
210 | 210 |
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::setInProgress(Z)(true); |
211 | 211 |
up.start(); |
212 | 212 |
app.@gr.grnet.pithos.web.client.Pithos::showUploadIndicator()(); |
213 |
app.@gr.grnet.pithos.web.client.Pithos::showUploadAlert(I)(files.length); |
|
213 | 214 |
}, |
214 | 215 |
|
215 | 216 |
FilesRemoved: function(up, files) { |
... | ... | |
222 | 223 |
BeforeUpload: function(up, file) { |
223 | 224 |
if ($wnd.console && $wnd.console.log) |
224 | 225 |
$wnd.console.log('About to upload ' + file.url); |
225 |
up.settings.url = file.url; |
|
226 |
up.settings.url = file.url + + "?X-Auth-Token=" + encodeURIComponent(token);
|
|
226 | 227 |
}, |
227 | 228 |
|
228 | 229 |
FileUploaded: function(up, file, response) { |
... | ... | |
240 | 241 |
$wnd.console.log('All files finished'); |
241 | 242 |
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::setInProgress(Z)(false); |
242 | 243 |
dlg.@gr.grnet.pithos.web.client.FileUploadDialog::hideUploadIndicator()(); |
244 |
app.@gr.grnet.pithos.web.client.Pithos::hideUploadAlert()(); |
|
245 |
var uris = []; |
|
246 |
for (var i = 0; i<files.length; i++) |
|
247 |
uris.push(files[i].url); |
|
248 |
app.@gr.grnet.pithos.web.client.Pithos::updateUploadFolder(Lcom/google/gwt/core/client/JsArrayString;)(uris); |
|
243 | 249 |
}, |
244 | 250 |
|
245 | 251 |
Error: function(up, error) { |
... | ... | |
343 | 349 |
var uploader = $wnd.$("#uploader").pluploadQueue(); |
344 | 350 |
if (uploader.runtime == 'html5') { |
345 | 351 |
uploader.settings.drop_element = 'rightPanel'; |
346 |
var dropElm = $wnd.document.getElementById(uploader.settings.drop_element); |
|
347 | 352 |
uploader.trigger('PostInit'); |
348 | 353 |
} |
349 | 354 |
}-*/; |
b/src/gr/grnet/pithos/web/client/Pithos.css | ||
---|---|---|
54 | 54 |
.statistics .gwt-HTML { |
55 | 55 |
font-size: 80%; |
56 | 56 |
} |
57 |
|
|
58 |
.uploadAlert { |
|
59 |
background-color: #4085a5; |
|
60 |
border: none; |
|
61 |
width: 350px; |
|
62 |
} |
|
63 |
|
|
64 |
.uploadAlertLink { |
|
65 |
text-decoration: underline; |
|
66 |
position: absolute; |
|
67 |
left: 200px; |
|
68 |
top: 2px; |
|
69 |
} |
|
70 |
|
|
71 |
.uploadAlertClose { |
|
72 |
cursor: pointer; |
|
73 |
position: absolute; |
|
74 |
right: 1px; |
|
75 |
top: 2px; |
|
76 |
} |
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
63 | 63 |
|
64 | 64 |
import com.google.gwt.core.client.EntryPoint; |
65 | 65 |
import com.google.gwt.core.client.GWT; |
66 |
import com.google.gwt.core.client.JavaScriptObject; |
|
67 |
import com.google.gwt.core.client.JsArray; |
|
68 |
import com.google.gwt.core.client.JsArrayString; |
|
66 | 69 |
import com.google.gwt.core.client.Scheduler; |
67 | 70 |
import com.google.gwt.core.client.Scheduler.RepeatingCommand; |
68 | 71 |
import com.google.gwt.core.client.Scheduler.ScheduledCommand; |
... | ... | |
102 | 105 |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
103 | 106 |
import com.google.gwt.user.client.ui.HorizontalPanel; |
104 | 107 |
import com.google.gwt.user.client.ui.HorizontalSplitPanel; |
108 |
import com.google.gwt.user.client.ui.PopupPanel; |
|
105 | 109 |
import com.google.gwt.user.client.ui.RootPanel; |
106 | 110 |
import com.google.gwt.user.client.ui.VerticalPanel; |
107 | 111 |
import com.google.gwt.view.client.SelectionChangeEvent; |
... | ... | |
126 | 130 |
|
127 | 131 |
@ClassName("gwt-HTML") |
128 | 132 |
String html(); |
133 |
|
|
134 |
String uploadAlert(); |
|
135 |
|
|
136 |
String uploadAlertLink(); |
|
137 |
|
|
138 |
String uploadAlertClose(); |
|
129 | 139 |
} |
130 | 140 |
|
131 | 141 |
public interface Resources extends ClientBundle { |
132 | 142 |
@Source("Pithos.css") |
133 | 143 |
Style pithosCss(); |
144 |
|
|
145 |
@Source("gr/grnet/pithos/resources/close-popup.png") |
|
146 |
ImageResource closePopup(); |
|
134 | 147 |
} |
135 | 148 |
|
136 | 149 |
public static Resources resources = GWT.create(Resources.class); |
... | ... | |
173 | 186 |
updateSharedFolder(f, showfiles, null); |
174 | 187 |
} |
175 | 188 |
|
176 |
public void updateOtherSharedFolder(Folder f, boolean showfiles) { |
|
177 |
otherSharedTreeView.updateFolder(f, showfiles); |
|
189 |
public void updateOtherSharedFolder(Folder f, boolean showfiles, Command callback) {
|
|
190 |
otherSharedTreeView.updateFolder(f, showfiles, callback);
|
|
178 | 191 |
} |
179 | 192 |
|
180 | 193 |
public MysharedTreeView getMySharedTreeView() { |
... | ... | |
281 | 294 |
private Toolbar toolbar; |
282 | 295 |
|
283 | 296 |
private FileUploadDialog fileUploadDialog = new FileUploadDialog(this); |
284 |
|
|
297 |
|
|
298 |
UploadAlert uploadAlert; |
|
299 |
|
|
285 | 300 |
@Override |
286 | 301 |
public void onModuleLoad() { |
287 | 302 |
if (parseUserCredentials()) |
... | ... | |
1160 | 1175 |
if (otherSharedTreeSelectionModel.getSelectedObject() != null) { |
1161 | 1176 |
deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel); |
1162 | 1177 |
applyPermissions(otherSharedTreeSelectionModel.getSelectedObject()); |
1163 |
updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true); |
|
1178 |
updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true, null);
|
|
1164 | 1179 |
showRelevantToolbarButtons(); |
1165 | 1180 |
} |
1166 | 1181 |
else { |
... | ... | |
1342 | 1357 |
} |
1343 | 1358 |
|
1344 | 1359 |
private void updateUploadFolder() { |
1360 |
updateUploadFolder(null); |
|
1361 |
} |
|
1362 |
|
|
1363 |
private void updateUploadFolder(final JsArrayString urls) { |
|
1345 | 1364 |
if (folderTreeView.equals(getSelectedTree()) || otherSharedTreeView.equals(getSelectedTree())) { |
1346 | 1365 |
Folder f = getSelection(); |
1347 | 1366 |
if (getSelectedTree().equals(getFolderTreeView())) |
... | ... | |
1350 | 1369 |
@Override |
1351 | 1370 |
public void execute() { |
1352 | 1371 |
updateStatistics(); |
1372 |
if (urls != null) |
|
1373 |
selectUploadedFiles(urls); |
|
1353 | 1374 |
} |
1354 | 1375 |
}, false); |
1355 | 1376 |
else |
1356 |
updateOtherSharedFolder(f, true); |
|
1377 |
updateOtherSharedFolder(f, true, null);
|
|
1357 | 1378 |
} |
1358 | 1379 |
} |
1359 | 1380 |
|
... | ... | |
1365 | 1386 |
|
1366 | 1387 |
public native void enableUploadArea() /*-{ |
1367 | 1388 |
var uploader = $wnd.$("#uploader").pluploadQueue(); |
1389 |
var dropElm = $wnd.document.getElementById('rightPanel'); |
|
1390 |
$wnd.plupload.removeAllEvents(dropElm, uploader.id); |
|
1368 | 1391 |
if (uploader.runtime == 'html5') { |
1369 | 1392 |
uploader.settings.drop_element = 'rightPanel'; |
1370 |
var dropElm = $wnd.document.getElementById(uploader.settings.drop_element); |
|
1371 | 1393 |
uploader.trigger('PostInit'); |
1372 | 1394 |
} |
1373 | 1395 |
}-*/; |
1396 |
|
|
1397 |
public void showUploadAlert(int numOfFiles) { |
|
1398 |
uploadAlert = new UploadAlert(this, numOfFiles); |
|
1399 |
uploadAlert.setPopupPositionAndShow(new PopupPanel.PositionCallback() { |
|
1400 |
|
|
1401 |
@Override |
|
1402 |
public void setPosition(int offsetWidth, int offsetHeight) { |
|
1403 |
uploadAlert.setPopupPosition((Window.getClientWidth() - offsetWidth)/2, Window.getClientHeight() - offsetHeight); |
|
1404 |
} |
|
1405 |
}); |
|
1406 |
} |
|
1407 |
|
|
1408 |
public void hideUploadAlert() { |
|
1409 |
uploadAlert.hide(); |
|
1410 |
} |
|
1411 |
|
|
1412 |
public void selectUploadedFiles(JsArrayString urls) { |
|
1413 |
List<String> selectedUrls = new ArrayList<String>(); |
|
1414 |
for (int i=0; i<urls.length(); i++) |
|
1415 |
selectedUrls.add(urls.get(i)); |
|
1416 |
fileList.selectByUrl(selectedUrls); |
|
1417 |
} |
|
1374 | 1418 |
} |
b/src/gr/grnet/pithos/web/client/UploadAlert.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2011-2012 GRNET S.A. All rights reserved. |
|
3 |
* |
|
4 |
* Redistribution and use in source and binary forms, with or |
|
5 |
* without modification, are permitted provided that the following |
|
6 |
* conditions are met: |
|
7 |
* |
|
8 |
* 1. Redistributions of source code must retain the above |
|
9 |
* copyright notice, this list of conditions and the following |
|
10 |
* disclaimer. |
|
11 |
* |
|
12 |
* 2. Redistributions in binary form must reproduce the above |
|
13 |
* copyright notice, this list of conditions and the following |
|
14 |
* disclaimer in the documentation and/or other materials |
|
15 |
* provided with the distribution. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
18 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
19 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
22 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
23 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
24 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
25 |
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
26 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
27 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
28 |
* POSSIBILITY OF SUCH DAMAGE. |
|
29 |
* |
|
30 |
* The views and conclusions contained in the software and |
|
31 |
* documentation are those of the authors and should not be |
|
32 |
* interpreted as representing official policies, either expressed |
|
33 |
* or implied, of GRNET S.A. |
|
34 |
*/ |
|
35 |
package gr.grnet.pithos.web.client; |
|
36 |
|
|
37 |
import com.google.gwt.event.dom.client.ClickEvent; |
|
38 |
import com.google.gwt.event.dom.client.ClickHandler; |
|
39 |
import com.google.gwt.user.client.ui.Anchor; |
|
40 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
41 |
import com.google.gwt.user.client.ui.HTML; |
|
42 |
import com.google.gwt.user.client.ui.Image; |
|
43 |
import com.google.gwt.user.client.ui.PopupPanel; |
|
44 |
|
|
45 |
/** |
|
46 |
* The 'Folder Context' menu implementation. |
|
47 |
*/ |
|
48 |
public class UploadAlert extends PopupPanel { |
|
49 |
|
|
50 |
/** |
|
51 |
* The widget's constructor. |
|
52 |
*/ |
|
53 |
public UploadAlert(final Pithos app, int numOfFiles) { |
|
54 |
// The popup's constructor's argument is a boolean specifying that it |
|
55 |
// auto-close itself when the user clicks outside of it. |
|
56 |
super(false); |
|
57 |
setAnimationEnabled(true); |
|
58 |
addStyleName(Pithos.resources.pithosCss().uploadAlert()); |
|
59 |
FlowPanel content = new FlowPanel(); |
|
60 |
String label = String.valueOf(numOfFiles) + " " + (numOfFiles > 1 ? "files are" : "file is") + " being uploaded"; |
|
61 |
content.add(new HTML(label)); |
|
62 |
Anchor a = new Anchor("Click for details"); |
|
63 |
a.addStyleName(Pithos.resources.pithosCss().uploadAlertLink()); |
|
64 |
a.addClickHandler(new ClickHandler() { |
|
65 |
|
|
66 |
@Override |
|
67 |
public void onClick(ClickEvent event) { |
|
68 |
app.getFileUploadDialog().center(); |
|
69 |
} |
|
70 |
}); |
|
71 |
content.add(a); |
|
72 |
Image close = new Image(Pithos.resources.closePopup()); |
|
73 |
close.addClickHandler(new ClickHandler() { |
|
74 |
|
|
75 |
@Override |
|
76 |
public void onClick(ClickEvent event) { |
|
77 |
hide(); |
|
78 |
} |
|
79 |
}); |
|
80 |
close.addStyleName(Pithos.resources.pithosCss().uploadAlertClose()); |
|
81 |
content.add(close); |
|
82 |
add(content); |
|
83 |
} |
|
84 |
} |
b/src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeView.java | ||
---|---|---|
49 | 49 |
import com.google.gwt.user.cellview.client.CellTree; |
50 | 50 |
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; |
51 | 51 |
import com.google.gwt.user.cellview.client.TreeNode; |
52 |
import com.google.gwt.user.client.Command; |
|
52 | 53 |
import com.google.gwt.user.client.ui.Composite; |
53 | 54 |
import com.google.gwt.user.client.ui.Tree; |
54 | 55 |
|
... | ... | |
175 | 176 |
return model.getSelection(); |
176 | 177 |
} |
177 | 178 |
|
178 |
public void updateFolder(Folder folder, boolean showfiles) { |
|
179 |
model.updateFolder(folder, showfiles); |
|
179 |
public void updateFolder(Folder folder, boolean showfiles, Command callback) {
|
|
180 |
model.updateFolder(folder, showfiles, callback);
|
|
180 | 181 |
} |
181 | 182 |
} |
b/src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeViewModel.java | ||
---|---|---|
156 | 156 |
dataProviderMap.put(f, new ListDataProvider<Folder>()); |
157 | 157 |
} |
158 | 158 |
final ListDataProvider<Folder> dataProvider = dataProviderMap.get(f); |
159 |
fetchFolder(f, dataProvider, false); |
|
159 |
fetchFolder(f, dataProvider, false, null);
|
|
160 | 160 |
return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null); |
161 | 161 |
} |
162 | 162 |
} |
... | ... | |
305 | 305 |
return selectionModel.getSelectedObject(); |
306 | 306 |
} |
307 | 307 |
|
308 |
public void updateFolder(Folder folder, boolean showfiles) { |
|
308 |
public void updateFolder(Folder folder, boolean showfiles, Command callback) {
|
|
309 | 309 |
if (dataProviderMap.get(folder) == null) { |
310 | 310 |
dataProviderMap.put(folder, new ListDataProvider<Folder>()); |
311 | 311 |
} |
312 | 312 |
final ListDataProvider<Folder> dataProvider = dataProviderMap.get(folder); |
313 |
fetchFolder(folder, dataProvider, showfiles); |
|
313 |
fetchFolder(folder, dataProvider, showfiles, callback);
|
|
314 | 314 |
} |
315 | 315 |
|
316 |
public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles) { |
|
316 |
public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles, final Command callback) {
|
|
317 | 317 |
String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()); |
318 | 318 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) { |
319 | 319 |
@Override |
... | ... | |
327 | 327 |
dataProvider.getList().clear(); |
328 | 328 |
dataProvider.getList().addAll(_result.getSubfolders()); |
329 | 329 |
app.getOtherSharedTreeView().updateChildren(f); |
330 |
if (callback != null) |
|
331 |
callback.execute(); |
|
330 | 332 |
} |
331 | 333 |
}); |
332 | 334 |
} |
Also available in: Unified diff