root / src / gr / ebs / gss / client / FileList.java @ bed4db0d
History | View | Annotate | Download (32.5 kB)
1 | 14ad7326 | pastith | /*
|
---|---|---|---|
2 | 14ad7326 | pastith | * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
|
3 | 14ad7326 | pastith | *
|
4 | 14ad7326 | pastith | * This file is part of GSS.
|
5 | 14ad7326 | pastith | *
|
6 | 14ad7326 | pastith | * GSS is free software: you can redistribute it and/or modify
|
7 | 14ad7326 | pastith | * it under the terms of the GNU General Public License as published by
|
8 | 14ad7326 | pastith | * the Free Software Foundation, either version 3 of the License, or
|
9 | 14ad7326 | pastith | * (at your option) any later version.
|
10 | 14ad7326 | pastith | *
|
11 | 14ad7326 | pastith | * GSS is distributed in the hope that it will be useful,
|
12 | 14ad7326 | pastith | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 14ad7326 | pastith | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 14ad7326 | pastith | * GNU General Public License for more details.
|
15 | 14ad7326 | pastith | *
|
16 | 14ad7326 | pastith | * You should have received a copy of the GNU General Public License
|
17 | 14ad7326 | pastith | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | 14ad7326 | pastith | */
|
19 | 14ad7326 | pastith | package gr.ebs.gss.client; |
20 | 14ad7326 | pastith | |
21 | 14ad7326 | pastith | import gr.ebs.gss.client.dnd.DnDFocusPanel; |
22 | a52ea5e4 | pastith | import gr.ebs.gss.client.dnd.DnDTreeItem; |
23 | 895035a2 | pastith | import gr.ebs.gss.client.rest.GetCommand; |
24 | f12de32e | koutsoub | import gr.ebs.gss.client.rest.MultipleHeadCommand; |
25 | bbad17b4 | pastith | import gr.ebs.gss.client.rest.RestCommand; |
26 | a52ea5e4 | pastith | import gr.ebs.gss.client.rest.RestException; |
27 | a52ea5e4 | pastith | import gr.ebs.gss.client.rest.resource.FileResource; |
28 | a52ea5e4 | pastith | import gr.ebs.gss.client.rest.resource.FolderResource; |
29 | abb31c1f | koutsoub | import gr.ebs.gss.client.rest.resource.OtherUserResource; |
30 | abb31c1f | koutsoub | import gr.ebs.gss.client.rest.resource.SharedResource; |
31 | a52ea5e4 | pastith | import gr.ebs.gss.client.rest.resource.TrashResource; |
32 | a52ea5e4 | pastith | import gr.ebs.gss.client.rest.resource.UserResource; |
33 | 14ad7326 | pastith | |
34 | 14ad7326 | pastith | import java.util.ArrayList; |
35 | 14ad7326 | pastith | import java.util.Collections; |
36 | 14ad7326 | pastith | import java.util.Comparator; |
37 | 14ad7326 | pastith | import java.util.List; |
38 | 14ad7326 | pastith | |
39 | 14ad7326 | pastith | import com.google.gwt.core.client.GWT; |
40 | eaf8a7cb | koutsoub | import com.google.gwt.http.client.URL; |
41 | 14ad7326 | pastith | import com.google.gwt.i18n.client.DateTimeFormat; |
42 | 14ad7326 | pastith | import com.google.gwt.user.client.DOM; |
43 | 14ad7326 | pastith | import com.google.gwt.user.client.DeferredCommand; |
44 | 14ad7326 | pastith | import com.google.gwt.user.client.Event; |
45 | 14ad7326 | pastith | import com.google.gwt.user.client.IncrementalCommand; |
46 | eaf8a7cb | koutsoub | import com.google.gwt.user.client.Window; |
47 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
48 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.ClickListener; |
49 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.Composite; |
50 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.Grid; |
51 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HTML; |
52 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
53 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HorizontalPanel; |
54 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.SourcesTableEvents; |
55 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.TableListener; |
56 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.TreeItem; |
57 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.Widget; |
58 | 14ad7326 | pastith | |
59 | 14ad7326 | pastith | /**
|
60 | 14ad7326 | pastith | * A composite that displays the list of files in a particular folder.
|
61 | 14ad7326 | pastith | */
|
62 | 14ad7326 | pastith | public class FileList extends Composite implements TableListener, ClickListener { |
63 | 14ad7326 | pastith | |
64 | 14ad7326 | pastith | private HTML prevButton = new HTML("<a href='javascript:;'>< Previous</a>", true); |
65 | 14ad7326 | pastith | |
66 | 14ad7326 | pastith | private HTML nextButton = new HTML("<a href='javascript:;'>Next ></a>", true); |
67 | 14ad7326 | pastith | |
68 | b3c6d52e | fstamatelopoulos | private String showingStats = ""; |
69 | b3c6d52e | fstamatelopoulos | |
70 | 14ad7326 | pastith | private int startIndex = 0; |
71 | 14ad7326 | pastith | |
72 | 14ad7326 | pastith | /**
|
73 | 14ad7326 | pastith | * A constant that denotes the completion of an IncrementalCommand.
|
74 | 14ad7326 | pastith | */
|
75 | 14ad7326 | pastith | public static final boolean DONE = false; |
76 | 14ad7326 | pastith | |
77 | 14ad7326 | pastith | private boolean clickControl = false; |
78 | 14ad7326 | pastith | |
79 | 14ad7326 | pastith | private boolean clickShift = false; |
80 | 14ad7326 | pastith | |
81 | 14ad7326 | pastith | private int firstShift = -1; |
82 | 14ad7326 | pastith | |
83 | 14ad7326 | pastith | private ArrayList<Integer> selectedRows = new ArrayList<Integer>(); |
84 | 14ad7326 | pastith | |
85 | 14ad7326 | pastith | /**
|
86 | 14ad7326 | pastith | * The context menu for the selected file.
|
87 | 14ad7326 | pastith | */
|
88 | 14ad7326 | pastith | final DnDFocusPanel contextMenu;
|
89 | 14ad7326 | pastith | |
90 | 14ad7326 | pastith | /**
|
91 | 14ad7326 | pastith | * Specifies that the images available for this composite will be the ones
|
92 | 14ad7326 | pastith | * available in FileContextMenu.
|
93 | 14ad7326 | pastith | */
|
94 | 14ad7326 | pastith | public interface Images extends FileContextMenu.Images, Folders.Images { |
95 | 14ad7326 | pastith | |
96 | 14ad7326 | pastith | @Resource("gr/ebs/gss/resources/blank.gif") |
97 | 14ad7326 | pastith | AbstractImagePrototype blank(); |
98 | 14ad7326 | pastith | |
99 | 14ad7326 | pastith | @Resource("gr/ebs/gss/resources/asc.png") |
100 | 14ad7326 | pastith | AbstractImagePrototype asc(); |
101 | 14ad7326 | pastith | |
102 | 14ad7326 | pastith | @Resource("gr/ebs/gss/resources/desc.png") |
103 | 14ad7326 | pastith | AbstractImagePrototype desc(); |
104 | 0e4865ee | pastith | |
105 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/document_shared.png") |
106 | f12de32e | koutsoub | AbstractImagePrototype documentShared(); |
107 | f12de32e | koutsoub | |
108 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/kcmfontinst.png") |
109 | 0e4865ee | pastith | AbstractImagePrototype wordprocessor(); |
110 | 0e4865ee | pastith | |
111 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/log.png") |
112 | 0e4865ee | pastith | AbstractImagePrototype spreadsheet(); |
113 | 0e4865ee | pastith | |
114 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/kpresenter_kpr.png") |
115 | 0e4865ee | pastith | AbstractImagePrototype presentation(); |
116 | 0e4865ee | pastith | |
117 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/acroread.png") |
118 | 0e4865ee | pastith | AbstractImagePrototype pdf(); |
119 | 0e4865ee | pastith | |
120 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/image.png") |
121 | 0e4865ee | pastith | AbstractImagePrototype image(); |
122 | 0e4865ee | pastith | |
123 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/video2.png") |
124 | 0e4865ee | pastith | AbstractImagePrototype video(); |
125 | 0e4865ee | pastith | |
126 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/knotify.png") |
127 | 0e4865ee | pastith | AbstractImagePrototype audio(); |
128 | 0e4865ee | pastith | |
129 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/html.png") |
130 | 0e4865ee | pastith | AbstractImagePrototype html(); |
131 | 0e4865ee | pastith | |
132 | 4e392495 | fstamatelopoulos | @Resource("gr/ebs/gss/resources/mimetypes/txt.png") |
133 | 4e392495 | fstamatelopoulos | AbstractImagePrototype txt(); |
134 | 4e392495 | fstamatelopoulos | |
135 | 0e4865ee | pastith | @Resource("gr/ebs/gss/resources/mimetypes/ark2.png") |
136 | 0e4865ee | pastith | AbstractImagePrototype zip(); |
137 | f12de32e | koutsoub | |
138 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/kcmfontinst_shared.png") |
139 | f12de32e | koutsoub | AbstractImagePrototype wordprocessorShared(); |
140 | f12de32e | koutsoub | |
141 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/log_shared.png") |
142 | f12de32e | koutsoub | AbstractImagePrototype spreadsheetShared(); |
143 | f12de32e | koutsoub | |
144 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/kpresenter_kpr_shared.png") |
145 | f12de32e | koutsoub | AbstractImagePrototype presentationShared(); |
146 | f12de32e | koutsoub | |
147 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/acroread_shared.png") |
148 | f12de32e | koutsoub | AbstractImagePrototype pdfShared(); |
149 | f12de32e | koutsoub | |
150 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/image_shared.png") |
151 | f12de32e | koutsoub | AbstractImagePrototype imageShared(); |
152 | f12de32e | koutsoub | |
153 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/video2_shared.png") |
154 | f12de32e | koutsoub | AbstractImagePrototype videoShared(); |
155 | f12de32e | koutsoub | |
156 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/knotify_shared.png") |
157 | f12de32e | koutsoub | AbstractImagePrototype audioShared(); |
158 | f12de32e | koutsoub | |
159 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/html_shared.png") |
160 | f12de32e | koutsoub | AbstractImagePrototype htmlShared(); |
161 | f12de32e | koutsoub | |
162 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/txt_shared.png") |
163 | f12de32e | koutsoub | AbstractImagePrototype txtShared(); |
164 | f12de32e | koutsoub | |
165 | f12de32e | koutsoub | @Resource("gr/ebs/gss/resources/mimetypes/ark2_shared.png") |
166 | f12de32e | koutsoub | AbstractImagePrototype zipShared(); |
167 | f12de32e | koutsoub | |
168 | 14ad7326 | pastith | } |
169 | 14ad7326 | pastith | |
170 | 14ad7326 | pastith | /**
|
171 | 14ad7326 | pastith | * A label with the number of files in this folder.
|
172 | 14ad7326 | pastith | */
|
173 | 14ad7326 | pastith | private HTML countLabel = new HTML(); |
174 | 14ad7326 | pastith | |
175 | 14ad7326 | pastith | /**
|
176 | 14ad7326 | pastith | * The table widget with the file list.
|
177 | 14ad7326 | pastith | */
|
178 | a52ea5e4 | pastith | private Grid table = new Grid(GSS.VISIBLE_FILE_COUNT + 1, 8); |
179 | 14ad7326 | pastith | |
180 | 14ad7326 | pastith | /**
|
181 | 14ad7326 | pastith | * The navigation bar for paginating the results.
|
182 | 14ad7326 | pastith | */
|
183 | 14ad7326 | pastith | private HorizontalPanel navBar = new HorizontalPanel(); |
184 | 14ad7326 | pastith | |
185 | 14ad7326 | pastith | /**
|
186 | 14ad7326 | pastith | * The number of files in this folder.
|
187 | 14ad7326 | pastith | */
|
188 | 14ad7326 | pastith | int folderFileCount;
|
189 | 14ad7326 | pastith | |
190 | 14ad7326 | pastith | /**
|
191 | a44876bf | fstamatelopoulos | * Total folder size
|
192 | a44876bf | fstamatelopoulos | */
|
193 | a44876bf | fstamatelopoulos | long folderTotalSize;
|
194 | a44876bf | fstamatelopoulos | |
195 | a44876bf | fstamatelopoulos | /**
|
196 | 14ad7326 | pastith | * A cache of the files in the list.
|
197 | 14ad7326 | pastith | */
|
198 | a52ea5e4 | pastith | private List<FileResource> files; |
199 | 14ad7326 | pastith | |
200 | 14ad7326 | pastith | /**
|
201 | 14ad7326 | pastith | * The widget's image bundle.
|
202 | 14ad7326 | pastith | */
|
203 | 14ad7326 | pastith | private final Images images; |
204 | 14ad7326 | pastith | |
205 | 14ad7326 | pastith | private String sortingProperty = "name"; |
206 | 14ad7326 | pastith | |
207 | 14ad7326 | pastith | private boolean sortingType = true; |
208 | 14ad7326 | pastith | |
209 | 14ad7326 | pastith | private HTML nameLabel; |
210 | 14ad7326 | pastith | |
211 | 14ad7326 | pastith | private HTML versionLabel; |
212 | 14ad7326 | pastith | |
213 | 14ad7326 | pastith | private HTML sizeLabel; |
214 | 14ad7326 | pastith | |
215 | 14ad7326 | pastith | private HTML dateLabel; |
216 | 14ad7326 | pastith | |
217 | 14ad7326 | pastith | private HTML ownerLabel; |
218 | a52ea5e4 | pastith | |
219 | f1fb019b | fstamatelopoulos | private HTML pathLabel; |
220 | f1fb019b | fstamatelopoulos | |
221 | 14ad7326 | pastith | /**
|
222 | 14ad7326 | pastith | * Construct the file list widget. This entails setting up the widget
|
223 | 14ad7326 | pastith | * layout, fetching the number of files in the current folder from the
|
224 | 14ad7326 | pastith | * server and filling the local file cache of displayed files with data from
|
225 | 14ad7326 | pastith | * the server, as well.
|
226 | 14ad7326 | pastith | *
|
227 | 14ad7326 | pastith | * @param _images
|
228 | 14ad7326 | pastith | */
|
229 | 0e4865ee | pastith | public FileList(Images _images) {
|
230 | 14ad7326 | pastith | images = _images; |
231 | 14ad7326 | pastith | |
232 | 14ad7326 | pastith | prevButton.addClickListener(this);
|
233 | 14ad7326 | pastith | nextButton.addClickListener(this);
|
234 | 14ad7326 | pastith | |
235 | 14ad7326 | pastith | contextMenu = new DnDFocusPanel(new HTML(images.fileContextMenu().getHTML())); |
236 | b4b188fe | koutsoub | contextMenu.addClickListener(new FileContextMenu(images, false, false)); |
237 | 14ad7326 | pastith | GSS.get().getDragController().makeDraggable(contextMenu); |
238 | a52ea5e4 | pastith | |
239 | 14ad7326 | pastith | // Setup the table.
|
240 | 14ad7326 | pastith | table.setCellSpacing(0);
|
241 | 14ad7326 | pastith | table.setCellPadding(2);
|
242 | 14ad7326 | pastith | table.setWidth("100%");
|
243 | 14ad7326 | pastith | |
244 | 14ad7326 | pastith | // Hook up events.
|
245 | 14ad7326 | pastith | table.addTableListener(this);
|
246 | 14ad7326 | pastith | |
247 | 14ad7326 | pastith | // Create the 'navigation' bar at the upper-right.
|
248 | 0e4865ee | pastith | HorizontalPanel innerNavBar = new HorizontalPanel();
|
249 | 14ad7326 | pastith | innerNavBar.setStyleName("gss-ListNavBar");
|
250 | 14ad7326 | pastith | innerNavBar.setSpacing(8);
|
251 | 14ad7326 | pastith | innerNavBar.add(prevButton); |
252 | 14ad7326 | pastith | innerNavBar.add(countLabel); |
253 | 14ad7326 | pastith | innerNavBar.add(nextButton); |
254 | 14ad7326 | pastith | navBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); |
255 | 14ad7326 | pastith | navBar.add(innerNavBar); |
256 | 14ad7326 | pastith | navBar.setWidth("100%");
|
257 | 14ad7326 | pastith | |
258 | 14ad7326 | pastith | initWidget(table); |
259 | 14ad7326 | pastith | setStyleName("gss-List");
|
260 | 14ad7326 | pastith | |
261 | 14ad7326 | pastith | initTable(); |
262 | 14ad7326 | pastith | DeferredCommand.addCommand(new IncrementalCommand() {
|
263 | 14ad7326 | pastith | |
264 | 14ad7326 | pastith | public boolean execute() { |
265 | 14ad7326 | pastith | return fetchRootFolder();
|
266 | 14ad7326 | pastith | } |
267 | 14ad7326 | pastith | }); |
268 | 14ad7326 | pastith | sinkEvents(Event.ONCONTEXTMENU);
|
269 | 14ad7326 | pastith | sinkEvents(Event.ONMOUSEUP);
|
270 | 14ad7326 | pastith | sinkEvents(Event.ONCLICK);
|
271 | 14ad7326 | pastith | sinkEvents(Event.ONKEYDOWN);
|
272 | eaf8a7cb | koutsoub | sinkEvents(Event.ONDBLCLICK);
|
273 | 18cd8128 | fstamatelopoulos | GSS.preventIESelection(); |
274 | 14ad7326 | pastith | } |
275 | 14ad7326 | pastith | |
276 | 14ad7326 | pastith | public void onClick(Widget sender) { |
277 | 14ad7326 | pastith | if (sender == nextButton) {
|
278 | 14ad7326 | pastith | // Move forward a page.
|
279 | 14ad7326 | pastith | clearSelectedRows(); |
280 | a52ea5e4 | pastith | startIndex += GSS.VISIBLE_FILE_COUNT; |
281 | 14ad7326 | pastith | if (startIndex >= folderFileCount)
|
282 | a52ea5e4 | pastith | startIndex -= GSS.VISIBLE_FILE_COUNT; |
283 | 14ad7326 | pastith | else
|
284 | 14ad7326 | pastith | update(); |
285 | 14ad7326 | pastith | } else if (sender == prevButton) { |
286 | 14ad7326 | pastith | clearSelectedRows(); |
287 | 14ad7326 | pastith | // Move back a page.
|
288 | a52ea5e4 | pastith | startIndex -= GSS.VISIBLE_FILE_COUNT; |
289 | 14ad7326 | pastith | if (startIndex < 0) |
290 | 14ad7326 | pastith | startIndex = 0;
|
291 | 14ad7326 | pastith | else
|
292 | 14ad7326 | pastith | update(); |
293 | 14ad7326 | pastith | } |
294 | 14ad7326 | pastith | } |
295 | 14ad7326 | pastith | |
296 | 0e4865ee | pastith | @Override
|
297 | 14ad7326 | pastith | public void onBrowserEvent(Event event) { |
298 | 848896d0 | koutsoub | if (files == null || files.size() == 0) { |
299 | 848896d0 | koutsoub | if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && selectedRows.size() == 0) { |
300 | 1f651a6a | koutsoub | FileContextMenu fm = new FileContextMenu(images, false, true); |
301 | 1f651a6a | koutsoub | fm.onEmptyEvent(event); |
302 | 1f651a6a | koutsoub | } |
303 | a52ea5e4 | pastith | return;
|
304 | 1f651a6a | koutsoub | } |
305 | 14ad7326 | pastith | if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && selectedRows.size() != 0) { |
306 | b4b188fe | koutsoub | FileContextMenu fm = new FileContextMenu(images, false, false); |
307 | 848896d0 | koutsoub | fm.onEvent(event); |
308 | 848896d0 | koutsoub | } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && selectedRows.size() == 0) { |
309 | b4b188fe | koutsoub | FileContextMenu fm = new FileContextMenu(images, false, true); |
310 | b4b188fe | koutsoub | fm.onEmptyEvent(event); |
311 | 848896d0 | koutsoub | } else if (DOM.eventGetType(event) == Event.ONDBLCLICK) |
312 | 848896d0 | koutsoub | if (getSelectedFiles().size() == 1) { |
313 | bbad17b4 | pastith | GSS app = GSS.get(); |
314 | eaf8a7cb | koutsoub | FileResource file = getSelectedFiles().get(0);
|
315 | 895035a2 | pastith | String dateString = RestCommand.getDate();
|
316 | bbad17b4 | pastith | String resource = file.getUri().substring(app.getApiPath().length() - 1, file.getUri().length()); |
317 | bbad17b4 | pastith | String sig = app.getCurrentUserResource().getUsername() + " " + |
318 | 895035a2 | pastith | RestCommand.calculateSig("GET", dateString, resource,
|
319 | bbad17b4 | pastith | RestCommand.base64decode(app.getToken())); |
320 | 555e8e59 | pastith | Window.open(file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date=" + URL.encodeComponent(dateString), "_blank", ""); |
321 | 848896d0 | koutsoub | event.preventDefault(); |
322 | 848896d0 | koutsoub | return;
|
323 | eaf8a7cb | koutsoub | } |
324 | fa6bdefa | koutsoub | if (DOM.eventGetType(event) == Event.ONCLICK) { |
325 | 14ad7326 | pastith | if (DOM.eventGetCtrlKey(event))
|
326 | 14ad7326 | pastith | clickControl = true;
|
327 | 14ad7326 | pastith | else
|
328 | 14ad7326 | pastith | clickControl = false;
|
329 | 14ad7326 | pastith | if (DOM.eventGetShiftKey(event)) {
|
330 | 14ad7326 | pastith | clickShift = true;
|
331 | 14ad7326 | pastith | if (selectedRows.size() == 1) |
332 | 14ad7326 | pastith | firstShift = selectedRows.get(0) - startIndex;
|
333 | 14ad7326 | pastith | event.preventDefault(); |
334 | 14ad7326 | pastith | } else {
|
335 | 14ad7326 | pastith | clickShift = false;
|
336 | 14ad7326 | pastith | firstShift = -1;
|
337 | 14ad7326 | pastith | event.preventDefault(); |
338 | 14ad7326 | pastith | } |
339 | 14ad7326 | pastith | } |
340 | 14ad7326 | pastith | super.onBrowserEvent(event);
|
341 | 14ad7326 | pastith | } |
342 | 14ad7326 | pastith | |
343 | 14ad7326 | pastith | /**
|
344 | 14ad7326 | pastith | * Retrieve the root folder for the current user.
|
345 | 14ad7326 | pastith | *
|
346 | 14ad7326 | pastith | * @return true if the retrieval was successful
|
347 | 14ad7326 | pastith | */
|
348 | 14ad7326 | pastith | protected boolean fetchRootFolder() { |
349 | a52ea5e4 | pastith | UserResource user = GSS.get().getCurrentUserResource(); |
350 | 14ad7326 | pastith | if (user == null) |
351 | 14ad7326 | pastith | return !DONE;
|
352 | 0e4865ee | pastith | // Update cache and clear selection.
|
353 | 0e4865ee | pastith | updateFileCache(true);
|
354 | 14ad7326 | pastith | return DONE;
|
355 | 14ad7326 | pastith | } |
356 | 14ad7326 | pastith | |
357 | 0e4865ee | pastith | public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
358 | 14ad7326 | pastith | // Select the row that was clicked (-1 to account for header row).
|
359 | 14ad7326 | pastith | if (row > folderFileCount)
|
360 | 14ad7326 | pastith | return;
|
361 | 14ad7326 | pastith | if (clickShift) {
|
362 | 0e4865ee | pastith | GWT.log("Row is: " + row + " fs: " + firstShift, null); |
363 | 14ad7326 | pastith | if (firstShift == -1) |
364 | 14ad7326 | pastith | firstShift = row; |
365 | 14ad7326 | pastith | else if (row > firstShift) { |
366 | 14ad7326 | pastith | clearSelectedRows(); |
367 | 14ad7326 | pastith | for (int i = firstShift; i < row; i++) { |
368 | 14ad7326 | pastith | selectedRows.add(startIndex + i); |
369 | 14ad7326 | pastith | styleRow(i, true);
|
370 | 14ad7326 | pastith | } |
371 | 14ad7326 | pastith | GSS.get().setCurrentSelection(getSelectedFiles()); |
372 | 14ad7326 | pastith | contextMenu.setFiles(getSelectedFiles()); |
373 | 5770ff9b | koutsoub | makeRowDraggable(row); |
374 | 14ad7326 | pastith | } else if (row != -1 && row == firstShift) { |
375 | 14ad7326 | pastith | selectedRows.add(row - 1);
|
376 | 14ad7326 | pastith | styleRow(row, true);
|
377 | 14ad7326 | pastith | styleRow(row - 1, true); |
378 | 028cdbe6 | Dimitris Routsis | GSS.get().setCurrentSelection(getSelectedFiles()); |
379 | 028cdbe6 | Dimitris Routsis | contextMenu.setFiles(getSelectedFiles()); |
380 | 028cdbe6 | Dimitris Routsis | makeRowDraggable(row); |
381 | 14ad7326 | pastith | } else if (row < firstShift) { |
382 | 0e4865ee | pastith | GWT.log("Row is:" + row + " fs:" + firstShift, null); |
383 | 14ad7326 | pastith | clearSelectedRows(); |
384 | 14ad7326 | pastith | |
385 | 14ad7326 | pastith | for (int i = firstShift; i >= row - 1; i--) { |
386 | 14ad7326 | pastith | selectedRows.add(startIndex + i); |
387 | 14ad7326 | pastith | styleRow(i, true);
|
388 | 14ad7326 | pastith | } |
389 | 14ad7326 | pastith | GSS.get().setCurrentSelection(getSelectedFiles()); |
390 | 5770ff9b | koutsoub | makeRowDraggable(row); |
391 | 14ad7326 | pastith | contextMenu.setFiles(getSelectedFiles()); |
392 | 14ad7326 | pastith | } |
393 | 14ad7326 | pastith | } else if (row > 0) |
394 | 14ad7326 | pastith | selectRow(row - 1);
|
395 | 14ad7326 | pastith | } |
396 | 14ad7326 | pastith | |
397 | 14ad7326 | pastith | /**
|
398 | 14ad7326 | pastith | * Initializes the table so that it contains enough rows for a full page of
|
399 | 14ad7326 | pastith | * files.
|
400 | 14ad7326 | pastith | */
|
401 | 14ad7326 | pastith | private void initTable() { |
402 | 14ad7326 | pastith | nameLabel = new HTML("Name"); |
403 | 14ad7326 | pastith | nameLabel.addClickListener(new ClickListener() {
|
404 | 14ad7326 | pastith | |
405 | 14ad7326 | pastith | public void onClick(Widget sender) { |
406 | 14ad7326 | pastith | sortFiles("name");
|
407 | 14ad7326 | pastith | update(); |
408 | 14ad7326 | pastith | } |
409 | 14ad7326 | pastith | |
410 | 14ad7326 | pastith | }); |
411 | 14ad7326 | pastith | versionLabel = new HTML("Version"); |
412 | 14ad7326 | pastith | versionLabel.addClickListener(new ClickListener() {
|
413 | 14ad7326 | pastith | |
414 | 14ad7326 | pastith | public void onClick(Widget sender) { |
415 | 14ad7326 | pastith | sortFiles("version");
|
416 | 14ad7326 | pastith | update(); |
417 | 14ad7326 | pastith | } |
418 | 14ad7326 | pastith | |
419 | 14ad7326 | pastith | }); |
420 | 14ad7326 | pastith | sizeLabel = new HTML("Size"); |
421 | 14ad7326 | pastith | sizeLabel.addClickListener(new ClickListener() {
|
422 | 14ad7326 | pastith | |
423 | 14ad7326 | pastith | public void onClick(Widget sender) { |
424 | 14ad7326 | pastith | sortFiles("size");
|
425 | 14ad7326 | pastith | update(); |
426 | 14ad7326 | pastith | } |
427 | 14ad7326 | pastith | |
428 | 14ad7326 | pastith | }); |
429 | 14ad7326 | pastith | dateLabel = new HTML("Date"); |
430 | 14ad7326 | pastith | dateLabel.addClickListener(new ClickListener() {
|
431 | 14ad7326 | pastith | |
432 | 14ad7326 | pastith | public void onClick(Widget sender) { |
433 | 14ad7326 | pastith | sortFiles("date");
|
434 | 14ad7326 | pastith | update(); |
435 | 14ad7326 | pastith | } |
436 | 14ad7326 | pastith | |
437 | 14ad7326 | pastith | }); |
438 | 14ad7326 | pastith | ownerLabel = new HTML("Owner"); |
439 | 14ad7326 | pastith | ownerLabel.addClickListener(new ClickListener() {
|
440 | 14ad7326 | pastith | |
441 | 14ad7326 | pastith | public void onClick(Widget sender) { |
442 | 14ad7326 | pastith | sortFiles("owner");
|
443 | 14ad7326 | pastith | update(); |
444 | 14ad7326 | pastith | } |
445 | 14ad7326 | pastith | |
446 | 14ad7326 | pastith | }); |
447 | f1fb019b | fstamatelopoulos | pathLabel = new HTML("Path"); |
448 | f1fb019b | fstamatelopoulos | pathLabel.addClickListener(new ClickListener() {
|
449 | f1fb019b | fstamatelopoulos | |
450 | f1fb019b | fstamatelopoulos | public void onClick(Widget sender) { |
451 | f1fb019b | fstamatelopoulos | sortFiles("path");
|
452 | f1fb019b | fstamatelopoulos | update(); |
453 | f1fb019b | fstamatelopoulos | } |
454 | f1fb019b | fstamatelopoulos | |
455 | f1fb019b | fstamatelopoulos | }); |
456 | 14ad7326 | pastith | // Create the header row.
|
457 | 14ad7326 | pastith | table.setText(0, 0, ""); |
458 | 14ad7326 | pastith | table.setWidget(0, 1, nameLabel); |
459 | 14ad7326 | pastith | table.setWidget(0, 2, ownerLabel); |
460 | f1fb019b | fstamatelopoulos | table.setWidget(0, 3, pathLabel); |
461 | f1fb019b | fstamatelopoulos | table.setWidget(0, 4, versionLabel); |
462 | f1fb019b | fstamatelopoulos | table.setWidget(0, 5, sizeLabel); |
463 | f1fb019b | fstamatelopoulos | table.setWidget(0, 6, dateLabel); |
464 | f1fb019b | fstamatelopoulos | table.setWidget(0, 7, navBar); |
465 | 14ad7326 | pastith | table.getRowFormatter().setStyleName(0, "gss-ListHeader"); |
466 | 14ad7326 | pastith | |
467 | 14ad7326 | pastith | // Initialize the rest of the rows.
|
468 | a52ea5e4 | pastith | for (int i = 1; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) { |
469 | 14ad7326 | pastith | table.setText(i, 0, ""); |
470 | 14ad7326 | pastith | table.setText(i, 1, ""); |
471 | 14ad7326 | pastith | table.setText(i, 2, ""); |
472 | 14ad7326 | pastith | table.setText(i, 3, ""); |
473 | 14ad7326 | pastith | table.setText(i, 4, ""); |
474 | 14ad7326 | pastith | table.setText(i, 5, ""); |
475 | 14ad7326 | pastith | table.setText(i, 6, ""); |
476 | f1fb019b | fstamatelopoulos | table.setText(i, 7, ""); |
477 | 14ad7326 | pastith | table.getCellFormatter().setWordWrap(i, 0, false); |
478 | 14ad7326 | pastith | table.getCellFormatter().setWordWrap(i, 1, false); |
479 | 14ad7326 | pastith | table.getCellFormatter().setWordWrap(i, 2, false); |
480 | 14ad7326 | pastith | table.getCellFormatter().setWordWrap(i, 3, false); |
481 | 14ad7326 | pastith | table.getCellFormatter().setWordWrap(i, 4, false); |
482 | 14ad7326 | pastith | table.getCellFormatter().setWordWrap(i, 5, false); |
483 | 14ad7326 | pastith | table.getCellFormatter().setWordWrap(i, 6, false); |
484 | f1fb019b | fstamatelopoulos | table.getCellFormatter().setWordWrap(i, 7, false); |
485 | f1fb019b | fstamatelopoulos | table.getCellFormatter().setHorizontalAlignment(i, 4, HasHorizontalAlignment.ALIGN_CENTER);
|
486 | 14ad7326 | pastith | } |
487 | 14ad7326 | pastith | prevButton.setVisible(false);
|
488 | 14ad7326 | pastith | nextButton.setVisible(false);
|
489 | 14ad7326 | pastith | } |
490 | 14ad7326 | pastith | |
491 | 14ad7326 | pastith | /**
|
492 | 14ad7326 | pastith | * Selects the given row (relative to the current page).
|
493 | 14ad7326 | pastith | *
|
494 | 14ad7326 | pastith | * @param row the row to be selected
|
495 | 14ad7326 | pastith | */
|
496 | 14ad7326 | pastith | private void selectRow(final int row) { |
497 | 14ad7326 | pastith | if (row < folderFileCount) {
|
498 | 14ad7326 | pastith | if (clickControl)
|
499 | 14ad7326 | pastith | if (selectedRows.contains(row)) {
|
500 | 14ad7326 | pastith | int i = selectedRows.indexOf(startIndex + row);
|
501 | 14ad7326 | pastith | selectedRows.remove(i); |
502 | 14ad7326 | pastith | styleRow(row, false);
|
503 | 14ad7326 | pastith | } else {
|
504 | 14ad7326 | pastith | selectedRows.add(startIndex + row); |
505 | 14ad7326 | pastith | styleRow(row, true);
|
506 | 14ad7326 | pastith | } |
507 | 1f93bc66 | koutsoub | else if (selectedRows.size() == 1 && selectedRows.contains(row)){ |
508 | 848896d0 | koutsoub | clearSelectedRows(); |
509 | 1f93bc66 | koutsoub | return;
|
510 | 1f93bc66 | koutsoub | } |
511 | 14ad7326 | pastith | else {
|
512 | 14ad7326 | pastith | clearSelectedRows(); |
513 | 14ad7326 | pastith | selectedRows.add(startIndex + row); |
514 | 14ad7326 | pastith | styleRow(row, true);
|
515 | 14ad7326 | pastith | } |
516 | 14ad7326 | pastith | if (selectedRows.size() == 1) |
517 | 14ad7326 | pastith | GSS.get().setCurrentSelection(files.get(selectedRows.get(0)));
|
518 | 6cf624d3 | koutsoub | else if(selectedRows.size() == 0) |
519 | 6cf624d3 | koutsoub | GSS.get().setCurrentSelection(null);
|
520 | 14ad7326 | pastith | else
|
521 | 14ad7326 | pastith | GSS.get().setCurrentSelection(getSelectedFiles()); |
522 | 14ad7326 | pastith | contextMenu.setFiles(getSelectedFiles()); |
523 | 5770ff9b | koutsoub | makeRowDraggable(row+1);
|
524 | 14ad7326 | pastith | } |
525 | 14ad7326 | pastith | } |
526 | 14ad7326 | pastith | |
527 | a52ea5e4 | pastith | public List<FileResource> getSelectedFiles() { |
528 | a52ea5e4 | pastith | List<FileResource> result = new ArrayList(); |
529 | 14ad7326 | pastith | for (int i : selectedRows) |
530 | 14ad7326 | pastith | result.add(files.get(i)); |
531 | 14ad7326 | pastith | return result;
|
532 | 14ad7326 | pastith | } |
533 | 14ad7326 | pastith | |
534 | 14ad7326 | pastith | /**
|
535 | 14ad7326 | pastith | * Make the specified row look like selected or not, according to the
|
536 | 14ad7326 | pastith | * <code>selected</code> flag.
|
537 | 14ad7326 | pastith | *
|
538 | 14ad7326 | pastith | * @param row
|
539 | 14ad7326 | pastith | * @param selected
|
540 | 14ad7326 | pastith | */
|
541 | 14ad7326 | pastith | void styleRow(final int row, final boolean selected) { |
542 | 14ad7326 | pastith | if (row != -1 && row >= 0) |
543 | 14ad7326 | pastith | if (selected)
|
544 | 14ad7326 | pastith | table.getRowFormatter().addStyleName(row + 1, "gss-SelectedRow"); |
545 | 14ad7326 | pastith | else
|
546 | 14ad7326 | pastith | table.getRowFormatter().removeStyleName(row + 1, "gss-SelectedRow"); |
547 | 14ad7326 | pastith | } |
548 | 14ad7326 | pastith | |
549 | 14ad7326 | pastith | /**
|
550 | 14ad7326 | pastith | * Update the display of the file list.
|
551 | 14ad7326 | pastith | */
|
552 | 14ad7326 | pastith | void update() {
|
553 | 14ad7326 | pastith | int count = folderFileCount;
|
554 | a52ea5e4 | pastith | int max = startIndex + GSS.VISIBLE_FILE_COUNT;
|
555 | 14ad7326 | pastith | if (max > count)
|
556 | 14ad7326 | pastith | max = count; |
557 | a44876bf | fstamatelopoulos | folderTotalSize = 0;
|
558 | 14ad7326 | pastith | |
559 | 14ad7326 | pastith | // Show the selected files.
|
560 | 14ad7326 | pastith | int i = 1; |
561 | a52ea5e4 | pastith | for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) { |
562 | 14ad7326 | pastith | // Don't read past the end.
|
563 | 14ad7326 | pastith | // if (i > folderFileCount)
|
564 | 14ad7326 | pastith | // break;
|
565 | 14ad7326 | pastith | if (startIndex + i > folderFileCount)
|
566 | 14ad7326 | pastith | break;
|
567 | 14ad7326 | pastith | // Add a new row to the table, then set each of its columns to the
|
568 | 14ad7326 | pastith | // proper values.
|
569 | 0e4865ee | pastith | FileResource file = files.get(startIndex + i - 1);
|
570 | 0e4865ee | pastith | table.setWidget(i, 0, getFileIcon(file).createImage());
|
571 | 14ad7326 | pastith | table.getRowFormatter().addStyleName(i, "gss-fileRow");
|
572 | a52ea5e4 | pastith | |
573 | 0e4865ee | pastith | table.setHTML(i, 1, file.getName());
|
574 | 0e4865ee | pastith | table.setText(i, 2, file.getOwner());
|
575 | 555e8e59 | pastith | table.setText(i, 3, file.getPath());
|
576 | 0e4865ee | pastith | table.setText(i, 4, String.valueOf(file.getVersion())); |
577 | 0e4865ee | pastith | table.setText(i, 5, String.valueOf(file.getFileSizeAsString())); |
578 | 663504f0 | fstamatelopoulos | final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); |
579 | 0e4865ee | pastith | table.setText(i, 6, formatter.format(file.getCreationDate()));
|
580 | 0e4865ee | pastith | folderTotalSize += file.getContentLength(); |
581 | 14ad7326 | pastith | } |
582 | 14ad7326 | pastith | |
583 | 14ad7326 | pastith | // Clear any remaining slots.
|
584 | a52ea5e4 | pastith | for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) { |
585 | 14ad7326 | pastith | table.setHTML(i, 0, " "); |
586 | 14ad7326 | pastith | table.setHTML(i, 1, " "); |
587 | 14ad7326 | pastith | table.setHTML(i, 2, " "); |
588 | 14ad7326 | pastith | table.setHTML(i, 3, " "); |
589 | 14ad7326 | pastith | table.setHTML(i, 4, " "); |
590 | 14ad7326 | pastith | table.setHTML(i, 5, " "); |
591 | 14ad7326 | pastith | table.setHTML(i, 6, " "); |
592 | f1fb019b | fstamatelopoulos | table.setHTML(i, 7, " "); |
593 | 14ad7326 | pastith | } |
594 | 14ad7326 | pastith | |
595 | a44876bf | fstamatelopoulos | if (folderFileCount == 0) { |
596 | b3c6d52e | fstamatelopoulos | showingStats = "no files";
|
597 | a44876bf | fstamatelopoulos | prevButton.setVisible(false);
|
598 | a44876bf | fstamatelopoulos | nextButton.setVisible(false);
|
599 | a44876bf | fstamatelopoulos | } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) { |
600 | 2bc32810 | fstamatelopoulos | if (folderFileCount == 1) |
601 | 2bc32810 | fstamatelopoulos | showingStats = "1 file";
|
602 | 2bc32810 | fstamatelopoulos | else
|
603 | 2bc32810 | fstamatelopoulos | showingStats = folderFileCount + " files";
|
604 | 2bc32810 | fstamatelopoulos | showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")"; |
605 | a44876bf | fstamatelopoulos | prevButton.setVisible(false);
|
606 | a44876bf | fstamatelopoulos | nextButton.setVisible(false);
|
607 | a44876bf | fstamatelopoulos | } else {
|
608 | b3c6d52e | fstamatelopoulos | showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")"; |
609 | a44876bf | fstamatelopoulos | prevButton.setVisible(startIndex != 0);
|
610 | a44876bf | fstamatelopoulos | nextButton.setVisible(startIndex + GSS.VISIBLE_FILE_COUNT < count); |
611 | a44876bf | fstamatelopoulos | } |
612 | b3c6d52e | fstamatelopoulos | updateCurrentlyShowingStats(); |
613 | a44876bf | fstamatelopoulos | |
614 | 14ad7326 | pastith | } |
615 | 14ad7326 | pastith | |
616 | 14ad7326 | pastith | /**
|
617 | 0e4865ee | pastith | * Return the proper icon based on the MIME type of the file.
|
618 | 0e4865ee | pastith | *
|
619 | 0e4865ee | pastith | * @param file
|
620 | 0e4865ee | pastith | * @return the icon
|
621 | 0e4865ee | pastith | */
|
622 | 0e4865ee | pastith | private AbstractImagePrototype getFileIcon(FileResource file) {
|
623 | 0e4865ee | pastith | String mimetype = file.getContentType();
|
624 | f12de32e | koutsoub | boolean shared = file.isShared();
|
625 | d6fe36f5 | pastith | if (mimetype == null) |
626 | d6fe36f5 | pastith | return shared ? images.documentShared() : images.document();
|
627 | a1b3ea42 | droutsis | mimetype = mimetype.toLowerCase(); |
628 | a1b3ea42 | droutsis | if (mimetype.startsWith("application/pdf")) |
629 | d6fe36f5 | pastith | return shared ? images.pdfShared() : images.pdf();
|
630 | a1b3ea42 | droutsis | else if (mimetype.startsWith("application/vnd.ms-excel")) |
631 | d6fe36f5 | pastith | return shared ? images.spreadsheetShared() : images.spreadsheet();
|
632 | a1b3ea42 | droutsis | else if (mimetype.startsWith("application/msword")) |
633 | d6fe36f5 | pastith | return shared ? images.wordprocessorShared() : images.wordprocessor();
|
634 | a1b3ea42 | droutsis | else if (mimetype.startsWith("application/vnd.ms-powerpoint")) |
635 | d6fe36f5 | pastith | return shared ? images.presentationShared() : images.presentation();
|
636 | a1b3ea42 | droutsis | else if (mimetype.startsWith("application/zip") || |
637 | a1b3ea42 | droutsis | mimetype.startsWith("application/gzip") ||
|
638 | a1b3ea42 | droutsis | mimetype.startsWith("application/x-gzip") ||
|
639 | a1b3ea42 | droutsis | mimetype.startsWith("application/x-tar") ||
|
640 | a1b3ea42 | droutsis | mimetype.startsWith("application/x-gtar"))
|
641 | d6fe36f5 | pastith | return shared ? images.zipShared() : images.zip();
|
642 | a1b3ea42 | droutsis | else if (mimetype.startsWith("text/html")) |
643 | d6fe36f5 | pastith | return shared ? images.htmlShared() : images.html();
|
644 | a1b3ea42 | droutsis | else if (mimetype.startsWith("text/plain")) |
645 | d6fe36f5 | pastith | return shared ? images.txtShared() : images.txt();
|
646 | d6fe36f5 | pastith | else if (mimetype.startsWith("image/")) |
647 | d6fe36f5 | pastith | return shared ? images.imageShared() : images.image();
|
648 | d6fe36f5 | pastith | else if (mimetype.startsWith("video/")) |
649 | d6fe36f5 | pastith | return shared ? images.videoShared() : images.video();
|
650 | d6fe36f5 | pastith | else if (mimetype.startsWith("audio/")) |
651 | d6fe36f5 | pastith | return shared ? images.audioShared() : images.audio();
|
652 | d6fe36f5 | pastith | return shared ? images.documentShared() : images.document();
|
653 | 0e4865ee | pastith | } |
654 | 0e4865ee | pastith | |
655 | 0e4865ee | pastith | /**
|
656 | c018c4de | pastith | * Update status panel with currently showing file stats.
|
657 | b3c6d52e | fstamatelopoulos | */
|
658 | b3c6d52e | fstamatelopoulos | public void updateCurrentlyShowingStats() { |
659 | b3c6d52e | fstamatelopoulos | GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats); |
660 | b3c6d52e | fstamatelopoulos | } |
661 | b3c6d52e | fstamatelopoulos | |
662 | b3c6d52e | fstamatelopoulos | /**
|
663 | 14ad7326 | pastith | * Adjust the height of the table by adding and removing rows as necessary.
|
664 | 14ad7326 | pastith | *
|
665 | 14ad7326 | pastith | * @param newHeight the new height to reach
|
666 | 14ad7326 | pastith | */
|
667 | 14ad7326 | pastith | void resizeTableHeight(final int newHeight) { |
668 | 14ad7326 | pastith | GWT.log("Panel: " + newHeight + ", parent: " + table.getParent().getOffsetHeight(), null); |
669 | 14ad7326 | pastith | // Fill the rest with empty slots.
|
670 | 14ad7326 | pastith | if (newHeight > table.getOffsetHeight())
|
671 | 14ad7326 | pastith | while (newHeight > table.getOffsetHeight()) {
|
672 | 14ad7326 | pastith | table.resizeRows(table.getRowCount() + 1);
|
673 | 14ad7326 | pastith | GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null); |
674 | 14ad7326 | pastith | } |
675 | 14ad7326 | pastith | else
|
676 | 14ad7326 | pastith | while (newHeight < table.getOffsetHeight()) {
|
677 | 14ad7326 | pastith | table.resizeRows(table.getRowCount() - 1);
|
678 | 14ad7326 | pastith | GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null); |
679 | 14ad7326 | pastith | } |
680 | 14ad7326 | pastith | } |
681 | 14ad7326 | pastith | |
682 | 18a508ee | fstamatelopoulos | public void updateFileCache(boolean updateSelectedFolder, final boolean clearSelection) { |
683 | a52ea5e4 | pastith | if (!updateSelectedFolder && !GSS.get().getFolders().getTrashItem().equals(GSS.get().getFolders().getCurrent()))
|
684 | 18a508ee | fstamatelopoulos | updateFileCache(clearSelection); |
685 | 848896d0 | koutsoub | else if (GSS.get().getFolders().getCurrent() != null) { |
686 | a52ea5e4 | pastith | final DnDTreeItem folderItem = (DnDTreeItem) GSS.get().getFolders().getCurrent();
|
687 | a52ea5e4 | pastith | if (folderItem.getFolderResource() != null) { |
688 | c018c4de | pastith | update(); |
689 | 0c8d0521 | koutsoub | GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, folderItem.getFolderResource().getUri()) {
|
690 | f12de32e | koutsoub | |
691 | f12de32e | koutsoub | @Override
|
692 | f12de32e | koutsoub | public void onComplete() { |
693 | f12de32e | koutsoub | folderItem.setUserObject(getResult()); |
694 | 0c8d0521 | koutsoub | if(GSS.get().getFolders().isFileItem(folderItem)){
|
695 | defd0822 | koutsoub | String[] filePaths = new String[folderItem.getFolderResource().getFilePaths().size()]; |
696 | defd0822 | koutsoub | int c=0; |
697 | defd0822 | koutsoub | for(String fpath : folderItem.getFolderResource().getFilePaths()){ |
698 | c018c4de | pastith | filePaths[c] = fpath + "?" + Math.random(); |
699 | defd0822 | koutsoub | c++; |
700 | defd0822 | koutsoub | } |
701 | defd0822 | koutsoub | MultipleHeadCommand<FileResource> getFiles = new MultipleHeadCommand<FileResource>(FileResource.class, filePaths){
|
702 | 0c8d0521 | koutsoub | |
703 | d6fe36f5 | pastith | @Override
|
704 | 0c8d0521 | koutsoub | public void onComplete(){ |
705 | defd0822 | koutsoub | List<FileResource> result = getResult();
|
706 | defd0822 | koutsoub | //remove random from path
|
707 | defd0822 | koutsoub | for(FileResource r : result){
|
708 | defd0822 | koutsoub | String p = r.getUri();
|
709 | defd0822 | koutsoub | int indexOfQuestionMark = p.lastIndexOf('?'); |
710 | defd0822 | koutsoub | if(indexOfQuestionMark>0) |
711 | defd0822 | koutsoub | r.setUri(p.substring(0, indexOfQuestionMark));
|
712 | defd0822 | koutsoub | } |
713 | defd0822 | koutsoub | folderItem.getFolderResource().setFiles(result); |
714 | 0c8d0521 | koutsoub | updateFileCache(clearSelection); |
715 | 0c8d0521 | koutsoub | } |
716 | 0c8d0521 | koutsoub | |
717 | 0c8d0521 | koutsoub | @Override
|
718 | 0c8d0521 | koutsoub | public void onError(String p, Throwable throwable) { |
719 | 0c8d0521 | koutsoub | if(throwable instanceof RestException) |
720 | 0c8d0521 | koutsoub | GSS.get().displayError("Unable to retrieve file details:"+((RestException)throwable).getHttpStatusText());
|
721 | 0c8d0521 | koutsoub | } |
722 | 0c8d0521 | koutsoub | |
723 | 0c8d0521 | koutsoub | @Override
|
724 | 0c8d0521 | koutsoub | public void onError(Throwable t) { |
725 | 0c8d0521 | koutsoub | GWT.log("", t);
|
726 | 0c8d0521 | koutsoub | GSS.get().displayError("Unable to fetch files for folder " + folderItem.getFolderResource().getName());
|
727 | 0c8d0521 | koutsoub | } |
728 | 0c8d0521 | koutsoub | |
729 | 0c8d0521 | koutsoub | }; |
730 | 0c8d0521 | koutsoub | DeferredCommand.addCommand(getFiles); |
731 | 0c8d0521 | koutsoub | } |
732 | 0c8d0521 | koutsoub | else
|
733 | 0c8d0521 | koutsoub | updateFileCache(clearSelection); |
734 | f12de32e | koutsoub | } |
735 | f12de32e | koutsoub | |
736 | f12de32e | koutsoub | @Override
|
737 | f12de32e | koutsoub | public void onError(Throwable t) { |
738 | f12de32e | koutsoub | GWT.log("", t);
|
739 | f12de32e | koutsoub | GSS.get().displayError("Unable to fetch folder " + folderItem.getFolderResource().getName());
|
740 | f12de32e | koutsoub | } |
741 | f12de32e | koutsoub | }; |
742 | f12de32e | koutsoub | DeferredCommand.addCommand(gf); |
743 | 848896d0 | koutsoub | } else if (folderItem.getTrashResource() != null) { |
744 | 895035a2 | pastith | GetCommand<TrashResource> gt = new GetCommand<TrashResource>(TrashResource.class, folderItem.getTrashResource().getUri()) {
|
745 | a52ea5e4 | pastith | |
746 | 0e4865ee | pastith | @Override
|
747 | a52ea5e4 | pastith | public void onComplete() { |
748 | a52ea5e4 | pastith | folderItem.setUserObject(getResult()); |
749 | 18a508ee | fstamatelopoulos | updateFileCache(clearSelection); |
750 | a52ea5e4 | pastith | } |
751 | a52ea5e4 | pastith | |
752 | 0e4865ee | pastith | @Override
|
753 | a52ea5e4 | pastith | public void onError(Throwable t) { |
754 | 848896d0 | koutsoub | if (t instanceof RestException && (((RestException) t).getHttpStatusCode() == 204 || ((RestException) t).getHttpStatusCode() == 1223)) { |
755 | 555e8e59 | pastith | folderItem.setUserObject(new TrashResource(folderItem.getTrashResource().getUri()));
|
756 | 18a508ee | fstamatelopoulos | updateFileCache(clearSelection); |
757 | 848896d0 | koutsoub | } else {
|
758 | a52ea5e4 | pastith | GWT.log("", t);
|
759 | a52ea5e4 | pastith | GSS.get().displayError("Unable to fetch trash resource");
|
760 | a52ea5e4 | pastith | } |
761 | a52ea5e4 | pastith | } |
762 | a52ea5e4 | pastith | }; |
763 | a52ea5e4 | pastith | DeferredCommand.addCommand(gt); |
764 | 848896d0 | koutsoub | } else if (folderItem.getSharedResource() != null) { |
765 | 895035a2 | pastith | GetCommand<SharedResource> gt = new GetCommand<SharedResource>(SharedResource.class, folderItem.getSharedResource().getUri()) {
|
766 | abb31c1f | koutsoub | |
767 | 0e4865ee | pastith | @Override
|
768 | abb31c1f | koutsoub | public void onComplete() { |
769 | abb31c1f | koutsoub | folderItem.setUserObject(getResult()); |
770 | 18a508ee | fstamatelopoulos | updateFileCache(clearSelection); |
771 | abb31c1f | koutsoub | } |
772 | abb31c1f | koutsoub | |
773 | 0e4865ee | pastith | @Override
|
774 | abb31c1f | koutsoub | public void onError(Throwable t) { |
775 | 848896d0 | koutsoub | GWT.log("", t);
|
776 | 848896d0 | koutsoub | GSS.get().displayError("Unable to fetch My Shares resource");
|
777 | abb31c1f | koutsoub | } |
778 | abb31c1f | koutsoub | }; |
779 | abb31c1f | koutsoub | DeferredCommand.addCommand(gt); |
780 | 848896d0 | koutsoub | } else if (folderItem.getOtherUserResource() != null) { |
781 | 895035a2 | pastith | GetCommand<OtherUserResource> gt = new GetCommand<OtherUserResource>(OtherUserResource.class, folderItem.getOtherUserResource().getUri()) {
|
782 | abb31c1f | koutsoub | |
783 | 0e4865ee | pastith | @Override
|
784 | abb31c1f | koutsoub | public void onComplete() { |
785 | abb31c1f | koutsoub | folderItem.setUserObject(getResult()); |
786 | 18a508ee | fstamatelopoulos | updateFileCache(clearSelection); |
787 | abb31c1f | koutsoub | } |
788 | abb31c1f | koutsoub | |
789 | 0e4865ee | pastith | @Override
|
790 | abb31c1f | koutsoub | public void onError(Throwable t) { |
791 | 848896d0 | koutsoub | GWT.log("", t);
|
792 | 848896d0 | koutsoub | GSS.get().displayError("Unable to fetch My Shares resource");
|
793 | abb31c1f | koutsoub | } |
794 | abb31c1f | koutsoub | }; |
795 | abb31c1f | koutsoub | DeferredCommand.addCommand(gt); |
796 | abb31c1f | koutsoub | } |
797 | a52ea5e4 | pastith | } else
|
798 | 18a508ee | fstamatelopoulos | updateFileCache(clearSelection); |
799 | a52ea5e4 | pastith | } |
800 | a52ea5e4 | pastith | |
801 | 14ad7326 | pastith | /**
|
802 | 14ad7326 | pastith | * Update the file cache with data from the server.
|
803 | 14ad7326 | pastith | *
|
804 | 14ad7326 | pastith | * @param userId the ID of the current user
|
805 | 14ad7326 | pastith | */
|
806 | 18a508ee | fstamatelopoulos | private void updateFileCache(boolean clearSelection) { |
807 | 18a508ee | fstamatelopoulos | if (clearSelection)
|
808 | 18a508ee | fstamatelopoulos | clearSelectedRows(); |
809 | 4bb05581 | koutsoub | clearLabels(); |
810 | 14ad7326 | pastith | sortingProperty = "name";
|
811 | ca65b898 | koutsoub | nameLabel.setHTML("Name " + images.desc().getHTML());
|
812 | 14ad7326 | pastith | sortingType = true;
|
813 | 14ad7326 | pastith | startIndex = 0;
|
814 | 14ad7326 | pastith | final TreeItem folderItem = GSS.get().getFolders().getCurrent();
|
815 | 14ad7326 | pastith | // Validation.
|
816 | b42845d6 | koutsoub | if (folderItem == null || GSS.get().getFolders().isOthersShared(folderItem)) { |
817 | a52ea5e4 | pastith | setFiles(new ArrayList<FileResource>()); |
818 | 14ad7326 | pastith | update(); |
819 | 14ad7326 | pastith | return;
|
820 | 14ad7326 | pastith | } |
821 | a52ea5e4 | pastith | if (folderItem instanceof DnDTreeItem) { |
822 | a52ea5e4 | pastith | DnDTreeItem dnd = (DnDTreeItem) folderItem; |
823 | a52ea5e4 | pastith | if (dnd.getFolderResource() != null) { |
824 | a52ea5e4 | pastith | if (GSS.get().getFolders().isTrashItem(dnd))
|
825 | a52ea5e4 | pastith | setFiles(new ArrayList<FileResource>()); |
826 | a52ea5e4 | pastith | else
|
827 | a52ea5e4 | pastith | setFiles(dnd.getFolderResource().getFiles()); |
828 | a52ea5e4 | pastith | |
829 | a52ea5e4 | pastith | } else if (dnd.getTrashResource() != null) |
830 | a52ea5e4 | pastith | setFiles(dnd.getTrashResource().getFiles()); |
831 | a52ea5e4 | pastith | else if (dnd.getSharedResource() != null) |
832 | a52ea5e4 | pastith | setFiles(dnd.getSharedResource().getFiles()); |
833 | a52ea5e4 | pastith | else if (dnd.getOtherUserResource() != null) |
834 | a52ea5e4 | pastith | setFiles(dnd.getOtherUserResource().getFiles()); |
835 | a52ea5e4 | pastith | else
|
836 | a52ea5e4 | pastith | setFiles(dnd.getFolderResource().getFiles()); |
837 | 14ad7326 | pastith | |
838 | 14ad7326 | pastith | update(); |
839 | a52ea5e4 | pastith | } |
840 | 14ad7326 | pastith | } |
841 | 14ad7326 | pastith | |
842 | 14ad7326 | pastith | /**
|
843 | 14ad7326 | pastith | * Fill the file cache with data.
|
844 | 14ad7326 | pastith | */
|
845 | a52ea5e4 | pastith | public void setFiles(final List<FileResource> _files) { |
846 | 848896d0 | koutsoub | if (_files.size() > 0 && !GSS.get().getFolders().isTrash(GSS.get().getFolders().getCurrent())) { |
847 | b9a56eb3 | koutsoub | files = new ArrayList<FileResource>(); |
848 | 848896d0 | koutsoub | for (FileResource fres : _files)
|
849 | 848896d0 | koutsoub | if (!fres.isDeleted())
|
850 | b9a56eb3 | koutsoub | files.add(fres); |
851 | 848896d0 | koutsoub | } else
|
852 | b9a56eb3 | koutsoub | files = _files; |
853 | a52ea5e4 | pastith | Collections.sort(files, new Comparator<FileResource>() { |
854 | 14ad7326 | pastith | |
855 | a52ea5e4 | pastith | public int compare(FileResource arg0, FileResource arg1) { |
856 | 14ad7326 | pastith | return arg0.getName().compareTo(arg1.getName());
|
857 | 14ad7326 | pastith | } |
858 | 14ad7326 | pastith | |
859 | 14ad7326 | pastith | }); |
860 | 14ad7326 | pastith | folderFileCount = files.size(); |
861 | 14ad7326 | pastith | } |
862 | 14ad7326 | pastith | |
863 | 14ad7326 | pastith | private void sortFiles(final String sortProperty) { |
864 | 14ad7326 | pastith | if (sortProperty.equals(sortingProperty))
|
865 | 14ad7326 | pastith | sortingType = !sortingType; |
866 | 14ad7326 | pastith | else {
|
867 | 14ad7326 | pastith | sortingProperty = sortProperty; |
868 | 14ad7326 | pastith | sortingType = true;
|
869 | 14ad7326 | pastith | } |
870 | 14ad7326 | pastith | clearLabels(); |
871 | 14ad7326 | pastith | clearSelectedRows(); |
872 | a52ea5e4 | pastith | if (files == null || files.size() == 0) |
873 | 14ad7326 | pastith | return;
|
874 | a52ea5e4 | pastith | Collections.sort(files, new Comparator<FileResource>() { |
875 | 14ad7326 | pastith | |
876 | a52ea5e4 | pastith | public int compare(FileResource arg0, FileResource arg1) { |
877 | 14ad7326 | pastith | if (sortingType)
|
878 | 14ad7326 | pastith | if (sortProperty.equals("version")) { |
879 | 14ad7326 | pastith | versionLabel.setHTML("Version " + images.desc().getHTML());
|
880 | 14ad7326 | pastith | return new Integer(arg0.getVersion()).compareTo(new Integer(arg1.getVersion())); |
881 | 14ad7326 | pastith | } else if (sortProperty.equals("owner")) { |
882 | 14ad7326 | pastith | ownerLabel.setHTML("Owner " + images.desc().getHTML());
|
883 | a52ea5e4 | pastith | return new Integer(arg0.getOwner()).compareTo(new Integer(arg1.getOwner())); |
884 | 14ad7326 | pastith | } else if (sortProperty.equals("date")) { |
885 | 14ad7326 | pastith | dateLabel.setHTML("Date " + images.desc().getHTML());
|
886 | a52ea5e4 | pastith | return arg0.getCreationDate().compareTo(arg1.getCreationDate());
|
887 | 14ad7326 | pastith | } else if (sortProperty.equals("size")) { |
888 | 14ad7326 | pastith | sizeLabel.setHTML("Size " + images.desc().getHTML());
|
889 | a52ea5e4 | pastith | return new Long(arg0.getContentLength()).compareTo(new Long(arg1.getContentLength())); |
890 | 14ad7326 | pastith | } else if (sortProperty.equals("name")) { |
891 | 14ad7326 | pastith | nameLabel.setHTML("Name " + images.desc().getHTML());
|
892 | 14ad7326 | pastith | return arg0.getName().compareTo(arg1.getName());
|
893 | f1fb019b | fstamatelopoulos | } else if (sortProperty.equals("path")) { |
894 | f1fb019b | fstamatelopoulos | pathLabel.setHTML("Path " + images.desc().getHTML());
|
895 | 555e8e59 | pastith | return arg0.getUri().compareTo(arg1.getUri());
|
896 | 14ad7326 | pastith | } else {
|
897 | 14ad7326 | pastith | nameLabel.setHTML("Name " + images.desc().getHTML());
|
898 | 14ad7326 | pastith | return arg0.getName().compareTo(arg1.getName());
|
899 | 14ad7326 | pastith | } |
900 | 14ad7326 | pastith | else if (sortProperty.equals("version")) { |
901 | 14ad7326 | pastith | versionLabel.setHTML("Version " + images.asc().getHTML());
|
902 | 14ad7326 | pastith | return new Integer(arg1.getVersion()).compareTo(new Integer(arg0.getVersion())); |
903 | a52ea5e4 | pastith | } else if (sortProperty.equals("owner")) { |
904 | 14ad7326 | pastith | ownerLabel.setHTML("Owner " + images.asc().getHTML());
|
905 | a52ea5e4 | pastith | return new Integer(arg1.getOwner()).compareTo(new Integer(arg0.getOwner())); |
906 | a52ea5e4 | pastith | } else if (sortProperty.equals("date")) { |
907 | 14ad7326 | pastith | dateLabel.setHTML("Date " + images.asc().getHTML());
|
908 | a52ea5e4 | pastith | return arg1.getCreationDate().compareTo(arg0.getCreationDate());
|
909 | 14ad7326 | pastith | } else if (sortProperty.equals("size")) { |
910 | 14ad7326 | pastith | sizeLabel.setHTML("Size " + images.asc().getHTML());
|
911 | a52ea5e4 | pastith | return new Long(arg1.getContentLength()).compareTo(new Long(arg0.getContentLength())); |
912 | 14ad7326 | pastith | } else if (sortProperty.equals("name")) { |
913 | 14ad7326 | pastith | nameLabel.setHTML("Name " + images.asc().getHTML());
|
914 | 14ad7326 | pastith | return arg1.getName().compareTo(arg0.getName());
|
915 | f1fb019b | fstamatelopoulos | } else if (sortProperty.equals("path")) { |
916 | f1fb019b | fstamatelopoulos | pathLabel.setHTML("Path " + images.asc().getHTML());
|
917 | 555e8e59 | pastith | return arg1.getUri().compareTo(arg0.getUri());
|
918 | 14ad7326 | pastith | } else {
|
919 | 14ad7326 | pastith | nameLabel.setHTML("Name " + images.asc().getHTML());
|
920 | 14ad7326 | pastith | return arg1.getName().compareTo(arg0.getName());
|
921 | 14ad7326 | pastith | } |
922 | 14ad7326 | pastith | } |
923 | 14ad7326 | pastith | |
924 | 14ad7326 | pastith | }); |
925 | 14ad7326 | pastith | } |
926 | 14ad7326 | pastith | |
927 | 14ad7326 | pastith | private void clearLabels() { |
928 | 14ad7326 | pastith | nameLabel.setText("Name");
|
929 | 14ad7326 | pastith | versionLabel.setText("Version");
|
930 | 14ad7326 | pastith | sizeLabel.setText("Size");
|
931 | 14ad7326 | pastith | dateLabel.setText("Date");
|
932 | 14ad7326 | pastith | ownerLabel.setText("Owner");
|
933 | f1fb019b | fstamatelopoulos | pathLabel.setText("Path");
|
934 | 14ad7326 | pastith | } |
935 | 14ad7326 | pastith | |
936 | 14ad7326 | pastith | /**
|
937 | 14ad7326 | pastith | * Retrieve the table.
|
938 | 14ad7326 | pastith | *
|
939 | 14ad7326 | pastith | * @return the table
|
940 | 14ad7326 | pastith | */
|
941 | 14ad7326 | pastith | Grid getTable() { |
942 | 14ad7326 | pastith | return table;
|
943 | 14ad7326 | pastith | } |
944 | 14ad7326 | pastith | |
945 | 14ad7326 | pastith | /**
|
946 | 14ad7326 | pastith | * Does the list contains the requested filename
|
947 | 14ad7326 | pastith | *
|
948 | 14ad7326 | pastith | * @param fileName
|
949 | 14ad7326 | pastith | * @return true/false
|
950 | 14ad7326 | pastith | */
|
951 | 14ad7326 | pastith | public boolean contains(String fileName) { |
952 | 14ad7326 | pastith | for (int i = 0; i < files.size(); i++) |
953 | 14ad7326 | pastith | if (files.get(i).getName().equals(fileName))
|
954 | 14ad7326 | pastith | return true; |
955 | 14ad7326 | pastith | return false; |
956 | 14ad7326 | pastith | } |
957 | 14ad7326 | pastith | |
958 | 14ad7326 | pastith | public void clearSelectedRows() { |
959 | 14ad7326 | pastith | for (int r : selectedRows) { |
960 | 14ad7326 | pastith | int row = r - startIndex;
|
961 | 14ad7326 | pastith | styleRow(row, false);
|
962 | 14ad7326 | pastith | } |
963 | 14ad7326 | pastith | selectedRows.clear(); |
964 | 14ad7326 | pastith | Object sel = GSS.get().getCurrentSelection();
|
965 | a52ea5e4 | pastith | if (sel instanceof FileResource || sel instanceof List) |
966 | 14ad7326 | pastith | GSS.get().setCurrentSelection(null);
|
967 | 14ad7326 | pastith | } |
968 | 14ad7326 | pastith | |
969 | 14ad7326 | pastith | /**
|
970 | 14ad7326 | pastith | *
|
971 | 14ad7326 | pastith | */
|
972 | 14ad7326 | pastith | public void selectAllRows() { |
973 | 14ad7326 | pastith | clearSelectedRows(); |
974 | 14ad7326 | pastith | int count = folderFileCount;
|
975 | a52ea5e4 | pastith | if (count == 0) |
976 | 14ad7326 | pastith | return;
|
977 | a52ea5e4 | pastith | int max = startIndex + GSS.VISIBLE_FILE_COUNT;
|
978 | 14ad7326 | pastith | if (max > count)
|
979 | 14ad7326 | pastith | max = count; |
980 | 14ad7326 | pastith | int i = 1; |
981 | a52ea5e4 | pastith | for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) { |
982 | 14ad7326 | pastith | // Don't read past the end.
|
983 | 14ad7326 | pastith | // if (i > folderFileCount)
|
984 | 14ad7326 | pastith | // break;
|
985 | 14ad7326 | pastith | if (startIndex + i > folderFileCount)
|
986 | 14ad7326 | pastith | break;
|
987 | a52ea5e4 | pastith | selectedRows.add(startIndex + i - 1);
|
988 | a52ea5e4 | pastith | styleRow(i - 1, true); |
989 | 14ad7326 | pastith | } |
990 | 14ad7326 | pastith | GSS.get().setCurrentSelection(getSelectedFiles()); |
991 | 14ad7326 | pastith | contextMenu.setFiles(getSelectedFiles()); |
992 | 5770ff9b | koutsoub | makeRowDraggable(i-1);
|
993 | 14ad7326 | pastith | |
994 | 14ad7326 | pastith | } |
995 | 14ad7326 | pastith | |
996 | 5770ff9b | koutsoub | private void makeRowDraggable(int row){ |
997 | 5770ff9b | koutsoub | int contextRow = getWidgetRow(contextMenu, table);
|
998 | 0e4865ee | pastith | if (contextRow != -1) |
999 | 0e4865ee | pastith | table.setWidget(contextRow, 0, getFileIcon(files.get(contextRow - 1)).createImage()); |
1000 | 0e4865ee | pastith | contextMenu.setWidget(new HTML(getFileIcon(files.get(row - 1)).getHTML())); |
1001 | 5770ff9b | koutsoub | table.setWidget(row, 0, contextMenu);
|
1002 | 5770ff9b | koutsoub | } |
1003 | 5770ff9b | koutsoub | |
1004 | 5770ff9b | koutsoub | private int getWidgetRow(Widget widget, Grid grid) { |
1005 | 5770ff9b | koutsoub | for (int row = 0; row < grid.getRowCount(); row++) |
1006 | 5770ff9b | koutsoub | for (int col = 0; col < grid.getCellCount(row); col++) { |
1007 | 5770ff9b | koutsoub | Widget w = table.getWidget(row, col); |
1008 | 5770ff9b | koutsoub | if (w == widget)
|
1009 | 5770ff9b | koutsoub | return row;
|
1010 | 5770ff9b | koutsoub | } |
1011 | 5770ff9b | koutsoub | return -1; |
1012 | 5770ff9b | koutsoub | } |
1013 | 5770ff9b | koutsoub | |
1014 | 14ad7326 | pastith | } |