Updated copyright notice
[pithos] / web_client / src / gr / grnet / pithos / web / client / AboutDialog.java
1 /*\r
2  *  Copyright (c) 2011 Greek Research and Technology Network\r
3  */\r
4 package gr.grnet.pithos.web.client;\r
5 \r
6 import com.google.gwt.core.client.GWT;\r
7 import com.google.gwt.dom.client.NativeEvent;\r
8 import com.google.gwt.event.dom.client.ClickEvent;\r
9 import com.google.gwt.event.dom.client.ClickHandler;\r
10 import com.google.gwt.event.dom.client.KeyCodes;\r
11 import com.google.gwt.user.client.Event.NativePreviewEvent;\r
12 import com.google.gwt.user.client.ui.Button;\r
13 import com.google.gwt.user.client.ui.DialogBox;\r
14 import com.google.gwt.user.client.ui.HTML;\r
15 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
16 import com.google.gwt.user.client.ui.VerticalPanel;\r
17 \r
18 /**\r
19  * The 'about' dialog box.\r
20  */\r
21 public class AboutDialog extends DialogBox {\r
22 \r
23         /**\r
24          * The widget constructor.\r
25          */\r
26         public AboutDialog() {\r
27                 // Set the dialog's caption.\r
28                 Configuration conf = (Configuration) GWT.create(Configuration.class);\r
29                 String service = conf.serviceName();\r
30                 setText("About " + service);\r
31                 setAnimationEnabled(true);\r
32                 // A VerticalPanel that contains the 'about' label and the 'OK' button.\r
33                 final VerticalPanel outer = new VerticalPanel();\r
34 \r
35                 // Create the 'about' text and set the style.\r
36                 final HTML text = new HTML("This is the Web client for the " + service +\r
37                                         " service. You can use it to store, retrieve and share " +\r
38                                         "files in the " + service + " server grid. <p>Pithos version: " +\r
39                                         conf.version() + "<br> Service designed and implemented by " + "<a href='http://www.grnet.gr'>GRNET</a></p>");\r
40                 text.setStyleName("pithos-AboutText");\r
41                 outer.add(text);\r
42 \r
43                 // Create the 'OK' button, along with a listener that hides the dialog\r
44                 // when the button is clicked.\r
45                 final Button confirm = new Button("Close", new ClickHandler() {\r
46 \r
47                         @Override\r
48                         public void onClick(ClickEvent event) {\r
49                                 hide();\r
50                         }\r
51                 });\r
52                 outer.add(confirm);\r
53                 outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);\r
54                 outer.setSpacing(8);\r
55                 setWidget(outer);\r
56         }\r
57 \r
58         @Override\r
59         protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
60                 super.onPreviewNativeEvent(preview);\r
61                 NativeEvent evt = preview.getNativeEvent();\r
62                 if (evt.getType().equals("keydown"))\r
63                         // Use the popup's key preview hooks to close the dialog when\r
64                         // either enter or escape is pressed.\r
65                         switch (evt.getKeyCode()) {\r
66                                 case KeyCodes.KEY_ENTER:\r
67                                 case KeyCodes.KEY_ESCAPE:\r
68                                         hide();\r
69                                         break;\r
70                         }\r
71         }\r
72 \r
73 }\r