Example usage for com.vaadin.server FontAwesome EXPAND

List of usage examples for com.vaadin.server FontAwesome EXPAND

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome EXPAND.

Prototype

FontAwesome EXPAND

To view the source code for com.vaadin.server FontAwesome EXPAND.

Click Source Link

Usage

From source file:org.ikasan.dashboard.ui.monitor.component.MonitorPanel.java

License:BSD License

protected Component createContentWrapper(final Component small, final Component large) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("monitor-panel-slot");

    final CssLayout card1 = new CssLayout();
    card1.setWidth("100%");
    card1.addStyleName(ValoTheme.LAYOUT_CARD);

    final CssLayout card2 = new CssLayout();
    card2.setWidth("100%");
    card2.addStyleName(ValoTheme.LAYOUT_CARD);

    final HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");

    Label caption = new Label(large.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    large.setCaption(null);/*from w w  w  .j av  a2  s.  c om*/

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max = tools.addItem("", VaadinIcons.EXPAND, new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            if (!slot.getStyleName().contains("max")) {
                selectedItem.setIcon(FontAwesome.COMPRESS);
                slot.removeAllComponents();
                card2.removeAllComponents();
                card2.addComponents(toolbar, large);
                slot.addComponents(card2);
                toggleMaximized(slot, true);
            } else {
                slot.removeStyleName("max");
                selectedItem.setIcon(FontAwesome.EXPAND);
                toggleMaximized(slot, false);
                card1.removeAllComponents();
                card1.addComponents(toolbar, small);
                slot.removeAllComponents();
                slot.addComponents(card1);
            }
        }
    });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", VaadinIcons.COG, null);
    root.addItem("Configure", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    root.addSeparator();
    root.addItem("Close", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card1.addComponents(toolbar, small);
    //        card2.addComponents(toolbar, large);
    slot.addComponent(card1);
    return slot;
}