Package net.frenopatico.citadels.view.windows

Source Code of net.frenopatico.citadels.view.windows.MainWindow

/**
*
*/
package net.frenopatico.citadels.view.windows;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Singleton;

import net.frenopatico.citadels.view.accessors.Messages;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.Window;

/**
* Window the give the user the opportunity to log in.
*
* @author eduardo.ramirez.ronco@gmail.com
*/
@Singleton
public class MainWindow extends Window {
    private static final long serialVersionUID = 2376788521405394546L;

    /**
     * Wire and initialize the window.
     *
     *@param requestURI URI for the current request.
     */
    public void initialize( final String requestURI ) {
        this.removeAllComponents();

        final HorizontalLayout authInfo = new HorizontalLayout();
        this.addComponent( new Label( "Demonstrating how to do Google accounts authentication in a <a href=\"http://www.vaadin.com\">Vaadin</a> application deployed to Google App Engine.", Label.CONTENT_XHTML ) );
        this.addComponent( authInfo );

        final UserService userService = UserServiceFactory.getUserService();
        final User currentUser = userService.getCurrentUser();

        final List<Link> links = new ArrayList<Link>( 1 );
        final Label email = new Label( currentUser.getNickname() );

        links.add( new Link( Messages.get( "app.logout" ), new ExternalResource( userService.createLogoutURL( requestURI ) ) ) );

        email.setStyleName( "email" );
        authInfo.addComponent( email );

        for( Link link : links ) {
            authInfo.addComponent( link );
        }
    }
}
TOP

Related Classes of net.frenopatico.citadels.view.windows.MainWindow

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.