First version of client that displays first level containers
[pithos-web-client] / src / gr / grnet / pithos / web / client / commands / DeleteCommand.java
1 /*
2  *  Copyright (c) 2011 Greek Research and Technology Network
3  */
4 package gr.grnet.pithos.web.client.commands;
5
6 import gr.grnet.pithos.web.client.DeleteFileDialog;
7 import gr.grnet.pithos.web.client.DeleteFolderDialog;
8 import gr.grnet.pithos.web.client.EditMenu.Images;
9 import gr.grnet.pithos.web.client.GSS;
10 import gr.grnet.pithos.web.client.rest.resource.FileResource;
11 import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
12 import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
13
14 import java.util.List;
15
16 import com.google.gwt.core.client.GWT;
17 import com.google.gwt.user.client.Command;
18 import com.google.gwt.user.client.ui.PopupPanel;
19
20
21 /**
22  * Delete selected object command
23  *
24  */
25 public class DeleteCommand implements Command{
26         private PopupPanel containerPanel;
27         final Images newImages;
28
29         /**
30          * @param _containerPanel
31          * @param _newImages the images of all the possible delete dialogs
32          */
33         public DeleteCommand( PopupPanel _containerPanel, final Images _newImages ){
34                 containerPanel = _containerPanel;
35                 newImages=_newImages;
36         }
37
38         @Override
39         public void execute() {
40                 containerPanel.hide();
41                 displayDelete();
42         }
43         /**
44          * Display the delete dialog, according to the selected object.
45          *
46          *
47          */
48         void displayDelete() {
49                 Object selection = GSS.get().getCurrentSelection();
50                 if (selection == null)
51                         return;
52                 GWT.log("selection: " + selection.toString(), null);
53                 if (selection instanceof RestResourceWrapper) {
54                         DeleteFolderDialog dlg = new DeleteFolderDialog(newImages);
55                         dlg.center();
56                 } else if (selection instanceof FileResource || selection instanceof List) {
57                         DeleteFileDialog dlg = new DeleteFileDialog(newImages);
58                         dlg.center();
59                 } else if (selection instanceof GroupUserResource) {
60                         // TODO implement user deletion
61                 }
62     }
63 }