root / src / org / gss_project / gss / web / client / CellTreeView.java @ 1206:292dec4eae08
History | View | Annotate | Download (19.9 kB)
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 org.gss_project.gss.web.client; |
20 |
|
21 |
import org.gss_project.gss.web.client.CellTreeViewModel.ClearSelection; |
22 |
import org.gss_project.gss.web.client.rest.GetCommand; |
23 |
import org.gss_project.gss.web.client.rest.RestException; |
24 |
import org.gss_project.gss.web.client.rest.resource.FolderResource; |
25 |
import org.gss_project.gss.web.client.rest.resource.MyFolderResource; |
26 |
import org.gss_project.gss.web.client.rest.resource.OtherUserResource; |
27 |
import org.gss_project.gss.web.client.rest.resource.OthersFolderResource; |
28 |
import org.gss_project.gss.web.client.rest.resource.OthersResource; |
29 |
import org.gss_project.gss.web.client.rest.resource.RestResource; |
30 |
import org.gss_project.gss.web.client.rest.resource.RestResourceWrapper; |
31 |
import org.gss_project.gss.web.client.rest.resource.SharedResource; |
32 |
import org.gss_project.gss.web.client.rest.resource.TrashFolderResource; |
33 |
import org.gss_project.gss.web.client.rest.resource.TrashResource; |
34 |
import org.gss_project.gss.web.client.rest.resource.UserResource; |
35 |
import gwtquery.plugins.droppable.client.gwt.DragAndDropCellTree; |
36 |
|
37 |
import java.util.Arrays; |
38 |
|
39 |
import com.google.gwt.core.client.GWT; |
40 |
import com.google.gwt.resources.client.ClientBundle; |
41 |
import com.google.gwt.resources.client.ImageResource; |
42 |
import com.google.gwt.resources.client.ImageResource.ImageOptions; |
43 |
import com.google.gwt.user.cellview.client.CellTree; |
44 |
import com.google.gwt.user.cellview.client.TreeNode; |
45 |
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; |
46 |
import com.google.gwt.user.client.DeferredCommand; |
47 |
import com.google.gwt.user.client.Event; |
48 |
import com.google.gwt.user.client.IncrementalCommand; |
49 |
import com.google.gwt.user.client.ui.Composite; |
50 |
import com.google.gwt.user.client.ui.Tree; |
51 |
import com.google.gwt.view.client.ProvidesKey; |
52 |
import com.google.gwt.view.client.SelectionChangeEvent; |
53 |
import com.google.gwt.view.client.SingleSelectionModel; |
54 |
import com.google.gwt.view.client.TreeViewModel; |
55 |
import com.google.gwt.view.client.SelectionChangeEvent.Handler; |
56 |
import com.google.gwt.view.client.TreeViewModel.NodeInfo; |
57 |
|
58 |
|
59 |
/**
|
60 |
* @author kman
|
61 |
*
|
62 |
*/
|
63 |
public class CellTreeView extends Composite{ |
64 |
public static final boolean DONE = false; |
65 |
Images images; |
66 |
|
67 |
SingleSelectionModel<RestResource> selectionModel = new SingleSelectionModel<RestResource>(new ProvidesKey<RestResource>() { |
68 |
|
69 |
@Override
|
70 |
public Object getKey(RestResource item) { |
71 |
return item.getClass().getName()+":"+item.getUri(); |
72 |
}}); |
73 |
FolderContextMenu menu; |
74 |
|
75 |
|
76 |
MyFolderResource myFolders=null;
|
77 |
TrashResource trash = null;
|
78 |
SharedResource myshared = null;
|
79 |
OthersResource others = null;
|
80 |
|
81 |
CellTreeViewModel model; |
82 |
CellTreeViewUtils utils; |
83 |
|
84 |
public interface Images extends ClientBundle,Tree.Resources, FolderContextMenu.Images { |
85 |
|
86 |
@Source("org/gss_project/gss/resources/folder_home.png") |
87 |
ImageResource home(); |
88 |
|
89 |
@Source("org/gss_project/gss/resources/folder_yellow.png") |
90 |
ImageResource folderYellow(); |
91 |
|
92 |
@Source("org/gss_project/gss/resources/mimetypes/document.png") |
93 |
ImageResource document(); |
94 |
|
95 |
@Source("org/gss_project/gss/resources/internet.png") |
96 |
ImageResource othersShared(); |
97 |
|
98 |
@Source("org/gss_project/gss/resources/edit_user.png") |
99 |
ImageResource myShared(); |
100 |
|
101 |
@Source("org/gss_project/gss/resources/folder_user.png") |
102 |
ImageResource sharedFolder(); |
103 |
|
104 |
@Source("org/gss_project/gss/resources/trashcan_empty.png") |
105 |
ImageResource trash(); |
106 |
} |
107 |
DragAndDropCellTree tree; |
108 |
/*public interface BasicResources extends CellTree.BasicResources{
|
109 |
@ImageOptions(flipRtl = true)
|
110 |
@Source("cellTreeLoadingBasic.gif")
|
111 |
ImageResource cellTreeLoading();
|
112 |
|
113 |
@Source({"GssCellTreeBasic.css"})
|
114 |
CellTree.Style cellTreeStyle();
|
115 |
}*/
|
116 |
public interface BasicResources extends CellTree.Resources { |
117 |
|
118 |
@ImageOptions(flipRtl = true) |
119 |
@Source("cellTreeClosedItem.gif") |
120 |
ImageResource cellTreeClosedItem(); |
121 |
|
122 |
@ImageOptions(flipRtl = true) |
123 |
@Source("cellTreeLoadingBasic.gif") |
124 |
ImageResource cellTreeLoading(); |
125 |
|
126 |
@ImageOptions(flipRtl = true) |
127 |
@Source("cellTreeOpenItem.gif") |
128 |
ImageResource cellTreeOpenItem(); |
129 |
|
130 |
//@Source({CellTree.Style.DEFAULT_CSS,"GssCellTreeBasic.css"})
|
131 |
@Source({"GssCellTreeBasic.css"}) |
132 |
CellTree.Style cellTreeStyle(); |
133 |
} |
134 |
/**
|
135 |
*
|
136 |
*/
|
137 |
public CellTreeView(final Images _images) { |
138 |
images = _images; |
139 |
model = new CellTreeViewModel(images,selectionModel);
|
140 |
/*
|
141 |
* Create the tree using the model. We use <code>null</code> as the default
|
142 |
* value of the root node. The default value will be passed to
|
143 |
* CustomTreeModel#getNodeInfo();
|
144 |
*/
|
145 |
CellTree.Resources res = GWT.create(BasicResources.class); |
146 |
tree = new DragAndDropCellTree(model,null, res){ |
147 |
@Override
|
148 |
public void onBrowserEvent(Event event) { |
149 |
// TODO Auto-generated method stub
|
150 |
super.onBrowserEvent(event);
|
151 |
} |
152 |
}; |
153 |
utils=new CellTreeViewUtils(tree);
|
154 |
tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); |
155 |
/*tree.addOpenHandler(new OpenHandler<TreeNode>() {
|
156 |
|
157 |
@Override
|
158 |
public void onOpen(OpenEvent<TreeNode> event) {
|
159 |
Window.alert("[NODE OPENED]"+event.getTarget());
|
160 |
|
161 |
}
|
162 |
});
|
163 |
tree.addOverDroppableHandler(new OverDroppableEventHandler() {
|
164 |
|
165 |
@Override
|
166 |
public void onOverDroppable(OverDroppableEvent event) {
|
167 |
GWT.log("OVER:"+event);
|
168 |
|
169 |
}
|
170 |
});
|
171 |
tree.addAttachHandler(new AttachEvent.Handler() {
|
172 |
|
173 |
@Override
|
174 |
public void onAttachOrDetach(AttachEvent event) {
|
175 |
GWT.log("ATTACH:"+event.getSource());
|
176 |
|
177 |
}
|
178 |
});*/
|
179 |
Handler selectionHandler = new SelectionChangeEvent.Handler() { |
180 |
@Override
|
181 |
public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) { |
182 |
NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(selectionModel.getSelectedObject()); |
183 |
if(nodeInfo==null || nodeInfo.getValueUpdater()==null){ |
184 |
GSS.get().showFileList(getSelection()); |
185 |
} |
186 |
else
|
187 |
nodeInfo.getValueUpdater().update(selectionModel.getSelectedObject()); |
188 |
GSS.get().setCurrentSelection(selectionModel.getSelectedObject()); |
189 |
|
190 |
|
191 |
} |
192 |
}; |
193 |
selectionModel.addSelectionChangeHandler(selectionHandler); |
194 |
sinkEvents(Event.ONCONTEXTMENU);
|
195 |
sinkEvents(Event.ONMOUSEUP);
|
196 |
initWidget(tree); |
197 |
FolderResource loadingResource = new FolderResource("loading"); |
198 |
loadingResource.setName("Loading....");
|
199 |
loadingResource.setShared(false);
|
200 |
RestResourceWrapper loading = new RestResourceWrapper(loadingResource);
|
201 |
model.getRootNodes().setList(Arrays.asList((RestResource)loading));
|
202 |
|
203 |
DeferredCommand.addCommand(new IncrementalCommand() {
|
204 |
|
205 |
@Override
|
206 |
public boolean execute() { |
207 |
return fetchRootFolders();
|
208 |
} |
209 |
}); |
210 |
} |
211 |
|
212 |
public void updateNode(RestResource resource){ |
213 |
NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(resource); |
214 |
|
215 |
if(nodeInfo!=null){ |
216 |
if(nodeInfo.getValueUpdater()==null){} |
217 |
else
|
218 |
nodeInfo.getValueUpdater().update(resource); |
219 |
} |
220 |
} |
221 |
|
222 |
public void updateNodeChildren(final RestResource resource){ |
223 |
|
224 |
if(resource instanceof RestResourceWrapper){ |
225 |
boolean updated=false; |
226 |
if(((RestResourceWrapper)resource).getResource().getFolders().size()==0){ |
227 |
if(((RestResourceWrapper)resource).getResource().getParentURI().equals(getMyFolders().getUri())){
|
228 |
updateNodeChildren(getMyFolders().getUri()); |
229 |
return;
|
230 |
} |
231 |
if(model.getMymap().get(((RestResourceWrapper)resource).getResource().getParentURI())!=null){ |
232 |
model.getMymap().get(((RestResourceWrapper)resource).getResource().getParentURI()).refresh(null);
|
233 |
updated=true;
|
234 |
} |
235 |
if(model.getOthersmap().get(((RestResourceWrapper)resource).getResource().getParentURI())!=null){ |
236 |
model.getOthersmap().get(((RestResourceWrapper)resource).getResource().getParentURI()).refresh(null);
|
237 |
updated=true;
|
238 |
} |
239 |
if(model.getSharedmap().get(((RestResourceWrapper)resource).getResource().getParentURI())!=null){ |
240 |
model.getSharedmap().get(((RestResourceWrapper)resource).getResource().getParentURI()).refresh(null);
|
241 |
updated=true;
|
242 |
} |
243 |
if(updated){
|
244 |
if(utils.doesSharedNodeContainsResourceIn1stLevel(resource.getUri())){
|
245 |
updateMySharedNode(); |
246 |
} |
247 |
else if(tree.getRootTreeNode().isChildOpen(2)){ |
248 |
utils.refreshNodeContainingResource(tree.getRootTreeNode().setChildOpen(2,true),resource.getUri()); |
249 |
} |
250 |
//return;
|
251 |
} |
252 |
} |
253 |
} |
254 |
|
255 |
utils.refreshNodeContainingResource(resource); |
256 |
if(utils.doesSharedNodeContainsResourceIn1stLevel(resource.getUri())){
|
257 |
updateMySharedNode(); |
258 |
} |
259 |
else if(tree.getRootTreeNode().isChildOpen(2)){ |
260 |
GWT.log("REFRESH THE OTHER WAY 2:"+resource);
|
261 |
utils.refreshNodeContainingResource(tree.getRootTreeNode().setChildOpen(2,true),resource.getUri()); |
262 |
} |
263 |
|
264 |
} |
265 |
public void updateNodeChildrenForRemove(final String resource){ |
266 |
GWT.log("********************************");
|
267 |
GWT.log("[UPDATENODECHILDREN]"+resource);
|
268 |
GWT.log("********************************");
|
269 |
boolean updated=false; |
270 |
TreeNode node=null; |
271 |
TreeNode sharedNode=null; |
272 |
if(tree.getRootTreeNode().isChildOpen(0)){ |
273 |
node = utils.getNodeContainingResource2(tree.getRootTreeNode().setChildOpen(0,true), resource); |
274 |
} |
275 |
GWT.log("CHECK NODE1:"+node+" "+resource); |
276 |
|
277 |
if(tree.getRootTreeNode().isChildOpen(2)){ |
278 |
GWT.log("CHECK NODE2:"+node);
|
279 |
if(node==null) |
280 |
node = utils.getNodeContainingResource2(tree.getRootTreeNode().setChildOpen(2,true), resource); |
281 |
|
282 |
} |
283 |
if(node==null) |
284 |
if(tree.getRootTreeNode().isChildOpen(3)){ |
285 |
GWT.log("CHECK NODE3:"+node);
|
286 |
node = utils.getNodeContainingResource2(tree.getRootTreeNode().setChildOpen(3,true), resource); |
287 |
} |
288 |
if(node != null && node.getValue() instanceof RestResourceWrapper){ |
289 |
GWT.log("*********************"+((RestResourceWrapper) node.getValue()).getResource().getFolders().size());
|
290 |
RestResourceWrapper wrapper = (RestResourceWrapper) node.getValue(); |
291 |
if(wrapper.getResource().countNotDeletedSubfolders()==1||wrapper.getResource().countNotDeletedSubfolders()==0){ |
292 |
updateNodeChildren(((RestResourceWrapper) node.getValue()).getResource().getParentURI()); |
293 |
if(((RestResourceWrapper) node.getValue()).getResource().getParentURI().equals(myFolders.getUri())){
|
294 |
if(utils.doesSharedNodeContainsResourceIn1stLevel(resource)||utils.doesSharedNodeContainsResourceIn2ndLevel(resource)){
|
295 |
updateMySharedNode(); |
296 |
} |
297 |
} |
298 |
|
299 |
} |
300 |
else
|
301 |
updateNodeChildren(((RestResource) node.getValue()).getUri()); |
302 |
return;
|
303 |
} |
304 |
updateNodeChildren(resource); |
305 |
} |
306 |
public void updateNodeChildren(final String resource){ |
307 |
|
308 |
|
309 |
GWT.log("REFRESH THE OTHER WAY");
|
310 |
utils.refreshNodeContainingResource(resource); |
311 |
if(utils.doesSharedNodeContainsResourceIn1stLevel(resource)||utils.doesSharedNodeContainsResourceIn2ndLevel(resource)){
|
312 |
GWT.log("REFRESH THE OTHER WAY 1:"+resource);
|
313 |
updateMySharedNode(); |
314 |
} |
315 |
else if(tree.getRootTreeNode().isChildOpen(2)){ |
316 |
GWT.log("REFRESH THE OTHER WAY 2:"+resource);
|
317 |
utils.refreshNodeContainingResource(tree.getRootTreeNode().setChildOpen(2,true),resource); |
318 |
} |
319 |
} |
320 |
|
321 |
protected void showPopup(final int x, final int y) { |
322 |
if (selectionModel.getSelectedObject() == null) |
323 |
return;
|
324 |
if (menu != null) |
325 |
menu.hide(); |
326 |
menu = new FolderContextMenu(images);
|
327 |
menu.setPopupPosition(x, y); |
328 |
menu.show(); |
329 |
} |
330 |
private boolean init=false; |
331 |
public boolean fetchRootFolders() { |
332 |
UserResource userResource = GSS.get().getCurrentUserResource(); |
333 |
if (userResource == null) |
334 |
return !DONE;
|
335 |
if(!init){
|
336 |
final String path = userResource.getFilesPath(); |
337 |
GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path, null) { |
338 |
|
339 |
@Override
|
340 |
public void onComplete() { |
341 |
myFolders = new MyFolderResource(getResult());
|
342 |
//selectionModel.setSelected(myFolders, true);
|
343 |
//rootNodes.setList(Arrays.asList((RestResource)rootResource));
|
344 |
//tree.getRootTreeNode().setChildOpen(0, true);
|
345 |
} |
346 |
|
347 |
@Override
|
348 |
public void onError(Throwable t) { |
349 |
GWT.log("Error fetching root folder", t);
|
350 |
GSS.get().displayError("Unable to fetch root folder");
|
351 |
} |
352 |
|
353 |
}; |
354 |
DeferredCommand.addCommand(gf); |
355 |
DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, GSS.get().getCurrentUserResource().getTrashPath(), null) { |
356 |
@Override
|
357 |
public void onComplete() { |
358 |
trash = getResult(); |
359 |
} |
360 |
|
361 |
@Override
|
362 |
public void onError(Throwable t) { |
363 |
if(t instanceof RestException){ |
364 |
int statusCode = ((RestException)t).getHttpStatusCode();
|
365 |
// On IE status code 1223 may be returned instead of 204.
|
366 |
if(statusCode == 204 || statusCode == 1223){ |
367 |
trash = new TrashResource(GSS.get().getCurrentUserResource().getTrashPath());
|
368 |
} |
369 |
else{
|
370 |
GWT.log("", t);
|
371 |
GSS.get().displayError("Unable to fetch trash folder:"+t.getMessage());
|
372 |
trash = new TrashResource(GSS.get().getCurrentUserResource().getTrashPath());
|
373 |
} |
374 |
} |
375 |
} |
376 |
}); |
377 |
GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, userResource.getSharedPath(), null) { |
378 |
|
379 |
@Override
|
380 |
public void onComplete() { |
381 |
myshared=getResult(); |
382 |
} |
383 |
|
384 |
@Override
|
385 |
public void onError(Throwable t) { |
386 |
GWT.log("Error fetching Shared Root folder", t);
|
387 |
GSS.get().displayError("Unable to fetch Shared Root folder");
|
388 |
} |
389 |
}; |
390 |
DeferredCommand.addCommand(gs); |
391 |
GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
|
392 |
userResource.getOthersPath(), null) {
|
393 |
|
394 |
@Override
|
395 |
public void onComplete() { |
396 |
others = getResult(); |
397 |
GSS.get().removeGlassPanel(); |
398 |
} |
399 |
|
400 |
@Override
|
401 |
public void onError(Throwable t) { |
402 |
GWT.log("Error fetching Others Root folder", t);
|
403 |
GSS.get().displayError("Unable to fetch Others Root folder");
|
404 |
} |
405 |
}; |
406 |
DeferredCommand.addCommand(go); |
407 |
} |
408 |
if(myFolders==null||trash==null||myshared==null||others==null) |
409 |
return !DONE;
|
410 |
model.getRootNodes().setList(Arrays.asList((RestResource)myFolders,(RestResource)trash,(RestResource)myshared,(RestResource)others));
|
411 |
tree.getRootTreeNode().setChildOpen(0, true); |
412 |
selectionModel.setSelected(myFolders, true);
|
413 |
return DONE;
|
414 |
} |
415 |
|
416 |
public Images getImages() {
|
417 |
return images;
|
418 |
} |
419 |
|
420 |
|
421 |
public void updateTrashNode(){ |
422 |
DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, GSS.get().getCurrentUserResource().getTrashPath(), null) { |
423 |
@Override
|
424 |
public void onComplete() { |
425 |
trash = getResult(); |
426 |
boolean trashIsOpen = tree.getRootTreeNode().isChildOpen(1); |
427 |
model.getRootNodes().getList().set(1, trash);
|
428 |
model.getRootNodes().refresh(); |
429 |
tree.getRootTreeNode().setChildOpen(1, true); |
430 |
} |
431 |
|
432 |
@Override
|
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 |
trash = new TrashResource(GSS.get().getCurrentUserResource().getTrashPath());
|
439 |
model.getRootNodes().getList().set(1, trash);
|
440 |
//model.getRootNodes().refresh();
|
441 |
} |
442 |
else{
|
443 |
GWT.log("", t);
|
444 |
GSS.get().displayError("Unable to fetch trash folder:"+t.getMessage());
|
445 |
trash = new TrashResource(GSS.get().getCurrentUserResource().getTrashPath());
|
446 |
model.getRootNodes().getList().set(1, trash);
|
447 |
//model.getRootNodes().refresh();
|
448 |
} |
449 |
} |
450 |
} |
451 |
}); |
452 |
} |
453 |
|
454 |
public void updateRootNode(){ |
455 |
final String path = GSS.get().getCurrentUserResource().getFilesPath(); |
456 |
GetCommand<FolderResource> gf = new GetCommand<FolderResource>(FolderResource.class, path, null) { |
457 |
|
458 |
@Override
|
459 |
public void onComplete() { |
460 |
myFolders = new MyFolderResource(getResult());
|
461 |
model.getRootNodes().getList().set(0, myFolders);
|
462 |
model.getRootNodes().refresh(); |
463 |
tree.getRootTreeNode().setChildOpen(0, true); |
464 |
|
465 |
} |
466 |
|
467 |
@Override
|
468 |
public void onError(Throwable t) { |
469 |
GWT.log("Error fetching root folder", t);
|
470 |
GSS.get().displayError("Unable to fetch root folder");
|
471 |
} |
472 |
|
473 |
}; |
474 |
DeferredCommand.addCommand(gf); |
475 |
} |
476 |
|
477 |
public void updateMySharedNode(){ |
478 |
GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, GSS.get().getCurrentUserResource().getSharedPath(), null) { |
479 |
|
480 |
@Override
|
481 |
public void onComplete() { |
482 |
myshared=getResult(); |
483 |
model.getRootNodes().getList().set(2, myshared);
|
484 |
} |
485 |
|
486 |
@Override
|
487 |
public void onError(Throwable t) { |
488 |
GWT.log("Error fetching Shared Root folder", t);
|
489 |
GSS.get().displayError("Unable to fetch Shared Root folder");
|
490 |
} |
491 |
}; |
492 |
DeferredCommand.addCommand(gs); |
493 |
} |
494 |
|
495 |
public void updateOtherNode(){ |
496 |
GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
|
497 |
GSS.get().getCurrentUserResource().getOthersPath(), null) {
|
498 |
|
499 |
@Override
|
500 |
public void onComplete() { |
501 |
others = getResult(); |
502 |
model.getRootNodes().getList().set(3, others);
|
503 |
} |
504 |
|
505 |
@Override
|
506 |
public void onError(Throwable t) { |
507 |
GWT.log("Error fetching Others Root folder", t);
|
508 |
GSS.get().displayError("Unable to fetch Others Root folder");
|
509 |
} |
510 |
}; |
511 |
DeferredCommand.addCommand(go); |
512 |
} |
513 |
|
514 |
|
515 |
public RestResource getSelection(){
|
516 |
return selectionModel.getSelectedObject();
|
517 |
} |
518 |
|
519 |
public void clearSelection(){ |
520 |
if(GSS.get().getCurrentSelection().equals(getSelection()))
|
521 |
GSS.get().setCurrentSelection(null);
|
522 |
selectionModel.setSelected(getSelection(), false);
|
523 |
} |
524 |
|
525 |
|
526 |
/**
|
527 |
* Retrieve the myFolders.
|
528 |
*
|
529 |
* @return the myFolders
|
530 |
*/
|
531 |
public MyFolderResource getMyFolders() {
|
532 |
return myFolders;
|
533 |
} |
534 |
|
535 |
|
536 |
/**
|
537 |
* Retrieve the myshared.
|
538 |
*
|
539 |
* @return the myshared
|
540 |
*/
|
541 |
public SharedResource getMyshared() {
|
542 |
return myshared;
|
543 |
} |
544 |
|
545 |
|
546 |
/**
|
547 |
* Retrieve the trash.
|
548 |
*
|
549 |
* @return the trash
|
550 |
*/
|
551 |
public TrashResource getTrash() {
|
552 |
return trash;
|
553 |
} |
554 |
|
555 |
|
556 |
/**
|
557 |
* Retrieve the others.
|
558 |
*
|
559 |
* @return the others
|
560 |
*/
|
561 |
public OthersResource getOthers() {
|
562 |
return others;
|
563 |
} |
564 |
|
565 |
|
566 |
/**
|
567 |
* Retrieve the model.
|
568 |
*
|
569 |
* @return the model
|
570 |
*/
|
571 |
public TreeViewModel getModel() {
|
572 |
return model;
|
573 |
} |
574 |
|
575 |
|
576 |
|
577 |
/**
|
578 |
* Retrieve the utils.
|
579 |
*
|
580 |
* @return the utils
|
581 |
*/
|
582 |
public CellTreeViewUtils getUtils() {
|
583 |
return utils;
|
584 |
} |
585 |
|
586 |
public interface RefreshHandler{ |
587 |
void onRefresh();
|
588 |
} |
589 |
|
590 |
|
591 |
public boolean isTrashOrTrashFolderSelected(){ |
592 |
return (getSelection() instanceof TrashResource) || (getSelection() instanceof TrashFolderResource); |
593 |
} |
594 |
|
595 |
public OtherUserResource getOtherUserResourceOfOtherFolder(OthersFolderResource res){
|
596 |
TreeNode n = utils.getNodeContainingResource(tree.getRootTreeNode().setChildOpen(3, true), res); |
597 |
|
598 |
if(n!=null){ |
599 |
if(n.getValue() instanceof OtherUserResource) |
600 |
return (OtherUserResource) n.getValue();
|
601 |
TreeNode parent = n.getParent();
|
602 |
|
603 |
while (parent!=null){ |
604 |
if(parent.getValue() instanceof OtherUserResource) |
605 |
return (OtherUserResource) parent.getValue();
|
606 |
parent = parent.getParent(); |
607 |
} |
608 |
} |
609 |
return null; |
610 |
} |
611 |
|
612 |
public void refreshCurrentNode(boolean clearSelection){ |
613 |
NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(selectionModel.getSelectedObject()); |
614 |
if(nodeInfo==null || nodeInfo.getValueUpdater()==null){ |
615 |
GSS.get().showFileList(getSelection(),clearSelection); |
616 |
} |
617 |
else{
|
618 |
if(!clearSelection)
|
619 |
((ClearSelection)nodeInfo.getValueUpdater()).setClearSelection(clearSelection); |
620 |
nodeInfo.getValueUpdater().update(selectionModel.getSelectedObject()); |
621 |
} |
622 |
} |
623 |
|
624 |
} |