Fixed various warnings
[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.FlexTable;\r
46 import com.google.gwt.user.client.ui.FocusPanel;\r
47 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
48 import com.google.gwt.user.client.ui.HorizontalPanel;\r
49 import com.google.gwt.user.client.ui.VerticalPanel;\r
50 \r
51 /**\r
52  * The 'Multiple file properties' dialog box implementation.\r
53  *\r
54  */\r
55 public class FilesPropertiesDialog extends AbstractPropertiesDialog {\r
56 \r
57         private final List<File> files;\r
58 \r
59         /**\r
60          * The widget's constructor.\r
61          *\r
62          * @param _files\r
63          */\r
64         public FilesPropertiesDialog(Pithos _app, final List<File> _files) {\r
65                 super(_app);\r
66 \r
67                 files = _files;\r
68 \r
69                 // Set the dialog's caption.\r
70                 setText("Files properties");\r
71 \r
72                 // Outer contains inner and buttons.\r
73                 final VerticalPanel outer = new VerticalPanel();\r
74                 final FocusPanel focusPanel = new FocusPanel(outer);\r
75                 // Inner contains generalPanel and permPanel.\r
76                 inner = new VerticalPanel();\r
77 \r
78                 inner.add(createGeneralPanel());\r
79 \r
80         outer.add(inner);\r
81 \r
82         final HorizontalPanel buttons = new HorizontalPanel();\r
83                 // Create the 'OK' button, along with a listener that hides the dialog\r
84                 // when the button is clicked.\r
85                 final Button ok = new Button("OK", new ClickHandler() {\r
86                         @Override\r
87                         public void onClick(ClickEvent event) {\r
88                                 accept();\r
89                                 closeDialog();\r
90                         }\r
91                 });\r
92                 buttons.add(ok);\r
93                 buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
94                 // Create the 'Cancel' button, along with a listener that hides the\r
95                 // dialog when the button is clicked.\r
96                 final Button cancel = new Button("Cancel", new ClickHandler() {\r
97                         @Override\r
98                         public void onClick(ClickEvent event) {\r
99                                 closeDialog();\r
100                         }\r
101                 });\r
102                 buttons.add(cancel);\r
103                 buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
104                 buttons.setSpacing(8);\r
105                 buttons.addStyleName("pithos-TabPanelBottom");\r
106                 outer.add(buttons);\r
107                 outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
108                 outer.addStyleName("pithos-TabPanelBottom");\r
109 \r
110                 focusPanel.setFocus(true);\r
111                 setWidget(outer);\r
112         }\r
113 \r
114     private VerticalPanel createGeneralPanel() {\r
115         VerticalPanel generalPanel = new VerticalPanel();\r
116 \r
117         final FlexTable generalTable = new FlexTable();\r
118         generalTable.setText(0, 0, String.valueOf(files.size())+" files selected");\r
119         generalTable.setText(1, 0, "Folder");\r
120         generalTable.setText(2, 0, "Tags");\r
121         Folder parent = files.get(0).getParent();\r
122         if(parent != null)\r
123             generalTable.setText(1, 1, parent.getName());\r
124         else\r
125             generalTable.setText(1, 1, "-");\r
126 \r
127                 generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
128                 generalTable.getFlexCellFormatter().setColSpan(0, 0, 2);\r
129                 generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");\r
130                 generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");\r
131                 generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");\r
132                 generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");\r
133                 generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");\r
134                 generalTable.setCellSpacing(4);\r
135 \r
136         generalPanel.add(generalTable);\r
137 \r
138         return generalPanel;\r
139     }\r
140 \r
141         /**\r
142          * Accepts any change and updates the file\r
143          *\r
144          */\r
145         @Override\r
146         protected void accept() {\r
147         }\r
148 }\r