Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / commands / PropertiesCommand.java @ e6e9f6e6

History | View | Annotate | Download (5 kB)

1 a57faaf0 Christos Stathis
/*
2 e6e9f6e6 Christos KK Loverdos
 * Copyright 2011-2013 GRNET S.A. All rights reserved.
3 63366925 Christos Stathis
 *
4 63366925 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 63366925 Christos Stathis
 * without modification, are permitted provided that the following
6 63366925 Christos Stathis
 * conditions are met:
7 63366925 Christos Stathis
 *
8 63366925 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 63366925 Christos Stathis
 *      disclaimer.
11 63366925 Christos Stathis
 *
12 63366925 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 63366925 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 63366925 Christos Stathis
 *      provided with the distribution.
16 63366925 Christos Stathis
 *
17 63366925 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 63366925 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 63366925 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 63366925 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 63366925 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 63366925 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 63366925 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 63366925 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 63366925 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 63366925 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 63366925 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 63366925 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 63366925 Christos Stathis
 *
30 63366925 Christos Stathis
 * The views and conclusions contained in the software and
31 63366925 Christos Stathis
 * documentation are those of the authors and should not be
32 63366925 Christos Stathis
 * interpreted as representing official policies, either expressed
33 63366925 Christos Stathis
 * or implied, of GRNET S.A.
34 a57faaf0 Christos Stathis
 */
35 a57faaf0 Christos Stathis
package gr.grnet.pithos.web.client.commands;
36 a57faaf0 Christos Stathis
37 9326b841 Christos Stathis
import gr.grnet.pithos.web.client.FilePermissionsDialog;
38 a57faaf0 Christos Stathis
import gr.grnet.pithos.web.client.FilePropertiesDialog;
39 71875b42 Christos Stathis
import gr.grnet.pithos.web.client.FilePublishDialog;
40 9326b841 Christos Stathis
import gr.grnet.pithos.web.client.FileVersionsDialog;
41 a57faaf0 Christos Stathis
import gr.grnet.pithos.web.client.FilesPropertiesDialog;
42 6b7d024f Christos Stathis
import gr.grnet.pithos.web.client.FolderPermissionsDialog;
43 a57faaf0 Christos Stathis
import gr.grnet.pithos.web.client.FolderPropertiesDialog;
44 749068ba Christos Stathis
import gr.grnet.pithos.web.client.Pithos;
45 31997f49 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.File;
46 31997f49 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Folder;
47 a57faaf0 Christos Stathis
48 a57faaf0 Christos Stathis
import java.util.List;
49 a57faaf0 Christos Stathis
50 a57faaf0 Christos Stathis
import com.google.gwt.user.client.Command;
51 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.PopupPanel;
52 a57faaf0 Christos Stathis
53 a57faaf0 Christos Stathis
/**
54 a57faaf0 Christos Stathis
 * The command that displays the appropriate Properties dialog, according to the
55 a57faaf0 Christos Stathis
 * selected object in the application.
56 a57faaf0 Christos Stathis
 *
57 a57faaf0 Christos Stathis
 */
58 a57faaf0 Christos Stathis
public class PropertiesCommand implements Command {
59 a57faaf0 Christos Stathis
60 9326b841 Christos Stathis
        public static final int PROPERTIES = 0;
61 9326b841 Christos Stathis
        public static final int PERMISSIONS = 1;
62 9326b841 Christos Stathis
        public static final int VERSIONS = 2;
63 71875b42 Christos Stathis
        public static final int PUBLISH = 3;
64 9326b841 Christos Stathis
65 a57faaf0 Christos Stathis
        private PopupPanel containerPanel;
66 a57faaf0 Christos Stathis
67 a57faaf0 Christos Stathis
        private int tabToShow = 0;
68 a57faaf0 Christos Stathis
69 31997f49 Christos Stathis
    private Object resource;
70 31997f49 Christos Stathis
71 68e165a9 Christos Stathis
    Pithos app;
72 31997f49 Christos Stathis
73 a57faaf0 Christos Stathis
        /**
74 a57faaf0 Christos Stathis
         * @param _containerPanel
75 a57faaf0 Christos Stathis
         * @param _tab the tab to switch to
76 a57faaf0 Christos Stathis
         */
77 7260b946 Christos Stathis
        public PropertiesCommand(Pithos _app, PopupPanel _containerPanel, Object _resource, int _tab) {
78 a57faaf0 Christos Stathis
                containerPanel = _containerPanel;
79 a57faaf0 Christos Stathis
                tabToShow = _tab;
80 31997f49 Christos Stathis
        resource = _resource;
81 31997f49 Christos Stathis
        app = _app;
82 a57faaf0 Christos Stathis
        }
83 a57faaf0 Christos Stathis
84 a57faaf0 Christos Stathis
        @Override
85 a57faaf0 Christos Stathis
        public void execute() {
86 31997f49 Christos Stathis
        if (containerPanel != null)
87 31997f49 Christos Stathis
                    containerPanel.hide();
88 31997f49 Christos Stathis
89 31997f49 Christos Stathis
        if (resource instanceof Folder) {
90 b3832e45 Christos Stathis
            final Folder folder = (Folder) resource;
91 6b7d024f Christos Stathis
            switch (tabToShow) {
92 6b7d024f Christos Stathis
                                case PROPERTIES:
93 6b7d024f Christos Stathis
                                        FolderPropertiesDialog dlg = new FolderPropertiesDialog(app, false, folder);
94 6b7d024f Christos Stathis
                                        dlg.center();
95 6b7d024f Christos Stathis
                                        break;
96 6b7d024f Christos Stathis
                                case PERMISSIONS:
97 a2f617f8 Christos Stathis
                                        app.scheduleFolderHeadCommand(folder, new Command() {
98 57dff0dd Christos Stathis
                                                
99 57dff0dd Christos Stathis
                                                @Override
100 57dff0dd Christos Stathis
                                                public void execute() {
101 57dff0dd Christos Stathis
                                                        FolderPermissionsDialog dlg1 = new FolderPermissionsDialog(app, folder);
102 57dff0dd Christos Stathis
                                                        dlg1.center();
103 57dff0dd Christos Stathis
                                                }
104 57dff0dd Christos Stathis
                                        });
105 6b7d024f Christos Stathis
                                        break;
106 6b7d024f Christos Stathis
                                default:
107 6b7d024f Christos Stathis
                                        break;
108 6b7d024f Christos Stathis
                        }
109 31997f49 Christos Stathis
        }
110 31997f49 Christos Stathis
        else if (resource instanceof List) {
111 7811b9d1 Christos Stathis
            @SuppressWarnings("unchecked")
112 7811b9d1 Christos Stathis
                        List<File> files = (List<File>) resource;
113 31997f49 Christos Stathis
            if (files.size() > 1) {
114 f6cd2099 Christos Stathis
                FilesPropertiesDialog dlg = new FilesPropertiesDialog(app, files);
115 f6cd2099 Christos Stathis
                dlg.center();
116 31997f49 Christos Stathis
            }
117 31997f49 Christos Stathis
            else {
118 57dff0dd Christos Stathis
                                final File f = files.get(0);
119 9326b841 Christos Stathis
                    switch (tabToShow) {
120 9326b841 Christos Stathis
                                        case PROPERTIES:
121 a2f617f8 Christos Stathis
                                app.scheduleFileHeadCommand(f, new Command() {
122 57dff0dd Christos Stathis
                                                        
123 57dff0dd Christos Stathis
                                                        @Override
124 57dff0dd Christos Stathis
                                                        public void execute() {
125 57dff0dd Christos Stathis
                                                                FilePropertiesDialog dlg = new FilePropertiesDialog(app, f);
126 57dff0dd Christos Stathis
                                                dlg.center();
127 57dff0dd Christos Stathis
                                                        }
128 57dff0dd Christos Stathis
                                                });
129 9326b841 Christos Stathis
                                                break;
130 9326b841 Christos Stathis
                                        case PERMISSIONS:
131 a2f617f8 Christos Stathis
                                app.scheduleFileHeadCommand(f, new Command() {
132 57dff0dd Christos Stathis
                                                        
133 57dff0dd Christos Stathis
                                                        @Override
134 57dff0dd Christos Stathis
                                                        public void execute() {
135 57dff0dd Christos Stathis
                                                                FilePermissionsDialog dlg = new FilePermissionsDialog(app, f);
136 57dff0dd Christos Stathis
                                                                dlg.center();
137 57dff0dd Christos Stathis
                                                        }
138 57dff0dd Christos Stathis
                                                });
139 9326b841 Christos Stathis
                                                break;
140 9326b841 Christos Stathis
                                        case VERSIONS:
141 9326b841 Christos Stathis
                                FileVersionsDialog dlg2 = new FileVersionsDialog(app, files.get(0));
142 9326b841 Christos Stathis
                                dlg2.center();
143 9326b841 Christos Stathis
                                                break;
144 71875b42 Christos Stathis
                                        case PUBLISH:
145 71875b42 Christos Stathis
                                app.scheduleFileHeadCommand(f, new Command() {
146 71875b42 Christos Stathis
                                                        
147 71875b42 Christos Stathis
                                                        @Override
148 71875b42 Christos Stathis
                                                        public void execute() {
149 71875b42 Christos Stathis
                                                                FilePublishDialog dlg = new FilePublishDialog(app, f);
150 71875b42 Christos Stathis
                                                                dlg.center();
151 71875b42 Christos Stathis
                                                        }
152 71875b42 Christos Stathis
                                                });
153 71875b42 Christos Stathis
                                                break;
154 9326b841 Christos Stathis
                                        default:
155 9326b841 Christos Stathis
                                                break;
156 9326b841 Christos Stathis
                                }
157 31997f49 Christos Stathis
            }
158 31997f49 Christos Stathis
        }
159 a57faaf0 Christos Stathis
        }
160 a57faaf0 Christos Stathis
}