org.balisunrise.vaadin.components.header.ModuleButton.java Source code

Java tutorial

Introduction

Here is the source code for org.balisunrise.vaadin.components.header.ModuleButton.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 org.balisunrise.vaadin.components.header;

import com.vaadin.server.ThemeResource;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.Notification;

/**
 *
 * @author Glauco
 */
public class ModuleButton extends CustomComponent {

    private MenuBar button;

    public ModuleButton() {
        init();
    }

    private void init() {
        setStyleName("b-module-button");
        setHeight("100%");

        button = new MenuBar();
        setCompositionRoot(button);

        MenuBar.MenuItem modules = button.addItem("", null);
        //modules.setIcon(new ThemeResource("img/modules.png"));
        modules.setDescription("Clique e selecione um mdulo");

        modules.addItem("Pessoas", c -> {
            Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION);
        });
        modules.addItem("Vendas", c -> {
            Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION);
        });
        modules.addItem("Financeiro", c -> {
            Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION);
        });
        modules.addItem("Estoque", c -> {
            Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION);
        });
        modules.addItem("Compras", c -> {
            Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION);
        });
    }
}