Merge branch 'master' into packaging
[pithos-web-client] / src / gr / grnet / pithos / web / client / FileList.java
1 /*
2  * Copyright 2011-2012 GRNET S.A. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or
5  * without modification, are permitted provided that the following
6  * conditions are met:
7  *
8  *   1. Redistributions of source code must retain the above
9  *      copyright notice, this list of conditions and the following
10  *      disclaimer.
11  *
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.
16  *
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.
29  *
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.
34  */
35
36 package gr.grnet.pithos.web.client;
37
38 import gr.grnet.pithos.web.client.foldertree.File;
39 import gr.grnet.pithos.web.client.foldertree.Folder;
40 import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
41
42 import java.util.ArrayList;
43 import java.util.Collections;
44 import java.util.Comparator;
45 import java.util.Iterator;
46 import java.util.List;
47
48 import com.google.gwt.cell.client.Cell.Context;
49 import com.google.gwt.cell.client.ImageResourceCell;
50 import com.google.gwt.cell.client.SafeHtmlCell;
51 import com.google.gwt.cell.client.TextCell;
52 import com.google.gwt.cell.client.ValueUpdater;
53 import com.google.gwt.core.client.GWT;
54 import com.google.gwt.event.dom.client.ContextMenuEvent;
55 import com.google.gwt.event.dom.client.ContextMenuHandler;
56 import com.google.gwt.http.client.URL;
57 import com.google.gwt.i18n.client.DateTimeFormat;
58 import com.google.gwt.resources.client.ImageResource;
59 import com.google.gwt.resources.client.ClientBundle.Source;
60 import com.google.gwt.resources.client.ImageResource.ImageOptions;
61 import com.google.gwt.resources.client.ImageResource.RepeatStyle;
62 import com.google.gwt.safehtml.client.SafeHtmlTemplates;
63 import com.google.gwt.safehtml.shared.SafeHtml;
64 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
65 import com.google.gwt.user.cellview.client.CellTable;
66 import com.google.gwt.user.cellview.client.Column;
67 import com.google.gwt.user.client.Command;
68 import com.google.gwt.user.client.DOM;
69 import com.google.gwt.user.client.Event;
70 import com.google.gwt.user.client.Window;
71 import com.google.gwt.user.client.ui.Composite;
72 import com.google.gwt.user.client.ui.VerticalPanel;
73 import com.google.gwt.view.client.ListDataProvider;
74 import com.google.gwt.view.client.MultiSelectionModel;
75 import com.google.gwt.view.client.ProvidesKey;
76 import com.google.gwt.view.client.SelectionChangeEvent;
77
78 /**
79  * A composite that displays the list of files in a particular folder.
80  */
81 public class FileList extends Composite {
82
83         ListDataProvider<File> provider = new ListDataProvider<File>();
84
85     /**
86        * The styles applied to the table.
87        */
88     interface TableStyle extends CellTable.Style {
89         String cellTableFirstColumnShared();
90     }
91
92         interface TableResources extends CellTable.Resources {
93             @Override
94                 @Source({CellTable.Style.DEFAULT_CSS, "PithosCellTable.css"})
95             TableStyle cellTableStyle();
96             
97             @Source("share.png")
98             @ImageOptions(repeatStyle = RepeatStyle.None)
99             ImageResource cellTableSharedIcon();
100         }
101         
102         static interface Templates extends SafeHtmlTemplates {
103             Templates INSTANCE = GWT.create(Templates.class);
104
105             @Template("<div id='dragHelper' style='border:1px solid black; background-color:#ffffff; color:black; width:150px;z-index:100'></div>")
106             SafeHtml outerHelper();
107
108         @Template("<span id='{0}'>{0}</span>")
109         public SafeHtml filenameSpan(String filename);
110
111         @Template("<a href='{0}' title='{1}' rel='lytebox[mnf]' onclick='myLytebox.start(this, false, false); return false;'>(view)</a>")
112         public SafeHtml viewLink(String link, String title);
113
114         @Template("<table><tr><td rowspan='3'>{0}</td><td style='font-size:95%;' id='{1}'>{1}</td></tr><tr><td>{2}</td></tr></table>")
115         public SafeHtml rendelContactCell(String imageHtml, String name, String fileSize);
116
117         @Template("<span id='{0}' class='{1}'>{2}</span>")
118         public SafeHtml spanWithIdAndClass(String id, String cssClass, String content);
119         }
120
121         protected final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
122
123         /**
124          * Specifies that the images available for this composite will be the ones
125          * available in FileContextMenu.
126          */
127         public interface Images extends FolderTreeView.Images {
128
129                 @Source("gr/grnet/pithos/resources/blank.gif")
130                 ImageResource blank();
131
132                 @Source("gr/grnet/pithos/resources/asc.png")
133                 ImageResource asc();
134
135                 @Source("gr/grnet/pithos/resources/desc.png")
136                 ImageResource desc();
137
138                 @Source("gr/grnet/pithos/resources/mimetypes/document_shared.png")
139                 ImageResource documentShared();
140
141                 @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst.png")
142                 ImageResource wordprocessor();
143
144                 @Source("gr/grnet/pithos/resources/mimetypes/log.png")
145                 ImageResource spreadsheet();
146
147                 @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr.png")
148                 ImageResource presentation();
149
150                 @Source("gr/grnet/pithos/resources/mimetypes/acroread.png")
151                 ImageResource pdf();
152
153                 @Source("gr/grnet/pithos/resources/mimetypes/image.png")
154                 ImageResource image();
155
156                 @Source("gr/grnet/pithos/resources/mimetypes/video2.png")
157                 ImageResource video();
158
159                 @Source("gr/grnet/pithos/resources/mimetypes/knotify.png")
160                 ImageResource audio();
161
162                 @Source("gr/grnet/pithos/resources/mimetypes/html.png")
163                 ImageResource html();
164
165                 @Source("gr/grnet/pithos/resources/mimetypes/txt.png")
166                 ImageResource txt();
167
168                 @Source("gr/grnet/pithos/resources/mimetypes/ark2.png")
169                 ImageResource zip();
170
171                 @Source("gr/grnet/pithos/resources/mimetypes/kcmfontinst_shared.png")
172                 ImageResource wordprocessorShared();
173
174                 @Source("gr/grnet/pithos/resources/mimetypes/log_shared.png")
175                 ImageResource spreadsheetShared();
176
177                 @Source("gr/grnet/pithos/resources/mimetypes/kpresenter_kpr_shared.png")
178                 ImageResource presentationShared();
179
180                 @Source("gr/grnet/pithos/resources/mimetypes/acroread_shared.png")
181                 ImageResource pdfShared();
182
183                 @Source("gr/grnet/pithos/resources/mimetypes/image_shared.png")
184                 ImageResource imageShared();
185
186                 @Source("gr/grnet/pithos/resources/mimetypes/video2_shared.png")
187                 ImageResource videoShared();
188
189                 @Source("gr/grnet/pithos/resources/mimetypes/knotify_shared.png")
190                 ImageResource audioShared();
191
192                 @Source("gr/grnet/pithos/resources/mimetypes/html_shared.png")
193                 ImageResource htmlShared();
194
195                 @Source("gr/grnet/pithos/resources/mimetypes/txt_shared.png")
196                 ImageResource txtShared();
197
198                 @Source("gr/grnet/pithos/resources/mimetypes/ark2_shared.png")
199                 ImageResource zipShared();
200
201         }
202         
203         /**
204          * The number of files in this folder.
205          */
206         int folderFileCount;
207
208         /**
209          * Total folder size
210          */
211         long folderTotalSize;
212
213         /**
214          * A cache of the files in the list.
215          */
216         private List<File> files;
217
218         /**
219          * The widget's image bundle.
220          */
221         protected final Images images;
222         
223         protected CellTable<File> celltable;
224
225         private final MultiSelectionModel<File> selectionModel;
226
227         Column<File, String> pathColumn;
228
229         protected final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
230
231         SortableHeader nameHeader;
232
233         SortableHeader pathHeader;
234
235     protected Pithos app;
236
237     /**
238          * Construct the file list widget. This entails setting up the widget
239          * layout, fetching the number of files in the current folder from the
240          * server and filling the local file cache of displayed files with data from
241          * the server, as well.
242          *
243          * @param _images
244          */
245         public FileList(final Pithos _app, Images _images) {
246         app = _app;
247                 images = _images;
248
249         final CellTable.Resources resources = GWT.create(TableResources.class);
250
251         ProvidesKey<File> keyProvider = new ProvidesKey<File>(){
252
253                         @Override
254                         public Object getKey(File item) {
255                                 return item.getUri();
256                         }
257                 };
258
259                 celltable = new CellTable<File>(10, resources, keyProvider);
260         celltable.setWidth("100%");
261         celltable.setStyleName("pithos-List");
262
263                 Column<File, ImageResource> status = new Column<File, ImageResource>(new ImageResourceCell() {
264                     @Override
265                 public boolean handlesSelection() {
266                     return false;
267                 }
268                 })
269         {
270                  @Override
271                  public ImageResource getValue(File entity) {
272                      return getFileIcon(entity);
273                  }
274
275                         @Override
276                         public String getCellStyleNames(Context context, File object) {
277                                 if (!object.getPermissions().isEmpty() && !object.isPublished())
278                                         return ((TableStyle) resources.cellTableStyle()).cellTableFirstColumnShared();
279                                 return super.getCellStyleNames(context, object);
280                         }
281             };
282             celltable.addColumn(status,"");
283
284         final Column<File,SafeHtml> nameColumn = new Column<File,SafeHtml>(new SafeHtmlCell()) {
285
286                         @Override
287                         public SafeHtml getValue(File object) {
288                                 SafeHtmlBuilder sb = new SafeHtmlBuilder();
289                                 sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
290                                 if (object.getContentType() != null && (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg"))) {
291                                 sb.appendHtmlConstant("&nbsp;")
292                       .append(Templates.INSTANCE.viewLink(app.getApiPath() + object.getOwner() + object.getUri(), object.getName()));
293                                 }
294                                 
295                                 return sb.toSafeHtml();
296                         }
297                         
298                 };
299         celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name", "name"));
300                 allHeaders.add(nameHeader);
301                 nameHeader.setUpdater(new FileValueUpdater(nameHeader));
302                 nameHeader.setSorted(true);
303                 nameHeader.setReverseSort(true);
304
305                 celltable.redrawHeaders();
306                 
307                 pathColumn = new Column<File, String>(new TextCell()) {
308
309                         @Override
310                         public String getValue(File f) {
311                                 String path;
312                                 if (!app.getSelectedTree().equals(app.mysharedTreeView)) {
313                                         path = f.getParent().getPrefix();
314                                         if (path.length() == 0)
315                                                 path = "/";
316                                 }
317                                 else {
318                                         path = f.getPath();
319                                         if (path.lastIndexOf("/") != -1)
320                                                 path = path.substring(0, path.lastIndexOf("/"));
321                                         else
322                                                 path = "/";
323                                 }
324                                 return path;
325                         }
326                 };
327                 pathHeader = new SortableHeader("Path", "path");
328                 celltable.addColumn(pathColumn, pathHeader);
329                 allHeaders.add(pathHeader);
330                 pathHeader.setUpdater(new FileValueUpdater(pathHeader));
331                 
332         Column<File,String> aColumn = new Column<File,String>(new TextCell()) {
333                         @Override
334                         public String getValue(File object) {
335                                 return object.getSizeAsString();
336                         }
337                 };
338         SortableHeader aheader = new SortableHeader("Size", "size");
339         celltable.addColumn(aColumn, aheader);
340                 allHeaders.add(aheader);
341                 aheader.setUpdater(new FileValueUpdater(aheader));
342
343         aColumn = new Column<File,String>(new TextCell()) {
344                         @Override
345                         public String getValue(File object) {
346                                 return object.getLastModified() != null ? formatter.format(object.getLastModified()) : "";
347                         }
348                 };
349         aheader = new SortableHeader("Last Modified", "date");
350                 celltable.addColumn(aColumn, aheader);
351                 allHeaders.add(aheader);
352                 aheader.setUpdater(new FileValueUpdater(aheader));
353                
354                 provider.addDataDisplay(celltable);
355
356                 VerticalPanel vp = new VerticalPanel();
357                 vp.setWidth("100%");
358                 vp.addStyleName("pithos-FileListContainer");
359
360         vp.add(celltable);
361
362                 vp.setCellWidth(celltable, "100%");
363         vp.addHandler(new ContextMenuHandler() {
364             @Override
365             public void onContextMenu(final ContextMenuEvent event) {
366                 final TreeView tree = app.getSelectedTree();
367                 if (tree != null) {
368                         final int x = event.getNativeEvent().getClientX();
369                         final int y = event.getNativeEvent().getClientY();
370                         final Folder selectedFolder = app.getSelection();
371                         app.scheduleFolderHeadCommand(selectedFolder, new Command() {
372                                                 
373                                                 @Override
374                                                 public void execute() {
375                                                         final List<File> selectedFiles = getSelectedFiles();
376                                                         Iterator<File> iter = selectedFiles.iterator();
377                                                         iterateFilesHeadCommand(iter, new Command() {
378                                                                 
379                                                                 @Override
380                                                                 public void execute() {
381                                                         FileContextMenu contextMenu = new FileContextMenu(app, images, tree, selectedFolder, selectedFiles);
382                                                         contextMenu.setPopupPosition(x, y);
383                                                         contextMenu.show();
384                                                                 }
385                                                         });
386                                                 }
387                                         });
388                 }
389             }
390         }, ContextMenuEvent.getType());
391                 initWidget(vp);
392
393                 selectionModel = new MultiSelectionModel<File>(keyProvider);
394                 selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
395                         
396                         @Override
397                         public void onSelectionChange(SelectionChangeEvent event) {
398                                 app.showRelevantToolbarButtons();
399                         }
400                 });
401                 
402                 celltable.setSelectionModel(selectionModel, PithosSelectionEventManager.<File> createDefaultManager());
403 //              celltable.setPageSize(Pithos.VISIBLE_FILE_COUNT);
404                 
405                 sinkEvents(Event.ONCONTEXTMENU);
406 //              sinkEvents(Event.ONMOUSEUP);
407 //              sinkEvents(Event.ONMOUSEDOWN);
408 //              sinkEvents(Event.ONCLICK);
409 //              sinkEvents(Event.ONKEYDOWN);
410                 sinkEvents(Event.ONDBLCLICK);
411                 Pithos.preventIESelection();
412         }
413
414         public List<File> getSelectedFiles() {
415         return new ArrayList<File>(selectionModel.getSelectedSet());
416         }
417         
418         @Override
419         public void onBrowserEvent(Event event) {
420
421 //              if (files == null || files.size() == 0) {
422 //                      if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
423 //                              contextMenu = new FileContextMenu(images, false, true);
424 //                contextMenu.show();
425 //                              event.preventDefault();
426 //                              event.cancelBubble(true);
427 //                      }
428 //                      return;
429 //              }
430 //              if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) {
431 //                      GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null);
432 //                      contextMenu =  new FileContextMenu(images, false, false);
433 //                      contextMenu = contextMenu.onEvent(event);
434 //                      event.cancelBubble(true);
435 //                      event.preventDefault();
436 //              } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
437 //                      contextMenu = new FileContextMenu(images, false, true);
438 //                      contextMenu = contextMenu.onEmptyEvent(event);
439 //                      event.cancelBubble(true);
440 //                      event.preventDefault();
441 //              } else 
442                 if (DOM.eventGetType(event) == Event.ONDBLCLICK)
443                         if (getSelectedFiles().size() == 1) {
444                                 File file = getSelectedFiles().get(0);
445                                 Window.open(app.getApiPath() + file.getOwner() + file.getUri(), "_blank", "");
446                                 event.preventDefault();
447                                 return;
448                         }
449                 super.onBrowserEvent(event);
450         }
451
452         /**
453          * Update the display of the file list.
454          */
455         void update() {
456                 showCellTable();
457         }
458
459         /**
460          * Return the proper icon based on the MIME type of the file.
461          *
462          * @param file
463          * @return the icon
464          */
465         protected ImageResource getFileIcon(File file) {
466                 String mimetype = file.getContentType();
467                 boolean published = file.isPublished();
468                 if (mimetype == null)
469                         return published ? images.documentShared() : images.document();
470                 mimetype = mimetype.toLowerCase();
471                 if (mimetype.startsWith("application/pdf"))
472                         return published ? images.pdfShared() : images.pdf();
473                 else if (mimetype.endsWith("excel"))
474                         return published ? images.spreadsheetShared() : images.spreadsheet();
475                 else if (mimetype.endsWith("msword"))
476                         return published ? images.wordprocessorShared() : images.wordprocessor();
477                 else if (mimetype.endsWith("powerpoint"))
478                         return published ? images.presentationShared() : images.presentation();
479                 else if (mimetype.startsWith("application/zip") ||
480                                         mimetype.startsWith("application/gzip") ||
481                                         mimetype.startsWith("application/x-gzip") ||
482                                         mimetype.startsWith("application/x-tar") ||
483                                         mimetype.startsWith("application/x-gtar"))
484                         return published ? images.zipShared() : images.zip();
485                 else if (mimetype.startsWith("text/html"))
486                         return published ? images.htmlShared() : images.html();
487                 else if (mimetype.startsWith("text/plain"))
488                         return published ? images.txtShared() : images.txt();
489                 else if (mimetype.startsWith("image/"))
490                         return published ? images.imageShared() : images.image();
491                 else if (mimetype.startsWith("video/"))
492                         return published ? images.videoShared() : images.video();
493                 else if (mimetype.startsWith("audio/"))
494                         return published ? images.audioShared() : images.audio();
495                 return published ? images.documentShared() : images.document();
496         }
497
498         /**
499          * Fill the file cache with data.
500          */
501         public void setFiles(final List<File> _files) {
502                 if (!app.getSelectedTree().equals(app.mysharedTreeView)) {
503                         if (celltable.getColumnIndex(pathColumn) != -1)
504                                 celltable.removeColumn(pathColumn);
505                 }
506                 else {
507                         if (celltable.getColumnIndex(pathColumn) == -1)
508                                 celltable.insertColumn(2, pathColumn, pathHeader);
509                 }
510                 files = new ArrayList<File>();
511         for (File fres : _files) {
512                         files.add(fres);
513         }
514         
515                 folderFileCount = files.size();
516                 
517                 for (SortableHeader header : allHeaders) {
518                         if (header.isSorted())
519                                 sortFiles(header.getProperty(), header.getReverseSort());
520                 }
521                 
522                 List<File> previousSelection = getSelectedFiles(); //Keep the previous selection
523
524                 provider.getList().clear();
525         provider.setList(files);
526         selectionModel.clear();
527         for (File f : files) {
528                 if (previousSelection.contains(f))
529                         selectionModel.setSelected(f, true);
530         }
531         
532         app.showFolderStatistics(folderFileCount);
533         celltable.setPageSize(folderFileCount);
534         }
535
536         /**
537          * Does the list contains the requested filename
538          *
539          * @param fileName
540          * @return true/false
541          */
542         public boolean contains(String fileName) {
543                 for (int i = 0; i < files.size(); i++)
544                         if (files.get(i).getName().equals(fileName))
545                                 return true;
546                 return false;
547         }
548
549         public void clearSelectedRows() {
550                 Iterator<File> it = selectionModel.getSelectedSet().iterator();
551                 while(it.hasNext()){
552                         selectionModel.setSelected(it.next(),false);
553                 }
554         }
555         
556         /**
557          *
558          */
559         public void selectAllRows() {
560                 Iterator<File> it = provider.getList().iterator();
561                 while(it.hasNext()){
562                         selectionModel.setSelected(it.next(),true);
563                 }
564         }
565
566         protected void sortFiles(final String sortingProperty, final boolean sortingType){
567                 Collections.sort(files, new Comparator<File>() {
568
569             @Override
570             public int compare(File arg0, File arg1) {
571                     if (sortingType){
572                             if (sortingProperty.equals("version")) {
573                                     return arg0.getVersion() - arg1.getVersion();
574                             } else if (sortingProperty.equals("owner")) {
575                                     return arg0.getOwner().compareTo(arg1.getOwner());
576                             } else if (sortingProperty.equals("date")) {
577                                         if (arg0.getLastModified() != null && arg1.getLastModified() != null)
578                                                 return arg0.getLastModified().compareTo(arg1.getLastModified());
579                                         return 0;
580                             } else if (sortingProperty.equals("size")) {
581                                     return (int) (arg0.getBytes() - arg1.getBytes());
582                             } else if (sortingProperty.equals("name")) {
583                                     return arg0.getName().compareTo(arg1.getName());
584                             } else if (sortingProperty.equals("path")) {
585                                     return arg0.getUri().compareTo(arg1.getUri());
586                             } else {
587                                     return arg0.getName().compareTo(arg1.getName());
588                             }
589                     }
590                     else if (sortingProperty.equals("version")) {
591                             
592                             return arg1.getVersion() - arg0.getVersion();
593                     } else if (sortingProperty.equals("owner")) {
594                             
595                             return arg1.getOwner().compareTo(arg0.getOwner());
596                     } else if (sortingProperty.equals("date")) {
597                             
598                             return arg1.getLastModified().compareTo(arg0.getLastModified());
599                     } else if (sortingProperty.equals("size")) {
600                             return (int) (arg1.getBytes() - arg0.getBytes());
601                     } else if (sortingProperty.equals("name")) {
602                             
603                             return arg1.getName().compareTo(arg0.getName());
604                     } else if (sortingProperty.equals("path")) {
605                             
606                             return arg1.getUri().compareTo(arg0.getUri());
607                     } else {
608                             
609                             return arg1.getName().compareTo(arg0.getName());
610                     }
611             }
612
613                 });
614         }
615         
616         final class FileValueUpdater implements ValueUpdater<String>{
617                 private SortableHeader header;
618                 /**
619                  * 
620                  */
621                 public FileValueUpdater(SortableHeader header) {
622                         this.header=header;
623                 }
624                 @Override
625                 public void update(String value) {
626                         header.setSorted(true);
627                         header.toggleReverseSort();
628
629                 for (SortableHeader otherHeader : allHeaders) {
630                   if (otherHeader != header) {
631                     otherHeader.setSorted(false);
632                     otherHeader.setReverseSort(true);
633                   }
634                 }
635                 celltable.redrawHeaders();
636                 sortFiles(header.getProperty(), header.getReverseSort());
637                 FileList.this.update();                 
638                 }
639                 
640         }
641
642         /**
643          * Shows the files in the cellTable 
644      */
645         private void showCellTable(){
646                 provider.setList(files);
647                 
648                 provider.refresh();
649                 
650                 //celltable.redraw();
651                 celltable.redrawHeaders();              
652         }
653         
654         void iterateFilesHeadCommand(final Iterator<File> iter, final Command callback) {
655                 if (iter.hasNext()) {
656                         File f = iter.next();
657                         app.scheduleFileHeadCommand(f, new Command() {
658                                 
659                                 @Override
660                                 public void execute() {
661                                         iterateFilesHeadCommand(iter, callback);
662                                 }
663                         });
664                 }
665                 else if (callback != null)
666                         callback.execute();
667         }
668 }