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.NewFolderCommand;
38 import gr.grnet.pithos.web.client.commands.PropertiesCommand;
39 import gr.grnet.pithos.web.client.commands.UploadFileCommand;
40 import gr.grnet.pithos.web.client.foldertree.File;
41 import gr.grnet.pithos.web.client.foldertree.Folder;
43 import java.util.List;
45 import com.google.gwt.resources.client.ClientBundle;
46 import com.google.gwt.resources.client.ImageResource;
47 import com.google.gwt.user.client.Command;
48 import com.google.gwt.user.client.ui.AbstractImagePrototype;
49 import com.google.gwt.user.client.ui.MenuBar;
50 import com.google.gwt.user.client.ui.MenuItem;
53 * The 'File' menu implementation.
55 public class FileMenu extends MenuBar {
58 * The widget's images.
60 private final Images images;
63 * An image bundle for this widgets images.
65 public interface Images extends ClientBundle,FilePropertiesDialog.Images {
67 @Source("gr/grnet/pithos/resources/folder_new.png")
68 ImageResource folderNew();
70 @Source("gr/grnet/pithos/resources/folder_outbox.png")
71 ImageResource fileUpdate();
73 @Source("gr/grnet/pithos/resources/view_text.png")
74 ImageResource viewText();
77 @Source("gr/grnet/pithos/resources/folder_inbox.png")
78 ImageResource download();
80 @Source("gr/grnet/pithos/resources/trashcan_empty.png")
81 ImageResource emptyTrash();
83 @Source("gr/grnet/pithos/resources/internet.png")
84 ImageResource sharing();
86 @Source("gr/grnet/pithos/resources/refresh.png")
87 ImageResource refresh();
89 @Source("gr/grnet/pithos/resources/")
90 ImageResource unselectAll();
94 * The widget's constructor.
96 * @param _images the image bundle passed on by the parent object
98 public FileMenu(Pithos _app, final Images _images) {
100 setAnimationEnabled(true);
103 Folder selectedFolder = _app.getFolderTreeView().getSelection();
104 List<File> selectedFiles = _app.getFileList().getSelectedFiles();
105 if (selectedFolder != null) {
106 MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(_app, null, selectedFolder, images));
107 addItem(newFolderItem);
109 MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(_app, null, selectedFolder));
112 if (selectedFiles.size() == 1) {
113 addItem(new MenuItem("<span><a class='hidden-link' href='" + _app.getApiPath() + _app.getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + _app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(images.download()).getHTML() + " Download</a></span>", true, (Command) null));
116 // MenuItem emptyTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this));
117 // emptyTrashItem.getElement().setId("topMenu.file.emptyTrash");
118 // contextMenu.addItem(emptyTrashItem);
120 // MenuItem refreshItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
121 // refreshItem.getElement().setId("topMenu.file.refresh");
122 // contextMenu.addItem(refreshItem);
124 // MenuItem sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1));
125 // sharingItem.getElement().setId("topMenu.file.sharing");
126 // contextMenu.addItem(sharingItem)
127 // .setVisible(propertiesVisible);
129 if (selectedFiles.size() > 0 || selectedFolder != null) {
130 MenuItem propertiesItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(_app, null, selectedFiles.size() > 0 ? selectedFiles : selectedFolder, images, 0));
131 addItem(propertiesItem);