Remove the redundant gss top-level directory.
[pithos] / src / gr / ebs / gss / client / QuitDialog.java
1 /*\r
2  * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.\r
3  *\r
4  * This file is part of GSS.\r
5  *\r
6  * GSS is free software: you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation, either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * GSS is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with GSS.  If not, see <http://www.gnu.org/licenses/>.\r
18  */\r
19 package gr.ebs.gss.client;\r
20 \r
21 import com.google.gwt.core.client.GWT;\r
22 import com.google.gwt.user.client.ui.Button;\r
23 import com.google.gwt.user.client.ui.ClickListener;\r
24 import com.google.gwt.user.client.ui.DialogBox;\r
25 import com.google.gwt.user.client.ui.HTML;\r
26 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
27 import com.google.gwt.user.client.ui.HorizontalPanel;\r
28 import com.google.gwt.user.client.ui.KeyboardListener;\r
29 import com.google.gwt.user.client.ui.VerticalPanel;\r
30 import com.google.gwt.user.client.ui.Widget;\r
31 \r
32 /**\r
33  * The 'quit' dialog box.\r
34  */\r
35 public class QuitDialog extends DialogBox {\r
36 \r
37         /**\r
38          * The widget's constructor.\r
39          */\r
40         public QuitDialog() {\r
41                 Configuration conf = (Configuration) GWT.create(Configuration.class);\r
42                 String service = conf.serviceName();\r
43                 setText("Quit " + service);\r
44 \r
45                 VerticalPanel outer = new VerticalPanel();\r
46                 HorizontalPanel buttons = new HorizontalPanel();\r
47 \r
48                 HTML text = new HTML("Are you sure you want to quit " + service + "?");\r
49                 text.setStyleName("gss-AboutText");\r
50                 outer.add(text);\r
51 \r
52                 // Create the 'Quit' button, along with a listener that hides the dialog\r
53                 // when the button is clicked and quits the application.\r
54                 Button quit = new Button("Quit", new ClickListener() {\r
55 \r
56                         public void onClick(Widget sender) {\r
57                                 hide();\r
58                                 GSS.get().logout();\r
59                         }\r
60                 });\r
61                 buttons.add(quit);\r
62                 buttons.setCellHorizontalAlignment(quit, HasHorizontalAlignment.ALIGN_CENTER);\r
63                 // Create the 'Cancel' button, along with a listener that hides the\r
64                 // dialog when the button is clicked.\r
65                 Button cancel = new Button("Cancel", new ClickListener() {\r
66 \r
67                         public void onClick(Widget sender) {\r
68                                 hide();\r
69                         }\r
70                 });\r
71                 buttons.add(cancel);\r
72                 buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
73                 buttons.setSpacing(8);\r
74                 outer.add(buttons);\r
75                 outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
76                 setWidget(outer);\r
77         }\r
78 \r
79         @Override\r
80         public boolean onKeyDownPreview(char key, int modifiers) {\r
81                 // Use the popup's key preview hooks to close the dialog when either\r
82                 // enter or escape is pressed.\r
83                 switch (key) {\r
84                         case KeyboardListener.KEY_ENTER:\r
85                                 hide();\r
86                                 GSS.get().logout();\r
87                                 break;\r
88                         case KeyboardListener.KEY_ESCAPE:\r
89                                 hide();\r
90                                 break;\r
91                 }\r
92                 return true;\r
93         }\r
94 \r
95 }\r