Use an exponential backoff strategy for retrying rolled back transactions.
[pithos] / src / gr / ebs / gss / 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.ebs.gss.client.commands;
20
21 import gr.ebs.gss.client.DeleteFileDialog;
22 import gr.ebs.gss.client.DeleteFolderDialog;
23 import gr.ebs.gss.client.DeleteGroupDialog;
24 import gr.ebs.gss.client.GSS;
25 import gr.ebs.gss.client.EditMenu.Images;
26 import gr.ebs.gss.client.rest.resource.FileResource;
27 import gr.ebs.gss.client.rest.resource.FolderResource;
28 import gr.ebs.gss.client.rest.resource.GroupResource;
29 import gr.ebs.gss.client.rest.resource.GroupUserResource;
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         /* (non-Javadoc)
56          * @see com.google.gwt.user.client.Command#execute()
57          */
58         public void execute() {
59                 containerPanel.hide();
60                 displayDelete();
61         }
62         /**
63          * Display the delete dialog, according to the selected object.
64          *
65          *
66          */
67         void displayDelete() {
68                 Object selection = GSS.get().getCurrentSelection();
69                 if (selection == null)
70                         return;
71                 GWT.log("selection: " + selection.toString(), null);
72                 if (selection instanceof FolderResource) {
73                         DeleteFolderDialog dlg = new DeleteFolderDialog(newImages);
74                         dlg.center();
75                 } else if (selection instanceof FileResource || selection instanceof List) {
76                         DeleteFileDialog dlg = new DeleteFileDialog(newImages);
77                         dlg.center();
78                 } else if (selection instanceof GroupUserResource) {
79                         // TODO implement user deletion
80                 } else if (selection instanceof GroupResource) {
81                         DeleteGroupDialog dlg = new DeleteGroupDialog(newImages);
82                         dlg.center();
83                 }
84         }
85 }