2 * Copyright 2011 Electronic Business Systems Ltd.
4 * This file is part of GSS.
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.
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.
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/>.
19 package gr.ebs.gss.client;
21 import static com.google.gwt.query.client.GQuery.$;
22 import gr.ebs.gss.client.CellTreeView.Images;
23 import gr.ebs.gss.client.CellTreeView.RefreshHandler;
24 import gr.ebs.gss.client.rest.GetCommand;
25 import gr.ebs.gss.client.rest.MultipleGetCommand;
26 import gr.ebs.gss.client.rest.RestException;
27 import gr.ebs.gss.client.rest.resource.FileResource;
28 import gr.ebs.gss.client.rest.resource.FolderResource;
29 import gr.ebs.gss.client.rest.resource.MyFolderResource;
30 import gr.ebs.gss.client.rest.resource.OtherUserResource;
31 import gr.ebs.gss.client.rest.resource.OthersFolderResource;
32 import gr.ebs.gss.client.rest.resource.OthersResource;
33 import gr.ebs.gss.client.rest.resource.RestResource;
34 import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
35 import gr.ebs.gss.client.rest.resource.SharedFolderResource;
36 import gr.ebs.gss.client.rest.resource.SharedResource;
37 import gr.ebs.gss.client.rest.resource.TrashFolderResource;
38 import gr.ebs.gss.client.rest.resource.TrashResource;
39 import gwtquery.plugins.draggable.client.DragAndDropManager;
40 import gwtquery.plugins.draggable.client.DraggableOptions;
41 import gwtquery.plugins.draggable.client.StopDragException;
42 import gwtquery.plugins.draggable.client.DraggableOptions.CursorAt;
43 import gwtquery.plugins.draggable.client.DraggableOptions.DragFunction;
44 import gwtquery.plugins.draggable.client.DraggableOptions.RevertOption;
45 import gwtquery.plugins.draggable.client.events.DragContext;
46 import gwtquery.plugins.droppable.client.DroppableOptions;
47 import gwtquery.plugins.droppable.client.DroppableOptions.DroppableFunction;
48 import gwtquery.plugins.droppable.client.events.DragAndDropContext;
49 import gwtquery.plugins.droppable.client.gwt.DragAndDropNodeInfo;
51 import java.util.ArrayList;
52 import java.util.Arrays;
53 import java.util.HashMap;
54 import java.util.List;
57 import com.google.gwt.cell.client.AbstractCell;
58 import com.google.gwt.cell.client.Cell;
59 import com.google.gwt.cell.client.ValueUpdater;
60 import com.google.gwt.core.client.GWT;
61 import com.google.gwt.dom.client.Style.Cursor;
62 import com.google.gwt.query.client.plugins.GQueryUi;
63 import com.google.gwt.safehtml.client.SafeHtmlTemplates;
64 import com.google.gwt.safehtml.shared.SafeHtml;
65 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
66 import com.google.gwt.user.client.DeferredCommand;
67 import com.google.gwt.user.client.Window;
68 import com.google.gwt.user.client.ui.AbstractImagePrototype;
69 import com.google.gwt.view.client.AsyncDataProvider;
70 import com.google.gwt.view.client.HasData;
71 import com.google.gwt.view.client.ListDataProvider;
72 import com.google.gwt.view.client.ProvidesKey;
73 import com.google.gwt.view.client.SingleSelectionModel;
74 import com.google.gwt.view.client.TreeViewModel;
82 public class CellTreeViewModel implements TreeViewModel{
84 private final ListDataProvider<RestResource> rootNodes = new ListDataProvider<RestResource>();
85 private Map<String,FolderResource> folderCache=new HashMap<String, FolderResource>();
87 SingleSelectionModel<RestResource> selectionModel;
88 Map<String, MyFolderDataProvider> mymap = new HashMap<String, MyFolderDataProvider>();
89 Map<String, MyFolderDataProvider> sharedmap = new HashMap<String, MyFolderDataProvider>();
90 Map<String, MyFolderDataProvider> othersmap = new HashMap<String, MyFolderDataProvider>();
91 static interface Templates extends SafeHtmlTemplates {
92 Templates INSTANCE = GWT.create(Templates.class);
94 @Template(" <div id='dragHelper' class='{0}'></div>")
95 SafeHtml outerHelper(String cssClassName);
98 void configureDragOperation(final DraggableOptions options) {
100 // set a custom element as drag helper. The content of the helper will be
101 // set when the drag will start
102 options.setHelper($(Templates.INSTANCE.outerHelper(
103 "drag").asString()));
104 // opacity of the drag helper
105 options.setOpacity((float) 0.9);
106 // cursor during the drag operation
107 options.setCursor(Cursor.MOVE);
108 // the cell being greater than the helper, force the position of the
109 // helper on the mouse cursor.
110 options.setCursorAt(new CursorAt(10, 10, null, null));
111 // append the helper to the body element
112 options.setAppendTo("body");
113 options.setCancel("select");
114 // set the revert option
115 options.setRevert(RevertOption.ON_INVALID_DROP);
117 options.setOnBeforeDragStart(new DragFunction() {
120 public void f(DragContext context) {
121 RestResource value = context.getDraggableData();
122 if(!CellTreeViewModel.this.selectionModel.isSelected(value)){
123 throw new StopDragException();
125 if(value instanceof TrashResource || value instanceof SharedResource || value instanceof OthersResource || value instanceof OtherUserResource){
126 throw new StopDragException();
131 // use a Function to fill the content of the helper
132 // we could also add a DragStartEventHandler on the DragAndDropTreeCell and
133 // DragAndDropCellList.
135 options.setOnDragStart(new DragFunction() {
136 public void f(DragContext context) {
137 RestResourceWrapper memberInfo = context.getDraggableData();
138 context.getHelper().setInnerHTML(memberInfo.getName());
147 public CellTreeViewModel(final Images _images,SingleSelectionModel<RestResource> selectionModel ) {
150 this.selectionModel=selectionModel;
153 private final Cell<RestResource> departmentCell = new AbstractCell<RestResource>("contextmenu"){
156 public void render(com.google.gwt.cell.client.Cell.Context arg0, RestResource arg1, SafeHtmlBuilder arg2) {
160 if(arg1 instanceof TrashFolderResource){
161 html = AbstractImagePrototype.create(images.folderYellow()).getHTML();
162 FolderResource res = ((RestResourceWrapper)arg1).getResource();
163 name = res.getName();
164 id = res.getParentName() +"."+name;
166 else if(arg1 instanceof RestResourceWrapper){
167 FolderResource res = ((RestResourceWrapper)arg1).getResource();
169 html = AbstractImagePrototype.create(images.sharedFolder()).getHTML();
170 else if(res.getParentName()==null){
171 html = AbstractImagePrototype.create(images.home()).getHTML();
174 html = AbstractImagePrototype.create(images.folderYellow()).getHTML();
175 name = res.getName();
176 if(res.getParentName() != null){
177 id = res.getParentName()+"."+name;
183 else if(arg1 instanceof TrashResource){
184 html = AbstractImagePrototype.create(images.trash()).getHTML();
189 else if(arg1 instanceof SharedResource){
190 html = AbstractImagePrototype.create(images.myShared()).getHTML();
194 else if(arg1 instanceof OthersResource){
195 html = AbstractImagePrototype.create(images.othersShared()).getHTML();
196 name = "Other's Shared";
199 else if(arg1 instanceof OtherUserResource){
200 html = AbstractImagePrototype.create(images.permUser()).getHTML();
201 name = ((OtherUserResource)arg1).getName();
204 arg2.appendHtmlConstant(html);
205 arg2.appendHtmlConstant("<span id='"+id +"'"+ " class='papala'>");
206 arg2.appendEscaped(name);
207 arg2.appendHtmlConstant("</span>");
210 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) {
211 if(event.getType().equals("contextmenu")){
212 selectionModel.setSelected(value, true);
213 GSS.get().setCurrentSelection(value);
214 GSS.get().getTreeView().showPopup(event.getClientX(), event.getClientY());
222 public <T> NodeInfo<?> getNodeInfo(final T value) {
225 DragAndDropNodeInfo n = new DragAndDropNodeInfo<RestResource>(getRootNodes(), departmentCell,
226 selectionModel, null);
227 configureFolderDrop(n);
228 configureDragOperation(n.getDraggableOptions());
231 else if (value instanceof MyFolderResource) {
233 MyFolderDataProvider dataProvider = new MyFolderDataProvider(
234 ((MyFolderResource) value),MyFolderResource.class);
235 DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
236 selectionModel, new ResourceValueUpdater());
237 mymap.put(((MyFolderResource) value).getUri(), dataProvider);
239 // permission cell are not draggable
240 //n.setCellDroppableOnly();
241 configureFolderDrop(n);
242 configureDragOperation(n.getDraggableOptions());
246 else if (value instanceof SharedResource) {
248 MyFolderDataProvider dataProvider = new MyFolderDataProvider(
249 ((SharedResource) value), SharedFolderResource.class);
250 sharedmap.put(((SharedResource) value).getUri(), dataProvider);
251 DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
252 selectionModel, new ResourceValueUpdater());
253 configureFolderDrop(n);
254 configureDragOperation(n.getDraggableOptions());
257 else if (value instanceof TrashResource) {
259 ListDataProvider<RestResource> trashProvider = new ListDataProvider<RestResource>();
260 List<RestResource> r = new ArrayList<RestResource>();
261 for(FolderResource f : GSS.get().getTreeView().getTrash().getFolders()){
262 r.add(new TrashFolderResource(f));
264 trashProvider.setList(r);
265 DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(trashProvider, departmentCell,
266 selectionModel, new ResourceValueUpdater());
267 configureFolderDrop(n);
268 configureDragOperation(n.getDraggableOptions());
271 else if (value instanceof OthersResource) {
273 OthersDataProvider dataProvider = new OthersDataProvider(
274 ((OthersResource) value), SharedFolderResource.class);
275 DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
276 selectionModel, null);
277 configureFolderDrop(n);
278 configureDragOperation(n.getDraggableOptions());
281 else if (value instanceof SharedFolderResource) {
283 MyFolderDataProvider dataProvider = new MyFolderDataProvider(
284 ((SharedFolderResource) value),SharedFolderResource.class);
285 DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
286 selectionModel, new ResourceValueUpdater());
287 sharedmap.put(((SharedFolderResource) value).getUri(), dataProvider);
288 configureFolderDrop(n);
289 configureDragOperation(n.getDraggableOptions());
292 else if (value instanceof OthersFolderResource) {
294 MyFolderDataProvider dataProvider = new MyFolderDataProvider(
295 ((OthersFolderResource) value),OthersFolderResource.class);
296 DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
297 selectionModel, new ResourceValueUpdater());
298 //nodeInfos.put(((OthersFolderResource) value).getUri(), n);
299 othersmap.put(((OthersFolderResource) value).getUri(), dataProvider);
300 configureFolderDrop(n);
301 configureDragOperation(n.getDraggableOptions());
304 else if (value instanceof OtherUserResource) {
306 MyFolderDataProvider dataProvider = new MyFolderDataProvider(
307 ((OtherUserResource) value),OthersFolderResource.class);
308 DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
309 selectionModel, new ResourceValueUpdater());
310 configureFolderDrop(n);
311 configureDragOperation(n.getDraggableOptions());
314 // TODO Auto-generated method stub
318 private void configureFolderDrop(DragAndDropNodeInfo<RestResource> n){
319 DroppableOptions options = n.getDroppableOptions();
320 options.setDroppableHoverClass("droppableHover");
321 // use a DroppableFunction here. We can also add a DropHandler in the tree
324 options.setOnOver(new DroppableFunction() {
327 public void f(final DragAndDropContext context) {
328 if(context.getDroppableData()!=null && context.getDroppableData() instanceof RestResource){
330 GSS.get().getTreeView().getUtils().openNodeContainingResource((RestResource) context.getDroppableData(), new RefreshHandler() {
333 public void onRefresh() {
335 DragAndDropManager.getInstance().update(context);//initialize(context, GQueryUi.Event.create(com.google.gwt.user.client.Event.getCurrentEvent()));
346 options.setOnDrop(new DroppableFunction() {
348 public void f(DragAndDropContext context) {
350 DnDFolderPopupMenu popup ;
351 if(context.getDraggableData() instanceof FileResource){
352 if(context.getDroppableData() instanceof RestResourceWrapper)
353 popup = new DnDFolderPopupMenu(images, ((RestResourceWrapper) context.getDroppableData()).getResource(), Arrays.asList(context.getDraggableData()));
355 popup = new DnDFolderPopupMenu(images, null, Arrays.asList(context.getDraggableData()));
359 if(context.getDroppableData() instanceof RestResourceWrapper)
360 popup = new DnDFolderPopupMenu(images, ((RestResourceWrapper) context.getDroppableData()).getResource(), context.getDraggableData());
362 popup = new DnDFolderPopupMenu(images, null, context.getDraggableData());
365 int left = context.getDroppable().getAbsoluteLeft() + 40;
366 int top = context.getDroppable().getAbsoluteTop() + 20;
367 popup.setPopupPosition(left, top);
375 public boolean isLeaf(Object value) {
376 if(value instanceof RestResourceWrapper)
377 return ((RestResourceWrapper)value).getResource().getFolders().size()==0;
378 else if(value instanceof TrashResource)
379 return ((TrashResource)value).getFolders().size()==0;
380 else if(value instanceof SharedResource)
381 return ((SharedResource)value).getFolders().size()==0;
382 else if(value instanceof OthersResource)
383 return ((OthersResource)value).getOtherUsers().size()==0;
384 else if(value instanceof OtherUserResource)
385 return ((OtherUserResource)value).getFolders().size()==0;
389 class ResourceValueUpdater implements ValueUpdater<RestResource>{
392 public void update(final RestResource value) {
393 if(value instanceof MyFolderResource){
394 GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
397 public void onComplete() {
398 FolderResource rootResource = getResult();
399 //((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
400 ((MyFolderResource)value).setResource(rootResource);
401 if(GSS.get().getTreeView().getSelection().getUri().equals(value.getUri()))
402 selectionModel.setSelected(value, true);
403 GSS.get().onResourceUpdate(value);
408 public void onError(Throwable t) {
409 GWT.log("Error fetching root folder", t);
410 GSS.get().displayError("Unable to fetch root folder");
414 DeferredCommand.addCommand(gf);
416 else if(value instanceof TrashResource){
417 DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, GSS.get().getCurrentUserResource().getTrashPath(), null) {
419 public void onComplete() {
420 //trash = getResult();
421 ((TrashResource)value).setFolders(getResult().getFolders());
422 ((TrashResource)value).setFiles(getResult().getFiles());
423 for(RestResource r : getRootNodes().getList()){
424 if(r instanceof TrashResource)
425 getRootNodes().getList().set(getRootNodes().getList().indexOf(r),GSS.get().getTreeView().getTrash());
427 GSS.get().getTreeView().updateNodeChildren(GSS.get().getTreeView().getTrash());
428 //GSS.get().showFileList(true);
429 GSS.get().onResourceUpdate(value);
433 public void onError(Throwable t) {
434 if(t instanceof RestException){
435 int statusCode = ((RestException)t).getHttpStatusCode();
436 // On IE status code 1223 may be returned instead of 204.
437 if(statusCode == 204 || statusCode == 1223){
438 ((TrashResource)value).setFolders(new ArrayList<FolderResource>());
439 ((TrashResource)value).setFiles(new ArrayList<FileResource>());
443 GSS.get().displayError("Unable to fetch trash folder:"+t.getMessage());
444 //GSS.get().getTreeView().getTrash() = new TrashResource(GSS.get().getCurrentUserResource().getTrashPath());
450 else if(value instanceof OthersFolderResource){
451 GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
454 public void onComplete() {
455 FolderResource rootResource = getResult();
456 //((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
457 ((OthersFolderResource)value).setResource(rootResource);
458 if(GSS.get().getTreeView().getSelection().getUri().equals(value.getUri()))
459 selectionModel.setSelected(value, true);
460 GSS.get().onResourceUpdate(value);
465 public void onError(Throwable t) {
466 GWT.log("Error fetching root folder", t);
467 GSS.get().displayError("Unable to fetch root folder");
471 DeferredCommand.addCommand(gf);
473 else if(value instanceof SharedFolderResource){
474 GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, value.getUri(), null) {
477 public void onComplete() {
478 FolderResource rootResource = getResult();
479 //((MyFolderResource)value).getResource().setFiles(rootResource.getFiles());
480 ((SharedFolderResource)value).setResource(rootResource);
481 if(GSS.get().getTreeView().getSelection().getUri().equals(value.getUri()))
482 selectionModel.setSelected(value, true);
483 GSS.get().onResourceUpdate(value);
488 public void onError(Throwable t) {
489 GWT.log("Error fetching root folder", t);
490 GSS.get().displayError("Unable to fetch root folder");
494 DeferredCommand.addCommand(gf);
496 else if(value instanceof SharedResource){
497 GetCommand<SharedResource> gf = new GetCommand<SharedResource>(SharedResource.class, value.getUri(), null) {
500 public void onComplete() {
501 SharedResource rootResource = getResult();
502 ((SharedResource)value).setFolders(getResult().getFolders());
503 ((SharedResource)value).setFiles(getResult().getFiles());
505 if(GSS.get().getTreeView().getSelection().getUri().equals(value.getUri()))
506 selectionModel.setSelected(value, true);
507 GSS.get().onResourceUpdate(value);
512 public void onError(Throwable t) {
513 GWT.log("Error fetching root folder", t);
514 GSS.get().displayError("Unable to fetch root folder");
518 DeferredCommand.addCommand(gf);
520 else if(value instanceof OtherUserResource){
521 GetCommand<OtherUserResource> gf = new GetCommand<OtherUserResource>(OtherUserResource.class, value.getUri(), null) {
524 public void onComplete() {
525 OtherUserResource rootResource = getResult();
526 ((OtherUserResource)value).setFolders(getResult().getFolders());
527 ((OtherUserResource)value).setFiles(getResult().getFiles());
529 if(GSS.get().getTreeView().getSelection().getUri().equals(value.getUri()))
530 selectionModel.setSelected(value, true);
531 GSS.get().onResourceUpdate(value);
536 public void onError(Throwable t) {
537 GWT.log("Error fetching root folder", t);
538 GSS.get().displayError("Unable to fetch root folder");
542 DeferredCommand.addCommand(gf);
548 class MyFolderDataProvider extends AsyncDataProvider<RestResource>{
549 private RestResource restResource;
550 private Class resourceClass;
551 public MyFolderDataProvider(RestResource department, Class resourceClass) {
552 super(new ProvidesKey<RestResource>() {
555 public Object getKey(RestResource item) {
556 return item.getUri();
558 this.restResource = department;
559 this.resourceClass=resourceClass;
563 protected void onRangeChanged(final HasData<RestResource> view) {
568 * Retrieve the restResource.
570 * @return the restResource
572 public RestResource getRestResource() {
578 * Modify the restResource.
580 * @param restResource the restResource to set
582 public void setRestResource(RestResource restResource) {
583 this.restResource = restResource;
585 List<RestResource> res =null;
586 public void refresh(final RefreshHandler refresh){
587 FolderResource cache = null;
588 if(restResource instanceof RestResourceWrapper && !((RestResourceWrapper)restResource).getResource().isNeedsExpanding())
589 cache = ((RestResourceWrapper)restResource).getResource();
590 GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, restResource.getUri(),cache ) {
593 public void onComplete() {
594 if(restResource instanceof RestResourceWrapper){
595 ((RestResourceWrapper)restResource).setResource(getResult());//restResource = getResult();
596 ((RestResourceWrapper)restResource).getResource().setNeedsExpanding(false);
598 if(usedCachedVersion()&&res!=null){
600 updateRowCount(res.size(), true);
601 updateRowData(0,res);
604 String[] folderPaths = null;
605 if(resourceClass.equals(MyFolderResource.class))
606 folderPaths=((MyFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
607 else if(resourceClass.equals(SharedFolderResource.class) && restResource instanceof SharedResource)
608 folderPaths=((SharedResource) restResource).getSubfolderPaths().toArray(new String[] {});
609 else if(resourceClass.equals(SharedFolderResource.class)){
610 folderPaths=((SharedFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
611 GWT.log("------------>"+folderPaths);
613 else if(resourceClass.equals(TrashFolderResource.class))
614 folderPaths=((TrashFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
615 else if(resourceClass.equals(OthersFolderResource.class) && restResource instanceof OtherUserResource)
616 folderPaths=((OtherUserResource) restResource).getSubfolderPaths().toArray(new String[] {});
617 else if(resourceClass.equals(OthersFolderResource.class))
618 folderPaths=((OthersFolderResource) restResource).getResource().getSubfolderPaths().toArray(new String[] {});
619 MultipleGetCommand.Cached[] cached = null;
620 if(restResource instanceof RestResourceWrapper)
621 cached=((RestResourceWrapper)restResource).getResource().getCache();
622 MultipleGetCommand<FolderResource> gf2 = new MultipleGetCommand<FolderResource>(FolderResource.class,
623 folderPaths, cached) {
626 public void onComplete() {
627 res = new ArrayList<RestResource>();
628 for(FolderResource r : getResult()){
632 else if(resourceClass.equals(MyFolderResource.class))
633 res.add(new MyFolderResource(r));
634 else if(resourceClass.equals(SharedFolderResource.class)){
635 res.add(new SharedFolderResource(r));
637 else if(resourceClass.equals(TrashFolderResource.class))
638 res.add(new TrashFolderResource(r));
639 else if(resourceClass.equals(OthersFolderResource.class))
640 res.add(new OthersFolderResource(r));
642 if(restResource instanceof RestResourceWrapper)
643 ((RestResourceWrapper)restResource).getResource().setFolders(getResult());
644 updateRowCount(res.size(), true);
645 updateRowData(0,res);
651 public void onError(Throwable t) {
652 GSS.get().displayError("Unable to fetch subfolders");
653 GWT.log("Unable to fetch subfolders", t);
657 public void onError(String p, Throwable throwable) {
658 GWT.log("Path:"+p, throwable);
662 DeferredCommand.addCommand(gf2);
667 public void onError(Throwable t) {
669 GWT.log("Error fetching root folder", t);
670 GSS.get().displayError("Unable to fetch root folder");
674 DeferredCommand.addCommand(gf);
679 class OthersDataProvider extends AsyncDataProvider<RestResource>{
680 private RestResource restResource;
681 private Class resourceClass;
682 public OthersDataProvider(RestResource department, Class resourceClass) {
683 super(new ProvidesKey<RestResource>() {
686 public Object getKey(RestResource item) {
687 return item.getUri();
689 this.restResource = department;
690 this.resourceClass=resourceClass;
694 protected void onRangeChanged(final HasData<RestResource> view) {
699 * Retrieve the restResource.
701 * @return the restResource
703 public RestResource getRestResource() {
709 * Modify the restResource.
711 * @param restResource the restResource to set
713 public void setRestResource(RestResource restResource) {
714 this.restResource = restResource;
717 public void refresh(final RefreshHandler refresh){
718 GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
719 restResource.getUri(), null) {
722 public void onComplete() {
723 final OthersResource others = getResult();
724 MultipleGetCommand<OtherUserResource> gogo = new MultipleGetCommand<OtherUserResource>(OtherUserResource.class,
725 others.getOthers().toArray(new String[] {}), null) {
728 public void onComplete() {
729 List<OtherUserResource> res = getResult();
730 updateRowCount(res.size(), true);
731 List<RestResource> r = new ArrayList<RestResource>();
737 public void onError(Throwable t) {
738 GWT.log("Error fetching Others Root folder", t);
739 GSS.get().displayError("Unable to fetch Others Root folder");
743 public void onError(String p, Throwable throwable) {
744 GWT.log("Path:"+p, throwable);
747 DeferredCommand.addCommand(gogo);
751 public void onError(Throwable t) {
752 GWT.log("Error fetching Others Root folder", t);
753 GSS.get().displayError("Unable to fetch Others Root folder");
756 DeferredCommand.addCommand(go);
763 * Retrieve the rootNodes.
765 * @return the rootNodes
767 public ListDataProvider<RestResource> getRootNodes() {
773 * Retrieve the mymap.
777 public Map<String, MyFolderDataProvider> getMymap() {
783 * Retrieve the sharedmap.
785 * @return the sharedmap
787 public Map<String, MyFolderDataProvider> getSharedmap() {
793 * Retrieve the othersmap.
795 * @return the othersmap
797 public Map<String, MyFolderDataProvider> getOthersmap() {