FilePropertiesDialog is broken into three dialogs
[pithos-web-client] / src / gr / grnet / pithos / web / client / FilesPropertiesDialog.java
1 /*\r
2  * Copyright 2011 GRNET S.A. All rights reserved.\r
3  *\r
4  * Redistribution and use in source and binary forms, with or\r
5  * without modification, are permitted provided that the following\r
6  * conditions are met:\r
7  *\r
8  *   1. Redistributions of source code must retain the above\r
9  *      copyright notice, this list of conditions and the following\r
10  *      disclaimer.\r
11  *\r
12  *   2. Redistributions in binary form must reproduce the above\r
13  *      copyright notice, this list of conditions and the following\r
14  *      disclaimer in the documentation and/or other materials\r
15  *      provided with the distribution.\r
16  *\r
17  * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
18  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
20  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
21  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
24  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
27  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
28  * POSSIBILITY OF SUCH DAMAGE.\r
29  *\r
30  * The views and conclusions contained in the software and\r
31  * documentation are those of the authors and should not be\r
32  * interpreted as representing official policies, either expressed\r
33  * or implied, of GRNET S.A.\r
34  */\r
35 package gr.grnet.pithos.web.client;\r
36 \r
37 import gr.grnet.pithos.web.client.foldertree.File;\r
38 import gr.grnet.pithos.web.client.foldertree.Folder;\r
39 \r
40 import java.util.List;\r
41 \r
42 import com.google.gwt.event.dom.client.ClickEvent;\r
43 import com.google.gwt.event.dom.client.ClickHandler;\r
44 import com.google.gwt.user.client.ui.Button;\r
45 import com.google.gwt.user.client.ui.DecoratedTabPanel;\r
46 import com.google.gwt.user.client.ui.DisclosurePanel;\r
47 import com.google.gwt.user.client.ui.FlexTable;\r
48 import com.google.gwt.user.client.ui.FlowPanel;\r
49 import com.google.gwt.user.client.ui.FocusPanel;\r
50 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
51 import com.google.gwt.user.client.ui.HorizontalPanel;\r
52 import com.google.gwt.user.client.ui.VerticalPanel;\r
53 \r
54 /**\r
55  * The 'Multiple file properties' dialog box implementation.\r
56  *\r
57  */\r
58 public class FilesPropertiesDialog extends AbstractPropertiesDialog {\r
59 \r
60         private final List<File> files;\r
61 \r
62         /**\r
63          * The widget's constructor.\r
64          *\r
65          * @param _files\r
66          */\r
67         public FilesPropertiesDialog(Pithos _app, final List<File> _files) {\r
68                 super(_app);\r
69 \r
70                 files = _files;\r
71 \r
72                 // Set the dialog's caption.\r
73                 setText("Files properties");\r
74 \r
75                 // Outer contains inner and buttons.\r
76                 final VerticalPanel outer = new VerticalPanel();\r
77                 final FocusPanel focusPanel = new FocusPanel(outer);\r
78                 // Inner contains generalPanel and permPanel.\r
79                 inner = new VerticalPanel();\r
80 \r
81                 inner.add(createGeneralPanel());\r
82 \r
83         outer.add(inner);\r
84 \r
85         final HorizontalPanel buttons = new HorizontalPanel();\r
86                 // Create the 'OK' button, along with a listener that hides the dialog\r
87                 // when the button is clicked.\r
88                 final Button ok = new Button("OK", new ClickHandler() {\r
89                         @Override\r
90                         public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
91                                 accept();\r
92                                 closeDialog();\r
93                         }\r
94                 });\r
95                 buttons.add(ok);\r
96                 buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
97                 // Create the 'Cancel' button, along with a listener that hides the\r
98                 // dialog when the button is clicked.\r
99                 final Button cancel = new Button("Cancel", new ClickHandler() {\r
100                         @Override\r
101                         public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
102                                 closeDialog();\r
103                         }\r
104                 });\r
105                 buttons.add(cancel);\r
106                 buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
107                 buttons.setSpacing(8);\r
108                 buttons.addStyleName("pithos-TabPanelBottom");\r
109                 outer.add(buttons);\r
110                 outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
111                 outer.addStyleName("pithos-TabPanelBottom");\r
112 \r
113                 focusPanel.setFocus(true);\r
114                 setWidget(outer);\r
115         }\r
116 \r
117     private VerticalPanel createGeneralPanel() {\r
118         VerticalPanel generalPanel = new VerticalPanel();\r
119 \r
120         final FlexTable generalTable = new FlexTable();\r
121         generalTable.setText(0, 0, String.valueOf(files.size())+" files selected");\r
122         generalTable.setText(1, 0, "Folder");\r
123         generalTable.setText(2, 0, "Tags");\r
124         Folder parent = files.get(0).getParent();\r
125         if(parent != null)\r
126             generalTable.setText(1, 1, parent.getName());\r
127         else\r
128             generalTable.setText(1, 1, "-");\r
129 \r
130                 generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
131                 generalTable.getFlexCellFormatter().setColSpan(0, 0, 2);\r
132                 generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");\r
133                 generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");\r
134                 generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");\r
135                 generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");\r
136                 generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");\r
137                 generalTable.setCellSpacing(4);\r
138 \r
139         generalPanel.add(generalTable);\r
140 \r
141         return generalPanel;\r
142     }\r
143 \r
144         /**\r
145          * Accepts any change and updates the file\r
146          *\r
147          */\r
148         @Override\r
149         protected void accept() {\r
150         }\r
151 }\r