drop implementation for files, initial drag support for folders
[pithos] / src / gr / ebs / gss / client / CellTreeViewModel.java
1 /*
2  * Copyright 2011 Electronic Business Systems Ltd.
3  *
4  * This file is part of GSS.
5  *
6  * GSS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 package gr.ebs.gss.client;
20
21 import gr.ebs.gss.client.CellTreeView.Images;
22 import gr.ebs.gss.client.CellTreeView.RefreshHandler;
23 import gr.ebs.gss.client.rest.GetCommand;
24 import gr.ebs.gss.client.rest.MultipleGetCommand;
25 import gr.ebs.gss.client.rest.RestException;
26 import gr.ebs.gss.client.rest.resource.FileResource;
27 import gr.ebs.gss.client.rest.resource.FolderResource;
28 import gr.ebs.gss.client.rest.resource.MyFolderResource;
29 import gr.ebs.gss.client.rest.resource.OtherUserResource;
30 import gr.ebs.gss.client.rest.resource.OthersFolderResource;
31 import gr.ebs.gss.client.rest.resource.OthersResource;
32 import gr.ebs.gss.client.rest.resource.RestResource;
33 import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
34 import gr.ebs.gss.client.rest.resource.SharedFolderResource;
35 import gr.ebs.gss.client.rest.resource.SharedResource;
36 import gr.ebs.gss.client.rest.resource.TrashFolderResource;
37 import gr.ebs.gss.client.rest.resource.TrashResource;
38 import gwtquery.plugins.draggable.client.DraggableOptions;
39 import gwtquery.plugins.draggable.client.DraggableOptions.CursorAt;
40 import gwtquery.plugins.draggable.client.DraggableOptions.DragFunction;
41 import gwtquery.plugins.draggable.client.DraggableOptions.RevertOption;
42 import gwtquery.plugins.draggable.client.events.DragContext;
43 import gwtquery.plugins.droppable.client.DroppableOptions;
44 import gwtquery.plugins.droppable.client.DroppableOptions.DroppableFunction;
45 import gwtquery.plugins.droppable.client.events.DragAndDropContext;
46 import gwtquery.plugins.droppable.client.gwt.DragAndDropNodeInfo;
47
48 import java.util.ArrayList;
49 import java.util.Arrays;
50 import java.util.HashMap;
51 import java.util.List;
52 import java.util.Map;
53 import static com.google.gwt.query.client.GQuery.$;
54
55 import com.google.gwt.cell.client.AbstractCell;
56 import com.google.gwt.cell.client.Cell;
57 import com.google.gwt.cell.client.ValueUpdater;
58 import com.google.gwt.core.client.GWT;
59 import com.google.gwt.dom.client.Style.Cursor;
60 import com.google.gwt.safehtml.client.SafeHtmlTemplates;
61 import com.google.gwt.safehtml.client.SafeHtmlTemplates.Template;
62 import com.google.gwt.safehtml.shared.SafeHtml;
63 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
64 import com.google.gwt.user.client.DeferredCommand;
65 import com.google.gwt.user.client.ui.AbstractImagePrototype;
66 import com.google.gwt.view.client.AsyncDataProvider;
67 import com.google.gwt.view.client.HasData;
68 import com.google.gwt.view.client.ListDataProvider;
69 import com.google.gwt.view.client.ProvidesKey;
70 import com.google.gwt.view.client.SingleSelectionModel;
71 import com.google.gwt.view.client.TreeViewModel;
72
73
74
75 /**
76  * @author kman
77  *
78  */
79 public class CellTreeViewModel implements TreeViewModel{
80         private final ListDataProvider<RestResource> rootNodes = new ListDataProvider<RestResource>();
81         final Images images;
82         SingleSelectionModel<RestResource> selectionModel;
83         Map<String, MyFolderDataProvider> mymap = new HashMap<String, MyFolderDataProvider>();
84         static interface Templates extends SafeHtmlTemplates {
85             Templates INSTANCE = GWT.create(Templates.class);
86
87             @Template(" <div id='dragHelper' class='{0}'></div>")
88             SafeHtml outerHelper(String cssClassName);
89           }
90
91         static void configureDragOperation(DraggableOptions options) {
92
93             // set a custom element as drag helper. The content of the helper will be
94             // set when the drag will start
95             options.setHelper($(Templates.INSTANCE.outerHelper(
96                 "drag").asString()));
97             // opacity of the drag helper
98             options.setOpacity((float) 0.9);
99             // cursor during the drag operation
100             options.setCursor(Cursor.MOVE);
101             // the cell being greater than the helper, force the position of the
102             // helper on the mouse cursor.
103             options.setCursorAt(new CursorAt(10, 10, null, null));
104             // append the helper to the body element
105             options.setAppendTo("body");
106             // set the revert option
107             options.setRevert(RevertOption.ON_INVALID_DROP);
108             // use a Function to fill the content of the helper
109             // we could also add a DragStartEventHandler on the DragAndDropTreeCell and
110             // DragAndDropCellList.
111             options.setOnDragStart(new DragFunction() {
112               public void f(DragContext context) {
113                 RestResourceWrapper memberInfo = context.getDraggableData();
114                 context.getHelper().setInnerHTML(memberInfo.getName());
115               }
116             });
117
118           }
119
120         /**
121          * 
122          */
123         public CellTreeViewModel(final Images _images,SingleSelectionModel<RestResource> selectionModel ) {
124                 super();
125                 images=_images;
126                 this.selectionModel=selectionModel;
127         }
128         
129         private final Cell<RestResource> departmentCell = new AbstractCell<RestResource>("contextmenu"){
130                 
131                 @Override
132                 public void render(com.google.gwt.cell.client.Cell.Context arg0, RestResource arg1, SafeHtmlBuilder arg2) {
133                         String html=null;
134                         String name=null;
135                         if(arg1 instanceof TrashFolderResource){
136                                 html = AbstractImagePrototype.create(images.folderYellow()).getHTML();
137                                 FolderResource res = ((RestResourceWrapper)arg1).getResource();
138                                 name=res.getName();
139                         }
140                         else if(arg1 instanceof RestResourceWrapper){
141                                 FolderResource res = ((RestResourceWrapper)arg1).getResource();
142                                 if(res.isShared())
143                                         html = AbstractImagePrototype.create(images.sharedFolder()).getHTML();
144                                 else if(res.getParentName()==null){
145                                         html = AbstractImagePrototype.create(images.home()).getHTML();
146                                 }
147                                 else
148                                         html = AbstractImagePrototype.create(images.folderYellow()).getHTML();
149                                 name = res.getName();
150                                 
151                         }
152                         else if(arg1 instanceof TrashResource){
153                                 html = AbstractImagePrototype.create(images.trash()).getHTML();
154                                 name="Trash";
155                         }
156                         
157                         else if(arg1 instanceof SharedResource){
158                                 html = AbstractImagePrototype.create(images.myShared()).getHTML();
159                                 name="My Shared";
160                         }
161                         else if(arg1 instanceof OthersResource){
162                                 html = AbstractImagePrototype.create(images.othersShared()).getHTML();
163                                 name = "Other's Shared";
164                         }
165                         else if(arg1 instanceof OtherUserResource){
166                                 html = AbstractImagePrototype.create(images.permUser()).getHTML();
167                                 name = ((OtherUserResource)arg1).getName();
168                         }
169                         arg2.appendHtmlConstant(html);
170                         arg2.appendHtmlConstant("<span class='papala'>");
171                         arg2.appendEscaped(name);
172                         arg2.appendHtmlConstant("</span>");
173                 }
174                 
175                 public void onBrowserEvent(Cell.Context context, com.google.gwt.dom.client.Element parent, RestResource value, com.google.gwt.dom.client.NativeEvent event, com.google.gwt.cell.client.ValueUpdater<RestResource> valueUpdater) {
176                         if(event.getType().equals("contextmenu")){
177                                 selectionModel.setSelected(value, true);
178                                 GSS.get().getTreeView().showPopup(event.getClientX(), event.getClientY());
179                         }
180                 };
181                 
182         };
183         
184         
185         @Override
186         public <T> NodeInfo<?> getNodeInfo(final T value) {
187                 
188                 if(value==null){
189                         return new DragAndDropNodeInfo<RestResource>(getRootNodes(), departmentCell,
190                                     selectionModel, null);
191                 }
192                 else if (value instanceof MyFolderResource) {
193                 // Second level.
194                         MyFolderDataProvider dataProvider = new MyFolderDataProvider(
195                     ((MyFolderResource) value),MyFolderResource.class);
196                 DragAndDropNodeInfo<RestResource> n =  new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
197                     selectionModel, new ResourceValueUpdater());
198                 //nodeInfos.put(((MyFolderResource) value).getUri(), n);
199                 mymap.put(((MyFolderResource) value).getUri(), dataProvider);
200                 DroppableOptions options = n.getDroppableOptions();
201                 options.setDroppableHoverClass("droppableHover");
202                 // use a DroppableFunction here. We can also add a DropHandler in the tree
203                 // itself
204                 options.setOnDrop(new DroppableFunction() {
205
206                   public void f(DragAndDropContext context) {
207                           
208                           DnDFolderPopupMenu popup ;
209                           if(context.getDraggableData() instanceof FileResource){
210                                   popup = new DnDFolderPopupMenu(images, ((MyFolderResource) context.getDroppableData()).getResource(), Arrays.asList(context.getDraggableData()));
211                           }
212                           else
213                                   popup = new DnDFolderPopupMenu(images, ((MyFolderResource) context.getDroppableData()).getResource(), context.getDraggableData());
214                           int left = context.getDroppable().getAbsoluteLeft() + 40;
215                   int top = context.getDroppable().getAbsoluteTop() + 20;
216                   popup.setPopupPosition(left, top);
217                          
218                           popup.show();
219                   }
220                 });
221                 // permission cell are not draggable
222                 //n.setCellDroppableOnly();
223                 configureDragOperation(n.getDraggableOptions());
224                 return n;
225                 }
226                 else if (value instanceof SharedResource) {
227                 // Second level.
228                         MyFolderDataProvider dataProvider = new MyFolderDataProvider(
229                     ((SharedResource) value), SharedFolderResource.class);
230                 return new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
231                     selectionModel, new ResourceValueUpdater());
232                 }
233                 else if (value instanceof TrashResource) {
234                 // Second level.
235                         ListDataProvider<RestResource> trashProvider = new ListDataProvider<RestResource>();
236                         List<RestResource> r = new ArrayList<RestResource>();
237                         for(FolderResource f : GSS.get().getTreeView().getTrash().getFolders()){
238                                 r.add(new TrashFolderResource(f));
239                         }
240                         trashProvider.setList(r);
241                 return new DragAndDropNodeInfo<RestResource>(trashProvider, departmentCell,
242                     selectionModel, new ResourceValueUpdater());
243                 }
244                 else if (value instanceof OthersResource) {
245                 // Second level.
246                         OthersDataProvider dataProvider = new OthersDataProvider(
247                     ((OthersResource) value), SharedFolderResource.class);
248                 return new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
249                     selectionModel, null);
250                 }
251                 else if (value instanceof SharedFolderResource) {
252                 // Second level.
253                         MyFolderDataProvider dataProvider = new MyFolderDataProvider(
254                     ((SharedFolderResource) value),SharedFolderResource.class);
255                 DragAndDropNodeInfo<RestResource> n =  new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
256                     selectionModel, new ResourceValueUpdater());
257                 //nodeInfos.put(((SharedFolderResource) value).getUri(), n);
258                 DroppableOptions options = n.getDroppableOptions();
259                 options.setDroppableHoverClass("droppableHover");
260                 // use a DroppableFunction here. We can also add a DropHandler in the tree
261                 // itself
262                 options.setOnDrop(new DroppableFunction() {
263
264                   public void f(DragAndDropContext context) {
265                           GWT.log("DROPPED");
266                     
267                   }
268                 });
269                 // permission cell are not draggable
270                 n.setCellDroppableOnly();
271                 return n;
272                 }
273                 else if (value instanceof OthersFolderResource) {
274                 // Second level.
275                         MyFolderDataProvider dataProvider = new MyFolderDataProvider(
276                     ((OthersFolderResource) value),OthersFolderResource.class);
277                 DragAndDropNodeInfo<RestResource> n =  new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
278                     selectionModel, new ResourceValueUpdater());
279                 //nodeInfos.put(((OthersFolderResource) value).getUri(), n);
280                 DroppableOptions options = n.getDroppableOptions();
281                 options.setDroppableHoverClass("droppableHover");
282                 // use a DroppableFunction here. We can also add a DropHandler in the tree
283                 // itself
284                 options.setOnDrop(new DroppableFunction() {
285
286                   public void f(DragAndDropContext context) {
287                           GWT.log("DROPPED");
288                     
289                   }
290                 });
291                 // permission cell are not draggable
292                 n.setCellDroppableOnly();
293                 return n;
294                 }
295                 else if (value instanceof OtherUserResource) {
296                 // Second level.
297                         MyFolderDataProvider dataProvider = new MyFolderDataProvider(
298                     ((OtherUserResource) value),OthersFolderResource.class);
299                 DragAndDropNodeInfo<RestResource> n =  new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
300                     selectionModel, new ResourceValueUpdater());
301                 //nodeInfos.put(((OtherUserResource) value).getUri(), n);
302                 DroppableOptions options = n.getDroppableOptions();
303                 options.setDroppableHoverClass("droppableHover");
304                 // use a DroppableFunction here. We can also add a DropHandler in the tree
305                 // itself
306                 options.setOnDrop(new DroppableFunction() {
307
308                   public void f(DragAndDropContext context) {
309                           GWT.log("DROPPED");
310                     
311                   }
312                 });
313                 // permission cell are not draggable
314                 n.setCellDroppableOnly();
315                 return n;
316                 }
317                 // TODO Auto-generated method stub
318                 return null;
319         }
320
321         @Override
322         public boolean isLeaf(Object value) {
323                 if(value instanceof RestResourceWrapper)
324                         return ((RestResourceWrapper)value).getResource().getFolders().size()==0;
325                 else if(value instanceof TrashResource)
326                         return ((TrashResource)value).getFolders().size()==0;
327                 else if(value instanceof SharedResource)
328                         return ((SharedResource)value).getFolders().size()==0;
329                 else if(value instanceof OthersResource)
330                         return ((OthersResource)value).getOtherUsers().size()==0;
331                 else if(value instanceof OtherUserResource)
332                         return ((OtherUserResource)value).getFolders().size()==0;
333                 return false;
334         }
335         
336         class ResourceValueUpdater implements  ValueUpdater<RestResource>{
337
338                 @Override
339                 public void update(final RestResource value) {
340                         if(value instanceof MyFolderResource){
341                                 GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
342
343                                         @Override
344                                         public void onComplete() {
345                                                 FolderResource rootResource = getResult();
346                                                 ((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
347                                                 if(GSS.get().getTreeView().getSelection().getUri().equals(value.getUri()))
348                                                         selectionModel.setSelected(value, true);
349                                                 GWT.log("UPDATYING");
350                                                 GSS.get().onResourceUpdate(value);
351                                                 
352                                         }
353         
354                                         @Override
355                                         public void onError(Throwable t) {
356                                                 GWT.log("Error fetching root folder", t);
357                                                 GSS.get().displayError("Unable to fetch root folder");
358                                         }
359         
360                                 };
361                                 DeferredCommand.addCommand(gf);
362                         }
363                         if(value instanceof TrashResource){
364                                 DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, GSS.get().getCurrentUserResource().getTrashPath(), null) {
365                                         @Override
366                                         public void onComplete() {
367                                                 //trash = getResult();
368                                                 for(RestResource r : getRootNodes().getList()){
369                                                         if(r instanceof TrashResource)
370                                                                 getRootNodes().getList().set(getRootNodes().getList().indexOf(r),GSS.get().getTreeView().getTrash());
371                                                 }
372                                                 GSS.get().getTreeView().updateNodeChildren(GSS.get().getTreeView().getTrash());
373                                         }
374
375                                         @Override
376                                         public void onError(Throwable t) {
377                                                 if(t instanceof RestException){
378                                                         int statusCode = ((RestException)t).getHttpStatusCode();
379                                                         // On IE status code 1223 may be returned instead of 204.
380                                                         if(statusCode == 204 || statusCode == 1223){
381                                                                 //trash = new TrashResource(GSS.get().getCurrentUserResource().getTrashPath());
382                                                 }
383                                                 else{
384                                                         GWT.log("", t);
385                                                         GSS.get().displayError("Unable to fetch trash folder:"+t.getMessage());
386                                                         //GSS.get().getTreeView().getTrash() = new TrashResource(GSS.get().getCurrentUserResource().getTrashPath());
387                                                 }
388                                         }
389                                 }
390                                 });
391                         }
392                         
393                 }
394                 
395         }
396         class MyFolderDataProvider extends AsyncDataProvider<RestResource>{
397                 private RestResource restResource;
398                 private Class resourceClass;
399                   public MyFolderDataProvider(RestResource department, Class resourceClass) {
400                     super(new ProvidesKey<RestResource>() {
401
402                                 @Override
403                                 public Object getKey(RestResource item) {
404                                         return item.getUri();
405                                 }});
406                     this.restResource = department;
407                     this.resourceClass=resourceClass;
408                     //CellTreeView.this.mymap.put(department.getUri(), MyFolderDataProvider.this);
409                   }
410
411                   @Override
412                   protected void onRangeChanged(final HasData<RestResource> view) {
413                         refresh(null);
414                   }
415                   
416                 /**
417                  * Retrieve the restResource.
418                  *
419                  * @return the restResource
420                  */
421                 public RestResource getRestResource() {
422                         return restResource;
423                 }
424                 
425                 
426                 /**
427                  * Modify the restResource.
428                  *
429                  * @param restResource the restResource to set
430                  */
431                 public void setRestResource(RestResource restResource) {
432                         this.restResource = restResource;
433                 }
434                 
435                   public void refresh(final RefreshHandler refresh){
436                           GWT.log("******************************************");
437                           GWT.log("[REFRESHING]:"+restResource.getUri());
438                           GWT.log("******************************************");
439                           GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, restResource.getUri(), null) {
440
441                                         @Override
442                                         public void onComplete() {
443                                                 if(restResource instanceof RestResourceWrapper)
444                                                         ((RestResourceWrapper)restResource).setResource(getResult());//restResource = getResult();
445                                                 
446                                                 //if(CellTreeView.this.mymap.get(restResource.getUri())!=null)
447                                                         //CellTreeView.this.mymap.get(restResource.getUri()).setRestResource(restResource);
448                                                 String[] folderPaths = null;
449                                                 if(resourceClass.equals(MyFolderResource.class))
450                                                         folderPaths=((MyFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
451                                                 else if(resourceClass.equals(SharedFolderResource.class) && restResource instanceof SharedResource)
452                                                         folderPaths=((SharedResource) restResource).getSubfolderPaths().toArray(new String[] {});
453                                                 else if(resourceClass.equals(SharedFolderResource.class)){
454                                                         folderPaths=((SharedFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
455                                                         GWT.log("------------>"+folderPaths);
456                                                 }
457                                                 else if(resourceClass.equals(TrashFolderResource.class))
458                                                         folderPaths=((TrashFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
459                                                 else if(resourceClass.equals(OthersFolderResource.class) && restResource instanceof OtherUserResource)
460                                                         folderPaths=((OtherUserResource) restResource).getSubfolderPaths().toArray(new String[] {});
461                                                 else if(resourceClass.equals(OthersFolderResource.class))
462                                                         folderPaths=((OthersFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
463                                                 MultipleGetCommand<FolderResource> gf2 = new MultipleGetCommand<FolderResource>(FolderResource.class,
464                                                                         folderPaths, null) {
465
466                                                         @Override
467                                                         public void onComplete() {
468                                                                 List<RestResource> res = new ArrayList<RestResource>();
469                                                                 for(FolderResource r : getResult()){
470                                                                         if(r.isDeleted()){
471                                                                                 
472                                                                         }
473                                                                         else if(resourceClass.equals(MyFolderResource.class))
474                                                                                 res.add(new MyFolderResource(r));
475                                                                         else if(resourceClass.equals(SharedFolderResource.class)){
476                                                                                 GWT.log("ADDING:"+r.getUri());
477                                                                                 res.add(new SharedFolderResource(r));
478                                                                         }
479                                                                         else if(resourceClass.equals(TrashFolderResource.class))
480                                                                                 res.add(new TrashFolderResource(r));
481                                                                         else if(resourceClass.equals(OthersFolderResource.class))
482                                                                                 res.add(new OthersFolderResource(r));
483                                                                 }
484                                                                 updateRowCount(res.size(), true);
485                                                                 updateRowData(0,res);
486                                                                 if(refresh!=null)
487                                                                         refresh.onRefresh();
488                                                         }
489
490                                                         @Override
491                                                         public void onError(Throwable t) {
492                                                                 GSS.get().displayError("Unable to fetch subfolders");
493                                                                 GWT.log("Unable to fetch subfolders", t);
494                                                         }
495
496                                                         @Override
497                                                         public void onError(String p, Throwable throwable) {
498                                                                 GWT.log("Path:"+p, throwable);
499                                                         }
500
501                                                 };
502                                                 DeferredCommand.addCommand(gf2);
503                                                 
504                                         }
505
506                                         @Override
507                                         public void onError(Throwable t) {
508                                                 GWT.log("Error fetching root folder", t);
509                                                 GSS.get().displayError("Unable to fetch root folder");
510                                         }
511
512                                 };
513                                 DeferredCommand.addCommand(gf);
514                   }               
515         }
516         
517         
518         class OthersDataProvider extends AsyncDataProvider<RestResource>{
519                 private RestResource restResource;
520                 private Class resourceClass;
521                   public OthersDataProvider(RestResource department, Class resourceClass) {
522                     super(new ProvidesKey<RestResource>() {
523
524                                 @Override
525                                 public Object getKey(RestResource item) {
526                                         return item.getUri();
527                                 }});
528                     this.restResource = department;
529                     this.resourceClass=resourceClass;
530                     //CellTreeView.this.mymap.put(department.getUri(), OthersDataProvider.this);
531                   }
532
533                   @Override
534                   protected void onRangeChanged(final HasData<RestResource> view) {
535                         refresh(null);
536                   }
537                   
538                 /**
539                  * Retrieve the restResource.
540                  *
541                  * @return the restResource
542                  */
543                 public RestResource getRestResource() {
544                         return restResource;
545                 }
546                 
547                 
548                 /**
549                  * Modify the restResource.
550                  *
551                  * @param restResource the restResource to set
552                  */
553                 public void setRestResource(RestResource restResource) {
554                         this.restResource = restResource;
555                 }
556                 
557                   public void refresh(final RefreshHandler refresh){
558                           GWT.log("******************************************");
559                           GWT.log("[REFRESHING]:"+restResource.getUri());
560                           GWT.log("******************************************");
561                           GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
562                           restResource.getUri(), null) {
563
564                                   @Override
565                                   public void onComplete() {
566                                           final OthersResource others = getResult();
567                           MultipleGetCommand<OtherUserResource> gogo = new MultipleGetCommand<OtherUserResource>(OtherUserResource.class,
568                                                   others.getOthers().toArray(new String[] {}), null) {
569
570                                   @Override
571                                   public void onComplete() {
572                                           List<OtherUserResource> res = getResult();
573                                           updateRowCount(res.size(), true);
574                                           List<RestResource> r = new ArrayList<RestResource>();
575                                           r.addAll(res);
576                                                                           updateRowData(0,r);
577                                   }
578
579                                   @Override
580                                   public void onError(Throwable t) {
581                                           GWT.log("Error fetching Others Root folder", t);
582                                           GSS.get().displayError("Unable to fetch Others Root folder");
583                                   }
584
585                                   @Override
586                                   public void onError(String p, Throwable throwable) {
587                                           GWT.log("Path:"+p, throwable);
588                                   }
589                           };
590                           DeferredCommand.addCommand(gogo);
591                                   }
592                         
593                                   @Override
594                                   public void onError(Throwable t) {
595                                           GWT.log("Error fetching Others Root folder", t);
596                                           GSS.get().displayError("Unable to fetch Others Root folder");
597                                   }
598                           };
599                           DeferredCommand.addCommand(go);
600                   }               
601         }
602
603
604         
605         /**
606          * Retrieve the rootNodes.
607          *
608          * @return the rootNodes
609          */
610         public ListDataProvider<RestResource> getRootNodes() {
611                 return rootNodes;
612         }
613
614         
615         /**
616          * Retrieve the mymap.
617          *
618          * @return the mymap
619          */
620         public Map<String, MyFolderDataProvider> getMymap() {
621                 return mymap;
622         }
623         
624         
625         
626         
627 }