org.cloud4gl.client.event.MenuSelectionEventHandler.java Source code

Java tutorial

Introduction

Here is the source code for org.cloud4gl.client.event.MenuSelectionEventHandler.java

Source

/*
 * Better places framework for  Gwt.
 *
 * Copyright (c) 2014, Rony George
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library 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 Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
package org.cloud4gl.client.event;

import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.History;

import org.cloud4gl.client.AppController;
import org.cloud4gl.client.CommonPlace;

/**
 * The MenuSelectionEventHandler listems to selection of items from the top tab bar
 * 
 * @author georon
 *
 */
public class MenuSelectionEventHandler implements SelectionHandler<Integer> {

    private AppController appController;

    public MenuSelectionEventHandler(AppController appController) {
        super();
        this.appController = appController;
    }

    @Override
    public void onSelection(SelectionEvent<Integer> event) {
        int selection = event.getSelectedItem();
        CommonPlace place = this.appController.getPlaceByIndex(selection);
        this.appController.getPlaceController().goTo(place);
        History.fireCurrentHistoryState();
    }

}