Statistics
| Branch: | Tag: | Revision:

root / web_client / src / gr / grnet / pithos / web / client / FilesPropertiesDialog.java @ 047a74bc

History | View | Annotate | Download (5.7 kB)

1
/*
2
 * Copyright 2011 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;
36

    
37
import gr.grnet.pithos.web.client.foldertree.File;
38
import gr.grnet.pithos.web.client.foldertree.Folder;
39

    
40
import java.util.List;
41

    
42
import com.google.gwt.event.dom.client.ClickEvent;
43
import com.google.gwt.event.dom.client.ClickHandler;
44
import com.google.gwt.user.client.ui.Button;
45
import com.google.gwt.user.client.ui.DecoratedTabPanel;
46
import com.google.gwt.user.client.ui.DisclosurePanel;
47
import com.google.gwt.user.client.ui.FlexTable;
48
import com.google.gwt.user.client.ui.FlowPanel;
49
import com.google.gwt.user.client.ui.FocusPanel;
50
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
51
import com.google.gwt.user.client.ui.HorizontalPanel;
52
import com.google.gwt.user.client.ui.VerticalPanel;
53

    
54
/**
55
 * The 'Multiple file properties' dialog box implementation.
56
 *
57
 */
58
public class FilesPropertiesDialog extends AbstractPropertiesDialog {
59

    
60
//        private final TristateCheckBox versionedCheck;
61

    
62
        private final List<File> files;
63

    
64
        /**
65
         * The widget's constructor.
66
         *
67
         * @param _files
68
         */
69
        public FilesPropertiesDialog(Pithos _app, final List<File> _files) {
70
                super(_app);
71

    
72
                files = _files;
73

    
74
                // Set the dialog's caption.
75
                setText("Files properties");
76

    
77
                // Outer contains inner and buttons.
78
                final VerticalPanel outer = new VerticalPanel();
79
                final FocusPanel focusPanel = new FocusPanel(outer);
80
                // Inner contains generalPanel and permPanel.
81
                inner = new DecoratedTabPanel();
82
                inner.setAnimationEnabled(true);
83

    
84
                inner.add(createGeneralPanel(), "General");
85

    
86
                inner.selectTab(0);
87
        outer.add(inner);
88

    
89
        final HorizontalPanel buttons = new HorizontalPanel();
90
                // Create the 'OK' button, along with a listener that hides the dialog
91
                // when the button is clicked.
92
                final Button ok = new Button("OK", new ClickHandler() {
93
                        @Override
94
                        public void onClick(@SuppressWarnings("unused") ClickEvent event) {
95
                                accept();
96
                                closeDialog();
97
                        }
98
                });
99
                buttons.add(ok);
100
                buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
101
                // Create the 'Cancel' button, along with a listener that hides the
102
                // dialog when the button is clicked.
103
                final Button cancel = new Button("Cancel", new ClickHandler() {
104
                        @Override
105
                        public void onClick(@SuppressWarnings("unused") ClickEvent event) {
106
                                closeDialog();
107
                        }
108
                });
109
                buttons.add(cancel);
110
                buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
111
                buttons.setSpacing(8);
112
                buttons.addStyleName("pithos-TabPanelBottom");
113
                outer.add(buttons);
114
                outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
115
                outer.addStyleName("pithos-TabPanelBottom");
116

    
117
                focusPanel.setFocus(true);
118
                setWidget(outer);
119
        }
120

    
121
    private VerticalPanel createGeneralPanel() {
122
        VerticalPanel generalPanel = new VerticalPanel();
123

    
124
        final FlexTable generalTable = new FlexTable();
125
        generalTable.setText(0, 0, String.valueOf(files.size())+" files selected");
126
        generalTable.setText(1, 0, "Folder");
127
        generalTable.setText(2, 0, "Tags");
128
        Folder parent = files.get(0).getParent();
129
        if(parent != null)
130
            generalTable.setText(1, 1, parent.getName());
131
        else
132
            generalTable.setText(1, 1, "-");
133

    
134
                generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
135
                generalTable.getFlexCellFormatter().setColSpan(0, 0, 2);
136
                generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
137
                generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");
138
                generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");
139
                generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");
140
                generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");
141
                generalTable.setCellSpacing(4);
142

    
143
        generalPanel.add(generalTable);
144

    
145
                DisclosurePanel allTags = new DisclosurePanel("All tags");
146
                allTagsContent = new FlowPanel();
147
                allTags.setContent(allTagsContent);
148
                generalPanel.add(allTags);
149
                generalPanel.setSpacing(4);
150

    
151
        return generalPanel;
152
    }
153

    
154
        /**
155
         * Accepts any change and updates the file
156
         *
157
         */
158
        @Override
159
        protected void accept() {
160
        }
161
}