Finished file versions
[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 TristateCheckBox versionedCheck;\r
61 \r
62         private final List<File> files;\r
63 \r
64         /**\r
65          * The widget's constructor.\r
66          *\r
67          * @param _files\r
68          */\r
69         public FilesPropertiesDialog(Pithos _app, final List<File> _files) {\r
70                 super(_app);\r
71 \r
72                 files = _files;\r
73 \r
74                 // Set the dialog's caption.\r
75                 setText("Files properties");\r
76 \r
77                 // Outer contains inner and buttons.\r
78                 final VerticalPanel outer = new VerticalPanel();\r
79                 final FocusPanel focusPanel = new FocusPanel(outer);\r
80                 // Inner contains generalPanel and permPanel.\r
81                 inner = new DecoratedTabPanel();\r
82                 inner.setAnimationEnabled(true);\r
83 \r
84                 inner.add(createGeneralPanel(), "General");\r
85 \r
86                 inner.selectTab(0);\r
87         outer.add(inner);\r
88 \r
89         final HorizontalPanel buttons = new HorizontalPanel();\r
90                 // Create the 'OK' button, along with a listener that hides the dialog\r
91                 // when the button is clicked.\r
92                 final Button ok = new Button("OK", new ClickHandler() {\r
93                         @Override\r
94                         public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
95                                 accept();\r
96                                 closeDialog();\r
97                         }\r
98                 });\r
99                 buttons.add(ok);\r
100                 buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
101                 // Create the 'Cancel' button, along with a listener that hides the\r
102                 // dialog when the button is clicked.\r
103                 final Button cancel = new Button("Cancel", new ClickHandler() {\r
104                         @Override\r
105                         public void onClick(@SuppressWarnings("unused") ClickEvent event) {\r
106                                 closeDialog();\r
107                         }\r
108                 });\r
109                 buttons.add(cancel);\r
110                 buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
111                 buttons.setSpacing(8);\r
112                 buttons.addStyleName("pithos-TabPanelBottom");\r
113                 outer.add(buttons);\r
114                 outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
115                 outer.addStyleName("pithos-TabPanelBottom");\r
116 \r
117                 focusPanel.setFocus(true);\r
118                 setWidget(outer);\r
119         }\r
120 \r
121     private VerticalPanel createGeneralPanel() {\r
122         VerticalPanel generalPanel = new VerticalPanel();\r
123 \r
124         final FlexTable generalTable = new FlexTable();\r
125         generalTable.setText(0, 0, String.valueOf(files.size())+" files selected");\r
126         generalTable.setText(1, 0, "Folder");\r
127         generalTable.setText(2, 0, "Tags");\r
128         Folder parent = files.get(0).getParent();\r
129         if(parent != null)\r
130             generalTable.setText(1, 1, parent.getName());\r
131         else\r
132             generalTable.setText(1, 1, "-");\r
133 \r
134                 generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
135                 generalTable.getFlexCellFormatter().setColSpan(0, 0, 2);\r
136                 generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");\r
137                 generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");\r
138                 generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");\r
139                 generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");\r
140                 generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");\r
141                 generalTable.setCellSpacing(4);\r
142 \r
143         generalPanel.add(generalTable);\r
144 \r
145                 DisclosurePanel allTags = new DisclosurePanel("All tags");\r
146                 allTagsContent = new FlowPanel();\r
147                 allTags.setContent(allTagsContent);\r
148                 generalPanel.add(allTags);\r
149                 generalPanel.setSpacing(4);\r
150 \r
151         return generalPanel;\r
152     }\r
153 \r
154         /**\r
155          * Accepts any change and updates the file\r
156          *\r
157          */\r
158         @Override\r
159         protected void accept() {\r
160         }\r
161 }\r