Revision 3331e8d8 web_client/src/gr/grnet/pithos/web/client/Pithos.java
b/web_client/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
58 | 58 |
import com.google.gwt.user.client.ui.PushButton; |
59 | 59 |
import com.google.gwt.view.client.SelectionChangeEvent; |
60 | 60 |
import com.google.gwt.view.client.SelectionChangeEvent.Handler; |
61 |
import com.google.gwt.view.client.SelectionModel; |
|
61 | 62 |
import com.google.gwt.view.client.SingleSelectionModel; |
63 |
import com.google.gwt.view.client.TreeViewModel; |
|
62 | 64 |
import gr.grnet.pithos.web.client.commands.UploadFileCommand; |
63 | 65 |
import gr.grnet.pithos.web.client.foldertree.AccountResource; |
64 | 66 |
import gr.grnet.pithos.web.client.foldertree.File; |
... | ... | |
66 | 68 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView; |
67 | 69 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeViewModel; |
68 | 70 |
import gr.grnet.pithos.web.client.foldertree.Resource; |
71 |
import gr.grnet.pithos.web.client.mysharedtree.MysharedTreeView; |
|
72 |
import gr.grnet.pithos.web.client.mysharedtree.MysharedTreeViewModel; |
|
69 | 73 |
import gr.grnet.pithos.web.client.rest.DeleteRequest; |
70 | 74 |
import gr.grnet.pithos.web.client.rest.GetRequest; |
71 | 75 |
import gr.grnet.pithos.web.client.rest.PutRequest; |
... | ... | |
108 | 112 |
*/ |
109 | 113 |
public class Pithos implements EntryPoint, ResizeHandler { |
110 | 114 |
|
111 |
/** |
|
112 |
* A constant that denotes the completion of an IncrementalCommand. |
|
113 |
*/ |
|
114 |
public static final boolean DONE = false; |
|
115 |
|
|
116 |
public static final int VISIBLE_FILE_COUNT = 25; |
|
117 |
|
|
115 |
public static final String HOME_CONTAINER = "pithos"; |
|
116 |
|
|
118 | 117 |
/** |
119 | 118 |
* Instantiate an application-level image bundle. This object will provide |
120 | 119 |
* programmatic access to all the images needed by widgets. |
... | ... | |
137 | 136 |
folderTreeView.updateFolder(f, showfiles); |
138 | 137 |
} |
139 | 138 |
|
139 |
public void updateSharedFolder(Folder f, boolean showfiles) { |
|
140 |
mysharedTreeView.updateFolder(f, showfiles); |
|
141 |
} |
|
142 |
|
|
140 | 143 |
public void updateTag(Tag t) { |
141 | 144 |
tagTreeView.updateTag(t); |
142 | 145 |
} |
... | ... | |
155 | 158 |
return tagList; |
156 | 159 |
} |
157 | 160 |
|
161 |
public MysharedTreeView getMySharedTreeView() { |
|
162 |
return mysharedTreeView; |
|
163 |
} |
|
164 |
|
|
158 | 165 |
/** |
159 | 166 |
* An aggregate image bundle that pulls together all the images for this |
160 | 167 |
* application into a single bundle. |
... | ... | |
232 | 239 |
private FolderTreeViewModel folderTreeViewModel; |
233 | 240 |
private FolderTreeView folderTreeView; |
234 | 241 |
|
242 |
private SingleSelectionModel<Folder> mysharedTreeSelectionModel; |
|
243 |
private MysharedTreeViewModel mysharedTreeViewModel; |
|
244 |
private MysharedTreeView mysharedTreeView; |
|
245 |
|
|
235 | 246 |
private SingleSelectionModel<Tag> tagTreeSelectionModel; |
236 | 247 |
private TagTreeViewModel tagTreeViewModel; |
237 | 248 |
private TagTreeView tagTreeView; |
238 | 249 |
|
239 | 250 |
private AccountResource account; |
240 | 251 |
|
252 |
private List<SingleSelectionModel> selectionModels = new ArrayList<SingleSelectionModel>(); |
|
253 |
|
|
241 | 254 |
@Override |
242 | 255 |
public void onModuleLoad() { |
243 | 256 |
if (parseUserCredentials()) |
... | ... | |
288 | 301 |
@Override |
289 | 302 |
public void onSelectionChange(SelectionChangeEvent event) { |
290 | 303 |
if (folderTreeSelectionModel.getSelectedObject() != null) { |
291 |
tagTreeSelectionModel.setSelected(tagTreeSelectionModel.getSelectedObject(), false);
|
|
304 |
deselectOthers(folderTreeSelectionModel);
|
|
292 | 305 |
Folder f = folderTreeSelectionModel.getSelectedObject(); |
293 | 306 |
updateFolder(f, true); |
294 | 307 |
} |
295 | 308 |
} |
296 | 309 |
}); |
310 |
selectionModels.add(folderTreeSelectionModel); |
|
297 | 311 |
|
298 | 312 |
folderTreeViewModel = new FolderTreeViewModel(this, folderTreeSelectionModel); |
299 | 313 |
folderTreeView = new FolderTreeView(folderTreeViewModel); |
... | ... | |
301 | 315 |
fileList = new FileList(this, images, folderTreeView); |
302 | 316 |
inner.add(fileList); |
303 | 317 |
|
318 |
mysharedTreeSelectionModel = new SingleSelectionModel<Folder>(); |
|
319 |
mysharedTreeSelectionModel.addSelectionChangeHandler(new Handler() { |
|
320 |
@Override |
|
321 |
public void onSelectionChange(SelectionChangeEvent event) { |
|
322 |
if (mysharedTreeSelectionModel.getSelectedObject() != null) { |
|
323 |
deselectOthers(mysharedTreeSelectionModel); |
|
324 |
updateSharedFolder(mysharedTreeSelectionModel.getSelectedObject(), true); |
|
325 |
} |
|
326 |
} |
|
327 |
}); |
|
328 |
selectionModels.add(mysharedTreeSelectionModel); |
|
329 |
mysharedTreeViewModel = new MysharedTreeViewModel(this, mysharedTreeSelectionModel); |
|
330 |
mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel); |
|
331 |
|
|
304 | 332 |
tagTreeSelectionModel = new SingleSelectionModel<Tag>(); |
305 | 333 |
tagTreeSelectionModel.addSelectionChangeHandler(new Handler() { |
306 | 334 |
@Override |
307 | 335 |
public void onSelectionChange(SelectionChangeEvent event) { |
308 | 336 |
if (tagTreeSelectionModel.getSelectedObject() != null) { |
309 |
folderTreeSelectionModel.setSelected(folderTreeSelectionModel.getSelectedObject(), false);
|
|
337 |
deselectOthers(tagTreeSelectionModel);
|
|
310 | 338 |
Tag t = tagTreeSelectionModel.getSelectedObject(); |
311 | 339 |
updateTag(t); |
312 | 340 |
} |
313 | 341 |
} |
314 | 342 |
}); |
343 |
selectionModels.add(tagTreeSelectionModel); |
|
315 | 344 |
tagTreeViewModel = new TagTreeViewModel(this, tagTreeSelectionModel); |
316 | 345 |
tagTreeView = new TagTreeView(tagTreeViewModel); |
317 | 346 |
|
... | ... | |
332 | 361 |
trees.add(treeHeader); |
333 | 362 |
|
334 | 363 |
trees.add(folderTreeView); |
335 |
trees.add(tagTreeView); |
|
364 |
trees.add(mysharedTreeView); |
|
365 |
// trees.add(tagTreeView); |
|
336 | 366 |
// Add the left and right panels to the split panel. |
337 | 367 |
splitPanel.setLeftWidget(trees); |
338 | 368 |
splitPanel.setRightWidget(inner); |
... | ... | |
372 | 402 |
}); |
373 | 403 |
} |
374 | 404 |
|
405 |
public void deselectOthers(SingleSelectionModel model) { |
|
406 |
for (SingleSelectionModel s : selectionModels) |
|
407 |
if (!s.equals(model)) |
|
408 |
s.setSelected(s.getSelectedObject(), false); |
|
409 |
} |
|
410 |
|
|
375 | 411 |
public void showFiles(Folder f) { |
376 | 412 |
Set<File> files = f.getFiles(); |
377 | 413 |
showFiles(files); |
... | ... | |
459 | 495 |
account = result; |
460 | 496 |
if (account.getContainers().isEmpty()) |
461 | 497 |
createHomeContainers(); |
462 |
else |
|
498 |
else {
|
|
463 | 499 |
folderTreeViewModel.initialize(account); |
500 |
} |
|
464 | 501 |
} |
465 | 502 |
|
466 | 503 |
@Override |
... | ... | |
811 | 848 |
createFolder.setHeader("Content-Type", "application/folder"); |
812 | 849 |
Scheduler.get().scheduleDeferred(createFolder); |
813 | 850 |
} |
851 |
|
|
852 |
public void addSelectionModel(SingleSelectionModel model) { |
|
853 |
selectionModels.add(model); |
|
854 |
} |
|
814 | 855 |
} |
Also available in: Unified diff