Revision e8288e3f

b/src/gr/grnet/pithos/web/client/FileContextMenu.java
43 43
import gr.grnet.pithos.web.client.commands.ToTrashCommand;
44 44
import gr.grnet.pithos.web.client.commands.UploadFileCommand;
45 45
import gr.grnet.pithos.web.client.foldertree.File;
46
import gr.grnet.pithos.web.client.foldertree.FileFolderResource;
46 47
import gr.grnet.pithos.web.client.foldertree.Folder;
47 48

  
48 49
import java.util.List;
49 50

  
50
import com.google.gwt.http.client.URL;
51 51
import com.google.gwt.resources.client.ClientBundle;
52 52
import com.google.gwt.resources.client.ImageResource;
53 53
import com.google.gwt.user.client.Command;
......
184 184
	 *
185 185
	 * @param newImages the image bundle passed on by the parent object
186 186
	 */
187
	public FileContextMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder selectedFolder, final List<File> selectedFiles) {
187
	public FileContextMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder selectedFolder, final List<FileFolderResource> selectedFiles) {
188 188
		// The popup's constructor's argument is a boolean specifying that it
189 189
		// auto-close itself when the user clicks outside of it.
190 190
		super(true);
......
198 198
        	canWrite = selectedFolder.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]);
199 199
		}
200 200
        else {
201
        	for (File f : selectedFiles) {
202
        		permissions = f.getPermissions().get(app.getUsername());
203
        		canWrite &= (f.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]));
201
        	for (FileFolderResource res : selectedFiles) {
202
        		if (res instanceof File) {
203
        			File f = (File) res;
204
	        		permissions = f.getPermissions().get(app.getUsername());
205
	        		canWrite &= (f.getOwner().equals(app.getUsername()) || (permissions!= null && permissions[1] != null && permissions[1]));
206
        		}
204 207
        	}
205 208
        }
206 209
        boolean isFolderTreeSelected = selectedTree.equals(app.getFolderTreeView());
......
253 256
			
254 257
			@Override
255 258
			public void execute() {
256
				for (File f : selectedFiles)
257
					Window.open(app.getApiPath() + f.getOwner() + f.getUri(), "_blank", "");
259
				for (FileFolderResource res : selectedFiles)
260
					if (res instanceof File) {
261
						File f = (File) res;
262
						Window.open(app.getApiPath() + f.getOwner() + f.getUri(), "_blank", "");
263
					}
258 264
			}
259 265
		}));
260 266

  
b/src/gr/grnet/pithos/web/client/FileList.java
36 36
package gr.grnet.pithos.web.client;
37 37

  
38 38
import gr.grnet.pithos.web.client.foldertree.File;
39
import gr.grnet.pithos.web.client.foldertree.FileFolderResource;
39 40
import gr.grnet.pithos.web.client.foldertree.Folder;
40 41
import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
42
import gr.grnet.pithos.web.client.foldertree.Resource;
41 43

  
42 44
import java.util.ArrayList;
43 45
import java.util.Collections;
......
54 56
import com.google.gwt.core.client.GWT;
55 57
import com.google.gwt.event.dom.client.ContextMenuEvent;
56 58
import com.google.gwt.event.dom.client.ContextMenuHandler;
57
import com.google.gwt.http.client.URL;
58 59
import com.google.gwt.i18n.client.DateTimeFormat;
59 60
import com.google.gwt.resources.client.ImageResource;
60
import com.google.gwt.resources.client.ClientBundle.Source;
61 61
import com.google.gwt.resources.client.ImageResource.ImageOptions;
62 62
import com.google.gwt.resources.client.ImageResource.RepeatStyle;
63 63
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
......
81 81
 */
82 82
public class FileList extends Composite {
83 83

  
84
	ListDataProvider<File> provider = new ListDataProvider<File>();
84
	ListDataProvider<FileFolderResource> provider = new ListDataProvider<FileFolderResource>();
85 85

  
86 86
    /**
87 87
       * The styles applied to the table.
......
198 198

  
199 199
		@Source("gr/grnet/pithos/resources/mimetypes/ark2_shared.png")
200 200
		ImageResource zipShared();
201

  
202 201
	}
203 202
	
204 203
	/**
......
214 213
	/**
215 214
	 * A cache of the files in the list.
216 215
	 */
217
	private List<File> files;
216
	private List<FileFolderResource> files;
218 217

  
219 218
	/**
220 219
	 * The widget's image bundle.
221 220
	 */
222 221
	protected final Images images;
223 222
	
224
	protected CellTable<File> celltable;
223
	protected CellTable<FileFolderResource> celltable;
225 224

  
226
	private final MultiSelectionModel<File> selectionModel;
225
	private final MultiSelectionModel<FileFolderResource> selectionModel;
227 226

  
228
	Column<File, String> pathColumn;
227
	Column<FileFolderResource, String> pathColumn;
229 228

  
230 229
	protected final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
231 230

  
......
249 248

  
250 249
        final CellTable.Resources resources = GWT.create(TableResources.class);
251 250

  
252
        ProvidesKey<File> keyProvider = new ProvidesKey<File>(){
251
        ProvidesKey<FileFolderResource> keyProvider = new ProvidesKey<FileFolderResource>(){
253 252

  
254 253
			@Override
255
			public Object getKey(File item) {
254
			public Object getKey(FileFolderResource item) {
256 255
				return item.getUri();
257 256
			}
258 257
		};
259 258

  
260
		celltable = new CellTable<File>(10, resources, keyProvider);
259
		celltable = new CellTable<FileFolderResource>(10, resources, keyProvider);
261 260
        celltable.setWidth("100%");
262 261
        celltable.setStyleName("pithos-List");
263 262

  
264
		Column<File, ImageResource> status = new Column<File, ImageResource>(new ImageResourceCell() {
265
		    @Override
266
	        public boolean handlesSelection() {
267
	            return false;
268
	        }
269
		})
270
        {
271
	         @Override
272
	         public ImageResource getValue(File entity) {
273
	             return getFileIcon(entity);
274
	         }
263
		Column<FileFolderResource, ImageResource> status = new Column<FileFolderResource, ImageResource>(
264
				new ImageResourceCell() {
265
					@Override
266
					public boolean handlesSelection() {
267
						return false;
268
					}
269
				}) {
270
			@Override
271
			public ImageResource getValue(FileFolderResource entity) {
272
				return getFileIcon(entity);
273
			}
275 274

  
276 275
			@Override
277
			public String getCellStyleNames(Context context, File object) {
278
				if (!object.getPermissions().isEmpty() && !object.isPublished())
279
					return ((TableStyle) resources.cellTableStyle()).cellTableFirstColumnShared();
276
			public String getCellStyleNames(Context context, FileFolderResource object) {
277
				if (object instanceof File) {
278
					File f = (File) object;
279
					if (!f.getPermissions().isEmpty() && !f.isPublished())
280
						return ((TableStyle) resources.cellTableStyle())
281
								.cellTableFirstColumnShared();
282
				}
280 283
				return super.getCellStyleNames(context, object);
281 284
			}
282
	    };
285
		};
283 286
	    celltable.addColumn(status,"");
284 287

  
285
        final Column<File,SafeHtml> nameColumn = new Column<File,SafeHtml>(new SafeHtmlCell()) {
288
        final Column<FileFolderResource,SafeHtml> nameColumn = new Column<FileFolderResource,SafeHtml>(new SafeHtmlCell()) {
286 289

  
287 290
			@Override
288
			public SafeHtml getValue(File object) {
291
			public SafeHtml getValue(FileFolderResource object) {
289 292
				SafeHtmlBuilder sb = new SafeHtmlBuilder();
290 293
				sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
291 294
				if (object.getContentType() != null && (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg"))) {
......
305 308

  
306 309
		celltable.redrawHeaders();
307 310
		
308
		pathColumn = new Column<File, String>(new TextCell()) {
311
		pathColumn = new Column<FileFolderResource, String>(new TextCell()) {
309 312

  
310 313
			@Override
311
			public String getValue(File f) {
314
			public String getValue(FileFolderResource f) {
312 315
				String path;
313 316
				if (!app.getSelectedTree().equals(app.mysharedTreeView)) {
314 317
					path = f.getParent().getPrefix();
......
330 333
		allHeaders.add(pathHeader);
331 334
		pathHeader.setUpdater(new FileValueUpdater(pathHeader));
332 335
		
333
        Column<File,String> aColumn = new Column<File,String>(new TextCell()) {
336
        Column<FileFolderResource,String> aColumn = new Column<FileFolderResource,String>(new TextCell()) {
334 337
			@Override
335
			public String getValue(File object) {
338
			public String getValue(FileFolderResource object) {
336 339
				return object.getSizeAsString();
337 340
			}
338 341
		};
......
341 344
		allHeaders.add(aheader);
342 345
		aheader.setUpdater(new FileValueUpdater(aheader));
343 346

  
344
        aColumn = new Column<File,String>(new TextCell()) {
347
        aColumn = new Column<FileFolderResource,String>(new TextCell()) {
345 348
			@Override
346
			public String getValue(File object) {
349
			public String getValue(FileFolderResource object) {
347 350
				return object.getLastModified() != null ? formatter.format(object.getLastModified()) : "";
348 351
			}
349 352
		};
......
373 376
						
374 377
						@Override
375 378
						public void execute() {
376
							final List<File> selectedFiles = getSelectedFiles();
377
							Iterator<File> iter = selectedFiles.iterator();
379
							final List<FileFolderResource> selectedFiles = getSelectedFiles();
380
							Iterator<FileFolderResource> iter = selectedFiles.iterator();
378 381
							iterateFilesHeadCommand(iter, new Command() {
379 382
								
380 383
								@Override
......
391 394
        }, ContextMenuEvent.getType());
392 395
		initWidget(vp);
393 396

  
394
		selectionModel = new MultiSelectionModel<File>(keyProvider);
397
		selectionModel = new MultiSelectionModel<FileFolderResource>(keyProvider);
395 398
		selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
396 399
			
397 400
			@Override
......
400 403
			}
401 404
		});
402 405
		
403
		celltable.setSelectionModel(selectionModel, PithosSelectionEventManager.<File> createDefaultManager());
406
		celltable.setSelectionModel(selectionModel, PithosSelectionEventManager.<FileFolderResource> createDefaultManager());
404 407
		
405 408
		sinkEvents(Event.ONCONTEXTMENU);
406 409
		sinkEvents(Event.ONDBLCLICK);
407 410
		Pithos.preventIESelection();
408 411
	}
409 412

  
410
	public List<File> getSelectedFiles() {
411
        return new ArrayList<File>(selectionModel.getSelectedSet());
413
	public List<FileFolderResource> getSelectedFiles() {
414
        return new ArrayList<FileFolderResource>(selectionModel.getSelectedSet());
412 415
	}
413 416
	
414 417
	@Override
......
416 419

  
417 420
		if (DOM.eventGetType(event) == Event.ONDBLCLICK)
418 421
			if (getSelectedFiles().size() == 1) {
419
				File file = getSelectedFiles().get(0);
420
				Window.open(app.getApiPath() + file.getOwner() + file.getUri(), "_blank", "");
421
				event.preventDefault();
422
				FileFolderResource res = getSelectedFiles().get(0);
423
				if (res instanceof File) {
424
					File file = (File) res;
425
					Window.open(app.getApiPath() + file.getOwner() + file.getUri(), "_blank", "");
426
					event.preventDefault();
427
				}
422 428
				return;
423 429
			}
424 430
		super.onBrowserEvent(event);
......
434 440
	/**
435 441
	 * Return the proper icon based on the MIME type of the file.
436 442
	 *
437
	 * @param file
443
	 * @param res
438 444
	 * @return the icon
439 445
	 */
440
	protected ImageResource getFileIcon(File file) {
446
	protected ImageResource getFileIcon(Resource res) {
447
		if (res instanceof Folder) {
448
			Folder f = (Folder) res;
449
			
450
			return f.isShared() ? images.sharedFolder() : images.folderYellow();
451
		}
452
		File file = (File) res;
441 453
		String mimetype = file.getContentType();
442 454
		boolean published = file.isPublished();
443 455
		if (mimetype == null)
......
473 485
	/**
474 486
	 * Fill the file cache with data.
475 487
	 */
476
	public void setFiles(final List<File> _files) {
488
	public void setFiles(final List<FileFolderResource> _files) {
477 489
		if (!app.getSelectedTree().equals(app.mysharedTreeView)) {
478 490
			if (celltable.getColumnIndex(pathColumn) != -1)
479 491
				celltable.removeColumn(pathColumn);
......
482 494
			if (celltable.getColumnIndex(pathColumn) == -1)
483 495
				celltable.insertColumn(2, pathColumn, pathHeader);
484 496
		}
485
		files = new ArrayList<File>();
486
    	for (File fres : _files) {
497
		files = new ArrayList<FileFolderResource>();
498
    	for (FileFolderResource fres : _files) {
487 499
			files.add(fres);
488 500
    	}
489 501
    	
......
494 506
				sortFiles(header.getProperty(), header.getReverseSort());
495 507
		}
496 508
		
497
		List<File> previousSelection = getSelectedFiles(); //Keep the previous selection
509
		List<FileFolderResource> previousSelection = getSelectedFiles(); //Keep the previous selection
498 510

  
499 511
		provider.getList().clear();
500 512
        provider.setList(files);
501 513
        selectionModel.clear();
502
    	for (File f : files) {
514
    	for (FileFolderResource f : files) {
503 515
    		if (previousSelection.contains(f))
504 516
    			selectionModel.setSelected(f, true);
505 517
    	}
......
522 534
	}
523 535

  
524 536
	public void clearSelectedRows() {
525
		Iterator<File> it = selectionModel.getSelectedSet().iterator();
537
		Iterator<FileFolderResource> it = selectionModel.getSelectedSet().iterator();
526 538
		while(it.hasNext()){
527 539
			selectionModel.setSelected(it.next(),false);
528 540
		}
......
532 544
	 *
533 545
	 */
534 546
	public void selectAllRows() {
535
		Iterator<File> it = provider.getList().iterator();
547
		Iterator<FileFolderResource> it = provider.getList().iterator();
536 548
		while(it.hasNext()){
537 549
			selectionModel.setSelected(it.next(),true);
538 550
		}
539 551
	}
540 552

  
541
	protected void sortFiles(final String sortingProperty, final boolean sortingType){
542
		Collections.sort(files, new Comparator<File>() {
553
	protected void sortFiles(final String sortingProperty,
554
			final boolean sortingType) {
555
		Collections.sort(files, new Comparator<FileFolderResource>() {
543 556

  
544
            @Override
545
            public int compare(File arg0, File arg1) {
546
                    if (sortingType){
547
                            if (sortingProperty.equals("version")) {
548
                                    return arg0.getVersion() - arg1.getVersion();
549
                            } else if (sortingProperty.equals("owner")) {
550
                                    return arg0.getOwner().compareTo(arg1.getOwner());
551
                            } else if (sortingProperty.equals("date")) {
552
                            		if (arg0.getLastModified() != null && arg1.getLastModified() != null)
553
                            			return arg0.getLastModified().compareTo(arg1.getLastModified());
554
                            		return 0;
555
                            } else if (sortingProperty.equals("size")) {
556
                                    return (int) (arg0.getBytes() - arg1.getBytes());
557
                            } else if (sortingProperty.equals("name")) {
558
                                    return arg0.getName().compareTo(arg1.getName());
559
                            } else if (sortingProperty.equals("path")) {
560
                                    return arg0.getUri().compareTo(arg1.getUri());
561
                            } else {
562
                                    return arg0.getName().compareTo(arg1.getName());
563
                            }
564
                    }
565
                    else if (sortingProperty.equals("version")) {
566
                            
567
                            return arg1.getVersion() - arg0.getVersion();
568
                    } else if (sortingProperty.equals("owner")) {
569
                            
570
                            return arg1.getOwner().compareTo(arg0.getOwner());
571
                    } else if (sortingProperty.equals("date")) {
572
                            
573
                            return arg1.getLastModified().compareTo(arg0.getLastModified());
574
                    } else if (sortingProperty.equals("size")) {
575
                            return (int) (arg1.getBytes() - arg0.getBytes());
576
                    } else if (sortingProperty.equals("name")) {
577
                            
578
                            return arg1.getName().compareTo(arg0.getName());
579
                    } else if (sortingProperty.equals("path")) {
580
                            
581
                            return arg1.getUri().compareTo(arg0.getUri());
582
                    } else {
583
                            
584
                            return arg1.getName().compareTo(arg0.getName());
585
                    }
586
            }
557
			@Override
558
			public int compare(FileFolderResource arg0, FileFolderResource arg1) {
559
				if (arg0 instanceof Folder && arg1 instanceof File)
560
					return -1;
561
				if (sortingType) {
562
					if (arg0 instanceof Folder && arg1 instanceof File)
563
						return -1;
564
					else if (arg0 instanceof File && arg1 instanceof Folder)
565
						return 1;
566
					else if (arg0 instanceof Folder && arg1 instanceof Folder)
567
						return arg0.getName().compareTo(arg1.getName());
568
					if (sortingProperty.equals("date")) {
569
						if (arg0.getLastModified() != null
570
								&& arg1.getLastModified() != null)
571
							return arg0.getLastModified().compareTo(
572
									arg1.getLastModified());
573
						return 0;
574
					} else if (sortingProperty.equals("size")) {
575
						return (int) (arg0.getBytes() - arg1.getBytes());
576
					} else if (sortingProperty.equals("name")) {
577
						return arg0.getName().compareTo(arg1.getName());
578
					} else if (sortingProperty.equals("path")) {
579
						return arg0.getUri().compareTo(arg1.getUri());
580
					} else {
581
						return arg0.getName().compareTo(arg1.getName());
582
					}
583
				} else if (arg0 instanceof Folder && arg1 instanceof File)
584
					return -1;
585
				else if (arg0 instanceof File && arg1 instanceof Folder)
586
					return 1;
587
				else if (arg0 instanceof Folder && arg1 instanceof Folder)
588
					return arg1.getName().compareTo(arg0.getName());
589

  
590
				else if (sortingProperty.equals("date")) {
591

  
592
					return arg1.getLastModified().compareTo(
593
							arg0.getLastModified());
594
				} else if (sortingProperty.equals("size")) {
595
					return (int) (arg1.getBytes() - arg0.getBytes());
596
				} else if (sortingProperty.equals("name")) {
597

  
598
					return arg1.getName().compareTo(arg0.getName());
599
				} else if (sortingProperty.equals("path")) {
600

  
601
					return arg1.getUri().compareTo(arg0.getUri());
602
				} else {
603

  
604
					return arg1.getName().compareTo(arg0.getName());
605
				}
606
			}
587 607

  
588 608
		});
589 609
	}
......
626 646
		celltable.redrawHeaders();		
627 647
	}
628 648
	
629
	void iterateFilesHeadCommand(final Iterator<File> iter, final Command callback) {
649
	void iterateFilesHeadCommand(final Iterator<FileFolderResource> iter, final Command callback) {
630 650
		if (iter.hasNext()) {
631
			File f = iter.next();
632
			app.scheduleFileHeadCommand(f, new Command() {
633
				
634
				@Override
635
				public void execute() {
636
					iterateFilesHeadCommand(iter, callback);
637
				}
638
			});
651
			FileFolderResource res = iter.next();
652
			if (res instanceof File) {
653
				File f = (File) res;
654
				app.scheduleFileHeadCommand(f, new Command() {
655
					
656
					@Override
657
					public void execute() {
658
						iterateFilesHeadCommand(iter, callback);
659
					}
660
				});
661
			}
639 662
		}
640 663
		else if (callback != null)
641 664
			callback.execute();
642 665
	}
643 666

  
644 667
	public void selectByUrl(List<String> selectedUrls) {
645
		Set<File> previous = selectionModel.getSelectedSet();
646
		for (File f : previous)
647
			selectionModel.setSelected(f, false);
668
		Set<FileFolderResource> previous = selectionModel.getSelectedSet();
669
		for (FileFolderResource res : previous)
670
			selectionModel.setSelected(res, false);
648 671
		
649 672
		int i = 0;
650 673
		boolean scrolled = false;
651
		for (File f : files) {
652
			if (selectedUrls.contains(app.getApiPath() + f.getOwner() + f.getUri())) {
653
				selectionModel.setSelected(f, true);
654
				if (!scrolled) {
655
					celltable.getRowElement(i).getCells().getItem(0).scrollIntoView();
656
					scrolled = true;
674
		for (FileFolderResource res : files) {
675
			if (res instanceof File) {
676
				File f = (File) res;
677
				if (selectedUrls.contains(app.getApiPath() + f.getOwner() + f.getUri())) {
678
					selectionModel.setSelected(f, true);
679
					if (!scrolled) {
680
						celltable.getRowElement(i).getCells().getItem(0).scrollIntoView();
681
						scrolled = true;
682
					}
657 683
				}
658 684
			}
659 685
			i++;
b/src/gr/grnet/pithos/web/client/Pithos.java
37 37
import gr.grnet.pithos.web.client.commands.UploadFileCommand;
38 38
import gr.grnet.pithos.web.client.foldertree.AccountResource;
39 39
import gr.grnet.pithos.web.client.foldertree.File;
40
import gr.grnet.pithos.web.client.foldertree.FileFolderResource;
40 41
import gr.grnet.pithos.web.client.foldertree.Folder;
41 42
import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
42 43
import gr.grnet.pithos.web.client.foldertree.FolderTreeViewModel;
......
603 604

  
604 605
    public void showFiles(final Folder f) {
605 606
        Set<File> files = f.getFiles();
606
        showFiles(files);
607
        List<FileFolderResource> list = new ArrayList<FileFolderResource>(files);
608
        list.addAll(f.getSubfolders());
609
        showFiles(list);
607 610
    }
608 611

  
609
    public void showFiles(Set<File> files) {
610
        fileList.setFiles(new ArrayList<File>(files));
612
    public void showFiles(List<FileFolderResource> files) {
613
        fileList.setFiles(new ArrayList<FileFolderResource>(files));
611 614
    }
612 615

  
613 616
    /**
b/src/gr/grnet/pithos/web/client/ToolsMenu.java
47 47
import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
48 48
import gr.grnet.pithos.web.client.commands.ToTrashCommand;
49 49
import gr.grnet.pithos.web.client.foldertree.File;
50
import gr.grnet.pithos.web.client.foldertree.FileFolderResource;
50 51
import gr.grnet.pithos.web.client.foldertree.Folder;
51 52
import gr.grnet.pithos.web.client.grouptree.Group;
52 53
import gr.grnet.pithos.web.client.grouptree.GroupTreeView;
......
54 55

  
55 56
import java.util.List;
56 57

  
57
import com.google.gwt.http.client.URL;
58 58
import com.google.gwt.user.client.Command;
59 59
import com.google.gwt.user.client.Window;
60 60
import com.google.gwt.user.client.ui.AbstractImagePrototype;
......
88 88
	 *
89 89
	 * @param newImages the image bundle passed on by the parent object
90 90
	 */
91
	public ToolsMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder folder, final List<File> files) {
91
	public ToolsMenu(final Pithos app, Images newImages, TreeView selectedTree, Folder folder, final List<FileFolderResource> files) {
92 92
		// The popup's constructor's argument is a boolean specifying that it
93 93
		// auto-close itself when the user clicks outside of it.
94 94
		super(true);
......
195 195
							
196 196
							@Override
197 197
							public void execute() {
198
					        	for (File f: files)
199
					        		Window.open(app.getApiPath() + f.getOwner() + f.getUri(), "_blank", "");
198
					        	for (FileFolderResource res: files) {
199
					        		if (res instanceof File) {
200
					        			File f = (File) res;
201
					        			Window.open(app.getApiPath() + f.getOwner() + f.getUri(), "_blank", "");
202
					        		}
203
					        	}
200 204
							}
201 205
						}));
202 206
			        	empty = false;
b/src/gr/grnet/pithos/web/client/foldertree/File.java
48 48
import com.google.gwt.json.client.JSONObject;
49 49
import com.google.gwt.json.client.JSONValue;
50 50

  
51
public class File extends Resource {
51
public class File extends FileFolderResource {
52 52
    private String name;
53 53

  
54 54
    private String hash;
b/src/gr/grnet/pithos/web/client/foldertree/FileFolderResource.java
1
package gr.grnet.pithos.web.client.foldertree;
2

  
3
import java.util.Date;
4

  
5
public abstract class FileFolderResource extends Resource {
6

  
7
	@Override
8
	public Date getLastModified() {
9
		// TODO Auto-generated method stub
10
		return null;
11
	}
12

  
13
    public abstract String getUri();
14

  
15
    public abstract String getName();
16
    
17
    public abstract String getContentType();
18

  
19
    public abstract String getOwner();
20

  
21
    public abstract Folder getParent();
22

  
23
    public abstract String getPath();
24
    
25
    public abstract String getSizeAsString();
26
    
27
    public abstract long getBytes();
28
}
b/src/gr/grnet/pithos/web/client/foldertree/Folder.java
53 53
import com.google.gwt.json.client.JSONParser;
54 54
import com.google.gwt.json.client.JSONValue;
55 55

  
56
public class Folder extends Resource {
56
public class Folder extends FileFolderResource {
57 57
    /*
58 58
     * The name of the folder. If the folder is a container this is its name. If it is a virtual folder this is the
59 59
     * last part of its path
......
92 92
        this.name = name;
93 93
    }
94 94
    
95
    public String getName() {
95
    @Override
96
	public String getName() {
96 97
        return name;
97 98
    }
98 99

  
......
261 262
        return files;
262 263
    }
263 264

  
264
    public Folder getParent() {
265
    @Override
266
	public Folder getParent() {
265 267
        return parent;
266 268
    }
267 269

  
268
    public String getUri() {
270
    @Override
271
	public String getUri() {
269 272
        return "/" + container + (prefix.length() == 0 ? "" : "/" + prefix);
270 273
    }
271 274

  
......
285 288
        return permissions;
286 289
    }
287 290

  
288
    public String getOwner() {
291
    @Override
292
	public String getOwner() {
289 293
        return owner;
290 294
    }
291 295

  
......
321 325
				return true;
322 326
		return false;
323 327
	}
328

  
329
	@Override
330
	public String getContentType() {
331
		return "application/folder";
332
	}
333

  
334
	@Override
335
	public String getPath() {
336
		return "";
337
	}
338

  
339
	@Override
340
	public String getSizeAsString() {
341
		return "0 KB";
342
	}
343

  
344
	@Override
345
	public long getBytes() {
346
		return 0;
347
	}
324 348
}
b/src/gr/grnet/pithos/web/client/grouptree/GroupTreeViewModel.java
38 38
import gr.grnet.pithos.web.client.Pithos;
39 39
import gr.grnet.pithos.web.client.commands.CreateGroupCommand;
40 40
import gr.grnet.pithos.web.client.foldertree.File;
41
import gr.grnet.pithos.web.client.foldertree.FileFolderResource;
41 42
import gr.grnet.pithos.web.client.grouptree.GroupTreeView.Templates;
42 43

  
44
import java.util.ArrayList;
43 45
import java.util.HashMap;
44 46
import java.util.HashSet;
45 47
import java.util.Map;
......
121 123
				Group selected = groupSelectionModel.getSelectedObject();
122 124
				if (selected != null) {
123 125
					app.deselectOthers(app.getGroupTreeView(), groupSelectionModel);
124
					app.showFiles(new HashSet<File>());
126
					app.showFiles(new ArrayList<FileFolderResource>());
125 127
					app.disableUploadArea();
126 128
					app.upload.setEnabled(false);
127 129
					app.showRelevantToolbarButtons();
......
147 149
			public void onSelectionChange(SelectionChangeEvent event) {
148 150
				if (userSelectionModel.getSelectedObject() != null) {
149 151
					app.deselectOthers(app.getGroupTreeView(), userSelectionModel);
150
					app.showFiles(new HashSet<File>());
152
					app.showFiles(new ArrayList<FileFolderResource>());
151 153
					app.showRelevantToolbarButtons();
152 154
				}
153 155
				else {
b/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java
37 37

  
38 38
import gr.grnet.pithos.web.client.Pithos;
39 39
import gr.grnet.pithos.web.client.foldertree.AccountResource;
40
import gr.grnet.pithos.web.client.foldertree.File;
40
import gr.grnet.pithos.web.client.foldertree.FileFolderResource;
41 41
import gr.grnet.pithos.web.client.foldertree.Folder;
42 42
import gr.grnet.pithos.web.client.rest.GetRequest;
43 43
import gr.grnet.pithos.web.client.rest.RestException;
44 44
import gr.grnet.pithos.web.client.tagtree.TagTreeView.Templates;
45 45

  
46
import java.util.ArrayList;
46 47
import java.util.Iterator;
47
import java.util.LinkedHashSet;
48 48
import java.util.List;
49
import java.util.Set;
50 49

  
51 50
import com.google.gwt.cell.client.AbstractCell;
52 51
import com.google.gwt.cell.client.Cell;
......
140 139
    public void fetchTag(Tag t) {
141 140
        AccountResource account = app.getAccount();
142 141
        Iterator<Folder> iter = account.getContainers().iterator();
143
        fetchTag(iter, t, new LinkedHashSet<File>());
142
        fetchTag(iter, t, new ArrayList<FileFolderResource>());
144 143
    }
145 144

  
146
    protected void fetchTag(final Iterator<Folder> iter, final Tag t, final Set<File> files) {
145
    protected void fetchTag(final Iterator<Folder> iter, final Tag t, final List<FileFolderResource> files) {
147 146
        if (iter.hasNext()) {
148 147
            Folder f = iter.next();
149 148
            String path = f.getUri() + "?format=json&meta=" + t.getName();

Also available in: Unified diff