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.DOM;
82 import com.google.gwt.user.client.Event;
83 import com.google.gwt.user.client.Window;
84 import com.google.gwt.user.client.ui.AbstractImagePrototype;
85 import com.google.gwt.user.client.ui.Button;
86 import com.google.gwt.user.client.ui.Composite;
87 import com.google.gwt.user.client.ui.HorizontalPanel;
88 import com.google.gwt.user.client.ui.VerticalPanel;
89 import com.google.gwt.view.client.ListDataProvider;
90 import com.google.gwt.view.client.MultiSelectionModel;
91 import com.google.gwt.view.client.ProvidesKey;
92 import com.google.gwt.view.client.SelectionChangeEvent;
93 import com.google.gwt.view.client.SelectionChangeEvent.Handler;
96 * A composite that displays the list of files in a particular folder.
98 public class FileList extends Composite {
100 ListDataProvider<File> provider = new ListDataProvider<File>();
103 * The styles applied to the table.
105 interface TableStyle extends CellTable.Style {
108 interface TableResources extends DragAndDropCellTable.Resources {
109 @Source({CellTable.Style.DEFAULT_CSS, "GssCellTable.css"})
110 TableStyle cellTableStyle();
113 static interface Templates extends SafeHtmlTemplates {
114 Templates INSTANCE = GWT.create(Templates.class);
116 @Template("<div id='dragHelper' style='border:1px solid black; background-color:#ffffff; color:black; width:150px;z-index:100'></div>")
117 SafeHtml outerHelper();
119 @Template("<span id='{0}'>{0}</span>")
120 public SafeHtml filenameSpan(String filename);
122 @Template("<a href='{0}' title='{1}' rel='lytebox[mnf]' onclick='myLytebox.start(this, false, false); return false;'>(view)</a>")
123 public SafeHtml viewLink(String link, String title);
125 @Template("<table><tr><td rowspan='3'>{0}</td><td style='font-size:95%;' id='{1}'>{1}</td></tr><tr><td>{2}</td></tr></table>")
126 public SafeHtml rendelContactCell(String imageHtml, String name, String fileSize);
128 @Template("<span id='{0}' class='{1}'>{2}</span>")
129 public SafeHtml spanWithIdAndClass(String id, String cssClass, String content);
132 private String showingStats = "";
134 private int startIndex = 0;
137 * A constant that denotes the completion of an IncrementalCommand.
139 public static final boolean DONE = false;
141 private final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
144 * Specifies that the images available for this composite will be the ones
145 * available in FileContextMenu.
147 public interface Images extends ClientBundle,FileContextMenu.Images, CellTreeView.Images {
149 @Source("gr/grnet/pithos/resources/blank.gif")
150 ImageResource blank();
152 @Source("gr/grnet/pithos/resources/asc.png")
155 @Source("gr/grnet/pithos/resources/desc.png")
156 ImageResource desc();
158 @Source("gr/grnet/pithos/resources/mimetypes/document_shared.png")
159 ImageResource documentShared();
161 @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst.png")
162 ImageResource wordprocessor();
164 @Source("gr/grnet/pithos/resources/mimetypes/log.png")
165 ImageResource spreadsheet();
167 @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr.png")
168 ImageResource presentation();
170 @Source("gr/grnet/pithos/resources/mimetypes/acroread.png")
173 @Source("gr/grnet/pithos/resources/mimetypes/image.png")
174 ImageResource image();
176 @Source("gr/grnet/pithos/resources/mimetypes/video2.png")
177 ImageResource video();
179 @Source("gr/grnet/pithos/resources/mimetypes/knotify.png")
180 ImageResource audio();
182 @Source("gr/grnet/pithos/resources/mimetypes/html.png")
183 ImageResource html();
185 @Source("gr/grnet/pithos/resources/mimetypes/txt.png")
188 @Source("gr/grnet/pithos/resources/mimetypes/ark2.png")
191 @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst_shared.png")
192 ImageResource wordprocessorShared();
194 @Source("gr/grnet/pithos/resources/mimetypes/log_shared.png")
195 ImageResource spreadsheetShared();
197 @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr_shared.png")
198 ImageResource presentationShared();
200 @Source("gr/grnet/pithos/resources/mimetypes/acroread_shared.png")
201 ImageResource pdfShared();
203 @Source("gr/grnet/pithos/resources/mimetypes/image_shared.png")
204 ImageResource imageShared();
206 @Source("gr/grnet/pithos/resources/mimetypes/video2_shared.png")
207 ImageResource videoShared();
209 @Source("gr/grnet/pithos/resources/mimetypes/knotify_shared.png")
210 ImageResource audioShared();
212 @Source("gr/grnet/pithos/resources/mimetypes/html_shared.png")
213 ImageResource htmlShared();
215 @Source("gr/grnet/pithos/resources/mimetypes/txt_shared.png")
216 ImageResource txtShared();
218 @Source("gr/grnet/pithos/resources/mimetypes/ark2_shared.png")
219 ImageResource zipShared();
224 * The number of files in this folder.
231 long folderTotalSize;
234 * A cache of the files in the list.
236 private List<File> files;
239 * The widget's image bundle.
241 private final Images images;
243 private FileContextMenu contextMenu;
245 private DragAndDropCellTable<File> celltable;
247 private final MultiSelectionModel<File> selectionModel;
249 private final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
251 SortableHeader nameHeader;
253 GssSimplePager pagerBottom;
255 GssSimplePager pagerTop;
257 Button uploadButtonBottom;
259 Button uploadButtonTop;
261 FolderTreeView treeView;
264 * Construct the file list widget. This entails setting up the widget
265 * layout, fetching the number of files in the current folder from the
266 * server and filling the local file cache of displayed files with data from
267 * the server, as well.
271 public FileList(Images _images, FolderTreeView _treeView) {
273 this.treeView = _treeView;
275 DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
277 ProvidesKey<File> keyProvider = new ProvidesKey<File>(){
280 public Object getKey(File item) {
281 return item.getUri();
285 celltable = new DragAndDropCellTable<File>(GSS.VISIBLE_FILE_COUNT, resources, keyProvider);
286 celltable.setWidth("100%");
287 celltable.setStyleName("pithos-List");
289 DragAndDropColumn<File, ImageResource> status = new DragAndDropColumn<File, ImageResource>(new ImageResourceCell() {
291 public boolean handlesSelection() {
297 public ImageResource getValue(File entity) {
298 return getFileIcon(entity);
301 celltable.addColumn(status,"");
302 initDragOperation(status);
304 final DragAndDropColumn<File,SafeHtml> nameColumn = new DragAndDropColumn<File,SafeHtml>(new SafeHtmlCell()) {
307 public SafeHtml getValue(File object) {
308 SafeHtmlBuilder sb = new SafeHtmlBuilder();
309 sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
310 if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg")) {
311 sb.appendHtmlConstant(" ")
312 .append(Templates.INSTANCE.viewLink(object.getUri(), object.getOwner() + " : " + object.getPath() + object.getName()));
315 return sb.toSafeHtml();
319 initDragOperation(nameColumn);
320 celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name"));
321 allHeaders.add(nameHeader);
322 nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
324 celltable.redrawHeaders();
326 DragAndDropColumn<File,String> aColumn = new DragAndDropColumn<File, String>(new TextCell()) {
328 public String getValue(File object) {
329 return object.getOwner();
332 SortableHeader aheader = new SortableHeader("Owner");
333 celltable.addColumn(aColumn, aheader);
334 initDragOperation(aColumn);
335 allHeaders.add(aheader);
336 aheader.setUpdater(new FileValueUpdater(aheader, "owner"));
338 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
340 public String getValue(File object) {
341 return object.getPath();
344 aheader = new SortableHeader("Path");
345 celltable.addColumn(aColumn, aheader);
346 initDragOperation(aColumn);
347 allHeaders.add(aheader);
348 aheader.setUpdater(new FileValueUpdater(aheader, "path"));
350 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
352 public String getValue(File object) {
353 return String.valueOf(object.getVersion());
356 aheader = new SortableHeader("Version");
357 celltable.addColumn(aColumn, aheader);
358 initDragOperation(aColumn);
359 allHeaders.add(aheader);
360 aheader.setUpdater(new FileValueUpdater(aheader, "version"));
362 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
364 public String getValue(File object) {
365 // TODO Auto-generated method stub
366 return object.getSizeAsString();
369 aheader = new SortableHeader("Size");
370 celltable.addColumn(aColumn, aheader);
371 initDragOperation(aColumn);
372 allHeaders.add(aheader);
373 aheader.setUpdater(new FileValueUpdater(aheader, "size"));
375 aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
377 public String getValue(File object) {
378 return formatter.format(object.getLastModified());
381 aheader = new SortableHeader("Last Modified");
382 celltable.addColumn(aColumn, aheader);
383 allHeaders.add(aheader);
384 aheader.setUpdater(new FileValueUpdater(aheader, "date"));
386 provider.addDataDisplay(celltable);
388 celltable.addDragStopHandler(new DragStopEventHandler() {
391 public void onDragStop(DragStopEvent event) {
392 GWT.log("DRAG STOPPED");
395 celltable.addDragStartHandler(new DragStartEventHandler() {
397 public void onDragStart(DragStartEvent event) {
398 FileResource value = event.getDraggableData();
400 com.google.gwt.dom.client.Element helper = event.getHelper();
401 SafeHtmlBuilder sb = new SafeHtmlBuilder();
402 sb.appendHtmlConstant("<b>");
403 DisplayHelper.log(value.getName());
404 if(getSelectedFiles().size()==1)
405 sb.appendEscaped(value.getName());
407 sb.appendEscaped(getSelectedFiles().size()+" files");
408 sb.appendHtmlConstant("</b>");
409 helper.setInnerHTML(sb.toSafeHtml().asString());
413 VerticalPanel vp = new VerticalPanel();
416 pagerTop = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
417 pagerTop.setVisible(false);
418 pagerTop.setDisplay(celltable);
419 uploadButtonTop = new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>");
420 uploadButtonTop.addClickHandler(new ClickHandler() {
423 public void onClick(ClickEvent event) {
424 new UploadFileCommand(null).execute();
427 HorizontalPanel topPanel = new HorizontalPanel();
428 topPanel.add(pagerTop);
429 topPanel.add(uploadButtonTop);
434 pagerBottom = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
435 pagerBottom.setVisible(false);
436 pagerBottom.setDisplay(celltable);
437 uploadButtonBottom=new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>");
438 uploadButtonBottom.addClickHandler(new ClickHandler() {
441 public void onClick(ClickEvent event) {
442 new UploadFileCommand(null).execute();
445 HorizontalPanel bottomPanel = new HorizontalPanel();
446 bottomPanel.add(pagerBottom);
447 bottomPanel.add(uploadButtonBottom);
450 vp.setCellWidth(celltable, "100%");
451 vp.addHandler(new ContextMenuHandler() {
453 public void onContextMenu(ContextMenuEvent event) {
454 contextMenu = new FileContextMenu(images, treeView.getSelection(), false);
455 int x = event.getNativeEvent().getClientX();
456 int y = event.getNativeEvent().getClientY();
457 contextMenu.setPopupPosition(x, y);
460 }, ContextMenuEvent.getType());
463 selectionModel = new MultiSelectionModel<File>(keyProvider);
465 Handler selectionHandler = new SelectionChangeEvent.Handler() {
467 public void onSelectionChange(SelectionChangeEvent event) {
468 if(getSelectedFiles().size() == 1)
469 GSS.get().setCurrentSelection(getSelectedFiles().get(0));
471 GSS.get().setCurrentSelection(getSelectedFiles());
474 selectionModel.addSelectionChangeHandler(selectionHandler);
476 celltable.setSelectionModel(selectionModel, GSSSelectionEventManager.<File> createDefaultManager());
477 celltable.setPageSize(GSS.VISIBLE_FILE_COUNT);
479 sinkEvents(Event.ONCONTEXTMENU);
480 sinkEvents(Event.ONMOUSEUP);
481 sinkEvents(Event.ONMOUSEDOWN);
482 sinkEvents(Event.ONCLICK);
483 sinkEvents(Event.ONKEYDOWN);
484 sinkEvents(Event.ONDBLCLICK);
485 GSS.preventIESelection();
488 public List<File> getSelectedFiles() {
489 return new ArrayList<File>(selectionModel.getSelectedSet());
492 private void initDragOperation(DragAndDropColumn<?, ?> column) {
493 // retrieve draggableOptions on the column
494 DraggableOptions draggableOptions = column.getDraggableOptions();
495 // use template to construct the helper. The content of the div will be set
497 draggableOptions.setHelper($(Templates.INSTANCE.outerHelper().asString()));
498 //draggableOptions.setZIndex(100);
499 // opacity of the helper
500 draggableOptions.setAppendTo("body");
501 //draggableOptions.setOpacity((float) 0.8);
502 draggableOptions.setContainment("document");
503 // cursor to use during the drag operation
504 draggableOptions.setCursor(Cursor.MOVE);
505 // set the revert option
506 draggableOptions.setRevert(RevertOption.ON_INVALID_DROP);
507 // prevents dragging when user click on the category drop-down list
508 draggableOptions.setCancel("select");
509 draggableOptions.setOnBeforeDragStart(new DragFunction() {
511 public void f(DragContext context) {
512 File value = context.getDraggableData();
513 if (!selectionModel.isSelected(value)) {
514 throw new StopDragException();
521 // public void onBrowserEvent(Event event) {
523 // if (files == null || files.size() == 0) {
524 // if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
525 // contextMenu = new FileContextMenu(images, false, true);
526 // contextMenu.show();
527 // event.preventDefault();
528 // event.cancelBubble(true);
532 // if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) {
533 // GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null);
534 // contextMenu = new FileContextMenu(images, false, false);
535 // contextMenu = contextMenu.onEvent(event);
536 // event.cancelBubble(true);
537 // event.preventDefault();
538 // } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
539 // contextMenu = new FileContextMenu(images, false, true);
540 // contextMenu = contextMenu.onEmptyEvent(event);
541 // event.cancelBubble(true);
542 // event.preventDefault();
543 // } else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
544 // if (getSelectedFiles().size() == 1) {
545 // GSS app = GSS.get();
546 // File file = getSelectedFiles().get(0);
547 // Window.open(file.getUri(), "_blank", "");
548 // event.preventDefault();
551 // super.onBrowserEvent(event);
555 * Update the display of the file list.
557 void update(boolean sort) {
558 int count = folderFileCount;
559 int max = startIndex + GSS.VISIBLE_FILE_COUNT;
565 folderTotalSize += f.getBytes();
567 if (folderFileCount == 0) {
568 showingStats = "no files";
569 } else if (folderFileCount < GSS.VISIBLE_FILE_COUNT) {
570 if (folderFileCount == 1)
571 showingStats = "1 file";
573 showingStats = folderFileCount + " files";
574 showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
576 showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
579 updateCurrentlyShowingStats();
584 * Return the proper icon based on the MIME type of the file.
589 private ImageResource getFileIcon(File file) {
590 String mimetype = file.getContentType();
591 boolean shared = file.isShared();
592 if (mimetype == null)
593 return shared ? images.documentShared() : images.document();
594 mimetype = mimetype.toLowerCase();
595 if (mimetype.startsWith("application/pdf"))
596 return shared ? images.pdfShared() : images.pdf();
597 else if (mimetype.endsWith("excel"))
598 return shared ? images.spreadsheetShared() : images.spreadsheet();
599 else if (mimetype.endsWith("msword"))
600 return shared ? images.wordprocessorShared() : images.wordprocessor();
601 else if (mimetype.endsWith("powerpoint"))
602 return shared ? images.presentationShared() : images.presentation();
603 else if (mimetype.startsWith("application/zip") ||
604 mimetype.startsWith("application/gzip") ||
605 mimetype.startsWith("application/x-gzip") ||
606 mimetype.startsWith("application/x-tar") ||
607 mimetype.startsWith("application/x-gtar"))
608 return shared ? images.zipShared() : images.zip();
609 else if (mimetype.startsWith("text/html"))
610 return shared ? images.htmlShared() : images.html();
611 else if (mimetype.startsWith("text/plain"))
612 return shared ? images.txtShared() : images.txt();
613 else if (mimetype.startsWith("image/"))
614 return shared ? images.imageShared() : images.image();
615 else if (mimetype.startsWith("video/"))
616 return shared ? images.videoShared() : images.video();
617 else if (mimetype.startsWith("audio/"))
618 return shared ? images.audioShared() : images.audio();
619 return shared ? images.documentShared() : images.document();
623 * Update status panel with currently showing file stats.
625 public void updateCurrentlyShowingStats() {
626 GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
630 * Fill the file cache with data.
632 public void setFiles(final List<File> _files) {
633 files = new ArrayList<File>();
634 for (File fres : _files)
635 if (!fres.isInTrash())
637 Collections.sort(files, new Comparator<File>() {
640 public int compare(File arg0, File arg1) {
641 return arg0.getName().compareTo(arg1.getName());
645 folderFileCount = files.size();
647 nameHeader.setSorted(true);
648 nameHeader.toggleReverseSort();
649 for (SortableHeader otherHeader : allHeaders) {
650 if (otherHeader != nameHeader) {
651 otherHeader.setSorted(false);
652 otherHeader.setReverseSort(true);
656 if(files.size() > GSS.VISIBLE_FILE_COUNT){
657 pagerBottom.setVisible(true);
658 pagerTop.setVisible(true);
661 pagerTop.setVisible(false);
662 pagerBottom.setVisible(false);
664 Folder selectedItem = treeView.getSelection();
666 provider.setList(files);
670 * Does the list contains the requested filename
675 public boolean contains(String fileName) {
676 for (int i = 0; i < files.size(); i++)
677 if (files.get(i).getName().equals(fileName))
682 public void clearSelectedRows() {
683 Iterator<File> it = selectionModel.getSelectedSet().iterator();
685 selectionModel.setSelected(it.next(),false);
693 public void selectAllRows() {
694 Iterator<File> it = provider.getList().iterator();
696 selectionModel.setSelected(it.next(),true);
703 private void sortFiles(final String sortingProperty, final boolean sortingType){
704 Collections.sort(files, new Comparator<File>() {
707 public int compare(File arg0, File arg1) {
708 AbstractImagePrototype descPrototype = AbstractImagePrototype.create(images.desc());
709 AbstractImagePrototype ascPrototype = AbstractImagePrototype.create(images.asc());
711 if (sortingProperty.equals("version")) {
712 return arg0.getVersion() - arg1.getVersion();
713 } else if (sortingProperty.equals("owner")) {
714 return arg0.getOwner().compareTo(arg1.getOwner());
715 } else if (sortingProperty.equals("date")) {
716 return arg0.getLastModified().compareTo(arg1.getLastModified());
717 } else if (sortingProperty.equals("size")) {
718 return (int) (arg0.getBytes() - arg1.getBytes());
719 } else if (sortingProperty.equals("name")) {
720 return arg0.getName().compareTo(arg1.getName());
721 } else if (sortingProperty.equals("path")) {
722 return arg0.getUri().compareTo(arg1.getUri());
724 return arg0.getName().compareTo(arg1.getName());
727 else if (sortingProperty.equals("version")) {
729 return arg1.getVersion() - arg0.getVersion();
730 } else if (sortingProperty.equals("owner")) {
732 return arg1.getOwner().compareTo(arg0.getOwner());
733 } else if (sortingProperty.equals("date")) {
735 return arg1.getLastModified().compareTo(arg0.getLastModified());
736 } else if (sortingProperty.equals("size")) {
737 return (int) (arg1.getBytes() - arg0.getBytes());
738 } else if (sortingProperty.equals("name")) {
740 return arg1.getName().compareTo(arg0.getName());
741 } else if (sortingProperty.equals("path")) {
743 return arg1.getUri().compareTo(arg0.getUri());
746 return arg1.getName().compareTo(arg0.getName());
753 final class FileValueUpdater implements ValueUpdater<String>{
754 private String property;
755 private SortableHeader header;
759 public FileValueUpdater(SortableHeader header,String property) {
760 this.property=property;
764 public void update(String value) {
765 header.setSorted(true);
766 header.toggleReverseSort();
768 for (SortableHeader otherHeader : allHeaders) {
769 if (otherHeader != header) {
770 otherHeader.setSorted(false);
771 otherHeader.setReverseSort(true);
774 celltable.redrawHeaders();
775 sortFiles(property, header.getReverseSort());
776 FileList.this.update(true);
782 * Shows the files in the cellTable
784 private void showCellTable(){
785 if(files.size()>GSS.VISIBLE_FILE_COUNT){
786 pagerBottom.setVisible(true);
787 pagerTop.setVisible(true);
790 pagerTop.setVisible(false);
791 pagerBottom.setVisible(false);
793 provider.setList(files);
797 //celltable.redraw();
798 celltable.redrawHeaders();