Revision 58777026 web_client/src/gr/grnet/pithos/web/client/FileList.java
b/web_client/src/gr/grnet/pithos/web/client/FileList.java | ||
---|---|---|
1 | 1 |
/* |
2 |
* Copyright (c) 2011 Greek Research and Technology Network |
|
2 |
* Copyright 2011 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. |
|
3 | 34 |
*/ |
4 | 35 |
|
5 | 36 |
package gr.grnet.pithos.web.client; |
6 | 37 |
|
38 |
import com.google.gwt.event.dom.client.ContextMenuEvent; |
|
39 |
import com.google.gwt.event.dom.client.ContextMenuHandler; |
|
7 | 40 |
import static com.google.gwt.query.client.GQuery.$; |
8 | 41 |
|
9 | 42 |
import gr.grnet.pithos.web.client.commands.UploadFileCommand; |
10 | 43 |
import gr.grnet.pithos.web.client.foldertree.File; |
11 | 44 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
12 | 45 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView; |
13 |
import gr.grnet.pithos.web.client.rest.GetCommand; |
|
14 |
import gr.grnet.pithos.web.client.rest.RestCommand; |
|
15 | 46 |
import gr.grnet.pithos.web.client.rest.resource.FileResource; |
16 |
import gr.grnet.pithos.web.client.rest.resource.OtherUserResource; |
|
17 |
import gr.grnet.pithos.web.client.rest.resource.OthersFolderResource; |
|
18 |
import gr.grnet.pithos.web.client.rest.resource.OthersResource; |
|
19 |
import gr.grnet.pithos.web.client.rest.resource.RestResource; |
|
20 |
import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper; |
|
21 |
import gr.grnet.pithos.web.client.rest.resource.SharedResource; |
|
22 |
import gr.grnet.pithos.web.client.rest.resource.TrashFolderResource; |
|
23 |
import gr.grnet.pithos.web.client.rest.resource.TrashResource; |
|
24 |
import gr.grnet.pithos.web.client.rest.resource.UserResource; |
|
25 | 47 |
import gwtquery.plugins.draggable.client.DraggableOptions; |
26 | 48 |
import gwtquery.plugins.draggable.client.StopDragException; |
27 | 49 |
import gwtquery.plugins.draggable.client.DraggableOptions.DragFunction; |
... | ... | |
40 | 62 |
import java.util.Iterator; |
41 | 63 |
import java.util.List; |
42 | 64 |
|
43 |
import com.google.gwt.cell.client.AbstractCell; |
|
44 | 65 |
import com.google.gwt.cell.client.ImageResourceCell; |
45 | 66 |
import com.google.gwt.cell.client.SafeHtmlCell; |
46 | 67 |
import com.google.gwt.cell.client.TextCell; |
... | ... | |
70 | 91 |
import com.google.gwt.view.client.ProvidesKey; |
71 | 92 |
import com.google.gwt.view.client.SelectionChangeEvent; |
72 | 93 |
import com.google.gwt.view.client.SelectionChangeEvent.Handler; |
73 |
import java.util.Set; |
|
74 | 94 |
|
75 | 95 |
/** |
76 | 96 |
* A composite that displays the list of files in a particular folder. |
... | ... | |
220 | 240 |
*/ |
221 | 241 |
private final Images images; |
222 | 242 |
|
223 |
private FileContextMenu menuShowing;
|
|
243 |
private FileContextMenu contextMenu;
|
|
224 | 244 |
|
225 | 245 |
private DragAndDropCellTable<File> celltable; |
226 | 246 |
|
... | ... | |
248 | 268 |
* |
249 | 269 |
* @param _images |
250 | 270 |
*/ |
251 |
public FileList(Images _images, FolderTreeView treeView) { |
|
271 |
public FileList(Images _images, FolderTreeView _treeView) {
|
|
252 | 272 |
images = _images; |
253 |
this.treeView = treeView; |
|
273 |
this.treeView = _treeView;
|
|
254 | 274 |
|
255 | 275 |
DragAndDropCellTable.Resources resources = GWT.create(TableResources.class); |
256 | 276 |
|
... | ... | |
428 | 448 |
|
429 | 449 |
vp.add(bottomPanel); |
430 | 450 |
vp.setCellWidth(celltable, "100%"); |
451 |
vp.addHandler(new ContextMenuHandler() { |
|
452 |
@Override |
|
453 |
public void onContextMenu(ContextMenuEvent event) { |
|
454 |
contextMenu = new FileContextMenu(images, treeView.getSelection(), false); |
|
455 |
int x = event.getNativeEvent().getClientX(); |
|
456 |
int y = event.getNativeEvent().getClientY(); |
|
457 |
contextMenu.setPopupPosition(x, y); |
|
458 |
contextMenu.show(); |
|
459 |
} |
|
460 |
}, ContextMenuEvent.getType()); |
|
431 | 461 |
initWidget(vp); |
432 | 462 |
|
433 | 463 |
selectionModel = new MultiSelectionModel<File>(keyProvider); |
... | ... | |
487 | 517 |
}); |
488 | 518 |
} |
489 | 519 |
|
490 |
public void showContextMenu(Event event){ |
|
491 |
menuShowing = new FileContextMenu(images, false, true); |
|
492 |
menuShowing=menuShowing.onEmptyEvent(event); |
|
493 |
} |
|
494 |
@Override |
|
495 |
public void onBrowserEvent(Event event) { |
|
496 |
|
|
497 |
if (files == null || files.size() == 0) { |
|
498 |
if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { |
|
499 |
menuShowing = new FileContextMenu(images, false, true); |
|
500 |
menuShowing=menuShowing.onEmptyEvent(event); |
|
501 |
event.preventDefault(); |
|
502 |
event.cancelBubble(true); |
|
503 |
} |
|
504 |
return; |
|
505 |
} |
|
506 |
if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) { |
|
507 |
GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null); |
|
508 |
menuShowing = new FileContextMenu(images, false, false); |
|
509 |
menuShowing=menuShowing.onEvent(event); |
|
510 |
event.cancelBubble(true); |
|
511 |
event.preventDefault(); |
|
512 |
} else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { |
|
513 |
menuShowing = new FileContextMenu(images, false, true); |
|
514 |
menuShowing=menuShowing.onEmptyEvent(event); |
|
515 |
event.cancelBubble(true); |
|
516 |
event.preventDefault(); |
|
517 |
} else if (DOM.eventGetType(event) == Event.ONDBLCLICK) |
|
518 |
if (getSelectedFiles().size() == 1) { |
|
519 |
GSS app = GSS.get(); |
|
520 |
File file = getSelectedFiles().get(0); |
|
521 |
Window.open(file.getUri(), "_blank", ""); |
|
522 |
event.preventDefault(); |
|
523 |
return; |
|
524 |
} |
|
525 |
super.onBrowserEvent(event); |
|
526 |
} |
|
520 |
// @Override |
|
521 |
// public void onBrowserEvent(Event event) { |
|
522 |
// |
|
523 |
// if (files == null || files.size() == 0) { |
|
524 |
// if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { |
|
525 |
// contextMenu = new FileContextMenu(images, false, true); |
|
526 |
// contextMenu.show(); |
|
527 |
// event.preventDefault(); |
|
528 |
// event.cancelBubble(true); |
|
529 |
// } |
|
530 |
// return; |
|
531 |
// } |
|
532 |
// if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) { |
|
533 |
// GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null); |
|
534 |
// contextMenu = new FileContextMenu(images, false, false); |
|
535 |
// contextMenu = contextMenu.onEvent(event); |
|
536 |
// event.cancelBubble(true); |
|
537 |
// event.preventDefault(); |
|
538 |
// } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { |
|
539 |
// contextMenu = new FileContextMenu(images, false, true); |
|
540 |
// contextMenu = contextMenu.onEmptyEvent(event); |
|
541 |
// event.cancelBubble(true); |
|
542 |
// event.preventDefault(); |
|
543 |
// } else if (DOM.eventGetType(event) == Event.ONDBLCLICK) |
|
544 |
// if (getSelectedFiles().size() == 1) { |
|
545 |
// GSS app = GSS.get(); |
|
546 |
// File file = getSelectedFiles().get(0); |
|
547 |
// Window.open(file.getUri(), "_blank", ""); |
|
548 |
// event.preventDefault(); |
|
549 |
// return; |
|
550 |
// } |
|
551 |
// super.onBrowserEvent(event); |
|
552 |
// } |
|
527 | 553 |
|
528 | 554 |
/** |
529 | 555 |
* Update the display of the file list. |
Also available in: Unified diff