2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\r
6 * GSS is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * GSS is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
\r
19 package gr.ebs.gss.client;
\r
21 import gr.ebs.gss.client.dnd.DnDFocusPanel;
\r
22 import gr.ebs.gss.client.rest.GetCommand;
\r
23 import gr.ebs.gss.client.rest.RestCommand;
\r
24 import gr.ebs.gss.client.rest.RestException;
\r
25 import gr.ebs.gss.client.rest.resource.FileResource;
\r
26 import gr.ebs.gss.client.rest.resource.SearchResource;
\r
27 import gr.ebs.gss.client.rest.resource.UserResource;
\r
29 import java.util.ArrayList;
\r
30 import java.util.Collections;
\r
31 import java.util.Comparator;
\r
32 import java.util.List;
\r
34 import com.google.gwt.core.client.GWT;
\r
35 import com.google.gwt.http.client.URL;
\r
36 import com.google.gwt.i18n.client.DateTimeFormat;
\r
37 import com.google.gwt.user.client.DOM;
\r
38 import com.google.gwt.user.client.DeferredCommand;
\r
39 import com.google.gwt.user.client.Event;
\r
40 import com.google.gwt.user.client.IncrementalCommand;
\r
41 import com.google.gwt.user.client.Window;
\r
42 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
43 import com.google.gwt.user.client.ui.ClickListener;
\r
44 import com.google.gwt.user.client.ui.Composite;
\r
45 import com.google.gwt.user.client.ui.Grid;
\r
46 import com.google.gwt.user.client.ui.HTML;
\r
47 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
\r
48 import com.google.gwt.user.client.ui.HorizontalPanel;
\r
49 import com.google.gwt.user.client.ui.SourcesTableEvents;
\r
50 import com.google.gwt.user.client.ui.TableListener;
\r
51 import com.google.gwt.user.client.ui.VerticalPanel;
\r
52 import com.google.gwt.user.client.ui.Widget;
\r
55 * A composite that displays a list of search results for a particular query on
\r
58 public class SearchResults extends Composite implements TableListener, ClickListener {
\r
60 private HTML prevButton = new HTML("<a href='javascript:;'>< Previous</a>", true);
\r
62 private HTML nextButton = new HTML("<a href='javascript:;'>Next ></a>", true);
\r
64 private String showingStats = "";
\r
66 private int startIndex = 0;
\r
69 * A constant that denotes the completion of an IncrementalCommand.
\r
71 public static final boolean DONE = false;
\r
73 private boolean clickControl = false;
\r
75 private boolean clickShift = false;
\r
77 private int firstShift = -1;
\r
79 private ArrayList<Integer> selectedRows = new ArrayList<Integer>();
\r
82 * The context menu for the selected file.
\r
84 final DnDFocusPanel contextMenu;
\r
87 * Specifies that the images available for this composite will be the ones
\r
88 * available in FileContextMenu.
\r
90 public interface Images extends FileContextMenu.Images, Folders.Images {
\r
92 @Resource("gr/ebs/gss/resources/blank.gif")
\r
93 AbstractImagePrototype blank();
\r
95 @Resource("gr/ebs/gss/resources/asc.png")
\r
96 AbstractImagePrototype asc();
\r
98 @Resource("gr/ebs/gss/resources/desc.png")
\r
99 AbstractImagePrototype desc();
\r
103 * A label with the number of files in this folder.
\r
105 private HTML countLabel = new HTML();
\r
108 * The table widget with the file list.
\r
110 private Grid table;
\r
113 * The navigation bar for paginating the results.
\r
115 private HorizontalPanel navBar = new HorizontalPanel();
\r
118 * The number of files in the search results
\r
120 private int folderFileCount;
\r
123 * Total search results size
\r
125 private long folderTotalSize;
\r
128 * A cache of the files in the list.
\r
130 private List<FileResource> files;
\r
133 * The widget's image bundle.
\r
135 private final Images images;
\r
137 private String sortingProperty = "name";
\r
139 private boolean sortingType = true;
\r
141 private HTML nameLabel;
\r
143 private HTML versionLabel;
\r
145 private HTML sizeLabel;
\r
147 private HTML dateLabel;
\r
149 private HTML ownerLabel;
\r
151 private HTML pathLabel;
\r
153 private HTML searchResults = new HTML("Results for search:");
\r
156 * Construct the file list widget. This entails setting up the widget
\r
157 * layout, fetching the number of files in the current folder from the
\r
158 * server and filling the local file cache of displayed files with data from
\r
159 * the server, as well.
\r
163 public SearchResults(final Images _images) {
\r
165 final GSS app = GSS.get();
\r
166 table = new Grid(GSS.VISIBLE_FILE_COUNT + 1, 8) {
\r
169 public void onBrowserEvent(Event event) {
\r
170 if (files == null || files.size() == 0)
\r
172 if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && selectedRows.size() != 0) {
\r
173 FileContextMenu fm = new FileContextMenu(images, false, false);
\r
174 fm.onClick(contextMenu);
\r
176 else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
\r
177 if(getSelectedFiles().size() == 1){
\r
178 FileResource file = getSelectedFiles().get(0);
\r
179 String dateString = RestCommand.getDate();
\r
180 String resource = file.getUri().substring(app.getApiPath().length()-1,file.getUri().length());
\r
181 String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(GSS.get().getToken()));
\r
182 Window.open(file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString), "_blank", "");
\r
184 if (DOM.eventGetType(event) == Event.ONCLICK) {
\r
185 if (DOM.eventGetCtrlKey(event))
\r
186 clickControl = true;
\r
188 clickControl = false;
\r
189 if (DOM.eventGetShiftKey(event)) {
\r
191 if (selectedRows.size() == 1)
\r
192 firstShift = selectedRows.get(0) - startIndex;
\r
193 //event.preventDefault();
\r
195 clickShift = false;
\r
197 //event.preventDefault();
\r
201 super.onBrowserEvent(event);
\r
204 prevButton.addClickListener(this);
\r
205 nextButton.addClickListener(this);
\r
207 contextMenu = new DnDFocusPanel(new HTML(images.fileContextMenu().getHTML()));
\r
208 contextMenu.addClickListener(new FileContextMenu(images, false, false));
\r
209 app.getDragController().makeDraggable(contextMenu);
\r
211 // Setup the table.
\r
212 table.setCellSpacing(0);
\r
213 table.setCellPadding(2);
\r
214 table.setWidth("100%");
\r
217 table.addTableListener(this);
\r
219 // Create the 'navigation' bar at the upper-right.
\r
220 HorizontalPanel innerNavBar = new HorizontalPanel();
\r
221 innerNavBar.setStyleName("gss-ListNavBar");
\r
222 innerNavBar.setSpacing(8);
\r
223 innerNavBar.add(prevButton);
\r
224 innerNavBar.add(countLabel);
\r
225 innerNavBar.add(nextButton);
\r
226 navBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
\r
227 navBar.add(innerNavBar);
\r
228 navBar.setWidth("100%");
\r
229 VerticalPanel vp = new VerticalPanel();
\r
230 vp.add(searchResults);
\r
231 searchResults.addStyleName("gss-searchlabel");
\r
234 table.setStyleName("gss-List");
\r
236 DeferredCommand.addCommand(new IncrementalCommand() {
\r
238 public boolean execute() {
\r
239 return fetchRootFolder();
\r
242 table.sinkEvents(Event.ONCONTEXTMENU);
\r
243 table.sinkEvents(Event.ONMOUSEUP);
\r
244 table.sinkEvents(Event.ONCLICK);
\r
245 table.sinkEvents(Event.ONKEYDOWN);
\r
246 table.sinkEvents(Event.ONDBLCLICK);
\r
247 preventIESelection();
\r
250 public void onClick(Widget sender) {
\r
251 if (sender == nextButton) {
\r
252 // Move forward a page.
\r
253 clearSelectedRows();
\r
254 startIndex += GSS.VISIBLE_FILE_COUNT;
\r
255 if (startIndex >= folderFileCount)
\r
256 startIndex -= GSS.VISIBLE_FILE_COUNT;
\r
259 } else if (sender == prevButton) {
\r
260 clearSelectedRows();
\r
261 // Move back a page.
\r
262 startIndex -= GSS.VISIBLE_FILE_COUNT;
\r
263 if (startIndex < 0)
\r
271 * Retrieve the root folder for the current user.
\r
273 * @return true if the retrieval was successful
\r
275 protected boolean fetchRootFolder() {
\r
276 UserResource user = GSS.get().getCurrentUserResource();
\r
279 updateFileCache("");
\r
283 public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
\r
284 // Select the row that was clicked (-1 to account for header row).
\r
285 if (row > folderFileCount)
\r
288 GWT.log("ROW is:" + row + " fs:" + firstShift, null);
\r
289 if (firstShift == -1)
\r
291 else if (row > firstShift) {
\r
292 clearSelectedRows();
\r
293 for (int i = firstShift; i < row; i++) {
\r
294 selectedRows.add(startIndex + i);
\r
297 GSS.get().setCurrentSelection(getSelectedFiles());
\r
298 //contextMenu.setFiles(getSelectedFiles());
\r
299 table.setWidget(row, 0, contextMenu);
\r
300 } else if (row != -1 && row == firstShift) {
\r
301 selectedRows.add(row);
\r
302 selectedRows.add(row - 1);
\r
303 styleRow(row, true);
\r
304 styleRow(row - 1, true);
\r
305 } else if (row < firstShift) {
\r
306 GWT.log("ROW is:" + row + " fs:" + firstShift, null);
\r
307 clearSelectedRows();
\r
309 for (int i = firstShift; i >= row - 1; i--) {
\r
310 selectedRows.add(startIndex + i);
\r
313 GSS.get().setCurrentSelection(getSelectedFiles());
\r
314 table.setWidget(row, 0, contextMenu);
\r
315 //contextMenu.setFiles(getSelectedFiles());
\r
318 } else if (row > 0)
\r
319 selectRow(row - 1);
\r
324 * Initializes the table so that it contains enough rows for a full page of
\r
327 private void initTable() {
\r
329 nameLabel = new HTML("Name");
\r
330 nameLabel.addClickListener(new ClickListener() {
\r
332 public void onClick(Widget sender) {
\r
337 versionLabel = new HTML("Version");
\r
338 versionLabel.addClickListener(new ClickListener() {
\r
340 public void onClick(Widget sender) {
\r
341 sortFiles("version");
\r
345 sizeLabel = new HTML("Size");
\r
346 sizeLabel.addClickListener(new ClickListener() {
\r
348 public void onClick(Widget sender) {
\r
353 dateLabel = new HTML("Last modified");
\r
354 dateLabel.addClickListener(new ClickListener() {
\r
356 public void onClick(Widget sender) {
\r
361 ownerLabel = new HTML("Owner");
\r
362 ownerLabel.addClickListener(new ClickListener() {
\r
364 public void onClick(Widget sender) {
\r
365 sortFiles("owner");
\r
370 pathLabel = new HTML("Path");
\r
371 pathLabel.addClickListener(new ClickListener() {
\r
373 public void onClick(Widget sender) {
\r
378 // Create the header row.
\r
379 table.setText(0, 0, "");
\r
380 // table.setText(0, 1, "Name");
\r
381 table.setWidget(0, 1, nameLabel);
\r
382 table.setWidget(0, 2, ownerLabel);
\r
383 // table.setText(0, 3, "Version");
\r
384 table.setWidget(0, 3, pathLabel);
\r
385 table.setWidget(0, 4, versionLabel);
\r
386 // table.setText(0, 4, "Size");
\r
387 table.setWidget(0, 5, sizeLabel);
\r
388 // table.setText(0, 5, "Last modified");
\r
389 table.setWidget(0, 6, dateLabel);
\r
390 table.setWidget(0, 7, navBar);
\r
391 table.getRowFormatter().setStyleName(0, "gss-ListHeader");
\r
393 // Initialize the rest of the rows.
\r
394 for (int i = 1; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
\r
395 table.setText(i, 0, "");
\r
396 table.setText(i, 1, "");
\r
397 table.setText(i, 2, "");
\r
398 table.setText(i, 3, "");
\r
399 table.setText(i, 4, "");
\r
400 table.setText(i, 5, "");
\r
401 table.setText(i, 6, "");
\r
402 table.getCellFormatter().setWordWrap(i, 0, false);
\r
403 table.getCellFormatter().setWordWrap(i, 1, false);
\r
404 table.getCellFormatter().setWordWrap(i, 2, false);
\r
405 table.getCellFormatter().setWordWrap(i, 3, false);
\r
406 table.getCellFormatter().setWordWrap(i, 4, false);
\r
407 table.getCellFormatter().setWordWrap(i, 5, false);
\r
408 table.getCellFormatter().setWordWrap(i, 6, false);
\r
409 table.getCellFormatter().setHorizontalAlignment(i, 4, HasHorizontalAlignment.ALIGN_CENTER);
\r
411 prevButton.setVisible(false);
\r
412 nextButton.setVisible(false);
\r
416 * Selects the given row (relative to the current page).
\r
418 * @param row the row to be selected
\r
420 private void selectRow(final int row) {
\r
421 if (row < folderFileCount) {
\r
423 if (selectedRows.contains(row)) {
\r
424 int i = selectedRows.indexOf(startIndex + row);
\r
425 selectedRows.remove(i);
\r
426 styleRow(row, false);
\r
428 for (int r : selectedRows) {
\r
429 int prow = r - startIndex;
\r
430 table.setWidget(prow + 1, 0, images.document().createImage());
\r
432 selectedRows.add(startIndex + row);
\r
433 styleRow(row, true);
\r
436 clearSelectedRows();
\r
437 selectedRows.add(startIndex + row);
\r
438 styleRow(row, true);
\r
440 if (selectedRows.size() == 1)
\r
441 GSS.get().setCurrentSelection(files.get(selectedRows.get(0)));
\r
443 GSS.get().setCurrentSelection(getSelectedFiles());
\r
444 //contextMenu.setFiles(getSelectedFiles());
\r
445 table.setWidget(row + 1, 0, contextMenu);
\r
449 public List<FileResource> getSelectedFiles() {
\r
450 List<FileResource> result = new ArrayList();
\r
451 for (int i : selectedRows)
\r
452 result.add(files.get(i));
\r
457 * Make the specified row look like selected or not, according to the
\r
458 * <code>selected</code> flag.
\r
463 void styleRow(final int row, final boolean selected) {
\r
464 if (row != -1 && row >= 0)
\r
466 table.getRowFormatter().addStyleName(row + 1, "gss-SelectedRow");
\r
468 table.getRowFormatter().removeStyleName(row + 1, "gss-SelectedRow");
\r
472 * Update the display of the file list.
\r
474 void update(boolean sort) {
\r
475 int count = folderFileCount;
\r
476 int max = startIndex + GSS.VISIBLE_FILE_COUNT;
\r
479 folderTotalSize = 0;
\r
481 if (sort && files != null && files.size() != 0) {
\r
483 clearSelectedRows();
\r
485 Collections.sort(files, new Comparator<FileResource>() {
\r
487 public int compare(FileResource arg0, FileResource arg1) {
\r
489 if (sortingProperty.equals("version")) {
\r
490 versionLabel.setHTML("Version " + images.desc().getHTML());
\r
491 return arg0.getVersion().compareTo(arg1.getVersion());
\r
492 } else if (sortingProperty.equals("owner")) {
\r
493 ownerLabel.setHTML("Owner " + images.desc().getHTML());
\r
494 return arg0.getOwner().compareTo(arg1.getOwner());
\r
495 } else if (sortingProperty.equals("date")) {
\r
496 dateLabel.setHTML("Last modified " + images.desc().getHTML());
\r
497 return arg0.getModificationDate().compareTo(arg1.getModificationDate());
\r
498 } else if (sortingProperty.equals("size")) {
\r
499 sizeLabel.setHTML("Size " + images.desc().getHTML());
\r
500 return arg0.getContentLength().compareTo(arg1.getContentLength());
\r
501 } else if (sortingProperty.equals("name")) {
\r
502 nameLabel.setHTML("Name " + images.desc().getHTML());
\r
503 return arg0.getName().compareTo(arg1.getName());
\r
504 } else if (sortingProperty.equals("path")) {
\r
505 pathLabel.setHTML("Path " + images.desc().getHTML());
\r
506 return arg0.getUri().compareTo(arg1.getUri());
\r
508 nameLabel.setHTML("Name " + images.desc().getHTML());
\r
509 return arg0.getName().compareTo(arg1.getName());
\r
511 else if (sortingProperty.equals("version")) {
\r
512 versionLabel.setHTML("Version " + images.asc().getHTML());
\r
513 return arg1.getVersion().compareTo(arg0.getVersion());
\r
514 } else if (sortingProperty.equals("owner")) {
\r
515 ownerLabel.setHTML("Owner " + images.asc().getHTML());
\r
516 return arg1.getOwner().compareTo(arg0.getOwner());
\r
517 } else if (sortingProperty.equals("date")) {
\r
518 dateLabel.setHTML("Last modified " + images.asc().getHTML());
\r
519 return arg1.getModificationDate().compareTo(arg0.getModificationDate());
\r
520 } else if (sortingProperty.equals("size")) {
\r
521 sizeLabel.setHTML("Size " + images.asc().getHTML());
\r
522 return arg1.getContentLength().compareTo(arg0.getContentLength());
\r
523 } else if (sortingProperty.equals("name")) {
\r
524 nameLabel.setHTML("Name " + images.asc().getHTML());
\r
525 return arg1.getName().compareTo(arg0.getName());
\r
526 } else if (sortingProperty.equals("path")) {
\r
527 pathLabel.setHTML("Path " + images.asc().getHTML());
\r
528 return arg1.getUri().compareTo(arg0.getUri());
\r
530 nameLabel.setHTML("Name " + images.asc().getHTML());
\r
531 return arg1.getName().compareTo(arg0.getName());
\r
538 // Show the selected files.
\r
540 for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
\r
541 // Don't read past the end.
\r
542 // if (i > folderFileCount)
\r
544 if (startIndex + i > folderFileCount)
\r
546 // Add a new row to the table, then set each of its columns to the
\r
548 table.setWidget(i, 0, images.document().createImage());
\r
549 FileResource fileHeader = files.get(startIndex + i - 1);
\r
550 table.getRowFormatter().addStyleName(i, "gss-fileRow");
\r
551 table.setHTML(i, 1, fileHeader.getName());
\r
552 table.setText(i, 2, fileHeader.getOwner());
\r
553 table.setText(i, 3, fileHeader.getPath());
\r
554 table.setText(i, 4, String.valueOf(fileHeader.getVersion()));
\r
555 table.setText(i, 5, String.valueOf(fileHeader.getFileSizeAsString()));
\r
556 final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
\r
557 table.setText(i, 6, formatter.format(fileHeader.getModificationDate()));
\r
558 folderTotalSize += fileHeader.getContentLength();
\r
561 // Clear any remaining slots.
\r
562 for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
\r
563 table.setHTML(i, 0, " ");
\r
564 table.setHTML(i, 1, " ");
\r
565 table.setHTML(i, 2, " ");
\r
566 table.setHTML(i, 3, " ");
\r
567 table.setHTML(i, 4, " ");
\r
568 table.setHTML(i, 5, " ");
\r
569 table.setHTML(i, 6, " ");
\r
570 table.setHTML(i, 7, " ");
\r
573 if (folderFileCount == 0) {
\r
574 showingStats = "no files";
\r
575 prevButton.setVisible(false);
\r
576 nextButton.setVisible(false);
\r
577 } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) {
\r
578 if (folderFileCount == 1)
\r
579 showingStats = "1 file";
\r
581 showingStats = folderFileCount + " files";
\r
582 showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
\r
583 prevButton.setVisible(false);
\r
584 nextButton.setVisible(false);
\r
586 showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
\r
587 prevButton.setVisible(startIndex != 0);
\r
588 nextButton.setVisible(startIndex + GSS.VISIBLE_FILE_COUNT < count);
\r
590 updateCurrentlyShowingStats();
\r
594 * update status panel with currently showing file stats
\r
596 public void updateCurrentlyShowingStats() {
\r
597 GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
\r
601 * Adjust the height of the table by adding and removing rows as necessary.
\r
603 * @param newHeight the new height to reach
\r
605 void resizeTableHeight(final int newHeight) {
\r
606 GWT.log("Panel: " + newHeight + ", parent: " + table.getParent().getOffsetHeight(), null);
\r
607 // Fill the rest with empty slots.
\r
608 if (newHeight > table.getOffsetHeight())
\r
609 while (newHeight > table.getOffsetHeight()) {
\r
610 // table.setHTML(table.getRowCount(), 5, " ");
\r
611 table.resizeRows(table.getRowCount() + 1);
\r
612 GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
\r
615 while (newHeight < table.getOffsetHeight()) {
\r
616 // table.setHTML(table.getRowCount(), 5, " ");
\r
617 table.resizeRows(table.getRowCount() - 1);
\r
618 GWT.log("Table: " + table.getOffsetHeight() + ", rows: " + table.getRowCount(), null);
\r
623 * Update the file cache with data from the server.
\r
625 public void updateFileCache(String query) {
\r
626 final GSS app = GSS.get();
\r
627 clearSelectedRows();
\r
630 app.showLoadingIndicator();
\r
631 if (query == null || query.trim().equals("")) {
\r
632 searchResults.setHTML("You must specify a query");
\r
633 setFiles(new ArrayList());
\r
635 app.hideLoadingIndicator();
\r
637 searchResults.setHTML("Search results for " + query);
\r
639 GetCommand<SearchResource> eg = new GetCommand<SearchResource>(SearchResource.class,
\r
640 app.getApiPath() + "search/" + URL.encodeComponent(query)) {
\r
643 public void onComplete() {
\r
644 SearchResource s = getResult();
\r
645 setFiles(s.getFiles());
\r
650 public void onError(Throwable t) {
\r
651 if(t instanceof RestException)
\r
652 app.displayError("Unable to perform search:"+((RestException)t).getHttpStatusText());
\r
654 app.displayError("System error performing search:"+t.getMessage());
\r
655 updateFileCache("");
\r
659 DeferredCommand.addCommand(eg);
\r
664 * Fill the file cache with data.
\r
667 * @param filePaths the files to set
\r
669 private void setFiles(List<FileResource> _files) {
\r
671 Collections.sort(files, new Comparator<FileResource>() {
\r
673 public int compare(FileResource arg0, FileResource arg1) {
\r
674 return arg0.getName().compareTo(arg1.getName());
\r
678 folderFileCount = files.size();
\r
679 GWT.log("File count:" + folderFileCount, null);
\r
682 private void sortFiles(final String sortProperty) {
\r
683 if (sortProperty.equals(sortingProperty))
\r
684 sortingType = !sortingType;
\r
686 sortingProperty = sortProperty;
\r
687 sortingType = true;
\r
692 private void clearLabels() {
\r
693 nameLabel.setText("Name");
\r
694 versionLabel.setText("Version");
\r
695 sizeLabel.setText("Size");
\r
696 dateLabel.setText("Last modified");
\r
697 ownerLabel.setText("Owner");
\r
698 pathLabel.setText("Path");
\r
702 * Retrieve the table.
\r
704 * @return the table
\r
711 * Does the list contains the requested filename
\r
714 * @return true/false
\r
716 public boolean contains(String fileName) {
\r
717 for (int i = 0; i < files.size(); i++)
\r
718 if (files.get(i).getName().equals(fileName))
\r
723 public void clearSelectedRows() {
\r
724 for (int r : selectedRows) {
\r
725 int row = r - startIndex;
\r
726 styleRow(row, false);
\r
727 table.setWidget(row + 1, 0, images.document().createImage());
\r
729 selectedRows.clear();
\r
730 Object sel = GSS.get().getCurrentSelection();
\r
731 if (sel instanceof FileResource || sel instanceof List)
\r
732 GSS.get().setCurrentSelection(null);
\r
735 public static native void preventIESelection() /*-{
\r
736 $doc.body.onselectstart = function () { return false; };
\r
739 public static native void enableIESelection() /*-{
\r
740 if ($doc.body.onselectstart != null)
\r
741 $doc.body.onselectstart = null;
\r
744 public void selectAllRows() {
\r
745 clearSelectedRows();
\r
746 int count = folderFileCount;
\r
749 int max = startIndex + GSS.VISIBLE_FILE_COUNT;
\r
753 for (; i < GSS.VISIBLE_FILE_COUNT + 1; ++i) {
\r
754 // Don't read past the end.
\r
755 // if (i > folderFileCount)
\r
757 if (startIndex + i > folderFileCount)
\r
759 selectedRows.add(startIndex + i - 1);
\r
760 styleRow(i - 1, true);
\r
762 GSS.get().setCurrentSelection(getSelectedFiles());
\r
763 //contextMenu.setFiles(getSelectedFiles());
\r
764 table.setWidget(i - 1, 0, contextMenu);
\r