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