2 * Copyright 2011 GRNET S.A. All rights reserved.
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the following
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials
15 * provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
30 * The views and conclusions contained in the software and
31 * documentation are those of the authors and should not be
32 * interpreted as representing official policies, either expressed
33 * or implied, of GRNET S.A.
36 package gr.grnet.pithos.web.client;
38 import com.google.gwt.event.dom.client.ContextMenuEvent;
39 import com.google.gwt.event.dom.client.ContextMenuHandler;
40 import static com.google.gwt.query.client.GQuery.$;
42 import gr.grnet.pithos.web.client.commands.UploadFileCommand;
43 import gr.grnet.pithos.web.client.foldertree.File;
44 import gr.grnet.pithos.web.client.foldertree.Folder;
45 import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
46 import gr.grnet.pithos.web.client.rest.resource.FileResource;
47 import gwtquery.plugins.draggable.client.DraggableOptions;
48 import gwtquery.plugins.draggable.client.StopDragException;
49 import gwtquery.plugins.draggable.client.DraggableOptions.DragFunction;
50 import gwtquery.plugins.draggable.client.DraggableOptions.RevertOption;
51 import gwtquery.plugins.draggable.client.events.DragContext;
52 import gwtquery.plugins.draggable.client.events.DragStartEvent;
53 import gwtquery.plugins.draggable.client.events.DragStopEvent;
54 import gwtquery.plugins.draggable.client.events.DragStartEvent.DragStartEventHandler;
55 import gwtquery.plugins.draggable.client.events.DragStopEvent.DragStopEventHandler;
56 import gwtquery.plugins.droppable.client.gwt.DragAndDropCellTable;
57 import gwtquery.plugins.droppable.client.gwt.DragAndDropColumn;
59 import java.util.ArrayList;
60 import java.util.Collections;
61 import java.util.Comparator;
62 import java.util.Iterator;
63 import java.util.List;
65 import com.google.gwt.cell.client.ImageResourceCell;
66 import com.google.gwt.cell.client.SafeHtmlCell;
67 import com.google.gwt.cell.client.TextCell;
68 import com.google.gwt.cell.client.ValueUpdater;
69 import com.google.gwt.core.client.GWT;
70 import com.google.gwt.dom.client.Style.Cursor;
71 import com.google.gwt.event.dom.client.ClickEvent;
72 import com.google.gwt.event.dom.client.ClickHandler;
73 import com.google.gwt.i18n.client.DateTimeFormat;
74 import com.google.gwt.resources.client.ClientBundle;
75 import com.google.gwt.resources.client.ImageResource;
76 import com.google.gwt.safehtml.client.SafeHtmlTemplates;
77 import com.google.gwt.safehtml.shared.SafeHtml;
78 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
79 import com.google.gwt.user.cellview.client.CellTable;
80 import com.google.gwt.user.cellview.client.GssSimplePager;
81 import com.google.gwt.user.client.Event;
82 import com.google.gwt.user.client.ui.AbstractImagePrototype;
83 import com.google.gwt.user.client.ui.Button;
84 import com.google.gwt.user.client.ui.Composite;
85 import com.google.gwt.user.client.ui.HorizontalPanel;
86 import com.google.gwt.user.client.ui.VerticalPanel;
87 import com.google.gwt.view.client.ListDataProvider;
88 import com.google.gwt.view.client.MultiSelectionModel;
89 import com.google.gwt.view.client.ProvidesKey;
90 import com.google.gwt.view.client.SelectionChangeEvent;
91 import com.google.gwt.view.client.SelectionChangeEvent.Handler;
94 * A composite that displays the list of files in a particular folder.
96 public class FileList extends Composite {
98 ListDataProvider<File> provider = new ListDataProvider<File>();
101 * The styles applied to the table.
103 interface TableStyle extends CellTable.Style {
106 interface TableResources extends DragAndDropCellTable.Resources {
107 @Source({CellTable.Style.DEFAULT_CSS, "GssCellTable.css"})
108 TableStyle cellTableStyle();
111 static interface Templates extends SafeHtmlTemplates {
112 Templates INSTANCE = GWT.create(Templates.class);
114 @Template("<div id='dragHelper' style='border:1px solid black; background-color:#ffffff; color:black; width:150px;z-index:100'></div>")
115 SafeHtml outerHelper();
117 @Template("<span id='{0}'>{0}</span>")
118 public SafeHtml filenameSpan(String filename);
120 @Template("<a href='{0}' title='{1}' rel='lytebox[mnf]' onclick='myLytebox.start(this, false, false); return false;'>(view)</a>")
121 public SafeHtml viewLink(String link, String title);
123 @Template("<table><tr><td rowspan='3'>{0}</td><td style='font-size:95%;' id='{1}'>{1}</td></tr><tr><td>{2}</td></tr></table>")
124 public SafeHtml rendelContactCell(String imageHtml, String name, String fileSize);
126 @Template("<span id='{0}' class='{1}'>{2}</span>")
127 public SafeHtml spanWithIdAndClass(String id, String cssClass, String content);
130 private String showingStats = "";
132 private int startIndex = 0;
135 * A constant that denotes the completion of an IncrementalCommand.
137 public static final boolean DONE = false;
139 private final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
142 * Specifies that the images available for this composite will be the ones
143 * available in FileContextMenu.
145 public interface Images extends ClientBundle,FileContextMenu.Images, CellTreeView.Images {
147 @Source("gr/grnet/pithos/resources/blank.gif")
148 ImageResource blank();
150 @Source("gr/grnet/pithos/resources/asc.png")
153 @Source("gr/grnet/pithos/resources/desc.png")
154 ImageResource desc();
156 @Source("gr/grnet/pithos/resources/mimetypes/document_shared.png")
157 ImageResource documentShared();
159 @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst.png")
160 ImageResource wordprocessor();
162 @Source("gr/grnet/pithos/resources/mimetypes/log.png")
163 ImageResource spreadsheet();
165 @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr.png")
166 ImageResource presentation();
168 @Source("gr/grnet/pithos/resources/mimetypes/acroread.png")
171 @Source("gr/grnet/pithos/resources/mimetypes/image.png")
172 ImageResource image();
174 @Source("gr/grnet/pithos/resources/mimetypes/video2.png")
175 ImageResource video();
177 @Source("gr/grnet/pithos/resources/mimetypes/knotify.png")
178 ImageResource audio();
180 @Source("gr/grnet/pithos/resources/mimetypes/html.png")
181 ImageResource html();
183 @Source("gr/grnet/pithos/resources/mimetypes/txt.png")
186 @Source("gr/grnet/pithos/resources/mimetypes/ark2.png")
189 @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst_shared.png")
190 ImageResource wordprocessorShared();
192 @Source("gr/grnet/pithos/resources/mimetypes/log_shared.png")
193 ImageResource spreadsheetShared();
195 @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr_shared.png")
196 ImageResource presentationShared();
198 @Source("gr/grnet/pithos/resources/mimetypes/acroread_shared.png")
199 ImageResource pdfShared();
201 @Source("gr/grnet/pithos/resources/mimetypes/image_shared.png")
202 ImageResource imageShared();
204 @Source("gr/grnet/pithos/resources/mimetypes/video2_shared.png")
205 ImageResource videoShared();
207 @Source("gr/grnet/pithos/resources/mimetypes/knotify_shared.png")
208 ImageResource audioShared();
210 @Source("gr/grnet/pithos/resources/mimetypes/html_shared.png")
211 ImageResource htmlShared();
213 @Source("gr/grnet/pithos/resources/mimetypes/txt_shared.png")
214 ImageResource txtShared();
216 @Source("gr/grnet/pithos/resources/mimetypes/ark2_shared.png")
217 ImageResource zipShared();
222 * The number of files in this folder.
229 long folderTotalSize;
232 * A cache of the files in the list.
234 private List<File> files;
237 * The widget's image bundle.
239 private final Images images;
241 private DragAndDropCellTable<File> celltable;
243 private final MultiSelectionModel<File> selectionModel;
245 private final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
247 SortableHeader nameHeader;
249 GssSimplePager pagerBottom;
251 GssSimplePager pagerTop;
253 Button uploadButtonBottom;
255 Button uploadButtonTop;
257 FolderTreeView treeView;
260 * Construct the file list widget. This entails setting up the widget
261 * layout, fetching the number of files in the current folder from the
262 * server and filling the local file cache of displayed files with data from
263 * the server, as well.
267 public FileList(Images _images, FolderTreeView _treeView) {
269 this.treeView = _treeView;
271 DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
273 ProvidesKey<File> keyProvider = new ProvidesKey<File>(){
276 public Object getKey(File item) {
277 return item.getUri();
281 celltable = new DragAndDropCellTable<File>(GSS.VISIBLE_FILE_COUNT, resources, keyProvider);
282 celltable.setWidth("100%");
283 celltable.setStyleName("pithos-List");
285 DragAndDropColumn<File, ImageResource> status = new DragAndDropColumn<File, ImageResource>(new ImageResourceCell() {
287 public boolean handlesSelection() {
293 public ImageResource getValue(File entity) {
294 return getFileIcon(entity);
297 celltable.addColumn(status,"");
298 initDragOperation(status);
300 final DragAndDropColumn<File,SafeHtml> nameColumn = new DragAndDropColumn<File,SafeHtml>(new SafeHtmlCell()) {
303 public SafeHtml getValue(File object) {
304 SafeHtmlBuilder sb = new SafeHtmlBuilder();
305 sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
306 if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg")) {
307 sb.appendHtmlConstant(" ")
308 .append(Templates.INSTANCE.viewLink(object.getUri(), object.getOwner() + " : " + object.getPath() + object.getName()));
311 return sb.toSafeHtml();
315 initDragOperation(nameColumn);
316 celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name"));
317 allHeaders.add(nameHeader);
318 nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
320 celltable.redrawHeaders();
322 DragAndDropColumn<File,String> aColumn = new DragAndDropColumn<File, String>(new TextCell()) {
324 public String getValue(File object) {
325 return object.getOwner();
328 SortableHeader aheader = new SortableHeader("Owner");
329 celltable.addColumn(aColumn, aheader);
330 initDragOperation(aColumn);
331 allHeaders.add(aheader);
332 aheader.setUpdater(new FileValueUpdater(aheader, "owner"));
334 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
336 public String getValue(File object) {
337 return object.getPath();
340 aheader = new SortableHeader("Path");
341 celltable.addColumn(aColumn, aheader);
342 initDragOperation(aColumn);
343 allHeaders.add(aheader);
344 aheader.setUpdater(new FileValueUpdater(aheader, "path"));
346 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
348 public String getValue(File object) {
349 return String.valueOf(object.getVersion());
352 aheader = new SortableHeader("Version");
353 celltable.addColumn(aColumn, aheader);
354 initDragOperation(aColumn);
355 allHeaders.add(aheader);
356 aheader.setUpdater(new FileValueUpdater(aheader, "version"));
358 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
360 public String getValue(File object) {
361 // TODO Auto-generated method stub
362 return object.getSizeAsString();
365 aheader = new SortableHeader("Size");
366 celltable.addColumn(aColumn, aheader);
367 initDragOperation(aColumn);
368 allHeaders.add(aheader);
369 aheader.setUpdater(new FileValueUpdater(aheader, "size"));
371 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
373 public String getValue(File object) {
374 return formatter.format(object.getLastModified());
377 aheader = new SortableHeader("Last Modified");
378 celltable.addColumn(aColumn, aheader);
379 allHeaders.add(aheader);
380 aheader.setUpdater(new FileValueUpdater(aheader, "date"));
382 provider.addDataDisplay(celltable);
384 celltable.addDragStopHandler(new DragStopEventHandler() {
387 public void onDragStop(DragStopEvent event) {
388 GWT.log("DRAG STOPPED");
391 celltable.addDragStartHandler(new DragStartEventHandler() {
393 public void onDragStart(DragStartEvent event) {
394 FileResource value = event.getDraggableData();
396 com.google.gwt.dom.client.Element helper = event.getHelper();
397 SafeHtmlBuilder sb = new SafeHtmlBuilder();
398 sb.appendHtmlConstant("<b>");
399 DisplayHelper.log(value.getName());
400 if(getSelectedFiles().size()==1)
401 sb.appendEscaped(value.getName());
403 sb.appendEscaped(getSelectedFiles().size()+" files");
404 sb.appendHtmlConstant("</b>");
405 helper.setInnerHTML(sb.toSafeHtml().asString());
409 VerticalPanel vp = new VerticalPanel();
412 pagerTop = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
413 pagerTop.setVisible(false);
414 pagerTop.setDisplay(celltable);
415 uploadButtonTop = new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>");
416 uploadButtonTop.addClickHandler(new ClickHandler() {
419 public void onClick(ClickEvent event) {
420 new UploadFileCommand(null).execute();
423 HorizontalPanel topPanel = new HorizontalPanel();
424 topPanel.add(pagerTop);
425 topPanel.add(uploadButtonTop);
430 pagerBottom = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
431 pagerBottom.setVisible(false);
432 pagerBottom.setDisplay(celltable);
433 uploadButtonBottom=new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>");
434 uploadButtonBottom.addClickHandler(new ClickHandler() {
437 public void onClick(ClickEvent event) {
438 new UploadFileCommand(null).execute();
441 HorizontalPanel bottomPanel = new HorizontalPanel();
442 bottomPanel.add(pagerBottom);
443 bottomPanel.add(uploadButtonBottom);
446 vp.setCellWidth(celltable, "100%");
447 vp.addHandler(new ContextMenuHandler() {
449 public void onContextMenu(ContextMenuEvent event) {
450 FileContextMenu contextMenu = new FileContextMenu(images, treeView.getSelection(), false);
451 int x = event.getNativeEvent().getClientX();
452 int y = event.getNativeEvent().getClientY();
453 contextMenu.setPopupPosition(x, y);
456 }, ContextMenuEvent.getType());
459 selectionModel = new MultiSelectionModel<File>(keyProvider);
461 Handler selectionHandler = new SelectionChangeEvent.Handler() {
463 public void onSelectionChange(SelectionChangeEvent event) {
464 if(getSelectedFiles().size() == 1)
465 GSS.get().setCurrentSelection(getSelectedFiles().get(0));
467 GSS.get().setCurrentSelection(getSelectedFiles());
470 selectionModel.addSelectionChangeHandler(selectionHandler);
472 celltable.setSelectionModel(selectionModel, GSSSelectionEventManager.<File> createDefaultManager());
473 celltable.setPageSize(GSS.VISIBLE_FILE_COUNT);
475 sinkEvents(Event.ONCONTEXTMENU);
476 // sinkEvents(Event.ONMOUSEUP);
477 // sinkEvents(Event.ONMOUSEDOWN);
478 // sinkEvents(Event.ONCLICK);
479 // sinkEvents(Event.ONKEYDOWN);
480 // sinkEvents(Event.ONDBLCLICK);
481 GSS.preventIESelection();
484 public List<File> getSelectedFiles() {
485 return new ArrayList<File>(selectionModel.getSelectedSet());
488 private void initDragOperation(DragAndDropColumn<?, ?> column) {
489 // retrieve draggableOptions on the column
490 DraggableOptions draggableOptions = column.getDraggableOptions();
491 // use template to construct the helper. The content of the div will be set
493 draggableOptions.setHelper($(Templates.INSTANCE.outerHelper().asString()));
494 //draggableOptions.setZIndex(100);
495 // opacity of the helper
496 draggableOptions.setAppendTo("body");
497 //draggableOptions.setOpacity((float) 0.8);
498 draggableOptions.setContainment("document");
499 // cursor to use during the drag operation
500 draggableOptions.setCursor(Cursor.MOVE);
501 // set the revert option
502 draggableOptions.setRevert(RevertOption.ON_INVALID_DROP);
503 // prevents dragging when user click on the category drop-down list
504 draggableOptions.setCancel("select");
505 draggableOptions.setOnBeforeDragStart(new DragFunction() {
507 public void f(DragContext context) {
508 File value = context.getDraggableData();
509 if (!selectionModel.isSelected(value)) {
510 throw new StopDragException();
517 // public void onBrowserEvent(Event event) {
519 // if (files == null || files.size() == 0) {
520 // if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
521 // contextMenu = new FileContextMenu(images, false, true);
522 // contextMenu.show();
523 // event.preventDefault();
524 // event.cancelBubble(true);
528 // if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) {
529 // GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null);
530 // contextMenu = new FileContextMenu(images, false, false);
531 // contextMenu = contextMenu.onEvent(event);
532 // event.cancelBubble(true);
533 // event.preventDefault();
534 // } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
535 // contextMenu = new FileContextMenu(images, false, true);
536 // contextMenu = contextMenu.onEmptyEvent(event);
537 // event.cancelBubble(true);
538 // event.preventDefault();
539 // } else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
540 // if (getSelectedFiles().size() == 1) {
541 // GSS app = GSS.get();
542 // File file = getSelectedFiles().get(0);
543 // Window.open(file.getUri(), "_blank", "");
544 // event.preventDefault();
547 // super.onBrowserEvent(event);
551 * Update the display of the file list.
553 void update(boolean sort) {
554 int count = folderFileCount;
555 int max = startIndex + GSS.VISIBLE_FILE_COUNT;
561 folderTotalSize += f.getBytes();
563 if (folderFileCount == 0) {
564 showingStats = "no files";
565 } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) {
566 if (folderFileCount == 1)
567 showingStats = "1 file";
569 showingStats = folderFileCount + " files";
570 showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
572 showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
575 updateCurrentlyShowingStats();
580 * Return the proper icon based on the MIME type of the file.
585 private ImageResource getFileIcon(File file) {
586 String mimetype = file.getContentType();
587 boolean shared = file.isShared();
588 if (mimetype == null)
589 return shared ? images.documentShared() : images.document();
590 mimetype = mimetype.toLowerCase();
591 if (mimetype.startsWith("application/pdf"))
592 return shared ? images.pdfShared() : images.pdf();
593 else if (mimetype.endsWith("excel"))
594 return shared ? images.spreadsheetShared() : images.spreadsheet();
595 else if (mimetype.endsWith("msword"))
596 return shared ? images.wordprocessorShared() : images.wordprocessor();
597 else if (mimetype.endsWith("powerpoint"))
598 return shared ? images.presentationShared() : images.presentation();
599 else if (mimetype.startsWith("application/zip") ||
600 mimetype.startsWith("application/gzip") ||
601 mimetype.startsWith("application/x-gzip") ||
602 mimetype.startsWith("application/x-tar") ||
603 mimetype.startsWith("application/x-gtar"))
604 return shared ? images.zipShared() : images.zip();
605 else if (mimetype.startsWith("text/html"))
606 return shared ? images.htmlShared() : images.html();
607 else if (mimetype.startsWith("text/plain"))
608 return shared ? images.txtShared() : images.txt();
609 else if (mimetype.startsWith("image/"))
610 return shared ? images.imageShared() : images.image();
611 else if (mimetype.startsWith("video/"))
612 return shared ? images.videoShared() : images.video();
613 else if (mimetype.startsWith("audio/"))
614 return shared ? images.audioShared() : images.audio();
615 return shared ? images.documentShared() : images.document();
619 * Update status panel with currently showing file stats.
621 public void updateCurrentlyShowingStats() {
622 GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
626 * Fill the file cache with data.
628 public void setFiles(final List<File> _files) {
629 files = new ArrayList<File>();
630 for (File fres : _files)
631 if (!fres.isInTrash())
633 Collections.sort(files, new Comparator<File>() {
636 public int compare(File arg0, File arg1) {
637 return arg0.getName().compareTo(arg1.getName());
641 folderFileCount = files.size();
643 nameHeader.setSorted(true);
644 nameHeader.toggleReverseSort();
645 for (SortableHeader otherHeader : allHeaders) {
646 if (otherHeader != nameHeader) {
647 otherHeader.setSorted(false);
648 otherHeader.setReverseSort(true);
652 if(files.size() > GSS.VISIBLE_FILE_COUNT){
653 pagerBottom.setVisible(true);
654 pagerTop.setVisible(true);
657 pagerTop.setVisible(false);
658 pagerBottom.setVisible(false);
660 Folder selectedItem = treeView.getSelection();
662 provider.setList(files);
666 * Does the list contains the requested filename
671 public boolean contains(String fileName) {
672 for (int i = 0; i < files.size(); i++)
673 if (files.get(i).getName().equals(fileName))
678 public void clearSelectedRows() {
679 Iterator<File> it = selectionModel.getSelectedSet().iterator();
681 selectionModel.setSelected(it.next(),false);
689 public void selectAllRows() {
690 Iterator<File> it = provider.getList().iterator();
692 selectionModel.setSelected(it.next(),true);
699 private void sortFiles(final String sortingProperty, final boolean sortingType){
700 Collections.sort(files, new Comparator<File>() {
703 public int compare(File arg0, File arg1) {
704 AbstractImagePrototype descPrototype = AbstractImagePrototype.create(images.desc());
705 AbstractImagePrototype ascPrototype = AbstractImagePrototype.create(images.asc());
707 if (sortingProperty.equals("version")) {
708 return arg0.getVersion() - arg1.getVersion();
709 } else if (sortingProperty.equals("owner")) {
710 return arg0.getOwner().compareTo(arg1.getOwner());
711 } else if (sortingProperty.equals("date")) {
712 return arg0.getLastModified().compareTo(arg1.getLastModified());
713 } else if (sortingProperty.equals("size")) {
714 return (int) (arg0.getBytes() - arg1.getBytes());
715 } else if (sortingProperty.equals("name")) {
716 return arg0.getName().compareTo(arg1.getName());
717 } else if (sortingProperty.equals("path")) {
718 return arg0.getUri().compareTo(arg1.getUri());
720 return arg0.getName().compareTo(arg1.getName());
723 else if (sortingProperty.equals("version")) {
725 return arg1.getVersion() - arg0.getVersion();
726 } else if (sortingProperty.equals("owner")) {
728 return arg1.getOwner().compareTo(arg0.getOwner());
729 } else if (sortingProperty.equals("date")) {
731 return arg1.getLastModified().compareTo(arg0.getLastModified());
732 } else if (sortingProperty.equals("size")) {
733 return (int) (arg1.getBytes() - arg0.getBytes());
734 } else if (sortingProperty.equals("name")) {
736 return arg1.getName().compareTo(arg0.getName());
737 } else if (sortingProperty.equals("path")) {
739 return arg1.getUri().compareTo(arg0.getUri());
742 return arg1.getName().compareTo(arg0.getName());
749 final class FileValueUpdater implements ValueUpdater<String>{
750 private String property;
751 private SortableHeader header;
755 public FileValueUpdater(SortableHeader header,String property) {
756 this.property=property;
760 public void update(String value) {
761 header.setSorted(true);
762 header.toggleReverseSort();
764 for (SortableHeader otherHeader : allHeaders) {
765 if (otherHeader != header) {
766 otherHeader.setSorted(false);
767 otherHeader.setReverseSort(true);
770 celltable.redrawHeaders();
771 sortFiles(property, header.getReverseSort());
772 FileList.this.update(true);
778 * Shows the files in the cellTable
780 private void showCellTable(){
781 if(files.size()>GSS.VISIBLE_FILE_COUNT){
782 pagerBottom.setVisible(true);
783 pagerTop.setVisible(true);
786 pagerTop.setVisible(false);
787 pagerBottom.setVisible(false);
789 provider.setList(files);
793 //celltable.redraw();
794 celltable.redrawHeaders();