Statistics
| Branch: | Tag: | Revision:

root / web_client / src / gr / grnet / pithos / web / client / commands / DeleteCommand.java @ 7529fcd7

History | View | Annotate | Download (3.2 kB)

1 ab1eb3f8 Christos Stathis
/*
2 58777026 Christos Stathis
 * Copyright 2011 GRNET S.A. All rights reserved.
3 58777026 Christos Stathis
 *
4 58777026 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 58777026 Christos Stathis
 * without modification, are permitted provided that the following
6 58777026 Christos Stathis
 * conditions are met:
7 58777026 Christos Stathis
 *
8 58777026 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 58777026 Christos Stathis
 *      disclaimer.
11 58777026 Christos Stathis
 *
12 58777026 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 58777026 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 58777026 Christos Stathis
 *      provided with the distribution.
16 58777026 Christos Stathis
 *
17 58777026 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 58777026 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 58777026 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 58777026 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 58777026 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 58777026 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 58777026 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 58777026 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 58777026 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 58777026 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 58777026 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 58777026 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 58777026 Christos Stathis
 *
30 58777026 Christos Stathis
 * The views and conclusions contained in the software and
31 58777026 Christos Stathis
 * documentation are those of the authors and should not be
32 58777026 Christos Stathis
 * interpreted as representing official policies, either expressed
33 58777026 Christos Stathis
 * or implied, of GRNET S.A.
34 ab1eb3f8 Christos Stathis
 */
35 ab1eb3f8 Christos Stathis
package gr.grnet.pithos.web.client.commands;
36 ab1eb3f8 Christos Stathis
37 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.DeleteFileDialog;
38 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.DeleteFolderDialog;
39 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.EditMenu.Images;
40 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.GSS;
41 4bcf5e39 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.File;
42 4bcf5e39 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Folder;
43 4bcf5e39 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Resource;
44 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.resource.FileResource;
45 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
46 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
47 ab1eb3f8 Christos Stathis
48 ab1eb3f8 Christos Stathis
import java.util.List;
49 ab1eb3f8 Christos Stathis
50 ab1eb3f8 Christos Stathis
import com.google.gwt.core.client.GWT;
51 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.Command;
52 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.PopupPanel;
53 ab1eb3f8 Christos Stathis
54 ab1eb3f8 Christos Stathis
55 ab1eb3f8 Christos Stathis
/**
56 ab1eb3f8 Christos Stathis
 * Delete selected object command
57 ab1eb3f8 Christos Stathis
 *
58 ab1eb3f8 Christos Stathis
 */
59 ab1eb3f8 Christos Stathis
public class DeleteCommand implements Command{
60 ab1eb3f8 Christos Stathis
        private PopupPanel containerPanel;
61 ab1eb3f8 Christos Stathis
        final Images newImages;
62 ab1eb3f8 Christos Stathis
63 816de19f Christos Stathis
    private Object resource;
64 4bcf5e39 Christos Stathis
65 ab1eb3f8 Christos Stathis
        /**
66 ab1eb3f8 Christos Stathis
         * @param _containerPanel
67 ab1eb3f8 Christos Stathis
         * @param _newImages the images of all the possible delete dialogs
68 ab1eb3f8 Christos Stathis
         */
69 816de19f Christos Stathis
        public DeleteCommand( PopupPanel _containerPanel, Object resource, final Images _newImages ){
70 ab1eb3f8 Christos Stathis
                containerPanel = _containerPanel;
71 4bcf5e39 Christos Stathis
                newImages = _newImages;
72 4bcf5e39 Christos Stathis
        this.resource = resource;
73 ab1eb3f8 Christos Stathis
        }
74 ab1eb3f8 Christos Stathis
75 ab1eb3f8 Christos Stathis
        @Override
76 ab1eb3f8 Christos Stathis
        public void execute() {
77 ab1eb3f8 Christos Stathis
                containerPanel.hide();
78 ab1eb3f8 Christos Stathis
                displayDelete();
79 ab1eb3f8 Christos Stathis
        }
80 ab1eb3f8 Christos Stathis
        /**
81 ab1eb3f8 Christos Stathis
         * Display the delete dialog, according to the selected object.
82 ab1eb3f8 Christos Stathis
         *
83 ab1eb3f8 Christos Stathis
         *
84 ab1eb3f8 Christos Stathis
         */
85 ab1eb3f8 Christos Stathis
        void displayDelete() {
86 4bcf5e39 Christos Stathis
                if (resource instanceof Folder) {
87 4bcf5e39 Christos Stathis
                        DeleteFolderDialog dlg = new DeleteFolderDialog(GSS.get(), newImages, (Folder) resource);
88 ab1eb3f8 Christos Stathis
                        dlg.center();
89 816de19f Christos Stathis
                } else if (resource instanceof List) {
90 816de19f Christos Stathis
                        DeleteFileDialog dlg = new DeleteFileDialog(newImages, (List<File>) resource);
91 ab1eb3f8 Christos Stathis
                        dlg.center();
92 ab1eb3f8 Christos Stathis
                }
93 9e8e14e4 Christos Stathis
    }
94 ab1eb3f8 Christos Stathis
}