root / src / gr / grnet / pithos / web / client / FileContextMenu.java @ 602ebeb4
History | View | Annotate | Download (8.2 kB)
1 | a57faaf0 | Christos Stathis | /*
|
---|---|---|---|
2 | 63366925 | Christos Stathis | * Copyright 2011 GRNET S.A. All rights reserved.
|
3 | 63366925 | Christos Stathis | *
|
4 | 63366925 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 63366925 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 63366925 | Christos Stathis | * conditions are met:
|
7 | 63366925 | Christos Stathis | *
|
8 | 63366925 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 63366925 | Christos Stathis | * disclaimer.
|
11 | 63366925 | Christos Stathis | *
|
12 | 63366925 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 63366925 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 63366925 | Christos Stathis | * provided with the distribution.
|
16 | 63366925 | Christos Stathis | *
|
17 | 63366925 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 63366925 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 63366925 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 63366925 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 63366925 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 63366925 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 63366925 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 63366925 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 63366925 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 63366925 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 63366925 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 63366925 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 63366925 | Christos Stathis | *
|
30 | 63366925 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 63366925 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 63366925 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 63366925 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | a57faaf0 | Christos Stathis | */
|
35 | a57faaf0 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | a57faaf0 | Christos Stathis | |
37 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.CopyCommand; |
38 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.CutCommand; |
39 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.DeleteCommand; |
40 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.PasteCommand; |
41 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.PropertiesCommand; |
42 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.RefreshCommand; |
43 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.RestoreTrashCommand; |
44 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.ToTrashCommand; |
45 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.UploadFileCommand; |
46 | d4374639 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.File; |
47 | 63366925 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Folder; |
48 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.rest.resource.FileResource; |
49 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.rest.resource.FolderResource; |
50 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.rest.resource.RestResource; |
51 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper; |
52 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.rest.resource.TrashFolderResource; |
53 | a57faaf0 | Christos Stathis | |
54 | a57faaf0 | Christos Stathis | import java.util.List; |
55 | a57faaf0 | Christos Stathis | |
56 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickEvent; |
57 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickHandler; |
58 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ContextMenuEvent; |
59 | a57faaf0 | Christos Stathis | import com.google.gwt.resources.client.ClientBundle; |
60 | a57faaf0 | Christos Stathis | import com.google.gwt.resources.client.ImageResource; |
61 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.Command; |
62 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.Event; |
63 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
64 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.MenuBar; |
65 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.MenuItem; |
66 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.PopupPanel; |
67 | a57faaf0 | Christos Stathis | |
68 | a57faaf0 | Christos Stathis | /**
|
69 | a57faaf0 | Christos Stathis | * The 'File Context' menu implementation.
|
70 | a57faaf0 | Christos Stathis | */
|
71 | 63366925 | Christos Stathis | public class FileContextMenu extends PopupPanel { |
72 | a57faaf0 | Christos Stathis | |
73 | a57faaf0 | Christos Stathis | /**
|
74 | a57faaf0 | Christos Stathis | * The widget's images.
|
75 | a57faaf0 | Christos Stathis | */
|
76 | a57faaf0 | Christos Stathis | private final Images images; |
77 | a57faaf0 | Christos Stathis | |
78 | a57faaf0 | Christos Stathis | private MenuItem cutItem; |
79 | a57faaf0 | Christos Stathis | |
80 | a57faaf0 | Christos Stathis | private MenuItem copyItem; |
81 | a57faaf0 | Christos Stathis | |
82 | a57faaf0 | Christos Stathis | private MenuItem pasteItem; |
83 | a57faaf0 | Christos Stathis | |
84 | a57faaf0 | Christos Stathis | private MenuItem updateItem; |
85 | a57faaf0 | Christos Stathis | |
86 | a57faaf0 | Christos Stathis | private MenuItem sharingItem; |
87 | a57faaf0 | Christos Stathis | |
88 | a57faaf0 | Christos Stathis | private MenuItem propItem; |
89 | a57faaf0 | Christos Stathis | |
90 | a57faaf0 | Christos Stathis | private MenuItem trashItem; |
91 | a57faaf0 | Christos Stathis | |
92 | a57faaf0 | Christos Stathis | private MenuItem deleteItem; |
93 | a57faaf0 | Christos Stathis | |
94 | a57faaf0 | Christos Stathis | private MenuItem downloadItem; |
95 | a57faaf0 | Christos Stathis | |
96 | a57faaf0 | Christos Stathis | private MenuItem saveAsItem; |
97 | a57faaf0 | Christos Stathis | |
98 | a57faaf0 | Christos Stathis | /**
|
99 | a57faaf0 | Christos Stathis | * The image bundle for this widget's images that reuses images defined in
|
100 | a57faaf0 | Christos Stathis | * other menus.
|
101 | a57faaf0 | Christos Stathis | */
|
102 | a57faaf0 | Christos Stathis | public interface Images extends ClientBundle,FileMenu.Images, EditMenu.Images { |
103 | a57faaf0 | Christos Stathis | |
104 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/mimetypes/document.png") |
105 | a57faaf0 | Christos Stathis | ImageResource fileContextMenu(); |
106 | a57faaf0 | Christos Stathis | |
107 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/doc_versions.png") |
108 | a57faaf0 | Christos Stathis | ImageResource versions(); |
109 | a57faaf0 | Christos Stathis | |
110 | a57faaf0 | Christos Stathis | @Override
|
111 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/group.png") |
112 | a57faaf0 | Christos Stathis | ImageResource sharing(); |
113 | a57faaf0 | Christos Stathis | |
114 | a57faaf0 | Christos Stathis | @Override
|
115 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/border_remove.png") |
116 | a57faaf0 | Christos Stathis | ImageResource unselectAll(); |
117 | a57faaf0 | Christos Stathis | |
118 | a57faaf0 | Christos Stathis | @Source("gr/grnet/pithos/resources/demo.png") |
119 | a57faaf0 | Christos Stathis | ImageResource viewImage(); |
120 | a57faaf0 | Christos Stathis | } |
121 | a57faaf0 | Christos Stathis | |
122 | a57faaf0 | Christos Stathis | public static native String getDate()/*-{ |
123 | a57faaf0 | Christos Stathis | return (new Date()).toUTCString();
|
124 | a57faaf0 | Christos Stathis | }-*/;
|
125 | a57faaf0 | Christos Stathis | |
126 | a57faaf0 | Christos Stathis | /**
|
127 | a57faaf0 | Christos Stathis | * The widget's constructor.
|
128 | a57faaf0 | Christos Stathis | *
|
129 | a57faaf0 | Christos Stathis | * @param newImages the image bundle passed on by the parent object
|
130 | a57faaf0 | Christos Stathis | */
|
131 | d4374639 | Christos Stathis | public FileContextMenu(Images newImages, Folder selectedFolder, List<File> selectedFiles, boolean isTrash) { |
132 | a57faaf0 | Christos Stathis | // The popup's constructor's argument is a boolean specifying that it
|
133 | a57faaf0 | Christos Stathis | // auto-close itself when the user clicks outside of it.
|
134 | a57faaf0 | Christos Stathis | super(true); |
135 | a57faaf0 | Christos Stathis | GSS gss = GSS.get(); |
136 | a57faaf0 | Christos Stathis | setAnimationEnabled(true);
|
137 | a57faaf0 | Christos Stathis | images = newImages; |
138 | 63366925 | Christos Stathis | MenuBar contextMenu = new MenuBar(true); |
139 | a57faaf0 | Christos Stathis | |
140 | 1e413f9b | Christos Stathis | pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + " Paste</span>", true, new PasteCommand(GSS.get(), this, selectedFolder)); |
141 | 63366925 | Christos Stathis | contextMenu.addItem(pasteItem); |
142 | 63366925 | Christos Stathis | |
143 | bdda6b2f | Christos Stathis | MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this, selectedFolder)); |
144 | 63366925 | Christos Stathis | contextMenu.addItem(upload); |
145 | 63366925 | Christos Stathis | |
146 | 63366925 | Christos Stathis | MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
147 | 63366925 | Christos Stathis | contextMenu.addItem(refresh); |
148 | 63366925 | Christos Stathis | |
149 | 63366925 | Christos Stathis | if (isTrash) {
|
150 | 63366925 | Christos Stathis | MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(this)); |
151 | a57faaf0 | Christos Stathis | contextMenu.addItem(restore); |
152 | 63366925 | Christos Stathis | |
153 | f1aabd89 | Christos Stathis | MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, null, images)); |
154 | a57faaf0 | Christos Stathis | contextMenu.addItem(delete); |
155 | a57faaf0 | Christos Stathis | } else {
|
156 | 1e413f9b | Christos Stathis | cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(GSS.get(), this, selectedFiles)); |
157 | 63366925 | Christos Stathis | contextMenu.addItem(cutItem); |
158 | 63366925 | Christos Stathis | |
159 | 1e413f9b | Christos Stathis | copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(GSS.get(), this, selectedFiles)); |
160 | 63366925 | Christos Stathis | contextMenu.addItem(copyItem); |
161 | 63366925 | Christos Stathis | |
162 | a57faaf0 | Christos Stathis | trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
163 | 63366925 | Christos Stathis | contextMenu.addItem(trashItem); |
164 | 63366925 | Christos Stathis | |
165 | d4374639 | Christos Stathis | deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, selectedFiles, images)); |
166 | 63366925 | Christos Stathis | contextMenu.addItem(deleteItem); |
167 | a57faaf0 | Christos Stathis | |
168 | a57faaf0 | Christos Stathis | sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1)); |
169 | 63366925 | Christos Stathis | contextMenu.addItem(sharingItem); |
170 | 63366925 | Christos Stathis | |
171 | a57faaf0 | Christos Stathis | propItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, images, 0)); |
172 | 63366925 | Christos Stathis | contextMenu.addItem(propItem); |
173 | 63366925 | Christos Stathis | |
174 | 1eddfbcc | Christos Stathis | downloadItem = 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(newImages.download()).getHTML() + " Download</a></span>", true, new Command() { |
175 | 63366925 | Christos Stathis | @Override
|
176 | 63366925 | Christos Stathis | public void execute() { |
177 | 63366925 | Christos Stathis | } |
178 | 1eddfbcc | Christos Stathis | }); |
179 | a57faaf0 | Christos Stathis | contextMenu.addItem(downloadItem); |
180 | a57faaf0 | Christos Stathis | |
181 | 63366925 | Christos Stathis | final Command unselectAllCommand = new Command() { |
182 | 63366925 | Christos Stathis | |
183 | 63366925 | Christos Stathis | @Override
|
184 | 63366925 | Christos Stathis | public void execute() { |
185 | 63366925 | Christos Stathis | hide(); |
186 | 63366925 | Christos Stathis | if(GSS.get().isFileListShowing())
|
187 | 63366925 | Christos Stathis | GSS.get().getFileList().clearSelectedRows(); |
188 | 63366925 | Christos Stathis | } |
189 | 63366925 | Christos Stathis | }; |
190 | a57faaf0 | Christos Stathis | MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect</span>", true, unselectAllCommand); |
191 | a57faaf0 | Christos Stathis | contextMenu.addItem(unSelect); |
192 | 63366925 | Christos Stathis | |
193 | a57faaf0 | Christos Stathis | } |
194 | a57faaf0 | Christos Stathis | add(contextMenu); |
195 | a57faaf0 | Christos Stathis | |
196 | 63366925 | Christos Stathis | // if (gss.getClipboard().hasFileItem())
|
197 | 63366925 | Christos Stathis | // pasteItem.setVisible(true);
|
198 | 63366925 | Christos Stathis | // else
|
199 | 63366925 | Christos Stathis | // pasteItem.setVisible(false);
|
200 | a57faaf0 | Christos Stathis | } |
201 | a57faaf0 | Christos Stathis | } |