2 * Copyright 2011 GRNET S.A. All rights reserved.
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the following
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
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.
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.
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.
35 package gr.grnet.pithos.web.client;
37 import gr.grnet.pithos.web.client.commands.EmptyTrashCommand;
38 import gr.grnet.pithos.web.client.commands.NewFolderCommand;
39 import gr.grnet.pithos.web.client.commands.PropertiesCommand;
40 import gr.grnet.pithos.web.client.commands.RefreshCommand;
41 import gr.grnet.pithos.web.client.commands.UploadFileCommand;
42 import gr.grnet.pithos.web.client.foldertree.File;
43 import gr.grnet.pithos.web.client.foldertree.Folder;
44 import gr.grnet.pithos.web.client.rest.resource.FileResource;
46 import java.util.List;
48 import com.google.gwt.event.dom.client.ClickEvent;
49 import com.google.gwt.event.dom.client.ClickHandler;
50 import com.google.gwt.resources.client.ClientBundle;
51 import com.google.gwt.resources.client.ImageResource;
52 import com.google.gwt.user.client.Command;
53 import com.google.gwt.user.client.ui.AbstractImagePrototype;
54 import com.google.gwt.user.client.ui.MenuBar;
55 import com.google.gwt.user.client.ui.MenuItem;
58 * The 'File' menu implementation.
60 public class FileMenu extends MenuBar {
63 * The widget's images.
65 private final Images images;
68 * An image bundle for this widgets images.
70 public interface Images extends ClientBundle,FilePropertiesDialog.Images {
72 @Source("gr/grnet/pithos/resources/folder_new.png")
73 ImageResource folderNew();
75 @Source("gr/grnet/pithos/resources/folder_outbox.png")
76 ImageResource fileUpdate();
78 @Source("gr/grnet/pithos/resources/view_text.png")
79 ImageResource viewText();
82 @Source("gr/grnet/pithos/resources/folder_inbox.png")
83 ImageResource download();
85 @Source("gr/grnet/pithos/resources/trashcan_empty.png")
86 ImageResource emptyTrash();
88 @Source("gr/grnet/pithos/resources/internet.png")
89 ImageResource sharing();
91 @Source("gr/grnet/pithos/resources/refresh.png")
92 ImageResource refresh();
94 @Source("gr/grnet/pithos/resources/")
95 ImageResource unselectAll();
99 * The widget's constructor.
101 * @param _images the image bundle passed on by the parent object
103 public FileMenu(GSS _app, final Images _images) {
105 setAnimationEnabled(true);
108 Folder selectedFolder = _app.getFolderTreeView().getSelection();
109 List<File> selectedFiles = _app.getFileList().getSelectedFiles();
110 if (selectedFolder != null) {
111 MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(null, selectedFolder, images));
112 addItem(newFolderItem);
114 MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(null, selectedFolder));
117 if (selectedFiles.size() == 1) {
118 addItem(new MenuItem("<span><a class='hidden-link' href='" + GSS.get().getApiPath() + GSS.get().getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + GSS.get().getToken() + "' target='_blank'>" + AbstractImagePrototype.create(images.download()).getHTML() + " Download</a></span>", true, (Command) null));
121 // MenuItem emptyTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this));
122 // emptyTrashItem.getElement().setId("topMenu.file.emptyTrash");
123 // contextMenu.addItem(emptyTrashItem);
125 // MenuItem refreshItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
126 // refreshItem.getElement().setId("topMenu.file.refresh");
127 // contextMenu.addItem(refreshItem);
129 // MenuItem sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1));
130 // sharingItem.getElement().setId("topMenu.file.sharing");
131 // contextMenu.addItem(sharingItem)
132 // .setVisible(propertiesVisible);
134 // MenuItem propertiesItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, images, 0));
135 // propertiesItem.getElement().setId("topMenu.file.properties");
136 // contextMenu.addItem(propertiesItem)
137 // .setVisible(propertiesVisible);