root / web_client / src / gr / grnet / pithos / web / client / EditMenu.java @ a39e5b47
History | View | Annotate | Download (7.5 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.ToTrashCommand; |
42 | e3f47376 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.File; |
43 | 6b4a2499 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Folder; |
44 | ab1eb3f8 | Christos Stathis | |
45 | ab1eb3f8 | Christos Stathis | import java.util.List; |
46 | ab1eb3f8 | Christos Stathis | |
47 | ab1eb3f8 | Christos Stathis | import com.google.gwt.resources.client.ClientBundle; |
48 | ab1eb3f8 | Christos Stathis | import com.google.gwt.resources.client.ImageResource; |
49 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.Command; |
50 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
51 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.ui.MenuBar; |
52 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.ui.MenuItem; |
53 | ab1eb3f8 | Christos Stathis | |
54 | ab1eb3f8 | Christos Stathis | /**
|
55 | ab1eb3f8 | Christos Stathis | * The 'Edit' menu implementation.
|
56 | ab1eb3f8 | Christos Stathis | */
|
57 | e3f47376 | Christos Stathis | public class EditMenu extends MenuBar { |
58 | ab1eb3f8 | Christos Stathis | |
59 | ab1eb3f8 | Christos Stathis | /**
|
60 | ab1eb3f8 | Christos Stathis | * The widget's images.
|
61 | ab1eb3f8 | Christos Stathis | */
|
62 | ab1eb3f8 | Christos Stathis | private final Images images; |
63 | ab1eb3f8 | Christos Stathis | |
64 | ab1eb3f8 | Christos Stathis | /**
|
65 | ab1eb3f8 | Christos Stathis | * An image bundle for this widget's images.
|
66 | ab1eb3f8 | Christos Stathis | */
|
67 | ab1eb3f8 | Christos Stathis | public interface Images extends ClientBundle, FileMenu.Images, MessagePanel.Images { |
68 | ab1eb3f8 | Christos Stathis | |
69 | ab1eb3f8 | Christos Stathis | /**
|
70 | ab1eb3f8 | Christos Stathis | * Will bundle the file 'editcut.png' residing in the package
|
71 | ab1eb3f8 | Christos Stathis | * 'gr.grnet.pithos.web.resources'.
|
72 | ab1eb3f8 | Christos Stathis | *
|
73 | ab1eb3f8 | Christos Stathis | * @return the image prototype
|
74 | ab1eb3f8 | Christos Stathis | */
|
75 | ab1eb3f8 | Christos Stathis | @Source("gr/grnet/pithos/resources/editcut.png") |
76 | ab1eb3f8 | Christos Stathis | ImageResource cut(); |
77 | ab1eb3f8 | Christos Stathis | |
78 | ab1eb3f8 | Christos Stathis | /**
|
79 | ab1eb3f8 | Christos Stathis | * Will bundle the file 'editcopy.png' residing in the package
|
80 | ab1eb3f8 | Christos Stathis | * 'gr.grnet.pithos.web.resources'.
|
81 | ab1eb3f8 | Christos Stathis | *
|
82 | ab1eb3f8 | Christos Stathis | * @return the image prototype
|
83 | ab1eb3f8 | Christos Stathis | */
|
84 | ab1eb3f8 | Christos Stathis | @Source("gr/grnet/pithos/resources/editcopy.png") |
85 | ab1eb3f8 | Christos Stathis | ImageResource copy(); |
86 | ab1eb3f8 | Christos Stathis | |
87 | ab1eb3f8 | Christos Stathis | /**
|
88 | ab1eb3f8 | Christos Stathis | * Will bundle the file 'editpaste.png' residing in the package
|
89 | ab1eb3f8 | Christos Stathis | * 'gr.grnet.pithos.web.resources'.
|
90 | ab1eb3f8 | Christos Stathis | *
|
91 | ab1eb3f8 | Christos Stathis | * @return the image prototype
|
92 | ab1eb3f8 | Christos Stathis | */
|
93 | ab1eb3f8 | Christos Stathis | @Source("gr/grnet/pithos/resources/editpaste.png") |
94 | ab1eb3f8 | Christos Stathis | ImageResource paste(); |
95 | ab1eb3f8 | Christos Stathis | |
96 | ab1eb3f8 | Christos Stathis | /**
|
97 | ab1eb3f8 | Christos Stathis | * Will bundle the file 'editdelete.png' residing in the package
|
98 | ab1eb3f8 | Christos Stathis | * 'gr.grnet.pithos.web.resources'.
|
99 | ab1eb3f8 | Christos Stathis | *
|
100 | ab1eb3f8 | Christos Stathis | * @return the image prototype
|
101 | ab1eb3f8 | Christos Stathis | */
|
102 | ab1eb3f8 | Christos Stathis | @Override
|
103 | ab1eb3f8 | Christos Stathis | @Source("gr/grnet/pithos/resources/editdelete.png") |
104 | ab1eb3f8 | Christos Stathis | ImageResource delete(); |
105 | ab1eb3f8 | Christos Stathis | |
106 | ab1eb3f8 | Christos Stathis | /**
|
107 | ab1eb3f8 | Christos Stathis | * Will bundle the file 'translate.png' residing in the package
|
108 | ab1eb3f8 | Christos Stathis | * 'gr.grnet.pithos.web.resources'.
|
109 | ab1eb3f8 | Christos Stathis | *
|
110 | ab1eb3f8 | Christos Stathis | * @return the image prototype
|
111 | ab1eb3f8 | Christos Stathis | */
|
112 | ab1eb3f8 | Christos Stathis | @Source("gr/grnet/pithos/resources/translate.png") |
113 | ab1eb3f8 | Christos Stathis | ImageResource selectAll(); |
114 | ab1eb3f8 | Christos Stathis | |
115 | ab1eb3f8 | Christos Stathis | /**
|
116 | ab1eb3f8 | Christos Stathis | * Will bundle the file 'border_remove.png' residing in the package
|
117 | ab1eb3f8 | Christos Stathis | * 'gr.grnet.pithos.web.resources'.
|
118 | ab1eb3f8 | Christos Stathis | *
|
119 | ab1eb3f8 | Christos Stathis | * @return the image prototype
|
120 | ab1eb3f8 | Christos Stathis | */
|
121 | ab1eb3f8 | Christos Stathis | @Source("gr/grnet/pithos/resources/border_remove.png") |
122 | ab1eb3f8 | Christos Stathis | ImageResource unselectAll(); |
123 | ab1eb3f8 | Christos Stathis | } |
124 | ab1eb3f8 | Christos Stathis | |
125 | ab1eb3f8 | Christos Stathis | /**
|
126 | ab1eb3f8 | Christos Stathis | * The widget's constructor.
|
127 | ab1eb3f8 | Christos Stathis | *
|
128 | ab1eb3f8 | Christos Stathis | * @param newImages the image bundle passed on by the parent object
|
129 | ab1eb3f8 | Christos Stathis | */
|
130 | f55cf326 | Christos Stathis | public EditMenu(final Pithos _app, final Images newImages) { |
131 | ab1eb3f8 | Christos Stathis | super(true); |
132 | ab1eb3f8 | Christos Stathis | setAnimationEnabled(true);
|
133 | ab1eb3f8 | Christos Stathis | images = newImages; |
134 | ab1eb3f8 | Christos Stathis | |
135 | e3f47376 | Christos Stathis | Folder selectedFolder = _app.getFolderTreeView().getSelection(); |
136 | e3f47376 | Christos Stathis | List<File> selectedFiles = _app.getFileList().getSelectedFiles(); |
137 | e3f47376 | Christos Stathis | |
138 | e3f47376 | Christos Stathis | String cutLabel = "Cut"; |
139 | e3f47376 | Christos Stathis | String copyLabel ="Copy"; |
140 | e3f47376 | Christos Stathis | String pasteLabel = "Paste"; |
141 | e3f47376 | Christos Stathis | if(selectedFiles.size() == 1) { |
142 | e3f47376 | Christos Stathis | cutLabel = "Cut File";
|
143 | e3f47376 | Christos Stathis | copyLabel = "Copy File";
|
144 | e3f47376 | Christos Stathis | } |
145 | e3f47376 | Christos Stathis | else if (selectedFiles.size() > 1) { |
146 | e3f47376 | Christos Stathis | cutLabel = "Cut Files";
|
147 | e3f47376 | Christos Stathis | copyLabel = "Copy Files";
|
148 | e3f47376 | Christos Stathis | } |
149 | e3f47376 | Christos Stathis | else if (selectedFolder != null) { |
150 | e3f47376 | Christos Stathis | cutLabel = "Cut Folder";
|
151 | e3f47376 | Christos Stathis | copyLabel = "Copy Folder";
|
152 | e3f47376 | Christos Stathis | } |
153 | e3f47376 | Christos Stathis | |
154 | e3f47376 | Christos Stathis | if (_app.getClipboard().hasFiles()) {
|
155 | e3f47376 | Christos Stathis | if (((List<File>) _app.getClipboard().getItem()).size() > 1) |
156 | e3f47376 | Christos Stathis | pasteLabel = "Paste Files";
|
157 | e3f47376 | Christos Stathis | else
|
158 | e3f47376 | Christos Stathis | pasteLabel = "Paste File";
|
159 | e3f47376 | Christos Stathis | } |
160 | e3f47376 | Christos Stathis | else
|
161 | e3f47376 | Christos Stathis | pasteLabel = "Paste Folder";
|
162 | e3f47376 | Christos Stathis | |
163 | e3f47376 | Christos Stathis | if (selectedFiles.size() > 0 || selectedFolder != null) { |
164 | e3f47376 | Christos Stathis | Object cutObject = null; |
165 | e3f47376 | Christos Stathis | if (selectedFiles.size() > 0) |
166 | e3f47376 | Christos Stathis | cutObject = selectedFiles; |
167 | e3f47376 | Christos Stathis | else if (selectedFolder != null) |
168 | e3f47376 | Christos Stathis | cutObject = selectedFolder; |
169 | e3f47376 | Christos Stathis | |
170 | 50326f36 | Christos Stathis | if (selectedFiles.size() != 0 || (selectedFolder != null && !selectedFolder.isContainer())) { |
171 | 50326f36 | Christos Stathis | MenuItem cutItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.cut()).getHTML() + " " + cutLabel + "</span>", true, new CutCommand(_app, null, cutObject)); |
172 | 50326f36 | Christos Stathis | addItem(cutItem); |
173 | 50326f36 | Christos Stathis | } |
174 | e3f47376 | Christos Stathis | |
175 | e3f47376 | Christos Stathis | MenuItem copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.copy()).getHTML() + " "+copyLabel+"</span>", true, new CopyCommand(_app, null, cutObject)); |
176 | e3f47376 | Christos Stathis | addItem(copyItem); |
177 | e3f47376 | Christos Stathis | |
178 | 50326f36 | Christos Stathis | if (selectedFiles.size() != 0 || (selectedFolder != null && !selectedFolder.isContainer())) { |
179 | 50326f36 | Christos Stathis | MenuItem moveToTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(_app, null, cutObject)); |
180 | 50326f36 | Christos Stathis | addItem(moveToTrashItem); |
181 | e3f47376 | Christos Stathis | |
182 | 50326f36 | Christos Stathis | MenuItem deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(null, cutObject, images)); |
183 | 50326f36 | Christos Stathis | addItem(deleteItem); |
184 | 50326f36 | Christos Stathis | } |
185 | e3f47376 | Christos Stathis | } |
186 | e3f47376 | Christos Stathis | |
187 | e3f47376 | Christos Stathis | if (selectedFolder != null && !_app.getClipboard().isEmpty()) { |
188 | e3f47376 | Christos Stathis | MenuItem pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + " " + pasteLabel + "</span>", true, new PasteCommand(_app, null, selectedFolder)); |
189 | e3f47376 | Christos Stathis | addItem(pasteItem); |
190 | e3f47376 | Christos Stathis | } |
191 | e3f47376 | Christos Stathis | |
192 | e3f47376 | Christos Stathis | |
193 | e3f47376 | Christos Stathis | MenuItem selectAllItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.selectAll()).getHTML() + " Select All</span>", true, new Command() { |
194 | e3f47376 | Christos Stathis | |
195 | e3f47376 | Christos Stathis | @Override
|
196 | e3f47376 | Christos Stathis | public void execute() { |
197 | e3f47376 | Christos Stathis | _app.getFileList().selectAllRows(); |
198 | 6b4a2499 | Christos Stathis | } |
199 | e3f47376 | Christos Stathis | }); |
200 | e3f47376 | Christos Stathis | addItem(selectAllItem); |
201 | ab1eb3f8 | Christos Stathis | |
202 | e3f47376 | Christos Stathis | MenuItem unSelectAllItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect All</span>", true, new Command() { |
203 | ab1eb3f8 | Christos Stathis | |
204 | e3f47376 | Christos Stathis | @Override
|
205 | e3f47376 | Christos Stathis | public void execute() { |
206 | e3f47376 | Christos Stathis | _app.getFileList().clearSelectedRows(); |
207 | e3f47376 | Christos Stathis | } |
208 | e3f47376 | Christos Stathis | }); |
209 | e3f47376 | Christos Stathis | addItem(unSelectAllItem); |
210 | e3f47376 | Christos Stathis | } |
211 | ab1eb3f8 | Christos Stathis | } |