Renamed all packages to gr.grnet.pithos.*
[pithos] / web_client / src / gr / grnet / pithos / web / client / commands / DeleteCommand.java
1 /*
2  * Copyright 2008, 2009 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.grnet.pithos.web.client.commands;
20
21 import gr.grnet.pithos.web.client.DeleteFileDialog;
22 import gr.grnet.pithos.web.client.DeleteFolderDialog;
23 import gr.grnet.pithos.web.client.DeleteGroupDialog;
24 import gr.grnet.pithos.web.client.EditMenu.Images;
25 import gr.grnet.pithos.web.client.GSS;
26 import gr.grnet.pithos.web.client.rest.resource.FileResource;
27 import gr.grnet.pithos.web.client.rest.resource.GroupResource;
28 import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
29 import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
30
31 import java.util.List;
32
33 import com.google.gwt.core.client.GWT;
34 import com.google.gwt.user.client.Command;
35 import com.google.gwt.user.client.ui.PopupPanel;
36
37
38 /**
39  * Delete selected object command
40  * @author kman
41  *
42  */
43 public class DeleteCommand implements Command{
44         private PopupPanel containerPanel;
45         final Images newImages;
46
47         /**
48          * @param _containerPanel
49          * @param _newImages the images of all the possible delete dialogs
50          */
51         public DeleteCommand( PopupPanel _containerPanel, final Images _newImages ){
52                 containerPanel = _containerPanel;
53                 newImages=_newImages;
54         }
55
56         @Override
57         public void execute() {
58                 containerPanel.hide();
59                 displayDelete();
60         }
61         /**
62          * Display the delete dialog, according to the selected object.
63          *
64          *
65          */
66         void displayDelete() {
67                 Object selection = GSS.get().getCurrentSelection();
68                 if (selection == null)
69                         return;
70                 GWT.log("selection: " + selection.toString(), null);
71                 if (selection instanceof RestResourceWrapper) {
72                         DeleteFolderDialog dlg = new DeleteFolderDialog(newImages);
73                         dlg.center();
74                 } else if (selection instanceof FileResource || selection instanceof List) {
75                         DeleteFileDialog dlg = new DeleteFileDialog(newImages);
76                         dlg.center();
77                 } else if (selection instanceof GroupUserResource) {
78                         // TODO implement user deletion
79                 } else if (selection instanceof GroupResource) {
80                         DeleteGroupDialog dlg = new DeleteGroupDialog(newImages);
81                         dlg.center();
82                 }
83         }
84 }