private DnDTreeItem rootItem;
- public FolderSubtree(PopupTree tree, final Images _images) {
- super(tree, _images);
- tree.clear();
+ public FolderSubtree(PopupTree aTree, final Images _images) {
+ super(aTree, _images);
+ aTree.clear();
DeferredCommand.addCommand(new IncrementalCommand() {
public boolean execute() {
});
}
- /**
- * @return
- */
public boolean fetchRootFolder() {
-
UserResource userResource = GSS.get().getCurrentUserResource();
if (userResource == null)
return !DONE;
final String path = userResource.getFilesPath();
GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path) {
+ @Override
public void onComplete() {
FolderResource rootResource = getResult();
rootItem = new DnDTreeItem(imageItemHTML(images.home(), rootResource.getName()), rootResource.getName(), false);
tree.addItem(rootItem);
rootItem.doDroppable();
GSS.get().getFolders().select(rootItem);
- //hack for lazy loading
- /*for(String s : rootResource.getSubfolderPaths()){
- if(!s.endsWith("/"))
- s=s+"/";
- String[] pathElements = s.split("/");
- FolderResource tr = new FolderResource(s);
- tr.setName(pathElements[pathElements.length-1]);
- DnDTreeItem child = (DnDTreeItem) addImageItem(rootItem, URL.decode(tr.getName()), images.folderYellow(), true);
- child.doDraggable();
- child.setUserObject(tr);
- child.setState(false);
- }*/
- //for(FolderResource r : rootResource.get)
updateSubFoldersLazily(rootItem, rootResource.getFolders(), images.folderYellow());
rootItem.setState(true);
- //updateSubfolders(rootItem, true);
}
+ @Override
public void onError(Throwable t) {
GWT.log("Error fetching root folder", t);
GSS.get().displayError("Unable to fetch root folder");
};
DeferredCommand.addCommand(gf);
-
return DONE;
}
-
-
public void updateSubfolders(final DnDTreeItem folderItem) {
if (folderItem.getFolderResource() == null) {
GWT.log("folder resource is null", null);
return;
}
- updateNodes(folderItem, folderItem);
-
+ updateNodes(folderItem);
}
- private void updateNodes(final DnDTreeItem folderItem, final DnDTreeItem initialParent) {
+ private void updateNodes(final DnDTreeItem folderItem) {
String parentName = "";
if (folderItem.getParentItem() != null)
parentName = ((DnDTreeItem) folderItem.getParentItem()).getFolderResource().getName() + "->";
parentName = parentName + folderItem.getFolderResource().getName();
- final boolean firstRun = getRootItem().getChildCount() == 0;
MultipleGetCommand<FolderResource> gf = new MultipleGetCommand<FolderResource>(FolderResource.class, folderItem .getFolderResource()
.getSubfolderPaths()
.toArray(new String[] {})) {
+ @Override
public void onComplete() {
List<FolderResource> res = getResult();
- /*folderItem.removeItems();
- if (folderItem.equals(getRootItem()))
- getRootItem().setState(true);
-
- for (FolderResource r : res) {
-
- DnDTreeItem child = (DnDTreeItem) addImageItem(folderItem, r.getName(), images.folderYellow(), true);
- child.doDraggable();
- child.setUserObject(r);
- child.setState(false);
- }*/
folderItem.getFolderResource().setFolders(res);
updateSubFoldersLazily(folderItem, res, images.folderYellow());
for (int i = 0; i < folderItem.getChildCount(); i++) {
DnDTreeItem anItem = (DnDTreeItem) folderItem.getChild(i);
-
- //if(anItem.getParentItem().equals(initialParent))
- //updateNodes(anItem, initialParent);
- //else
- updateSubFoldersLazily(anItem, anItem.getFolderResource().getFolders(), images.folderYellow());
- anItem.setState(false);
+ updateSubFoldersLazily(anItem, anItem.getFolderResource().getFolders(), images.folderYellow());
+ anItem.setState(false);
}
}
+ @Override
public void onError(Throwable t) {
GSS.get().displayError("Unable to fetch subfolders");
GWT.log("Unable to fetch subfolders", t);
GWT.log("Path:"+p, throwable);
}
-
};
DeferredCommand.addCommand(gf);
-
}
public void updateFolderAndSubfolders(final DnDTreeItem folderItem) {
final String path = folderItem.getFolderResource().getUri();
GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path) {
+ @Override
public void onComplete() {
FolderResource rootResource = getResult();
if (!folderItem.equals(rootItem)) {
updateSubfolders(folderItem);
}
+ @Override
public void onError(Throwable t) {
GWT.log("Error fetching folder", t);
GSS.get().displayError("Unable to fetch folder:" + folderItem.getFolderResource().getName());
}
};
DeferredCommand.addCommand(gf);
-
}
/**
return rootItem;
}
-
-
}
private DnDTreeItem rootItem;
- public MyShareSubtree(PopupTree tree, final Images _images) {
- super(tree, _images);
+ public MyShareSubtree(PopupTree aTree, final Images _images) {
+ super(aTree, _images);
DeferredCommand.addCommand(new IncrementalCommand() {
GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, userResource.getSharedPath()) {
+ @Override
public void onComplete() {
rootItem = new DnDTreeItem(imageItemHTML(images.myShared(), "My Shared"), "My Shared", false);
rootItem.setUserObject(getResult());
update(rootItem);
}
+ @Override
public void onError(Throwable t) {
GWT.log("Error fetching Shared Root folder", t);
GSS.get().displayError("Unable to fetch Shared Root folder");
};
DeferredCommand.addCommand(gs);
return DONE;
-
}
public void update(final DnDTreeItem folderItem) {
folderItem.removeItems();
List<String> newPaths = new ArrayList<String>();
for (String s : folderItem.getFolderResource().getSubfolderPaths()) {
-
if (!s.endsWith("/"))
s = s + "/";
if (rootItem.getSharedResource().getSubfolderPaths().contains(s))
folderItem.getFolderResource().setSubfolderPaths(newPaths);
MultipleGetCommand<FolderResource> gf = new MultipleGetCommand<FolderResource>(FolderResource.class, newPaths.toArray(new String[] {})) {
+ @Override
public void onComplete() {
List<FolderResource> res = getResult();
for (FolderResource r : res) {
-
DnDTreeItem child = (DnDTreeItem) addImageItem(folderItem, r.getName(), images.folderYellow(), true);
child.setUserObject(r);
child.setState(false);
if(folderItem.getState())
update(child);
}
-
}
+ @Override
public void onError(Throwable t) {
GSS.get().displayError("Unable to fetch subfolders");
GWT.log("Unable to fetch subfolders", t);
newPaths.add(r);
MultipleGetCommand<FolderResource> gf = new MultipleGetCommand<FolderResource>(FolderResource.class, newPaths.toArray(new String[] {})) {
+ @Override
public void onComplete() {
List<FolderResource> res = getResult();
for (FolderResource r : res) {
child.doDraggable();
update(child);
}
-
}
+ @Override
public void onError(Throwable t) {
GSS.get().displayError("Unable to fetch subfolders");
GWT.log("Unable to fetch subfolders", t);
}
}
- private void handleFolders(DnDTreeItem child, FolderResource ff, List<FolderResource> folders) {
-
- }
-
- private boolean isRoot(FolderResource f, List<FolderResource> folders) {
- for (FolderResource t : folders)
- if (!f.getUri().equals(t.getUri()) && f.getUri().startsWith(t.getUri()))
- return false;
- return true;
- }
-
private boolean isRoot(String f, List<String> folders) {
for (String t : folders)
if (!f.equals(t) && f.startsWith(t))
return true;
}
-
-
public void updateFolderAndSubfolders(final DnDTreeItem folderItem) {
if (folderItem.getFolderResource() != null) {
final String path = folderItem.getFolderResource().getUri();
GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, GSS.get().getCurrentUserResource().getSharedPath()) {
+ @Override
public void onComplete() {
rootItem.setUserObject(getResult());
GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path) {
+ @Override
public void onComplete() {
FolderResource rootResource = getResult();
if(rootItem.getSharedResource().getSubfolderPaths().contains(rootResource.getUri())){
folderItem.getParentItem().removeItem(folderItem);
}
+ @Override
public void onError(Throwable t) {
GWT.log("Error fetching folder", t);
GSS.get().displayError("Unable to fetch folder:" + folderItem.getFolderResource().getName());
DeferredCommand.addCommand(gf);
}
+ @Override
public void onError(Throwable t) {
GWT.log("Error fetching Shared Root folder", t);
GSS.get().displayError("Unable to fetch Shared Root folder");
}
};
DeferredCommand.addCommand(gs);
-
}
else if( folderItem.getSharedResource() != null){
GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, GSS.get().getCurrentUserResource().getSharedPath()) {
+ @Override
public void onComplete() {
rootItem.setUserObject(getResult());
rootItem.removeItems();
update(rootItem);
}
+ @Override
public void onError(Throwable t) {
GWT.log("Error fetching Shared Root folder", t);
GSS.get().displayError("Unable to fetch Shared Root folder");
};
DeferredCommand.addCommand(gs);
}
-
}
/**
return rootItem;
}
-
-
-
public void updateNode(TreeItem node, FolderResource folder) {
node.getWidget().removeStyleName("gss-SelectedRow");
if (node instanceof DnDTreeItem) {
final Images images;
- public Subtree(PopupTree tree, final Images _images) {
+ public Subtree(PopupTree aTree, final Images _images) {
images = _images;
- this.tree = tree;
-
+ tree = aTree;
}
/**
return item;
}
-
-
/**
* Generates HTML for a tree item with an attached icon.
*
item.updateWidget(imageItemHTML(image, subfolder.getName()));
item.setUserObject(subfolder);
itemList.add(item);
-
}
for (DnDTreeItem it : itemList)
it.remove();
for (int i = 0; i < folderItem.getChildCount(); i++) {
DnDTreeItem c = (DnDTreeItem) folderItem.getChild(i);
c.doDraggable();
- FolderResource f = (FolderResource) c.getUserObject();
}
}
-
-
private boolean listContainsFolder(FolderResource folder, List<FolderResource> subfolders) {
for (FolderResource f : subfolders)
if (f.getUri().equals(folder.getUri()))
return false;
}
-
}
import com.google.gwt.user.client.IncrementalCommand;
import com.google.gwt.user.client.ui.TreeItem;
-
-
/**
* @author kman
*/
private DnDTreeItem rootItem;
- public TrashSubtree(PopupTree tree, final Images _images) {
- super(tree, _images);
-
+ public TrashSubtree(PopupTree aTree, final Images _images) {
+ super(aTree, _images);
DeferredCommand.addCommand(new IncrementalCommand() {
public boolean execute() {
}
public boolean updateInit() {
-
UserResource userResource = GSS.get().getCurrentUserResource();
if ( userResource == null || GSS.get().getFolders().getRootItem() == null)
return !DONE;
update();
return DONE;
-
}
public void update() {
DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, GSS.get().getCurrentUserResource().getTrashPath()) {
+ @Override
public void onComplete() {
if(rootItem == null){
rootItem = new DnDTreeItem(imageItemHTML(images.trash(), "Trash"), "Trash", false);
}
}
+ @Override
public void onError(Throwable t) {
if(t instanceof RestException){
int statusCode = ((RestException)t).getHttpStatusCode();
- //empty trash ie returns 1223 status code instead of 204
+ // On IE status code 1223 may be returned instead of 204.
if(statusCode == 204 || statusCode == 1223){
GWT.log("Trash is empty", null);
if(rootItem == null){
}
}
});
-
}
/**