org.gss_project.gss.web.client.AboutDialog.java Source code

Java tutorial

Introduction

Here is the source code for org.gss_project.gss.web.client.AboutDialog.java

Source

/*
 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
 *
 * This file is part of GSS.
 *
 * GSS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GSS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.gss_project.gss.web.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * The 'about' dialog box.
 */
public class AboutDialog extends DialogBox {

    /**
     * The widget constructor.
     */
    public AboutDialog() {
        // Set the dialog's caption.
        Configuration conf = (Configuration) GWT.create(Configuration.class);
        String service = conf.serviceName();
        setText("About " + service);
        setAnimationEnabled(true);
        // A VerticalPanel that contains the 'about' label and the 'OK' button.
        final VerticalPanel outer = new VerticalPanel();

        // Create the 'about' text and set the style.
        final HTML text = new HTML("This is the Web client for the " + service
                + " service. You can use it to store, retrieve and share " + "files in the " + service
                + " server grid. <p>Pithos version: " + conf.version()
                + "<br> A GRNET service designed and implemented by " + "<a href='http://www.grnet.gr'>GRNET</a>"
                + " and " + "<a href='http://www.ebs.gr' target='about'>EBS</a></p>");
        text.setStyleName("gss-AboutText");
        outer.add(text);

        // Create the 'OK' button, along with a listener that hides the dialog
        // when the button is clicked.
        final Button confirm = new Button("Close", new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                hide();
            }
        });
        outer.add(confirm);
        outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);
        outer.setSpacing(8);
        setWidget(outer);
    }

    @Override
    protected void onPreviewNativeEvent(NativePreviewEvent preview) {
        super.onPreviewNativeEvent(preview);
        NativeEvent evt = preview.getNativeEvent();
        if (evt.getType().equals("keydown"))
            // Use the popup's key preview hooks to close the dialog when
            // either enter or escape is pressed.
            switch (evt.getKeyCode()) {
            case KeyCodes.KEY_ENTER:
            case KeyCodes.KEY_ESCAPE:
                hide();
                break;
            }
    }

}