Statistics
| Branch: | Tag: | Revision:

root / gss / src / gr / ebs / gss / client / SearchResults.java @ 780606ca

History | View | Annotate | Download (23.7 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 eaf8a7cb koutsoub
import gr.ebs.gss.client.rest.AbstractRestCommand;
23 a52ea5e4 pastith
import gr.ebs.gss.client.rest.ExecuteGet;
24 e08c358f koutsoub
import gr.ebs.gss.client.rest.RestException;
25 a52ea5e4 pastith
import gr.ebs.gss.client.rest.resource.FileResource;
26 a52ea5e4 pastith
import gr.ebs.gss.client.rest.resource.SearchResource;
27 a52ea5e4 pastith
import gr.ebs.gss.client.rest.resource.UserResource;
28 14ad7326 pastith
29 14ad7326 pastith
import java.util.ArrayList;
30 14ad7326 pastith
import java.util.Collections;
31 14ad7326 pastith
import java.util.Comparator;
32 14ad7326 pastith
import java.util.List;
33 14ad7326 pastith
34 14ad7326 pastith
import com.google.gwt.core.client.GWT;
35 a52ea5e4 pastith
import com.google.gwt.http.client.URL;
36 14ad7326 pastith
import com.google.gwt.i18n.client.DateTimeFormat;
37 14ad7326 pastith
import com.google.gwt.user.client.DOM;
38 14ad7326 pastith
import com.google.gwt.user.client.DeferredCommand;
39 14ad7326 pastith
import com.google.gwt.user.client.Event;
40 14ad7326 pastith
import com.google.gwt.user.client.IncrementalCommand;
41 eaf8a7cb koutsoub
import com.google.gwt.user.client.Window;
42 14ad7326 pastith
import com.google.gwt.user.client.ui.AbstractImagePrototype;
43 14ad7326 pastith
import com.google.gwt.user.client.ui.ClickListener;
44 14ad7326 pastith
import com.google.gwt.user.client.ui.Composite;
45 14ad7326 pastith
import com.google.gwt.user.client.ui.Grid;
46 14ad7326 pastith
import com.google.gwt.user.client.ui.HTML;
47 14ad7326 pastith
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
48 14ad7326 pastith
import com.google.gwt.user.client.ui.HorizontalPanel;
49 14ad7326 pastith
import com.google.gwt.user.client.ui.SourcesTableEvents;
50 14ad7326 pastith
import com.google.gwt.user.client.ui.TableListener;
51 14ad7326 pastith
import com.google.gwt.user.client.ui.VerticalPanel;
52 14ad7326 pastith
import com.google.gwt.user.client.ui.Widget;
53 14ad7326 pastith
54 14ad7326 pastith
/**
55 14ad7326 pastith
 * A composite that displays a list of search results for a particular query on
56 14ad7326 pastith
 * files.
57 14ad7326 pastith
 */
58 14ad7326 pastith
public class SearchResults extends Composite implements TableListener, ClickListener {
59 14ad7326 pastith
60 14ad7326 pastith
        private HTML prevButton = new HTML("<a href='javascript:;'>&lt; Previous</a>", true);
61 14ad7326 pastith
62 14ad7326 pastith
        private HTML nextButton = new HTML("<a href='javascript:;'>Next &gt;</a>", true);
63 14ad7326 pastith
64 b3c6d52e fstamatelopoulos
        private String showingStats = "";
65 b3c6d52e fstamatelopoulos
66 14ad7326 pastith
        private int startIndex = 0;
67 14ad7326 pastith
68 14ad7326 pastith
        /**
69 14ad7326 pastith
         * A constant that denotes the completion of an IncrementalCommand.
70 14ad7326 pastith
         */
71 14ad7326 pastith
        public static final boolean DONE = false;
72 14ad7326 pastith
73 14ad7326 pastith
        private boolean clickControl = false;
74 14ad7326 pastith
75 14ad7326 pastith
        private boolean clickShift = false;
76 14ad7326 pastith
77 14ad7326 pastith
        private int firstShift = -1;
78 14ad7326 pastith
79 14ad7326 pastith
        private ArrayList<Integer> selectedRows = new ArrayList<Integer>();
80 14ad7326 pastith
81 14ad7326 pastith
        /**
82 14ad7326 pastith
         * The context menu for the selected file.
83 14ad7326 pastith
         */
84 14ad7326 pastith
        final DnDFocusPanel contextMenu;
85 14ad7326 pastith
86 14ad7326 pastith
        /**
87 14ad7326 pastith
         * Specifies that the images available for this composite will be the ones
88 14ad7326 pastith
         * available in FileContextMenu.
89 14ad7326 pastith
         */
90 14ad7326 pastith
        public interface Images extends FileContextMenu.Images, Folders.Images {
91 14ad7326 pastith
92 14ad7326 pastith
                @Resource("gr/ebs/gss/resources/blank.gif")
93 14ad7326 pastith
                AbstractImagePrototype blank();
94 14ad7326 pastith
95 14ad7326 pastith
                @Resource("gr/ebs/gss/resources/asc.png")
96 14ad7326 pastith
                AbstractImagePrototype asc();
97 14ad7326 pastith
98 14ad7326 pastith
                @Resource("gr/ebs/gss/resources/desc.png")
99 14ad7326 pastith
                AbstractImagePrototype desc();
100 14ad7326 pastith
        }
101 14ad7326 pastith
102 14ad7326 pastith
        /**
103 14ad7326 pastith
         * A label with the number of files in this folder.
104 14ad7326 pastith
         */
105 14ad7326 pastith
        private HTML countLabel = new HTML();
106 14ad7326 pastith
107 14ad7326 pastith
        /**
108 14ad7326 pastith
         * The table widget with the file list.
109 14ad7326 pastith
         */
110 780606ca pastith
        private Grid table;
111 14ad7326 pastith
112 14ad7326 pastith
        /**
113 14ad7326 pastith
         * The navigation bar for paginating the results.
114 14ad7326 pastith
         */
115 14ad7326 pastith
        private HorizontalPanel navBar = new HorizontalPanel();
116 14ad7326 pastith
117 14ad7326 pastith
        /**
118 4b29a3ca fstamatelopoulos
         * The number of files in the search results
119 14ad7326 pastith
         */
120 780606ca pastith
        private int folderFileCount;
121 14ad7326 pastith
122 14ad7326 pastith
        /**
123 4b29a3ca fstamatelopoulos
         * Total search results size
124 4b29a3ca fstamatelopoulos
         */
125 780606ca pastith
        private long folderTotalSize;
126 4b29a3ca fstamatelopoulos
127 4b29a3ca fstamatelopoulos
        /**
128 14ad7326 pastith
         * A cache of the files in the list.
129 14ad7326 pastith
         */
130 a52ea5e4 pastith
        private List<FileResource> files;
131 14ad7326 pastith
132 14ad7326 pastith
        /**
133 14ad7326 pastith
         * The widget's image bundle.
134 14ad7326 pastith
         */
135 14ad7326 pastith
        private final Images images;
136 14ad7326 pastith
137 14ad7326 pastith
        private String sortingProperty = "name";
138 14ad7326 pastith
139 14ad7326 pastith
        private boolean sortingType = true;
140 14ad7326 pastith
141 14ad7326 pastith
        private HTML nameLabel;
142 14ad7326 pastith
143 14ad7326 pastith
        private HTML versionLabel;
144 14ad7326 pastith
145 14ad7326 pastith
        private HTML sizeLabel;
146 14ad7326 pastith
147 14ad7326 pastith
        private HTML dateLabel;
148 14ad7326 pastith
149 14ad7326 pastith
        private HTML ownerLabel;
150 14ad7326 pastith
151 14ad7326 pastith
        private HTML pathLabel;
152 14ad7326 pastith
153 14ad7326 pastith
        private HTML searchResults = new HTML("Results for search:");
154 14ad7326 pastith
155 14ad7326 pastith
        /**
156 14ad7326 pastith
         * Construct the file list widget. This entails setting up the widget
157 14ad7326 pastith
         * layout, fetching the number of files in the current folder from the
158 14ad7326 pastith
         * server and filling the local file cache of displayed files with data from
159 14ad7326 pastith
         * the server, as well.
160 14ad7326 pastith
         *
161 14ad7326 pastith
         * @param _images
162 14ad7326 pastith
         */
163 14ad7326 pastith
        public SearchResults(final Images _images) {
164 14ad7326 pastith
                images = _images;
165 a52ea5e4 pastith
                table = new Grid(GSS.VISIBLE_FILE_COUNT + 1, 8){
166 780606ca pastith
167 780606ca pastith
                        @Override
168 14ad7326 pastith
                        public void onBrowserEvent(Event event) {
169 14ad7326 pastith
                                if (files == null || files.size() == 0)
170 14ad7326 pastith
                                        return;
171 14ad7326 pastith
                                if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && selectedRows.size() != 0) {
172 b4b188fe koutsoub
                                        FileContextMenu fm = new FileContextMenu(images, false, false);
173 14ad7326 pastith
                                        fm.onClick(contextMenu);
174 14ad7326 pastith
                                }
175 eaf8a7cb koutsoub
                                else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
176 eaf8a7cb koutsoub
                                        if(getSelectedFiles().size() == 1){
177 eaf8a7cb koutsoub
                                                FileResource file = getSelectedFiles().get(0);
178 eaf8a7cb koutsoub
                                                String dateString = AbstractRestCommand.getDate();
179 b964f3a7 pastith
                                                String resource = file.getPath().substring(GSS.GSS_REST_PATH.length()-1,file.getPath().length());
180 eaf8a7cb koutsoub
                                                String sig = GSS.get().getCurrentUserResource().getUsername()+" "+AbstractRestCommand.calculateSig("GET", dateString, resource, AbstractRestCommand.base64decode(GSS.get().getToken()));
181 eaf8a7cb koutsoub
                                                Window.open(file.getPath() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString), "_blank", "");
182 eaf8a7cb koutsoub
                                        }
183 fa6bdefa koutsoub
                                if (DOM.eventGetType(event) == Event.ONCLICK) {
184 14ad7326 pastith
                                        if (DOM.eventGetCtrlKey(event))
185 14ad7326 pastith
                                                clickControl = true;
186 14ad7326 pastith
                                        else
187 14ad7326 pastith
                                                clickControl = false;
188 14ad7326 pastith
                                        if (DOM.eventGetShiftKey(event)) {
189 14ad7326 pastith
                                                clickShift = true;
190 14ad7326 pastith
                                                if (selectedRows.size() == 1)
191 14ad7326 pastith
                                                        firstShift = selectedRows.get(0) - startIndex;
192 14ad7326 pastith
                                                //event.preventDefault();
193 14ad7326 pastith
                                        } else {
194 14ad7326 pastith
                                                clickShift = false;
195 14ad7326 pastith
                                                firstShift = -1;
196 14ad7326 pastith
                                                //event.preventDefault();
197 14ad7326 pastith
                                        }
198 14ad7326 pastith
                                }
199 14ad7326 pastith
200 14ad7326 pastith
                                super.onBrowserEvent(event);
201 14ad7326 pastith
                        }
202 14ad7326 pastith
                };
203 14ad7326 pastith
                prevButton.addClickListener(this);
204 14ad7326 pastith
                nextButton.addClickListener(this);
205 14ad7326 pastith
206 14ad7326 pastith
                contextMenu = new DnDFocusPanel(new HTML(images.fileContextMenu().getHTML()));
207 b4b188fe koutsoub
                contextMenu.addClickListener(new FileContextMenu(images, false, false));
208 14ad7326 pastith
                GSS.get().getDragController().makeDraggable(contextMenu);
209 14ad7326 pastith
210 14ad7326 pastith
                // Setup the table.
211 14ad7326 pastith
                table.setCellSpacing(0);
212 14ad7326 pastith
                table.setCellPadding(2);
213 14ad7326 pastith
                table.setWidth("100%");
214 14ad7326 pastith
215 14ad7326 pastith
                // Hook up events.
216 14ad7326 pastith
                table.addTableListener(this);
217 14ad7326 pastith
218 14ad7326 pastith
                // Create the 'navigation' bar at the upper-right.
219 780606ca pastith
                HorizontalPanel innerNavBar = new HorizontalPanel();
220 14ad7326 pastith
                innerNavBar.setStyleName("gss-ListNavBar");
221 14ad7326 pastith
                innerNavBar.setSpacing(8);
222 14ad7326 pastith
                innerNavBar.add(prevButton);
223 14ad7326 pastith
                innerNavBar.add(countLabel);
224 14ad7326 pastith
                innerNavBar.add(nextButton);
225 14ad7326 pastith
                navBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
226 14ad7326 pastith
                navBar.add(innerNavBar);
227 14ad7326 pastith
                navBar.setWidth("100%");
228 14ad7326 pastith
                VerticalPanel vp = new VerticalPanel();
229 14ad7326 pastith
                vp.add(searchResults);
230 14ad7326 pastith
                searchResults.addStyleName("gss-searchlabel");
231 14ad7326 pastith
                vp.add(table);
232 14ad7326 pastith
                initWidget(vp);
233 14ad7326 pastith
                table.setStyleName("gss-List");
234 14ad7326 pastith
                initTable();
235 14ad7326 pastith
                DeferredCommand.addCommand(new IncrementalCommand() {
236 14ad7326 pastith
237 14ad7326 pastith
                        public boolean execute() {
238 14ad7326 pastith
                                return fetchRootFolder();
239 14ad7326 pastith
                        }
240 14ad7326 pastith
                });
241 14ad7326 pastith
                table.sinkEvents(Event.ONCONTEXTMENU);
242 14ad7326 pastith
                table.sinkEvents(Event.ONMOUSEUP);
243 14ad7326 pastith
                table.sinkEvents(Event.ONCLICK);
244 14ad7326 pastith
                table.sinkEvents(Event.ONKEYDOWN);
245 eaf8a7cb koutsoub
                table.sinkEvents(Event.ONDBLCLICK);
246 14ad7326 pastith
                preventIESelection();
247 14ad7326 pastith
        }
248 14ad7326 pastith
249 14ad7326 pastith
        public void onClick(Widget sender) {
250 14ad7326 pastith
                if (sender == nextButton) {
251 14ad7326 pastith
                        // Move forward a page.
252 14ad7326 pastith
                        clearSelectedRows();
253 a52ea5e4 pastith
                        startIndex += GSS.VISIBLE_FILE_COUNT;
254 14ad7326 pastith
                        if (startIndex >= folderFileCount)
255 a52ea5e4 pastith
                                startIndex -= GSS.VISIBLE_FILE_COUNT;
256 14ad7326 pastith
                        else
257 14ad7326 pastith
                                update();
258 14ad7326 pastith
                } else if (sender == prevButton) {
259 14ad7326 pastith
                        clearSelectedRows();
260 14ad7326 pastith
                        // Move back a page.
261 a52ea5e4 pastith
                        startIndex -= GSS.VISIBLE_FILE_COUNT;
262 14ad7326 pastith
                        if (startIndex < 0)
263 14ad7326 pastith
                                startIndex = 0;
264 14ad7326 pastith
                        else
265 14ad7326 pastith
                                update();
266 14ad7326 pastith
                }
267 14ad7326 pastith
        }
268 14ad7326 pastith
269 14ad7326 pastith
        /**
270 14ad7326 pastith
         * Retrieve the root folder for the current user.
271 14ad7326 pastith
         *
272 14ad7326 pastith
         * @return true if the retrieval was successful
273 14ad7326 pastith
         */
274 14ad7326 pastith
        protected boolean fetchRootFolder() {
275 a52ea5e4 pastith
                UserResource user = GSS.get().getCurrentUserResource();
276 14ad7326 pastith
                if (user == null)
277 14ad7326 pastith
                        return !DONE;
278 a52ea5e4 pastith
                updateFileCache("");
279 14ad7326 pastith
                return DONE;
280 14ad7326 pastith
        }
281 14ad7326 pastith
282 780606ca pastith
        public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
283 14ad7326 pastith
                // Select the row that was clicked (-1 to account for header row).
284 14ad7326 pastith
                if (row > folderFileCount)
285 14ad7326 pastith
                        return;
286 14ad7326 pastith
                if (clickShift) {
287 14ad7326 pastith
                        GWT.log("ROW is:" + row + " fs:" + firstShift, null);
288 14ad7326 pastith
                        if (firstShift == -1)
289 14ad7326 pastith
                                firstShift = row;
290 14ad7326 pastith
                        else if (row > firstShift) {
291 14ad7326 pastith
                                clearSelectedRows();
292 14ad7326 pastith
                                for (int i = firstShift; i < row; i++) {
293 14ad7326 pastith
                                        selectedRows.add(startIndex + i);
294 14ad7326 pastith
                                        styleRow(i, true);
295 14ad7326 pastith
                                }
296 14ad7326 pastith
                                GSS.get().setCurrentSelection(getSelectedFiles());
297 a52ea5e4 pastith
                                //contextMenu.setFiles(getSelectedFiles());
298 14ad7326 pastith
                                table.setWidget(row, 0, contextMenu);
299 14ad7326 pastith
                        } else if (row != -1 && row == firstShift) {
300 14ad7326 pastith
                                selectedRows.add(row);
301 14ad7326 pastith
                                selectedRows.add(row - 1);
302 14ad7326 pastith
                                styleRow(row, true);
303 14ad7326 pastith
                                styleRow(row - 1, true);
304 14ad7326 pastith
                        } else if (row < firstShift) {
305 14ad7326 pastith
                                GWT.log("ROW is:" + row + " fs:" + firstShift, null);
306 14ad7326 pastith
                                clearSelectedRows();
307 14ad7326 pastith
308 14ad7326 pastith
                                for (int i = firstShift; i >= row - 1; i--) {
309 14ad7326 pastith
                                        selectedRows.add(startIndex + i);
310 14ad7326 pastith
                                        styleRow(i, true);
311 14ad7326 pastith
                                }
312 14ad7326 pastith
                                GSS.get().setCurrentSelection(getSelectedFiles());
313 14ad7326 pastith
                                table.setWidget(row, 0, contextMenu);
314 a52ea5e4 pastith
                                //contextMenu.setFiles(getSelectedFiles());
315 14ad7326 pastith
                        }
316 14ad7326 pastith
317 14ad7326 pastith
                } else if (row > 0)
318 14ad7326 pastith
                        selectRow(row - 1);
319 14ad7326 pastith
320 14ad7326 pastith
        }
321 14ad7326 pastith
322 14ad7326 pastith
        /**
323 14ad7326 pastith
         * Initializes the table so that it contains enough rows for a full page of
324 14ad7326 pastith
         * files.
325 14ad7326 pastith
         */
326 14ad7326 pastith
        private void initTable() {
327 14ad7326 pastith
328 14ad7326 pastith
                nameLabel = new HTML("Name");
329 14ad7326 pastith
                nameLabel.addClickListener(new ClickListener() {
330 14ad7326 pastith
331 14ad7326 pastith
                        public void onClick(Widget sender) {
332 14ad7326 pastith
                                sortFiles("name");
333 14ad7326 pastith
                                update();
334 14ad7326 pastith
335 14ad7326 pastith
                        }
336 14ad7326 pastith
337 14ad7326 pastith
                });
338 14ad7326 pastith
                versionLabel = new HTML("Version");
339 14ad7326 pastith
                versionLabel.addClickListener(new ClickListener() {
340 14ad7326 pastith
341 14ad7326 pastith
                        public void onClick(Widget sender) {
342 14ad7326 pastith
                                sortFiles("version");
343 14ad7326 pastith
                                update();
344 14ad7326 pastith
345 14ad7326 pastith
                        }
346 14ad7326 pastith
347 14ad7326 pastith
                });
348 14ad7326 pastith
                sizeLabel = new HTML("Size");
349 14ad7326 pastith
                sizeLabel.addClickListener(new ClickListener() {
350 14ad7326 pastith
351 14ad7326 pastith
                        public void onClick(Widget sender) {
352 14ad7326 pastith
                                sortFiles("size");
353 14ad7326 pastith
                                update();
354 14ad7326 pastith
355 14ad7326 pastith
                        }
356 14ad7326 pastith
357 14ad7326 pastith
                });
358 14ad7326 pastith
                dateLabel = new HTML("Date");
359 14ad7326 pastith
                dateLabel.addClickListener(new ClickListener() {
360 14ad7326 pastith
361 14ad7326 pastith
                        public void onClick(Widget sender) {
362 14ad7326 pastith
                                sortFiles("date");
363 14ad7326 pastith
                                update();
364 14ad7326 pastith
365 14ad7326 pastith
                        }
366 14ad7326 pastith
367 14ad7326 pastith
                });
368 14ad7326 pastith
                ownerLabel = new HTML("Owner");
369 14ad7326 pastith
                ownerLabel.addClickListener(new ClickListener() {
370 14ad7326 pastith
371 14ad7326 pastith
                        public void onClick(Widget sender) {
372 14ad7326 pastith
                                sortFiles("owner");
373 14ad7326 pastith
                                update();
374 14ad7326 pastith
375 14ad7326 pastith
                        }
376 14ad7326 pastith
377 14ad7326 pastith
                });
378 14ad7326 pastith
379 14ad7326 pastith
                pathLabel = new HTML("Path");
380 14ad7326 pastith
                pathLabel.addClickListener(new ClickListener() {
381 14ad7326 pastith
382 14ad7326 pastith
                        public void onClick(Widget sender) {
383 14ad7326 pastith
                                sortFiles("path");
384 14ad7326 pastith
                                update();
385 14ad7326 pastith
386 14ad7326 pastith
                        }
387 14ad7326 pastith
388 14ad7326 pastith
                });
389 14ad7326 pastith
                // Create the header row.
390 14ad7326 pastith
                table.setText(0, 0, "");
391 14ad7326 pastith
                // table.setText(0, 1, "Name");
392 14ad7326 pastith
                table.setWidget(0, 1, nameLabel);
393 14ad7326 pastith
                table.setWidget(0, 2, ownerLabel);
394 14ad7326 pastith
                // table.setText(0, 3, "Version");
395 14ad7326 pastith
                table.setWidget(0, 3, pathLabel);
396 14ad7326 pastith
                table.setWidget(0, 4, versionLabel);
397 14ad7326 pastith
                // table.setText(0, 4, "Size");
398 14ad7326 pastith
                table.setWidget(0, 5, sizeLabel);
399 14ad7326 pastith
                // table.setText(0, 5, "Date");
400 14ad7326 pastith
                table.setWidget(0, 6, dateLabel);
401 14ad7326 pastith
                table.setWidget(0, 7, navBar);
402 14ad7326 pastith
                table.getRowFormatter().setStyleName(0, "gss-ListHeader");
403 14ad7326 pastith
404 14ad7326 pastith
                // Initialize the rest of the rows.
405 a52ea5e4 pastith
                for (int i = 1; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
406 14ad7326 pastith
                        table.setText(i, 0, "");
407 14ad7326 pastith
                        table.setText(i, 1, "");
408 14ad7326 pastith
                        table.setText(i, 2, "");
409 14ad7326 pastith
                        table.setText(i, 3, "");
410 14ad7326 pastith
                        table.setText(i, 4, "");
411 14ad7326 pastith
                        table.setText(i, 5, "");
412 14ad7326 pastith
                        table.setText(i, 6, "");
413 14ad7326 pastith
                        table.getCellFormatter().setWordWrap(i, 0, false);
414 14ad7326 pastith
                        table.getCellFormatter().setWordWrap(i, 1, false);
415 14ad7326 pastith
                        table.getCellFormatter().setWordWrap(i, 2, false);
416 14ad7326 pastith
                        table.getCellFormatter().setWordWrap(i, 3, false);
417 14ad7326 pastith
                        table.getCellFormatter().setWordWrap(i, 4, false);
418 14ad7326 pastith
                        table.getCellFormatter().setWordWrap(i, 5, false);
419 14ad7326 pastith
                        table.getCellFormatter().setWordWrap(i, 6, false);
420 31fe3066 fstamatelopoulos
                        table.getCellFormatter().setHorizontalAlignment(i, 4, HasHorizontalAlignment.ALIGN_CENTER);
421 14ad7326 pastith
                }
422 14ad7326 pastith
                prevButton.setVisible(false);
423 14ad7326 pastith
                nextButton.setVisible(false);
424 14ad7326 pastith
        }
425 14ad7326 pastith
426 14ad7326 pastith
        /**
427 14ad7326 pastith
         * Selects the given row (relative to the current page).
428 14ad7326 pastith
         *
429 14ad7326 pastith
         * @param row the row to be selected
430 14ad7326 pastith
         */
431 14ad7326 pastith
        private void selectRow(final int row) {
432 14ad7326 pastith
                if (row < folderFileCount) {
433 14ad7326 pastith
                        if (clickControl)
434 14ad7326 pastith
                                if (selectedRows.contains(row)) {
435 14ad7326 pastith
                                        int i = selectedRows.indexOf(startIndex + row);
436 14ad7326 pastith
                                        selectedRows.remove(i);
437 14ad7326 pastith
                                        styleRow(row, false);
438 14ad7326 pastith
                                } else {
439 14ad7326 pastith
                                        for (int r : selectedRows) {
440 14ad7326 pastith
                                                int prow = r - startIndex;
441 14ad7326 pastith
                                                table.setWidget(prow + 1, 0, images.document().createImage());
442 14ad7326 pastith
                                        }
443 14ad7326 pastith
                                        selectedRows.add(startIndex + row);
444 14ad7326 pastith
                                        styleRow(row, true);
445 14ad7326 pastith
                                }
446 14ad7326 pastith
                        else {
447 14ad7326 pastith
                                clearSelectedRows();
448 14ad7326 pastith
                                selectedRows.add(startIndex + row);
449 14ad7326 pastith
                                styleRow(row, true);
450 14ad7326 pastith
                        }
451 14ad7326 pastith
                        if (selectedRows.size() == 1)
452 14ad7326 pastith
                                GSS.get().setCurrentSelection(files.get(selectedRows.get(0)));
453 14ad7326 pastith
                        else
454 14ad7326 pastith
                                GSS.get().setCurrentSelection(getSelectedFiles());
455 a52ea5e4 pastith
                        //contextMenu.setFiles(getSelectedFiles());
456 14ad7326 pastith
                        table.setWidget(row + 1, 0, contextMenu);
457 14ad7326 pastith
                }
458 14ad7326 pastith
        }
459 14ad7326 pastith
460 a52ea5e4 pastith
        public List<FileResource> getSelectedFiles() {
461 a52ea5e4 pastith
                List<FileResource> result = new ArrayList();
462 14ad7326 pastith
                for (int i : selectedRows)
463 14ad7326 pastith
                        result.add(files.get(i));
464 14ad7326 pastith
                return result;
465 14ad7326 pastith
        }
466 14ad7326 pastith
467 14ad7326 pastith
        /**
468 14ad7326 pastith
         * Make the specified row look like selected or not, according to the
469 14ad7326 pastith
         * <code>selected</code> flag.
470 14ad7326 pastith
         *
471 14ad7326 pastith
         * @param row
472 14ad7326 pastith
         * @param selected
473 14ad7326 pastith
         */
474 14ad7326 pastith
        void styleRow(final int row, final boolean selected) {
475 14ad7326 pastith
                if (row != -1 && row >= 0)
476 14ad7326 pastith
                        if (selected)
477 14ad7326 pastith
                                table.getRowFormatter().addStyleName(row + 1, "gss-SelectedRow");
478 14ad7326 pastith
                        else
479 14ad7326 pastith
                                table.getRowFormatter().removeStyleName(row + 1, "gss-SelectedRow");
480 14ad7326 pastith
        }
481 14ad7326 pastith
482 14ad7326 pastith
        /**
483 14ad7326 pastith
         * Update the display of the file list.
484 14ad7326 pastith
         */
485 14ad7326 pastith
        void update() {
486 14ad7326 pastith
                int count = folderFileCount;
487 a52ea5e4 pastith
                int max = startIndex + GSS.VISIBLE_FILE_COUNT;
488 14ad7326 pastith
                if (max > count)
489 14ad7326 pastith
                        max = count;
490 4b29a3ca fstamatelopoulos
                folderTotalSize = 0;
491 14ad7326 pastith
492 14ad7326 pastith
                // Show the selected files.
493 14ad7326 pastith
                int i = 1;
494 a52ea5e4 pastith
                for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
495 14ad7326 pastith
                        // Don't read past the end.
496 14ad7326 pastith
                        // if (i > folderFileCount)
497 14ad7326 pastith
                        // break;
498 14ad7326 pastith
                        if (startIndex + i > folderFileCount)
499 14ad7326 pastith
                                break;
500 14ad7326 pastith
                        // Add a new row to the table, then set each of its columns to the
501 14ad7326 pastith
                        // proper values.
502 14ad7326 pastith
                        table.setWidget(i, 0, images.document().createImage());
503 a52ea5e4 pastith
                        FileResource fileHeader = files.get(startIndex + i - 1);
504 14ad7326 pastith
                        table.getRowFormatter().addStyleName(i, "gss-fileRow");
505 14ad7326 pastith
                        table.setHTML(i, 1, fileHeader.getName());
506 a52ea5e4 pastith
                        table.setText(i, 2, fileHeader.getOwner());
507 c9b3132d fstamatelopoulos
                        table.setText(i, 3, URL.decodeComponent(fileHeader.getPath().substring(GSS.GSS_REST_PATH.length()+fileHeader.getOwner().length()+6,fileHeader.getPath().length()-fileHeader.getName().length())));
508 14ad7326 pastith
                        table.setText(i, 4, String.valueOf(fileHeader.getVersion()));
509 14ad7326 pastith
                        table.setText(i, 5, String.valueOf(fileHeader.getFileSizeAsString()));
510 31fe3066 fstamatelopoulos
                        final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
511 a52ea5e4 pastith
                        table.setText(i, 6, formatter.format(fileHeader.getCreationDate()));
512 4b29a3ca fstamatelopoulos
                        folderTotalSize += fileHeader.getContentLength();
513 14ad7326 pastith
                }
514 14ad7326 pastith
515 14ad7326 pastith
                // Clear any remaining slots.
516 a52ea5e4 pastith
                for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
517 14ad7326 pastith
                        table.setHTML(i, 0, "&nbsp;");
518 14ad7326 pastith
                        table.setHTML(i, 1, "&nbsp;");
519 14ad7326 pastith
                        table.setHTML(i, 2, "&nbsp;");
520 14ad7326 pastith
                        table.setHTML(i, 3, "&nbsp;");
521 14ad7326 pastith
                        table.setHTML(i, 4, "&nbsp;");
522 14ad7326 pastith
                        table.setHTML(i, 5, "&nbsp;");
523 14ad7326 pastith
                        table.setHTML(i, 6, "&nbsp;");
524 14ad7326 pastith
                        table.setHTML(i, 7, "&nbsp;");
525 14ad7326 pastith
                }
526 14ad7326 pastith
527 4b29a3ca fstamatelopoulos
                if (folderFileCount == 0) {
528 b3c6d52e fstamatelopoulos
                        showingStats = "no files";
529 4b29a3ca fstamatelopoulos
                        prevButton.setVisible(false);
530 4b29a3ca fstamatelopoulos
                        nextButton.setVisible(false);
531 4b29a3ca fstamatelopoulos
                } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) {
532 2bc32810 fstamatelopoulos
                        if (folderFileCount == 1)
533 2bc32810 fstamatelopoulos
                                showingStats = "1 file";
534 2bc32810 fstamatelopoulos
                        else
535 2bc32810 fstamatelopoulos
                                showingStats = folderFileCount + " files";
536 2bc32810 fstamatelopoulos
                        showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
537 4b29a3ca fstamatelopoulos
                        prevButton.setVisible(false);
538 4b29a3ca fstamatelopoulos
                        nextButton.setVisible(false);
539 4b29a3ca fstamatelopoulos
                } else {
540 b3c6d52e fstamatelopoulos
                        showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
541 4b29a3ca fstamatelopoulos
                        prevButton.setVisible(startIndex != 0);
542 4b29a3ca fstamatelopoulos
                        nextButton.setVisible(startIndex + GSS.VISIBLE_FILE_COUNT < count);
543 4b29a3ca fstamatelopoulos
                }
544 b3c6d52e fstamatelopoulos
                updateCurrentlyShowingStats();
545 14ad7326 pastith
        }
546 14ad7326 pastith
547 14ad7326 pastith
        /**
548 b3c6d52e fstamatelopoulos
         *  update status panel with currently showing file stats
549 b3c6d52e fstamatelopoulos
         */
550 b3c6d52e fstamatelopoulos
        public void updateCurrentlyShowingStats() {
551 b3c6d52e fstamatelopoulos
                GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
552 b3c6d52e fstamatelopoulos
        }
553 b3c6d52e fstamatelopoulos
554 b3c6d52e fstamatelopoulos
        /**
555 14ad7326 pastith
         * Adjust the height of the table by adding and removing rows as necessary.
556 14ad7326 pastith
         *
557 14ad7326 pastith
         * @param newHeight the new height to reach
558 14ad7326 pastith
         */
559 14ad7326 pastith
        void resizeTableHeight(final int newHeight) {
560 14ad7326 pastith
                GWT.log("Panel: " + newHeight + ", parent: " + table.getParent().getOffsetHeight(), null);
561 14ad7326 pastith
                // Fill the rest with empty slots.
562 14ad7326 pastith
                if (newHeight > table.getOffsetHeight())
563 14ad7326 pastith
                        while (newHeight > table.getOffsetHeight()) {
564 14ad7326 pastith
                                // table.setHTML(table.getRowCount(), 5, "&nbsp;");
565 14ad7326 pastith
                                table.resizeRows(table.getRowCount() + 1);
566 14ad7326 pastith
                                GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
567 14ad7326 pastith
                        }
568 14ad7326 pastith
                else
569 14ad7326 pastith
                        while (newHeight < table.getOffsetHeight()) {
570 14ad7326 pastith
                                // table.setHTML(table.getRowCount(), 5, "&nbsp;");
571 14ad7326 pastith
                                table.resizeRows(table.getRowCount() - 1);
572 14ad7326 pastith
                                GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
573 14ad7326 pastith
                        }
574 14ad7326 pastith
        }
575 14ad7326 pastith
576 14ad7326 pastith
        /**
577 14ad7326 pastith
         * Update the file cache with data from the server.
578 14ad7326 pastith
         */
579 780606ca pastith
        public void updateFileCache(String query) {
580 14ad7326 pastith
                clearSelectedRows();
581 14ad7326 pastith
                sortingProperty = "name";
582 4bb05581 koutsoub
                clearLabels();
583 ca65b898 koutsoub
                nameLabel.setHTML("Name&nbsp;" + images.desc().getHTML());
584 14ad7326 pastith
                sortingType = true;
585 14ad7326 pastith
                startIndex = 0;
586 14ad7326 pastith
                GSS.get().showLoadingIndicator();
587 14ad7326 pastith
                if (query == null || query.trim().equals("")) {
588 14ad7326 pastith
                        searchResults.setHTML("You must specify a query");
589 14ad7326 pastith
                        setFiles(new ArrayList());
590 14ad7326 pastith
                        update();
591 14ad7326 pastith
                        GSS.get().hideLoadingIndicator();
592 14ad7326 pastith
                } else{
593 14ad7326 pastith
                        searchResults.setHTML("Search results for " + query);
594 3c793c5c koutsoub
595 780606ca pastith
                        ExecuteGet<SearchResource> eg = new ExecuteGet<SearchResource>(SearchResource.class,
596 780606ca pastith
                                                GSS.GSS_REST_PATH+"search/"+URL.encodeComponent(query)){
597 a52ea5e4 pastith
598 a52ea5e4 pastith
                                @Override
599 a52ea5e4 pastith
                                public void onComplete() {
600 a52ea5e4 pastith
                                        SearchResource s = getResult();
601 3c793c5c koutsoub
                                        setFiles(s.getFiles());
602 3c793c5c koutsoub
                                        update();
603 a52ea5e4 pastith
                                }
604 a52ea5e4 pastith
605 780606ca pastith
                                @Override
606 a52ea5e4 pastith
                                public void onError(Throwable t) {
607 e08c358f koutsoub
                                        if(t instanceof RestException)
608 e08c358f koutsoub
                                                GSS.get().displayError("Unable to perform search:"+((RestException)t).getHttpStatusText());
609 e08c358f koutsoub
                                        else
610 e08c358f koutsoub
                                                GSS.get().displayError("System error performing search:"+t.getMessage());
611 a52ea5e4 pastith
                                        updateFileCache("");
612 a52ea5e4 pastith
                                }
613 a52ea5e4 pastith
614 a52ea5e4 pastith
                        };
615 a52ea5e4 pastith
                        DeferredCommand.addCommand(eg);
616 a52ea5e4 pastith
                }
617 14ad7326 pastith
        }
618 14ad7326 pastith
619 14ad7326 pastith
        /**
620 14ad7326 pastith
         * Fill the file cache with data.
621 14ad7326 pastith
         *
622 14ad7326 pastith
         * @param _files
623 a52ea5e4 pastith
         * @param filePaths the files to set
624 14ad7326 pastith
         */
625 780606ca pastith
        private void setFiles(List<FileResource> _files) {
626 14ad7326 pastith
                files = _files;
627 a52ea5e4 pastith
                Collections.sort(files, new Comparator<FileResource>() {
628 14ad7326 pastith
629 a52ea5e4 pastith
                        public int compare(FileResource arg0, FileResource arg1) {
630 14ad7326 pastith
                                return arg0.getName().compareTo(arg1.getName());
631 14ad7326 pastith
                        }
632 14ad7326 pastith
633 14ad7326 pastith
                });
634 14ad7326 pastith
                folderFileCount = files.size();
635 14ad7326 pastith
                GWT.log("File count:" + folderFileCount, null);
636 14ad7326 pastith
        }
637 14ad7326 pastith
638 14ad7326 pastith
        private void sortFiles(final String sortProperty) {
639 14ad7326 pastith
                if (sortProperty.equals(sortingProperty))
640 14ad7326 pastith
                        sortingType = !sortingType;
641 14ad7326 pastith
                else {
642 14ad7326 pastith
                        sortingProperty = sortProperty;
643 14ad7326 pastith
                        sortingType = true;
644 14ad7326 pastith
                }
645 14ad7326 pastith
                clearLabels();
646 14ad7326 pastith
                clearSelectedRows();
647 14ad7326 pastith
                if (files == null || files.size() == 0)
648 14ad7326 pastith
                        return;
649 a52ea5e4 pastith
                Collections.sort(files, new Comparator<FileResource>() {
650 14ad7326 pastith
651 a52ea5e4 pastith
                        public int compare(FileResource arg0, FileResource arg1) {
652 14ad7326 pastith
                                if (sortingType)
653 14ad7326 pastith
                                        if (sortProperty.equals("version")) {
654 14ad7326 pastith
                                                versionLabel.setHTML("Version&nbsp;" + images.desc().getHTML());
655 14ad7326 pastith
                                                return new Integer(arg0.getVersion()).compareTo(new Integer(arg1.getVersion()));
656 14ad7326 pastith
                                        } else if (sortProperty.equals("owner")) {
657 14ad7326 pastith
                                                ownerLabel.setHTML("Owner&nbsp;" + images.desc().getHTML());
658 a52ea5e4 pastith
                                                GWT.log(arg0.getOwner() + "/" + arg1.getOwner(), null);
659 a52ea5e4 pastith
                                                return arg0.getOwner().compareTo(arg1.getOwner());
660 14ad7326 pastith
                                        } else if (sortProperty.equals("date")) {
661 14ad7326 pastith
                                                dateLabel.setHTML("Date&nbsp;" + images.desc().getHTML());
662 a52ea5e4 pastith
                                                return arg0.getCreationDate().compareTo(arg1.getCreationDate());
663 14ad7326 pastith
                                        } else if (sortProperty.equals("size")) {
664 14ad7326 pastith
                                                sizeLabel.setHTML("Size&nbsp;" + images.desc().getHTML());
665 a52ea5e4 pastith
                                                return new Long(arg0.getContentLength()).compareTo(new Long(arg1.getContentLength()));
666 14ad7326 pastith
                                        } else if (sortProperty.equals("name")) {
667 14ad7326 pastith
                                                nameLabel.setHTML("Name&nbsp;" + images.desc().getHTML());
668 14ad7326 pastith
                                                return arg0.getName().compareTo(arg1.getName());
669 14ad7326 pastith
                                        } else if (sortProperty.equals("path")) {
670 14ad7326 pastith
                                                pathLabel.setHTML("Path&nbsp;" + images.desc().getHTML());
671 14ad7326 pastith
                                                return arg0.getPath().compareTo(arg1.getPath());
672 14ad7326 pastith
                                        } else {
673 14ad7326 pastith
                                                nameLabel.setHTML("Name&nbsp;" + images.desc().getHTML());
674 14ad7326 pastith
                                                return arg0.getName().compareTo(arg1.getName());
675 14ad7326 pastith
                                        }
676 14ad7326 pastith
                                else if (sortProperty.equals("version")) {
677 14ad7326 pastith
                                        versionLabel.setHTML("Version&nbsp;" + images.asc().getHTML());
678 14ad7326 pastith
                                        return new Integer(arg1.getVersion()).compareTo(new Integer(arg0.getVersion()));
679 14ad7326 pastith
                                } else if (sortProperty.equals("owner")) {
680 14ad7326 pastith
                                        ownerLabel.setHTML("Owner&nbsp;" + images.asc().getHTML());
681 a52ea5e4 pastith
                                        return arg1.getOwner().compareTo(arg0.getOwner());
682 14ad7326 pastith
                                } else if (sortProperty.equals("date")) {
683 14ad7326 pastith
                                        dateLabel.setHTML("Date&nbsp;" + images.asc().getHTML());
684 a52ea5e4 pastith
                                        return arg1.getCreationDate().compareTo(arg0.getCreationDate());
685 14ad7326 pastith
                                } else if (sortProperty.equals("size")) {
686 14ad7326 pastith
                                        sizeLabel.setHTML("Size&nbsp;" + images.asc().getHTML());
687 a52ea5e4 pastith
                                        return new Long(arg1.getContentLength()).compareTo(new Long(arg0.getContentLength()));
688 14ad7326 pastith
                                } else if (sortProperty.equals("name")) {
689 14ad7326 pastith
                                        nameLabel.setHTML("Name&nbsp;" + images.asc().getHTML());
690 14ad7326 pastith
                                        return arg1.getName().compareTo(arg0.getName());
691 14ad7326 pastith
                                } else if (sortProperty.equals("path")) {
692 14ad7326 pastith
                                        pathLabel.setHTML("Path&nbsp;" + images.asc().getHTML());
693 14ad7326 pastith
                                        return arg1.getPath().compareTo(arg0.getPath());
694 14ad7326 pastith
                                } else {
695 14ad7326 pastith
                                        nameLabel.setHTML("Name&nbsp;" + images.asc().getHTML());
696 14ad7326 pastith
                                        return arg1.getName().compareTo(arg0.getName());
697 14ad7326 pastith
                                }
698 14ad7326 pastith
                        }
699 14ad7326 pastith
700 14ad7326 pastith
                });
701 14ad7326 pastith
        }
702 14ad7326 pastith
703 14ad7326 pastith
        private void clearLabels() {
704 14ad7326 pastith
                nameLabel.setText("Name");
705 14ad7326 pastith
                versionLabel.setText("Version");
706 14ad7326 pastith
                sizeLabel.setText("Size");
707 14ad7326 pastith
                dateLabel.setText("Date");
708 14ad7326 pastith
                ownerLabel.setText("Owner");
709 14ad7326 pastith
                pathLabel.setText("Path");
710 14ad7326 pastith
        }
711 14ad7326 pastith
712 14ad7326 pastith
        /**
713 14ad7326 pastith
         * Retrieve the table.
714 14ad7326 pastith
         *
715 14ad7326 pastith
         * @return the table
716 14ad7326 pastith
         */
717 14ad7326 pastith
        Grid getTable() {
718 14ad7326 pastith
                return table;
719 14ad7326 pastith
        }
720 14ad7326 pastith
721 14ad7326 pastith
        /**
722 14ad7326 pastith
         * Does the list contains the requested filename
723 14ad7326 pastith
         *
724 14ad7326 pastith
         * @param fileName
725 14ad7326 pastith
         * @return true/false
726 14ad7326 pastith
         */
727 14ad7326 pastith
        public boolean contains(String fileName) {
728 14ad7326 pastith
                for (int i = 0; i < files.size(); i++)
729 14ad7326 pastith
                        if (files.get(i).getName().equals(fileName))
730 14ad7326 pastith
                                return true;
731 14ad7326 pastith
                return false;
732 14ad7326 pastith
        }
733 14ad7326 pastith
734 14ad7326 pastith
        public void clearSelectedRows() {
735 14ad7326 pastith
                for (int r : selectedRows) {
736 14ad7326 pastith
                        int row = r - startIndex;
737 14ad7326 pastith
                        styleRow(row, false);
738 14ad7326 pastith
                        table.setWidget(row + 1, 0, images.document().createImage());
739 14ad7326 pastith
                }
740 14ad7326 pastith
                selectedRows.clear();
741 14ad7326 pastith
                Object sel = GSS.get().getCurrentSelection();
742 a52ea5e4 pastith
                if (sel instanceof FileResource || sel instanceof List)
743 14ad7326 pastith
                        GSS.get().setCurrentSelection(null);
744 14ad7326 pastith
        }
745 14ad7326 pastith
746 14ad7326 pastith
        public static native void preventIESelection() /*-{
747 14ad7326 pastith
             $doc.body.onselectstart = function () { return false; };
748 14ad7326 pastith
         }-*/;
749 14ad7326 pastith
750 14ad7326 pastith
        public static native void enableIESelection() /*-{
751 14ad7326 pastith
         if ($doc.body.onselectstart != null)
752 14ad7326 pastith
             $doc.body.onselectstart = null;
753 14ad7326 pastith
         }-*/;
754 14ad7326 pastith
755 14ad7326 pastith
        public void selectAllRows() {
756 14ad7326 pastith
                clearSelectedRows();
757 14ad7326 pastith
                int count = folderFileCount;
758 14ad7326 pastith
                if (count == 0)
759 14ad7326 pastith
                        return;
760 a52ea5e4 pastith
                int max = startIndex + GSS.VISIBLE_FILE_COUNT;
761 14ad7326 pastith
                if (max > count)
762 14ad7326 pastith
                        max = count;
763 14ad7326 pastith
                int i = 1;
764 a52ea5e4 pastith
                for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
765 14ad7326 pastith
                        // Don't read past the end.
766 14ad7326 pastith
                        // if (i > folderFileCount)
767 14ad7326 pastith
                        // break;
768 14ad7326 pastith
                        if (startIndex + i > folderFileCount)
769 14ad7326 pastith
                                break;
770 14ad7326 pastith
                        selectedRows.add(startIndex + i - 1);
771 14ad7326 pastith
                        styleRow(i - 1, true);
772 14ad7326 pastith
                }
773 14ad7326 pastith
                GSS.get().setCurrentSelection(getSelectedFiles());
774 a52ea5e4 pastith
                //contextMenu.setFiles(getSelectedFiles());
775 14ad7326 pastith
                table.setWidget(i - 1, 0, contextMenu);
776 14ad7326 pastith
        }
777 14ad7326 pastith
778 14ad7326 pastith
}