import gr.ebs.gss.client.rest.GetCommand;
import gr.ebs.gss.client.rest.RestCommand;
import gr.ebs.gss.client.rest.resource.FileResource;
+import gr.ebs.gss.client.rest.resource.OtherUserResource;
+import gr.ebs.gss.client.rest.resource.OthersFolderResource;
import gr.ebs.gss.client.rest.resource.RestResource;
import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
import gr.ebs.gss.client.rest.resource.SharedResource;
import com.google.gwt.cell.client.AbstractCell;
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.cell.client.Cell.Context;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.RepeatingCommand;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style.Cursor;
+import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.http.client.URL;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.resources.client.ClientBundle;
return celltable;
}
-
/**
* The number of files in this folder.
private final List<SortableHeader> allHeaders = new ArrayList<SortableHeader>();
SortableHeader nameHeader;
SimplePager pager;
+ SimplePager pagerTop;
/**
* Construct the file list widget. This entails setting up the widget
* layout, fetching the number of files in the current folder from the
}
};
+ celltable = new DragAndDropCellTable<FileResource>(GSS.VISIBLE_FILE_COUNT,resources,keyProvider);
+
+ DragAndDropColumn<FileResource, ImageResource> status = new DragAndDropColumn<FileResource, ImageResource>(new ImageResourceCell(){
+ @Override
+ public boolean handlesSelection() {
+ return false;
+ }
+ }) {
+ @Override
+ public ImageResource getValue(FileResource entity) {
+ return getFileIcon(entity);
+ }
+
+ };
+ celltable.addColumn(status,"");
+
+ initDragOperation(status);
final DragAndDropColumn<FileResource,SafeHtml> nameColumn = new DragAndDropColumn<FileResource,SafeHtml>(new SafeHtmlCell()) {
sb.appendEscaped(object.getName());
sb.appendHtmlConstant("</span>");
}
+
return sb.toSafeHtml();
}
-
};
initDragOperation(nameColumn);
- celltable = new DragAndDropCellTable<FileResource>(GSS.VISIBLE_FILE_COUNT,resources,keyProvider){
- @Override
- protected void onBrowserEvent2(Event event) {
- /*if (DOM.eventGetType((Event) event) == Event.ONMOUSEDOWN && DOM.eventGetButton((Event) event) == NativeEvent.BUTTON_RIGHT){
- fireClickEvent((Element) event.getEventTarget().cast());
- }*/
- super.onBrowserEvent2(event);
- }
- };
- provider.addDataDisplay(celltable);
- celltable.addDragStopHandler(dragStop);
- 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());
- sb.appendEscaped(value.getName());
- sb.appendHtmlConstant("</b>");
- helper.setInnerHTML(sb.toSafeHtml().asString());
-
- }
- });
- Column<FileResource, ImageResource> status = new Column<FileResource, ImageResource>(new ImageResourceCell()) {
- @Override
- public ImageResource getValue(FileResource entity) {
- return getFileIcon(entity);
- }
- };
- celltable.addColumn(status,"");
-
-
celltable.addColumn(nameColumn,nameHeader = new SortableHeader("Name"));
allHeaders.add(nameHeader);
nameHeader.setSorted(true);
nameHeader.toggleReverseSort();
nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
celltable.redrawHeaders();
- SortableHeader aheader;
- celltable.addColumn(new TextColumn<FileResource>() {
+
+
+
+
+ SortableHeader aheader;
+ DragAndDropColumn<FileResource,String> aColumn;
+ celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
@Override
public String getValue(FileResource object) {
return GSS.get().findUserFullName(object.getOwner());
}
},aheader = new SortableHeader("Owner"));
+ initDragOperation(aColumn);
allHeaders.add(aheader);
aheader.setUpdater(new FileValueUpdater(aheader, "owner"));
- celltable.addColumn(new TextColumn<FileResource>() {
+ celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
@Override
public String getValue(FileResource object) {
// TODO Auto-generated method stub
return object.getPath();
}
},aheader = new SortableHeader("Path"));
+ initDragOperation(aColumn);
allHeaders.add(aheader);
+
aheader.setUpdater(new FileValueUpdater(aheader, "path"));
- celltable.addColumn(new TextColumn<FileResource>() {
+ celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
@Override
public String getValue(FileResource object) {
- // TODO Auto-generated method stub
return object.getVersion().toString();
}
},aheader = new SortableHeader("Version"));
+ initDragOperation(aColumn);
allHeaders.add(aheader);
aheader.setUpdater(new FileValueUpdater(aheader, "version"));
- celltable.addColumn(new TextColumn<FileResource>() {
+ celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
@Override
public String getValue(FileResource object) {
// TODO Auto-generated method stub
return object.getFileSizeAsString();
}
},aheader = new SortableHeader("Size"));
+ initDragOperation(aColumn);
allHeaders.add(aheader);
aheader.setUpdater(new FileValueUpdater(aheader, "size"));
- celltable.addColumn(new TextColumn<FileResource>() {
+ celltable.addColumn(aColumn=new DragAndDropColumn<FileResource,String>(new TextCell()) {
@Override
public String getValue(FileResource object) {
return formatter.format(object.getModificationDate());
},aheader = new SortableHeader("Last Modified"));
allHeaders.add(aheader);
aheader.setUpdater(new FileValueUpdater(aheader, "date"));
+
+
+ provider.addDataDisplay(celltable);
+ celltable.addDragStopHandler(dragStop);
+ 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 SimplePager(SimplePager.TextLocation.CENTER);
+ pagerTop.setDisplay(celltable);
+ vp.add(pagerTop);
celltable.setWidth("100%");
vp.add(celltable);
pager = new SimplePager(SimplePager.TextLocation.CENTER);
pager.setDisplay(celltable);
- //celltable.setPageSize(2);
vp.add(pager);
vp.setCellWidth(celltable, "100%");
initWidget(vp);
-
- //initWidget(celltable);
+ pager.setVisible(false);
+ pagerTop.setVisible(false);
+
celltable.setStyleName("gss-List");
selectionModel = new MultiSelectionModel<FileResource>();
GSS.get().setCurrentSelection(getSelectedFiles().get(0));
else
GSS.get().setCurrentSelection(getSelectedFiles());
- //contextMenu.setFiles(getSelectedFiles());
}
};
selectionModel.addSelectionChangeHandler(selectionHandler);
//evObj.initEvent('click', true, true);
//element.dispatchEvent(evObj);
//}-*/;
-
+
+
+
public List<FileResource> getSelectedFiles() {
return new ArrayList<FileResource>(selectionModel.getSelectedSet());
}
// prevents dragging when user click on the category drop-down list
draggableOptions.setCancel("select");
+
draggableOptions.setOnBeforeDragStart(new DragFunction() {
@Override
} else {
showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
}
+ showCellTable();
updateCurrentlyShowingStats();
}
private ImageResource getFileIcon(FileResource file) {
String mimetype = file.getContentType();
boolean shared = false;
- //TODO: FETCH USER OF OTHER FOLDER ITEM
- //if(GSS.get().getTreeView().getSelection()!=null && (GSS.get().getTreeView().getSelection() instanceof OtherUserResource || GSS.get().getTreeView().getSelection() instanceof OthersFolderResource))
- /*Folders folders = GSS.get().getFolders();
- if(folders.getCurrent() != null && folders.isOthersSharedItem(folders.getCurrent())){
- DnDTreeItem otherUser = (DnDTreeItem) folders.getUserOfSharedItem(folders.getCurrent());
- if(otherUser==null)
- shared = false;
+ if(GSS.get().getTreeView().getSelection()!=null && (GSS.get().getTreeView().getSelection() instanceof OtherUserResource || GSS.get().getTreeView().getSelection() instanceof OthersFolderResource)){
+ OtherUserResource otherUser = null;
+ if(GSS.get().getTreeView().getSelection() instanceof OtherUserResource)
+ otherUser = (OtherUserResource) GSS.get().getTreeView().getSelection();
+ else if (GSS.get().getTreeView().getSelection() instanceof OthersFolderResource){
+ otherUser = GSS.get().getTreeView().getOtherUserResourceOfOtherFolder((OthersFolderResource) GSS.get().getTreeView().getSelection());
+ }
+ if(otherUser ==null)
+ shared=false;
else{
- String uname = otherUser.getOtherUserResource().getUsername();
+ String uname = otherUser.getUsername();
if(uname==null)
- uname = ((DnDTreeItem)folders.getSharesItem()).getOthersResource().getUsernameOfUri(otherUser.getOtherUserResource().getUri());
+ uname = GSS.get().getTreeView().getOthers().getUsernameOfUri(otherUser.getUri());
if(uname != null)
shared = file.isShared();
}
}
- else*/
+ else
shared = file.isShared();
if (mimetype == null)
return shared ? images.documentShared() : images.document();
public void updateCurrentlyShowingStats() {
GSS.get().getStatusPanel().updateCurrentlyShowing(showingStats);
}
-
- public void updateFileCache(boolean updateSelectedFolder, final boolean clearSelection) {
- updateFileCache(updateSelectedFolder, clearSelection, null);
- }
-
- public void updateFileCache(boolean updateSelectedFolder, final boolean clearSelection, final String newFilename) {
- if (!updateSelectedFolder && !GSS.get().getTreeView().getSelection().equals(GSS.get().getTreeView().getTrash()))
- updateFileCache(clearSelection);
- else if (GSS.get().getTreeView().getSelection() != null) {
- update(true);
- }
- updateFileCache(clearSelection);
- }
-
-
- private void updateFileCache(boolean clearSelection) {
- updateFileCache(clearSelection, null);
- }
-
- /**
- * Update the file cache with data from the server.
- *
- * @param newFilename the new name of the previously selected file,
- * if a rename operation has taken place
- */
- private void updateFileCache(boolean clearSelection, String newFilename) {
- if (clearSelection)
+
+ public void updateFileCache(boolean clearSelection){
+ if(clearSelection)
clearSelectedRows();
- startIndex = 0;
final RestResource folderItem = GSS.get().getTreeView().getSelection();
// Validation.
if (folderItem == null || folderItem.equals(GSS.get().getTreeView().getOthers())) {
update(true);
return;
}
- if (folderItem instanceof RestResourceWrapper) {
+ else if (folderItem instanceof RestResourceWrapper) {
setFiles(((RestResourceWrapper) folderItem).getResource().getFiles());
update(true);
}
- if (folderItem instanceof SharedResource) {
+ else if (folderItem instanceof SharedResource) {
setFiles(((SharedResource) folderItem).getFiles());
update(true);
}
- if (folderItem instanceof TrashResource) {
+ else if (folderItem instanceof OtherUserResource) {
+ setFiles(((OtherUserResource) folderItem).getFiles());
+ update(true);
+ }
+ else if (folderItem instanceof TrashResource) {
setFiles(((TrashResource) folderItem).getFiles());
update(true);
}
}
+
/**
* Fill the file cache with data.
*
*/
public void selectAllRows() {
- Iterator<FileResource> it = selectionModel.getSelectedSet().iterator();
+ Iterator<FileResource> it = provider.getList().iterator();
while(it.hasNext()){
selectionModel.setSelected(it.next(),true);
}
*/
private void showCellTable(){
-
- //celltable.setRowCount(files.size());
- //celltable.setRowData(0,files);
if(files.size()>=GSS.VISIBLE_FILE_COUNT){
pager.setVisible(true);
+ pagerTop.setVisible(true);
}
else{
+ pagerTop.setVisible(false);
pager.setVisible(false);
}
provider.setList(files);