com.cerebro.provevaadin.Game.java Source code

Java tutorial

Introduction

Here is the source code for com.cerebro.provevaadin.Game.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cerebro.provevaadin;

import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author matteo
 */
class Game extends HorizontalLayout {

    Logger logger = LoggerFactory.getLogger(Game.class);

    public Game() {

        Subject currentUser = SecurityUtils.getSubject();

        this.addComponent(new Label("Area di gioco"));

        Button logout = new Button("Esci");
        this.addComponent(logout);
        logout.addClickListener((Button.ClickEvent e) -> {
            logger.info("Esco dall'applicazione");
            logger.info("Pulsante: " + e.toString());
            SecurityUtils.getSubject().logout();
            UI.getCurrent().getSession().close();
            UI.getCurrent().getPage().setLocation("");
        });
    }

}