root / src / gr / ebs / gss / client / AboutDialog.java @ 7a3445c1
History | View | Annotate | Download (3.1 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
|
3 |
*
|
4 |
* This file is part of GSS.
|
5 |
*
|
6 |
* GSS is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* GSS is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
package gr.ebs.gss.client; |
20 |
|
21 |
import com.google.gwt.core.client.GWT; |
22 |
import com.google.gwt.dom.client.NativeEvent; |
23 |
import com.google.gwt.event.dom.client.ClickEvent; |
24 |
import com.google.gwt.event.dom.client.ClickHandler; |
25 |
import com.google.gwt.event.dom.client.KeyCodes; |
26 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
27 |
import com.google.gwt.user.client.ui.Button; |
28 |
import com.google.gwt.user.client.ui.DialogBox; |
29 |
import com.google.gwt.user.client.ui.HTML; |
30 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
31 |
import com.google.gwt.user.client.ui.VerticalPanel; |
32 |
|
33 |
/**
|
34 |
* The 'about' dialog box.
|
35 |
*/
|
36 |
public class AboutDialog extends DialogBox { |
37 |
|
38 |
/**
|
39 |
* The widget constructor.
|
40 |
*/
|
41 |
public AboutDialog() {
|
42 |
// Set the dialog's caption.
|
43 |
Configuration conf = (Configuration) GWT.create(Configuration.class); |
44 |
String service = conf.serviceName();
|
45 |
setText("About " + service);
|
46 |
setAnimationEnabled(true);
|
47 |
// A VerticalPanel that contains the 'about' label and the 'OK' button.
|
48 |
final VerticalPanel outer = new VerticalPanel(); |
49 |
|
50 |
// Create the 'about' text and set the style.
|
51 |
final HTML text = new HTML("This is the Web client for the " + service + |
52 |
" service. You can use it to store, retrieve and share " +
|
53 |
"files in the " + service + " server grid. <p>Pithos version: " + |
54 |
conf.version() + "<br> A GRNET service designed and implemented by " + "<a href='http://www.grnet.gr'>GRNET</a>" + " and " + |
55 |
"<a href='http://www.ebs.gr' target='about'>EBS</a></p>");
|
56 |
text.setStyleName("gss-AboutText");
|
57 |
outer.add(text); |
58 |
|
59 |
// Create the 'OK' button, along with a listener that hides the dialog
|
60 |
// when the button is clicked.
|
61 |
final Button confirm = new Button("Close", new ClickHandler() { |
62 |
|
63 |
@Override
|
64 |
public void onClick(ClickEvent event) { |
65 |
hide(); |
66 |
} |
67 |
}); |
68 |
outer.add(confirm); |
69 |
outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER); |
70 |
outer.setSpacing(8);
|
71 |
setWidget(outer); |
72 |
} |
73 |
|
74 |
@Override
|
75 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
76 |
super.onPreviewNativeEvent(preview);
|
77 |
NativeEvent evt = preview.getNativeEvent(); |
78 |
if (evt.getType().equals("keydown")) |
79 |
// Use the popup's key preview hooks to close the dialog when
|
80 |
// either enter or escape is pressed.
|
81 |
switch (evt.getKeyCode()) {
|
82 |
case KeyCodes.KEY_ENTER:
|
83 |
case KeyCodes.KEY_ESCAPE:
|
84 |
hide(); |
85 |
break;
|
86 |
} |
87 |
} |
88 |
|
89 |
} |