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