Example usage for com.vaadin.ui NativeButton NativeButton

List of usage examples for com.vaadin.ui NativeButton NativeButton

Introduction

In this page you can find the example usage for com.vaadin.ui NativeButton NativeButton.

Prototype

public NativeButton(String caption) 

Source Link

Usage

From source file:pl.exsio.frameset.vaadin.navigation.menu.CssButtonsMenu.java

License:Open Source License

private void build(MenuItem menu, final int level, ComponentContainer container) {
    for (final MenuItem item : menu.getChildren()) {
        Button b = new NativeButton(t(item.getLabel()));
        b.addStyleName("menu-item-" + item.getFrame().getKey());
        b.setIcon(((VaadinFrame) item.getFrame()).getIcon());
        b.addClickListener(new Button.ClickListener() {
            @Override//from   w  w  w  .j  a v  a2 s .co m
            public void buttonClick(Button.ClickEvent event) {
                ((FramesetUI) getUI()).getFramesetNavigator().navigateTo(item.getFrame());
                if (item.getChildren().size() > 0) {
                    CssLayout submenu = (CssLayout) item.getParam("submenu");
                    submenu.setVisible(!submenu.isVisible());
                }
            }
        });
        this.buttons.add(b);
        container.addComponent(b);
        item.addParam("button", b);
        item.addParam("container", container);
        if (item.getChildren().size() > 0) {
            CssLayout subContainer = new CssLayout() {
                {
                    addStyleName("sub-menu");
                    addStyleName("menu-level-" + level);
                    setVisible(false);
                }
            };

            this.build(item, level + 1, subContainer);
            container.addComponent(subContainer);

            item.addParam("submenu", subContainer);
        }
    }
}