Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / AboutDialog.java @ 2637c9cd

History | View | Annotate | Download (3.9 kB)

1 a57faaf0 Christos Stathis
/*
2 63366925 Christos Stathis
 * Copyright 2011 GRNET S.A. All rights reserved.
3 63366925 Christos Stathis
 *
4 63366925 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 63366925 Christos Stathis
 * without modification, are permitted provided that the following
6 63366925 Christos Stathis
 * conditions are met:
7 63366925 Christos Stathis
 *
8 63366925 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 63366925 Christos Stathis
 *      disclaimer.
11 63366925 Christos Stathis
 *
12 63366925 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 63366925 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 63366925 Christos Stathis
 *      provided with the distribution.
16 63366925 Christos Stathis
 *
17 63366925 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 63366925 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 63366925 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 63366925 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 63366925 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 63366925 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 63366925 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 63366925 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 63366925 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 63366925 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 63366925 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 63366925 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 63366925 Christos Stathis
 *
30 63366925 Christos Stathis
 * The views and conclusions contained in the software and
31 63366925 Christos Stathis
 * documentation are those of the authors and should not be
32 63366925 Christos Stathis
 * interpreted as representing official policies, either expressed
33 63366925 Christos Stathis
 * or implied, of GRNET S.A.
34 a57faaf0 Christos Stathis
 */
35 a57faaf0 Christos Stathis
package gr.grnet.pithos.web.client;
36 a57faaf0 Christos Stathis
37 a57faaf0 Christos Stathis
import com.google.gwt.core.client.GWT;
38 a57faaf0 Christos Stathis
import com.google.gwt.dom.client.NativeEvent;
39 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.ClickEvent;
40 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.ClickHandler;
41 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.KeyCodes;
42 a57faaf0 Christos Stathis
import com.google.gwt.user.client.Event.NativePreviewEvent;
43 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.Button;
44 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.DialogBox;
45 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.HTML;
46 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
47 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.VerticalPanel;
48 a57faaf0 Christos Stathis
49 a57faaf0 Christos Stathis
/**
50 a57faaf0 Christos Stathis
 * The 'about' dialog box.
51 a57faaf0 Christos Stathis
 */
52 a57faaf0 Christos Stathis
public class AboutDialog extends DialogBox {
53 a57faaf0 Christos Stathis
54 a57faaf0 Christos Stathis
        /**
55 a57faaf0 Christos Stathis
         * The widget constructor.
56 a57faaf0 Christos Stathis
         */
57 a57faaf0 Christos Stathis
        public AboutDialog() {
58 a57faaf0 Christos Stathis
                // Set the dialog's caption.
59 a57faaf0 Christos Stathis
                Configuration conf = (Configuration) GWT.create(Configuration.class);
60 a57faaf0 Christos Stathis
                String service = conf.serviceName();
61 a57faaf0 Christos Stathis
                setText("About " + service);
62 a57faaf0 Christos Stathis
                setAnimationEnabled(true);
63 a57faaf0 Christos Stathis
                // A VerticalPanel that contains the 'about' label and the 'OK' button.
64 a57faaf0 Christos Stathis
                final VerticalPanel outer = new VerticalPanel();
65 a57faaf0 Christos Stathis
66 a57faaf0 Christos Stathis
                // Create the 'about' text and set the style.
67 a57faaf0 Christos Stathis
                final HTML text = new HTML("This is the Web client for the " + service +
68 a57faaf0 Christos Stathis
                                        " service. You can use it to store, retrieve and share " +
69 a57faaf0 Christos Stathis
                                        "files in the " + service + " server grid. <p>Pithos version: " +
70 a57faaf0 Christos Stathis
                                        conf.version() + "<br> Service designed and implemented by " + "<a href='http://www.grnet.gr'>GRNET</a></p>");
71 a57faaf0 Christos Stathis
                text.setStyleName("pithos-AboutText");
72 a57faaf0 Christos Stathis
                outer.add(text);
73 a57faaf0 Christos Stathis
74 a57faaf0 Christos Stathis
                // Create the 'OK' button, along with a listener that hides the dialog
75 a57faaf0 Christos Stathis
                // when the button is clicked.
76 a57faaf0 Christos Stathis
                final Button confirm = new Button("Close", new ClickHandler() {
77 a57faaf0 Christos Stathis
78 a57faaf0 Christos Stathis
                        @Override
79 a57faaf0 Christos Stathis
                        public void onClick(ClickEvent event) {
80 a57faaf0 Christos Stathis
                                hide();
81 a57faaf0 Christos Stathis
                        }
82 a57faaf0 Christos Stathis
                });
83 a57faaf0 Christos Stathis
                outer.add(confirm);
84 a57faaf0 Christos Stathis
                outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);
85 a57faaf0 Christos Stathis
                outer.setSpacing(8);
86 a57faaf0 Christos Stathis
                setWidget(outer);
87 a57faaf0 Christos Stathis
        }
88 a57faaf0 Christos Stathis
89 a57faaf0 Christos Stathis
        @Override
90 a57faaf0 Christos Stathis
        protected void onPreviewNativeEvent(NativePreviewEvent preview) {
91 a57faaf0 Christos Stathis
                super.onPreviewNativeEvent(preview);
92 a57faaf0 Christos Stathis
                NativeEvent evt = preview.getNativeEvent();
93 a57faaf0 Christos Stathis
                if (evt.getType().equals("keydown"))
94 a57faaf0 Christos Stathis
                        // Use the popup's key preview hooks to close the dialog when
95 a57faaf0 Christos Stathis
                        // either enter or escape is pressed.
96 a57faaf0 Christos Stathis
                        switch (evt.getKeyCode()) {
97 a57faaf0 Christos Stathis
                                case KeyCodes.KEY_ENTER:
98 a57faaf0 Christos Stathis
                                case KeyCodes.KEY_ESCAPE:
99 a57faaf0 Christos Stathis
                                        hide();
100 a57faaf0 Christos Stathis
                                        break;
101 a57faaf0 Christos Stathis
                        }
102 a57faaf0 Christos Stathis
        }
103 a57faaf0 Christos Stathis
104 a57faaf0 Christos Stathis
}