Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (4.5 kB)

1
/*
2
 * Copyright 2011-2013 GRNET S.A. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or
5
 * without modification, are permitted provided that the following
6
 * conditions are met:
7
 *
8
 *   1. Redistributions of source code must retain the above
9
 *      copyright notice, this list of conditions and the following
10
 *      disclaimer.
11
 *
12
 *   2. Redistributions in binary form must reproduce the above
13
 *      copyright notice, this list of conditions and the following
14
 *      disclaimer in the documentation and/or other materials
15
 *      provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
 * POSSIBILITY OF SUCH DAMAGE.
29
 *
30
 * The views and conclusions contained in the software and
31
 * documentation are those of the authors and should not be
32
 * interpreted as representing official policies, either expressed
33
 * or implied, of GRNET S.A.
34
 */
35
package gr.grnet.pithos.web.client.commands;
36

    
37
import gr.grnet.pithos.web.client.*;
38
import gr.grnet.pithos.web.client.FileShareDialog;
39
import gr.grnet.pithos.web.client.foldertree.File;
40
import gr.grnet.pithos.web.client.foldertree.Folder;
41

    
42
import java.util.List;
43

    
44
import com.google.gwt.user.client.Command;
45
import com.google.gwt.user.client.ui.PopupPanel;
46

    
47
/**
48
 * The command that displays the appropriate Properties dialog, according to the
49
 * selected object in the application.
50
 *
51
 */
52
public class PropertiesCommand implements Command {
53

    
54
        public static final int PROPERTIES = 0;
55
        public static final int PERMISSIONS = 1;
56
        public static final int VERSIONS = 2;
57
        public static final int PUBLISH = 3;
58

    
59
        private PopupPanel containerPanel;
60

    
61
        private int tabToShow = 0;
62

    
63
    private Object resource;
64

    
65
    Pithos app;
66

    
67
        /**
68
         * @param _containerPanel
69
         * @param _tab the tab to switch to
70
         */
71
        public PropertiesCommand(Pithos _app, PopupPanel _containerPanel, Object _resource, int _tab) {
72
                containerPanel = _containerPanel;
73
                tabToShow = _tab;
74
        resource = _resource;
75
        app = _app;
76
        }
77

    
78
        @Override
79
        public void execute() {
80
        if (containerPanel != null)
81
                    containerPanel.hide();
82

    
83
        Pithos.LOG("PropertiesCommand::execute(), resource = ", resource);
84
        if (resource instanceof Folder) {
85
            final Folder folder = (Folder) resource;
86
            switch (tabToShow) {
87
                                case PROPERTIES:
88
                                        FolderPropertiesDialog dlg = new FolderPropertiesDialog(app, false, folder);
89
                                        dlg.center();
90
                                        break;
91
                                case PERMISSIONS:
92
                                        app.scheduleFolderHeadCommand(folder, new Command() {
93
                                                
94
                                                @Override
95
                                                public void execute() {
96
                                                        FolderPermissionsDialog dlg1 = new FolderPermissionsDialog(app, folder);
97
                                                        dlg1.center();
98
                                                }
99
                                        });
100
                                        break;
101
                                default:
102
                                        break;
103
                        }
104
        }
105
        else if (resource instanceof List) {
106
            @SuppressWarnings("unchecked")
107
                        List<File> files = (List<File>) resource;
108
            if (files.size() > 1) {
109
                FilesPropertiesDialog dlg = new FilesPropertiesDialog(app, files);
110
                dlg.center();
111
            }
112
            else {
113
                                final File f = files.get(0);
114
                    switch (tabToShow) {
115
                                        case PROPERTIES:
116
                                app.scheduleFileHeadCommand(f, new Command() {
117
                                                        
118
                                                        @Override
119
                                                        public void execute() {
120
                                                                FilePropertiesDialog dlg = new FilePropertiesDialog(app, f);
121
                                                dlg.center();
122
                                                        }
123
                                                });
124
                                                break;
125
                                        case PERMISSIONS:
126
                                app.scheduleFileHeadCommand(f, new Command() {
127
                                                        
128
                                                        @Override
129
                                                        public void execute() {
130
                                FileShareDialog dlg = new FileShareDialog(app, f);
131
                                                                dlg.center();
132
                                                        }
133
                                                });
134
                                                break;
135
                                        case VERSIONS:
136
                                FileVersionsDialog dlg2 = new FileVersionsDialog(app, files.get(0));
137
                                dlg2.center();
138
                                                break;
139
                                        default:
140
                                                break;
141
                                }
142
            }
143
        }
144
        }
145
}