commit e6b93be173f7c6bc6bcd48109bf0e5e6bd59b85b
Author: Christos Stathis <chstath@ebs.gr>
Date:   Tue Mar 20 12:14:12 2012 +0200

    A first attempt to have resizable and sortable headers in the filelist

diff --git a/src/gr/grnet/pithos/web/client/ColumnResizeHelper.java b/src/gr/grnet/pithos/web/client/ColumnResizeHelper.java
new file mode 100644
index 0000000..a95410b
--- /dev/null
+++ b/src/gr/grnet/pithos/web/client/ColumnResizeHelper.java
@@ -0,0 +1,67 @@
+package gr.grnet.pithos.web.client;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.NativeEvent;
+import com.google.gwt.dom.client.Node;
+import com.google.gwt.dom.client.NodeList;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.cellview.client.AbstractCellTable;
+import com.google.gwt.user.cellview.client.Column;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Event.NativePreviewEvent;
+import com.google.gwt.user.client.Event.NativePreviewHandler;
+
+public class ColumnResizeHelper<T> implements NativePreviewHandler {
+
+  private HandlerRegistration handler;
+  private AbstractCellTable<T> table;
+  private Column<T, ?> col;
+  private Element el;
+
+  public static <T> void handleResize(AbstractCellTable<T> table, NativeEvent event) {
+    String eventType = event.getType();
+    if (eventType.equals("mousedown")) {
+      int clientX = event.getClientX();
+      Element eventTargetEl = event.getEventTarget().cast();
+      int absoluteLeft = eventTargetEl.getAbsoluteLeft();
+      int offsetWidth = eventTargetEl.getOffsetWidth();
+      if (clientX > absoluteLeft + offsetWidth - 10) {
+        // Get column
+        NodeList<Node> nodes = eventTargetEl.getParentElement().getChildNodes();
+        for (int i = 0; i < nodes.getLength(); i++) {
+          if (nodes.getItem(i).equals(eventTargetEl)) {
+            event.preventDefault();
+            event.stopPropagation();
+            new ColumnResizeHelper<T>(table, table.getColumn(i), eventTargetEl);
+            break;
+          }
+        }
+        return;
+      }
+    }
+  }
+
+  private ColumnResizeHelper(AbstractCellTable<T> table, Column<T, ?> col, Element el) {
+    this.el = el;
+    this.table = table;
+    this.col = col;
+    handler = Event.addNativePreviewHandler(this);
+  }
+
+  @Override
+  public void onPreviewNativeEvent(NativePreviewEvent event) {
+    NativeEvent nativeEvent = event.getNativeEvent();
+    nativeEvent.preventDefault();
+    nativeEvent.stopPropagation();
+
+    if (nativeEvent.getType().equals("mousemove")) {
+      int absoluteLeft = el.getAbsoluteLeft();
+      int clientX = nativeEvent.getClientX();
+      int newWidth = clientX - absoluteLeft;
+      newWidth = newWidth < 10 ? 10 : newWidth;
+      table.setColumnWidth(col, newWidth + "px");
+    } else if (nativeEvent.getType().equals("mouseup")) {
+      handler.removeHandler();
+    }
+  }
+}
diff --git a/src/gr/grnet/pithos/web/client/FileList.java b/src/gr/grnet/pithos/web/client/FileList.java
index 9cd5d20..a4fb93d 100644
--- a/src/gr/grnet/pithos/web/client/FileList.java
+++ b/src/gr/grnet/pithos/web/client/FileList.java
@@ -271,7 +271,7 @@ public class FileList extends Composite {
 				return super.getCellStyleNames(context, object);
 			}
 	    };
-	    celltable.addColumn(status,"");
+	    celltable.addColumn(status, new ResizableHeader<File>("", celltable, status));
 
         final Column<File,SafeHtml> nameColumn = new Column<File,SafeHtml>(new SafeHtmlCell()) {
 
@@ -288,7 +288,7 @@ public class FileList extends Composite {
 			}
 			
 		};
-        celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name"));
+        celltable.addColumn(nameColumn, nameHeader = new ResizableHeader<File>("Name", celltable, nameColumn));
 		allHeaders.add(nameHeader);
 		nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
 
diff --git a/src/gr/grnet/pithos/web/client/Pithos.java b/src/gr/grnet/pithos/web/client/Pithos.java
index 4d67a82..22ef9be 100644
--- a/src/gr/grnet/pithos/web/client/Pithos.java
+++ b/src/gr/grnet/pithos/web/client/Pithos.java
@@ -53,7 +53,6 @@ import gr.grnet.pithos.web.client.rest.GetRequest;
 import gr.grnet.pithos.web.client.rest.HeadRequest;
 import gr.grnet.pithos.web.client.rest.PutRequest;
 import gr.grnet.pithos.web.client.rest.RestException;
-import gr.grnet.pithos.web.client.tagtree.Tag;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -64,6 +63,7 @@ import java.util.Set;
 import com.google.gwt.core.client.EntryPoint;
 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.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
@@ -459,14 +459,22 @@ public class Pithos implements EntryPoint, ResizeHandler {
             }
         });
         
-//        Scheduler.get().scheduleDeferred(new Command() {
-//			
-//			@Override
-//			public void execute() {
-//				displayError("lalala");
-//				
-//			}
-//		});
+        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
+			
+			@Override
+			public boolean execute() {
+				Folder f = getSelection();
+				if (f != null) {
+					if (getSelectedTree().equals(folderTreeView))
+						updateFolder(f, true, null);
+					else if (getSelectedTree().equals(mysharedTreeView))
+						updateSharedFolder(f, true);
+					else if (getSelectedTree().equals(otherSharedTreeView))
+						updateOtherSharedFolder(f, true);
+				}
+				return true;
+			}
+		}, 3000);
     }
 
     public void applyPermissions(Folder f) {
diff --git a/src/gr/grnet/pithos/web/client/ResizableHeader.java b/src/gr/grnet/pithos/web/client/ResizableHeader.java
new file mode 100644
index 0000000..8e80517
--- /dev/null
+++ b/src/gr/grnet/pithos/web/client/ResizableHeader.java
@@ -0,0 +1,113 @@
+package gr.grnet.pithos.web.client;
+
+
+import com.google.gwt.cell.client.AbstractCell;
+import com.google.gwt.cell.client.Cell.Context;
+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.shared.HandlerRegistration;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
+import com.google.gwt.user.cellview.client.AbstractCellTable;
+import com.google.gwt.user.cellview.client.Column;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Event.NativePreviewEvent;
+import com.google.gwt.user.client.Event.NativePreviewHandler;
+
+public class ResizableHeader<T> extends SortableHeader { 
+	
+	private Column<T, ?> column = null;
+	private AbstractCellTable<T> cellTable;
+	private String title = "";
+	static private final int width = 10;
+
+	public ResizableHeader(String title, AbstractCellTable<T> cellTable, Column<T, ?> column) {
+		super(title);
+		this.title  = title;
+		this.cellTable = cellTable;
+		this.column = column;
+	}
+
+	@Override 
+	public String getValue() 
+	{ 
+		return title;
+	}
+	
+	@Override
+	public void onBrowserEvent(Context context, Element target, NativeEvent event) {
+	    String eventType = event.getType();
+		int clientX = event.getClientX();
+		int absoluteLeft = target.getAbsoluteLeft();
+		int offsetWidth = target.getOffsetWidth();
+		if (clientX > absoluteLeft + offsetWidth - width) {
+			setCursor(target, Cursor.COL_RESIZE);
+		} else {
+			setCursor(target, Cursor.DEFAULT);
+		}
+    	if(eventType.equals("mousedown")) {
+			if (clientX > absoluteLeft + offsetWidth - width) {
+	            new ColumnResizeHelper<T>(cellTable, column, target);
+			}
+	        event.preventDefault();
+	        event.stopPropagation();
+	    } else {
+	    	return;
+	    }
+	}
+
+	private void setCursor(Element element, Cursor cursor) {
+		element.getStyle().setCursor(cursor);
+	}
+
+class ColumnResizeHelper<T> implements NativePreviewHandler {
+
+	  private HandlerRegistration handler;
+	  private AbstractCellTable<T> table;
+	  private Column<T, ?> col;
+	  private Element el;
+
+	  public ColumnResizeHelper(AbstractCellTable<T> table, Column<T, ?> col, Element el) {
+	    this.el = el;
+	    this.table = table;
+	    this.col = col;
+	    handler = Event.addNativePreviewHandler(this);
+	  }
+
+	  @Override
+	  public void onPreviewNativeEvent(NativePreviewEvent event) {
+	    NativeEvent nativeEvent = event.getNativeEvent();
+	    nativeEvent.preventDefault();
+	    nativeEvent.stopPropagation();
+
+	    if (nativeEvent.getType().equals("mousemove")) {
+	      int absoluteLeft = el.getAbsoluteLeft();
+	      int clientX = nativeEvent.getClientX();
+	      int newWidth = clientX - absoluteLeft;
+	      newWidth = newWidth < 10 ? 10 : newWidth;
+	      table.setColumnWidth(col, newWidth + "px");
+	    } else if (nativeEvent.getType().equals("mouseup")) {
+	      handler.removeHandler();
+	    }
+	  }
+	}
+
+	static class HeaderCell extends AbstractCell<String> {
+	
+		public HeaderCell() {
+			super("click", "mousedown", "mousemove");
+		}
+		
+		@Override
+		public void render(com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) {
+			sb.append(
+					new SafeHtmlBuilder()
+			        .append(SafeHtmlUtils.fromString(value))
+			        .toSafeHtml());
+		}
+		
+	}
+};
+
+
