2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\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
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
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
19 package gr.ebs.gss.client;
\r
21 import com.google.gwt.core.client.GWT;
\r
22 import com.google.gwt.dom.client.NativeEvent;
\r
23 import com.google.gwt.event.dom.client.ClickEvent;
\r
24 import com.google.gwt.event.dom.client.ClickHandler;
\r
25 import com.google.gwt.event.dom.client.KeyCodes;
\r
26 import com.google.gwt.user.client.Event.NativePreviewEvent;
\r
27 import com.google.gwt.user.client.ui.Button;
\r
28 import com.google.gwt.user.client.ui.DialogBox;
\r
29 import com.google.gwt.user.client.ui.HTML;
\r
30 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
\r
31 import com.google.gwt.user.client.ui.HorizontalPanel;
\r
32 import com.google.gwt.user.client.ui.VerticalPanel;
\r
35 * The 'quit' dialog box.
\r
37 public class QuitDialog extends DialogBox {
\r
40 * The widget's constructor.
\r
42 public QuitDialog() {
\r
43 Configuration conf = (Configuration) GWT.create(Configuration.class);
\r
44 String service = conf.serviceName();
\r
45 setText("Quit " + service);
\r
47 VerticalPanel outer = new VerticalPanel();
\r
48 HorizontalPanel buttons = new HorizontalPanel();
\r
50 HTML text = new HTML("Are you sure you want to quit " + service + "?");
\r
51 text.setStyleName("gss-AboutText");
\r
54 // Create the 'Quit' button, along with a listener that hides the dialog
\r
55 // when the button is clicked and quits the application.
\r
56 Button quit = new Button("Quit", new ClickHandler() {
\r
58 public void onClick(ClickEvent event) {
\r
64 buttons.setCellHorizontalAlignment(quit, HasHorizontalAlignment.ALIGN_CENTER);
\r
65 // Create the 'Cancel' button, along with a listener that hides the
\r
66 // dialog when the button is clicked.
\r
67 Button cancel = new Button("Cancel", new ClickHandler() {
\r
69 public void onClick(ClickEvent event) {
\r
73 buttons.add(cancel);
\r
74 buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
\r
75 buttons.setSpacing(8);
\r
77 outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
\r
82 protected void onPreviewNativeEvent(NativePreviewEvent preview) {
\r
83 super.onPreviewNativeEvent(preview);
\r
85 NativeEvent evt = preview.getNativeEvent();
\r
86 if (evt.getType().equals("keydown"))
\r
87 // Use the popup's key preview hooks to close the dialog when either
\r
88 // enter or escape is pressed.
\r
89 switch (evt.getKeyCode()) {
\r
90 case KeyCodes.KEY_ENTER:
\r
94 case KeyCodes.KEY_ESCAPE:
\r