/*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2013 GRNET S.A. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
package gr.grnet.pithos.web.client;
-import com.google.gwt.event.dom.client.ContextMenuEvent;
-import com.google.gwt.event.dom.client.ContextMenuHandler;
-import static com.google.gwt.query.client.GQuery.$;
-
-import gr.grnet.pithos.web.client.commands.UploadFileCommand;
-import gr.grnet.pithos.web.client.foldertree.File;
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gwtquery.plugins.draggable.client.DraggableOptions;
-import gwtquery.plugins.draggable.client.StopDragException;
-import gwtquery.plugins.draggable.client.DraggableOptions.DragFunction;
-import gwtquery.plugins.draggable.client.DraggableOptions.RevertOption;
-import gwtquery.plugins.draggable.client.events.DragContext;
-import gwtquery.plugins.draggable.client.events.DragStartEvent;
-import gwtquery.plugins.draggable.client.events.DragStopEvent;
-import gwtquery.plugins.draggable.client.events.DragStartEvent.DragStartEventHandler;
-import gwtquery.plugins.draggable.client.events.DragStopEvent.DragStopEventHandler;
-import gwtquery.plugins.droppable.client.gwt.DragAndDropCellTable;
-import gwtquery.plugins.droppable.client.gwt.DragAndDropColumn;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
+import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.cell.client.ImageResourceCell;
import com.google.gwt.cell.client.SafeHtmlCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.Style.Cursor;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.ContextMenuEvent;
+import com.google.gwt.event.dom.client.ContextMenuHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.resources.client.ImageResource.ImageOptions;
+import com.google.gwt.resources.client.ImageResource.RepeatStyle;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.CellTable;
-import com.google.gwt.user.cellview.client.GssSimplePager;
+import com.google.gwt.user.cellview.client.Column;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.ProvidesKey;
import com.google.gwt.view.client.SelectionChangeEvent;
-import com.google.gwt.view.client.SelectionChangeEvent.Handler;
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.Folder;
+import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
+
+import java.util.*;
/**
* A composite that displays the list of files in a particular folder.
* The styles applied to the table.
*/
interface TableStyle extends CellTable.Style {
+ String cellTableFirstColumnShared();
}
- interface TableResources extends DragAndDropCellTable.Resources {
- @Source({CellTable.Style.DEFAULT_CSS, "GssCellTable.css"})
+ interface TableResources extends CellTable.Resources {
+ @Override
+ @Source({CellTable.Style.DEFAULT_CSS, "PithosCellTable.css"})
TableStyle cellTableStyle();
+
+ @Source("share.png")
+ @ImageOptions(repeatStyle = RepeatStyle.None)
+ ImageResource cellTableSharedIcon();
}
static interface Templates extends SafeHtmlTemplates {
public SafeHtml spanWithIdAndClass(String id, String cssClass, String content);
}
- private String showingStats = "";
-
- private int startIndex = 0;
-
- /**
- * A constant that denotes the completion of an IncrementalCommand.
- */
- public static final boolean DONE = false;
-
- private final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
+ protected final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
/**
* Specifies that the images available for this composite will be the ones
* available in FileContextMenu.
*/
- public interface Images extends ClientBundle,FileContextMenu.Images, CellTreeView.Images {
+ public interface Images extends FolderTreeView.Images {
@Source("gr/grnet/pithos/resources/blank.gif")
ImageResource blank();
/**
* The widget's image bundle.
*/
- private final Images images;
+ protected final Images images;
- private DragAndDropCellTable<File> celltable;
+ protected CellTable<File> celltable;
private final MultiSelectionModel<File> selectionModel;
- private final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
-
- SortableHeader nameHeader;
-
- GssSimplePager pagerBottom;
+ Column<File, String> pathColumn;
- GssSimplePager pagerTop;
+ protected final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
- Button uploadButtonBottom;
+ SortableHeader nameHeader;
- Button uploadButtonTop;
+ SortableHeader pathHeader;
- FolderTreeView treeView;
+ protected Pithos app;
/**
* Construct the file list widget. This entails setting up the widget
*
* @param _images
*/
- public FileList(Images _images, FolderTreeView _treeView) {
+ public FileList(final Pithos _app, Images _images) {
+ app = _app;
images = _images;
- this.treeView = _treeView;
- DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
+ final CellTable.Resources resources = GWT.create(TableResources.class);
ProvidesKey<File> keyProvider = new ProvidesKey<File>(){
}
};
- celltable = new DragAndDropCellTable<File>(Pithos.VISIBLE_FILE_COUNT, resources, keyProvider);
+ celltable = new CellTable<File>(10, resources, keyProvider);
celltable.setWidth("100%");
celltable.setStyleName("pithos-List");
- DragAndDropColumn<File, ImageResource> status = new DragAndDropColumn<File, ImageResource>(new ImageResourceCell() {
+ Column<File, ImageResource> status = new Column<File, ImageResource>(new ImageResourceCell() {
@Override
public boolean handlesSelection() {
return false;
public ImageResource getValue(File entity) {
return getFileIcon(entity);
}
+
+ @Override
+ public String getCellStyleNames(Context context, File object) {
+ if (!object.getPermissions().isEmpty() && !object.isPublished())
+ return ((TableStyle) resources.cellTableStyle()).cellTableFirstColumnShared();
+ return super.getCellStyleNames(context, object);
+ }
};
celltable.addColumn(status,"");
- initDragOperation(status);
- final DragAndDropColumn<File,SafeHtml> nameColumn = new DragAndDropColumn<File,SafeHtml>(new SafeHtmlCell()) {
+ final Column<File,SafeHtml> nameColumn = new Column<File,SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(File object) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
- sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
- if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg")) {
+ sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
+ if (object.getContentType() != null && (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg"))) {
sb.appendHtmlConstant(" ")
- .append(Templates.INSTANCE.viewLink(object.getUri(), object.getOwner() + " : " + object.getPath() + object.getName()));
+ .append(Templates.INSTANCE.viewLink(Pithos.getFileViewURL(object), object.getName()));
}
return sb.toSafeHtml();
}
};
- initDragOperation(nameColumn);
- celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name"));
+ celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name", "name"));
allHeaders.add(nameHeader);
- nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
+ nameHeader.setUpdater(new FileValueUpdater(nameHeader));
+ nameHeader.setSorted(true);
+ nameHeader.setReverseSort(true);
celltable.redrawHeaders();
- DragAndDropColumn<File,String> aColumn = new DragAndDropColumn<File, String>(new TextCell()) {
- @Override
- public String getValue(File object) {
- return object.getOwner();
- }
- };
- SortableHeader aheader = new SortableHeader("Owner");
- celltable.addColumn(aColumn, aheader);
- initDragOperation(aColumn);
- allHeaders.add(aheader);
- aheader.setUpdater(new FileValueUpdater(aheader, "owner"));
-
- aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
- @Override
- public String getValue(File object) {
- return object.getPath();
- }
- };
- aheader = new SortableHeader("Path");
- celltable.addColumn(aColumn, aheader);
- initDragOperation(aColumn);
- allHeaders.add(aheader);
- aheader.setUpdater(new FileValueUpdater(aheader, "path"));
+ pathColumn = new Column<File, String>(new TextCell()) {
- aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
@Override
- public String getValue(File object) {
- return String.valueOf(object.getVersion());
+ public String getValue(File f) {
+ String path;
+ if (!app.getSelectedTree().equals(app.mysharedTreeView)) {
+ path = f.getParent().getPrefix();
+ if (path.length() == 0)
+ path = "/";
+ }
+ else {
+ path = f.getPath();
+ if (path.lastIndexOf("/") != -1)
+ path = path.substring(0, path.lastIndexOf("/"));
+ else
+ path = "/";
+ }
+ return path;
}
};
- aheader = new SortableHeader("Version");
- celltable.addColumn(aColumn, aheader);
- initDragOperation(aColumn);
- allHeaders.add(aheader);
- aheader.setUpdater(new FileValueUpdater(aheader, "version"));
-
- aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
+ pathHeader = new SortableHeader("Path", "path");
+ celltable.addColumn(pathColumn, pathHeader);
+ allHeaders.add(pathHeader);
+ pathHeader.setUpdater(new FileValueUpdater(pathHeader));
+
+ Column<File,String> aColumn = new Column<File,String>(new TextCell()) {
@Override
public String getValue(File object) {
- // TODO Auto-generated method stub
return object.getSizeAsString();
}
};
- aheader = new SortableHeader("Size");
+ SortableHeader aheader = new SortableHeader("Size", "size");
celltable.addColumn(aColumn, aheader);
- initDragOperation(aColumn);
allHeaders.add(aheader);
- aheader.setUpdater(new FileValueUpdater(aheader, "size"));
+ aheader.setUpdater(new FileValueUpdater(aheader));
- aColumn = new DragAndDropColumn<File,String>(new TextCell()) {
+ aColumn = new Column<File,String>(new TextCell()) {
@Override
public String getValue(File object) {
- return formatter.format(object.getLastModified());
+ return object.getLastModified() != null ? formatter.format(object.getLastModified()) : "";
}
};
- aheader = new SortableHeader("Last Modified");
+ aheader = new SortableHeader("Last Modified", "date");
celltable.addColumn(aColumn, aheader);
allHeaders.add(aheader);
- aheader.setUpdater(new FileValueUpdater(aheader, "date"));
+ aheader.setUpdater(new FileValueUpdater(aheader));
provider.addDataDisplay(celltable);
- celltable.addDragStopHandler(new DragStopEventHandler() {
-
- @Override
- public void onDragStop(DragStopEvent event) {
- GWT.log("DRAG STOPPED");
- }
- });
- celltable.addDragStartHandler(new DragStartEventHandler() {
-
- public void onDragStart(DragStartEvent event) {
- FileResource value = event.getDraggableData();
-
- com.google.gwt.dom.client.Element helper = event.getHelper();
- SafeHtmlBuilder sb = new SafeHtmlBuilder();
- sb.appendHtmlConstant("<b>");
- DisplayHelper.log(value.getName());
- if(getSelectedFiles().size()==1)
- sb.appendEscaped(value.getName());
- else
- sb.appendEscaped(getSelectedFiles().size()+" files");
- sb.appendHtmlConstant("</b>");
- helper.setInnerHTML(sb.toSafeHtml().asString());
- }
- });
-
VerticalPanel vp = new VerticalPanel();
vp.setWidth("100%");
-
- pagerTop = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
- pagerTop.setVisible(false);
- pagerTop.setDisplay(celltable);
- uploadButtonTop = new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>");
- uploadButtonTop.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- new UploadFileCommand(null, treeView.getSelection()).execute();
- }
- });
- HorizontalPanel topPanel = new HorizontalPanel();
- topPanel.add(pagerTop);
- topPanel.add(uploadButtonTop);
- vp.add(topPanel);
+ vp.addStyleName("pithos-FileListContainer");
vp.add(celltable);
- pagerBottom = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
- pagerBottom.setVisible(false);
- pagerBottom.setDisplay(celltable);
- uploadButtonBottom=new Button("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>");
- uploadButtonBottom.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- new UploadFileCommand(null, treeView.getSelection()).execute();
- }
- });
- HorizontalPanel bottomPanel = new HorizontalPanel();
- bottomPanel.add(pagerBottom);
- bottomPanel.add(uploadButtonBottom);
-
- vp.add(bottomPanel);
vp.setCellWidth(celltable, "100%");
vp.addHandler(new ContextMenuHandler() {
@Override
- public void onContextMenu(ContextMenuEvent event) {
- Folder selectedFolder = treeView.getSelection();
- if (!selectedFolder.isTrash()) {
- FileContextMenu contextMenu = new FileContextMenu(images, selectedFolder, getSelectedFiles(), false);
- int x = event.getNativeEvent().getClientX();
- int y = event.getNativeEvent().getClientY();
- contextMenu.setPopupPosition(x, y);
- contextMenu.show();
- }
+ public void onContextMenu(final ContextMenuEvent event) {
+ final TreeView tree = app.getSelectedTree();
+ if (tree != null) {
+ final int x = event.getNativeEvent().getClientX();
+ final int y = event.getNativeEvent().getClientY();
+ final Folder selectedFolder = app.getSelection();
+ app.scheduleFolderHeadCommand(selectedFolder, new Command() {
+
+ @Override
+ public void execute() {
+ final List<File> selectedFiles = getSelectedFiles();
+ Iterator<File> iter = selectedFiles.iterator();
+ iterateFilesHeadCommand(iter, new Command() {
+
+ @Override
+ public void execute() {
+ FileContextMenu contextMenu = new FileContextMenu(app, images, tree, selectedFolder, selectedFiles);
+ contextMenu.setPopupPosition(x, y);
+ contextMenu.show();
+ }
+ });
+ }
+ });
+ }
}
}, ContextMenuEvent.getType());
initWidget(vp);
selectionModel = new MultiSelectionModel<File>(keyProvider);
-
- Handler selectionHandler = new SelectionChangeEvent.Handler() {
- @Override
- public void onSelectionChange(SelectionChangeEvent event) {
- if(getSelectedFiles().size() == 1)
- Pithos.get().setCurrentSelection(getSelectedFiles().get(0));
- else
- Pithos.get().setCurrentSelection(getSelectedFiles());
- }
- };
- selectionModel.addSelectionChangeHandler(selectionHandler);
-
- celltable.setSelectionModel(selectionModel, GSSSelectionEventManager.<File> createDefaultManager());
- celltable.setPageSize(Pithos.VISIBLE_FILE_COUNT);
+ selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
+
+ @Override
+ public void onSelectionChange(SelectionChangeEvent event) {
+ app.showRelevantToolbarButtons();
+ }
+ });
+
+ celltable.setSelectionModel(selectionModel, PithosSelectionEventManager.<File> createDefaultManager());
sinkEvents(Event.ONCONTEXTMENU);
-// sinkEvents(Event.ONMOUSEUP);
-// sinkEvents(Event.ONMOUSEDOWN);
-// sinkEvents(Event.ONCLICK);
-// sinkEvents(Event.ONKEYDOWN);
-// sinkEvents(Event.ONDBLCLICK);
+ sinkEvents(Event.ONDBLCLICK);
Pithos.preventIESelection();
}
return new ArrayList<File>(selectionModel.getSelectedSet());
}
- private void initDragOperation(DragAndDropColumn<?, ?> column) {
- // retrieve draggableOptions on the column
- DraggableOptions draggableOptions = column.getDraggableOptions();
- // use template to construct the helper. The content of the div will be set
- // after
- draggableOptions.setHelper($(Templates.INSTANCE.outerHelper().asString()));
- //draggableOptions.setZIndex(100);
- // opacity of the helper
- draggableOptions.setAppendTo("body");
- //draggableOptions.setOpacity((float) 0.8);
- draggableOptions.setContainment("document");
- // cursor to use during the drag operation
- draggableOptions.setCursor(Cursor.MOVE);
- // set the revert option
- draggableOptions.setRevert(RevertOption.ON_INVALID_DROP);
- // prevents dragging when user click on the category drop-down list
- draggableOptions.setCancel("select");
- draggableOptions.setOnBeforeDragStart(new DragFunction() {
- @Override
- public void f(DragContext context) {
- File value = context.getDraggableData();
- if (!selectionModel.isSelected(value)) {
- throw new StopDragException();
- }
+ @Override
+ public void onBrowserEvent(Event event) {
+
+ if (DOM.eventGetType(event) == Event.ONDBLCLICK)
+ if (getSelectedFiles().size() == 1) {
+ File file = getSelectedFiles().get(0);
+ Window.open(Pithos.getFileViewURL(file), "_blank", "");
+ event.preventDefault();
+ return;
}
- });
- }
-
-// @Override
-// public void onBrowserEvent(Event event) {
-//
-// if (files == null || files.size() == 0) {
-// if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
-// contextMenu = new FileContextMenu(images, false, true);
-// contextMenu.show();
-// event.preventDefault();
-// event.cancelBubble(true);
-// }
-// return;
-// }
-// if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) {
-// GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null);
-// contextMenu = new FileContextMenu(images, false, false);
-// contextMenu = contextMenu.onEvent(event);
-// event.cancelBubble(true);
-// event.preventDefault();
-// } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
-// contextMenu = new FileContextMenu(images, false, true);
-// contextMenu = contextMenu.onEmptyEvent(event);
-// event.cancelBubble(true);
-// event.preventDefault();
-// } else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
-// if (getSelectedFiles().size() == 1) {
-// Pithos app = Pithos.get();
-// File file = getSelectedFiles().get(0);
-// Window.open(file.getUri(), "_blank", "");
-// event.preventDefault();
-// return;
-// }
-// super.onBrowserEvent(event);
-// }
+ super.onBrowserEvent(event);
+ }
/**
* Update the display of the file list.
*/
- void update(boolean sort) {
- int count = folderFileCount;
- int max = startIndex + Pithos.VISIBLE_FILE_COUNT;
- if (max > count)
- max = count;
- folderTotalSize = 0;
-
- for(File f : files){
- folderTotalSize += f.getBytes();
- }
- if (folderFileCount == 0) {
- showingStats = "no files";
- } else if (folderFileCount < Pithos.VISIBLE_FILE_COUNT) {
- if (folderFileCount == 1)
- showingStats = "1 file";
- else
- showingStats = folderFileCount + " files";
- showingStats += " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
- } else {
- showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
- }
+ void update() {
showCellTable();
- updateCurrentlyShowingStats();
-
}
/**
* @param file
* @return the icon
*/
- private ImageResource getFileIcon(File file) {
+ protected ImageResource getFileIcon(File file) {
String mimetype = file.getContentType();
- boolean shared = file.isShared();
+ boolean published = file.isPublished();
if (mimetype == null)
- return shared ? images.documentShared() : images.document();
+ return published ? images.documentShared() : images.document();
mimetype = mimetype.toLowerCase();
if (mimetype.startsWith("application/pdf"))
- return shared ? images.pdfShared() : images.pdf();
+ return published ? images.pdfShared() : images.pdf();
else if (mimetype.endsWith("excel"))
- return shared ? images.spreadsheetShared() : images.spreadsheet();
+ return published ? images.spreadsheetShared() : images.spreadsheet();
else if (mimetype.endsWith("msword"))
- return shared ? images.wordprocessorShared() : images.wordprocessor();
+ return published ? images.wordprocessorShared() : images.wordprocessor();
else if (mimetype.endsWith("powerpoint"))
- return shared ? images.presentationShared() : images.presentation();
+ return published ? images.presentationShared() : images.presentation();
else if (mimetype.startsWith("application/zip") ||
mimetype.startsWith("application/gzip") ||
mimetype.startsWith("application/x-gzip") ||
mimetype.startsWith("application/x-tar") ||
mimetype.startsWith("application/x-gtar"))
- return shared ? images.zipShared() : images.zip();
+ return published ? images.zipShared() : images.zip();
else if (mimetype.startsWith("text/html"))
- return shared ? images.htmlShared() : images.html();
+ return published ? images.htmlShared() : images.html();
else if (mimetype.startsWith("text/plain"))
- return shared ? images.txtShared() : images.txt();
+ return published ? images.txtShared() : images.txt();
else if (mimetype.startsWith("image/"))
- return shared ? images.imageShared() : images.image();
+ return published ? images.imageShared() : images.image();
else if (mimetype.startsWith("video/"))
- return shared ? images.videoShared() : images.video();
+ return published ? images.videoShared() : images.video();
else if (mimetype.startsWith("audio/"))
- return shared ? images.audioShared() : images.audio();
- return shared ? images.documentShared() : images.document();
+ return published ? images.audioShared() : images.audio();
+ return published ? images.documentShared() : images.document();
}
/**
- * Update status panel with currently showing file stats.
- */
- public void updateCurrentlyShowingStats() {
- Pithos.get().getStatusPanel().updateCurrentlyShowing(showingStats);
- }
-
- /**
* Fill the file cache with data.
*/
public void setFiles(final List<File> _files) {
+ if (!app.getSelectedTree().equals(app.mysharedTreeView)) {
+ if (celltable.getColumnIndex(pathColumn) != -1)
+ celltable.removeColumn(pathColumn);
+ }
+ else {
+ if (celltable.getColumnIndex(pathColumn) == -1)
+ celltable.insertColumn(2, pathColumn, pathHeader);
+ }
files = new ArrayList<File>();
- for (File fres : _files)
- if (!fres.isInTrash())
- files.add(fres);
- Collections.sort(files, new Comparator<File>() {
-
- @Override
- public int compare(File arg0, File arg1) {
- return arg0.getName().compareTo(arg1.getName());
- }
-
- });
+ for (File fres : _files) {
+ files.add(fres);
+ }
+
folderFileCount = files.size();
- nameHeader.setSorted(true);
- nameHeader.toggleReverseSort();
- for (SortableHeader otherHeader : allHeaders) {
- if (otherHeader != nameHeader) {
- otherHeader.setSorted(false);
- otherHeader.setReverseSort(true);
- }
- }
-
- if(files.size() > Pithos.VISIBLE_FILE_COUNT){
- pagerBottom.setVisible(true);
- pagerTop.setVisible(true);
- }
- else{
- pagerTop.setVisible(false);
- pagerBottom.setVisible(false);
- }
- Folder selectedItem = treeView.getSelection();
+ for (SortableHeader header : allHeaders) {
+ if (header.isSorted())
+ sortFiles(header.getProperty(), header.getReverseSort());
+ }
+
+ List<File> previousSelection = getSelectedFiles(); //Keep the previous selection
+ provider.getList().clear();
provider.setList(files);
+ selectionModel.clear();
+ for (File f : files) {
+ if (previousSelection.contains(f))
+ selectionModel.setSelected(f, true);
+ }
+
+ app.showFolderStatistics(folderFileCount);
+ celltable.setPageSize(folderFileCount);
}
/**
}
}
-
/**
*
*/
while(it.hasNext()){
selectionModel.setSelected(it.next(),true);
}
-
-
}
-
- private void sortFiles(final String sortingProperty, final boolean sortingType){
+ protected void sortFiles(final String sortingProperty, final boolean sortingType){
Collections.sort(files, new Comparator<File>() {
@Override
public int compare(File arg0, File arg1) {
- AbstractImagePrototype descPrototype = AbstractImagePrototype.create(images.desc());
- AbstractImagePrototype ascPrototype = AbstractImagePrototype.create(images.asc());
if (sortingType){
if (sortingProperty.equals("version")) {
return arg0.getVersion() - arg1.getVersion();
} else if (sortingProperty.equals("owner")) {
- return arg0.getOwner().compareTo(arg1.getOwner());
+ return arg0.getOwnerID().compareTo(arg1.getOwnerID());
} else if (sortingProperty.equals("date")) {
- return arg0.getLastModified().compareTo(arg1.getLastModified());
+ if (arg0.getLastModified() != null && arg1.getLastModified() != null)
+ return arg0.getLastModified().compareTo(arg1.getLastModified());
+ return 0;
} else if (sortingProperty.equals("size")) {
return (int) (arg0.getBytes() - arg1.getBytes());
} else if (sortingProperty.equals("name")) {
return arg1.getVersion() - arg0.getVersion();
} else if (sortingProperty.equals("owner")) {
- return arg1.getOwner().compareTo(arg0.getOwner());
+ return arg1.getOwnerID().compareTo(arg0.getOwnerID());
} else if (sortingProperty.equals("date")) {
return arg1.getLastModified().compareTo(arg0.getLastModified());
}
final class FileValueUpdater implements ValueUpdater<String>{
- private String property;
private SortableHeader header;
/**
*
*/
- public FileValueUpdater(SortableHeader header,String property) {
- this.property=property;
+ public FileValueUpdater(SortableHeader header) {
this.header=header;
}
@Override
}
}
celltable.redrawHeaders();
- sortFiles(property, header.getReverseSort());
- FileList.this.update(true);
+ sortFiles(header.getProperty(), header.getReverseSort());
+ FileList.this.update();
}
}
* Shows the files in the cellTable
*/
private void showCellTable(){
- if(files.size()> Pithos.VISIBLE_FILE_COUNT){
- pagerBottom.setVisible(true);
- pagerTop.setVisible(true);
- }
- else{
- pagerTop.setVisible(false);
- pagerBottom.setVisible(false);
- }
provider.setList(files);
provider.refresh();
//celltable.redraw();
celltable.redrawHeaders();
}
+
+ void iterateFilesHeadCommand(final Iterator<File> iter, final Command callback) {
+ if (iter.hasNext()) {
+ File f = iter.next();
+ app.scheduleFileHeadCommand(f, new Command() {
+
+ @Override
+ public void execute() {
+ iterateFilesHeadCommand(iter, callback);
+ }
+ });
+ }
+ else if (callback != null)
+ callback.execute();
+ }
- public void showTrash() {
- uploadButtonBottom.setVisible(false);
- uploadButtonTop.setVisible(false);
- }
-
- public void showFiles() {
- uploadButtonBottom.setVisible(true);
- uploadButtonTop.setVisible(true);
- }
+ public void selectByUrl(List<String> selectedUrls) {
+ Set<File> previous = selectionModel.getSelectedSet();
+ for (File f : previous)
+ selectionModel.setSelected(f, false);
+
+ int i = 0;
+ boolean scrolled = false;
+ for (File f : files) {
+ if (selectedUrls.contains(Pithos.getStorageAPIURL() + f.getOwnerID() + f.getUri())) {
+ selectionModel.setSelected(f, true);
+ if (!scrolled) {
+ celltable.getRowElement(i).getCells().getItem(0).scrollIntoView();
+ scrolled = true;
+ }
+ }
+ i++;
+ }
+ }
}