Example usage for com.vaadin.ui MenuBar MenuBar

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

Introduction

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

Prototype

public MenuBar() 

Source Link

Document

Constructs an empty, horizontal menu.

Usage

From source file:com.cavisson.gui.dashboard.components.controls.Dragging.java

License:Apache License

public Dragging() {
    setMargin(true);/*from w  w  w  .  jav a 2 s  . co m*/
    setSpacing(true);

    Label h1 = new Label("Dragging Components");
    h1.addStyleName("h1");
    addComponent(h1);

    MenuBar options = new MenuBar();
    options.setCaption("Drop Hints");
    addComponent(options);

    // Use these styles to hide irrelevant drag hints
    // Can be used either on a parent or directly on the DnDWrapper
    MenuItem opt = options.addItem("Vertical", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            if (selectedItem.isChecked()) {
                sample.removeStyleName("no-vertical-drag-hints");
            } else {
                sample.addStyleName("no-vertical-drag-hints");
            }
        }
    });
    opt.setCheckable(true);
    opt.setChecked(true);

    opt = options.addItem("Horizontal", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            if (selectedItem.isChecked()) {
                sample.removeStyleName("no-horizontal-drag-hints");
            } else {
                sample.addStyleName("no-horizontal-drag-hints");
            }
        }
    });
    opt.setCheckable(true);
    opt.setChecked(true);

    opt = options.addItem("Box", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            if (selectedItem.isChecked()) {
                sample.removeStyleName("no-box-drag-hints");
            } else {
                sample.addStyleName("no-box-drag-hints");
            }
        }
    });
    opt.setCheckable(true);
    opt.setChecked(true);

    sample = new SortableLayout();
    sample.setSizeUndefined();
    sample.setHeight("100px");

    for (final Component component : createComponents()) {
        sample.addComponent(component);
    }

    addComponent(sample);

}

From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java

License:Apache License

static MenuBar getMenuBar() {
    Command click = new Command() {
        @Override// w w  w . j  a v  a  2s . c  om
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Clicked " + selectedItem.getText());
        }
    };

    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");
    final MenuBar.MenuItem file = menubar.addItem("File", null);
    final MenuBar.MenuItem newItem = file.addItem("New", null);
    file.addItem("Open file...", click);
    file.addSeparator();

    newItem.addItem("File", click);
    newItem.addItem("Folder", click);
    newItem.addItem("Project...", click);

    file.addItem("Close", click);
    file.addItem("Close All", click);
    file.addSeparator();

    file.addItem("Save", click);
    file.addItem("Save As...", click);
    file.addItem("Save All", click);

    final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
    edit.addItem("Undo", click);
    edit.addItem("Redo", click).setEnabled(false);
    edit.addSeparator();

    edit.addItem("Cut", click);
    edit.addItem("Copy", click);
    edit.addItem("Paste", click);
    edit.addSeparator();

    final MenuBar.MenuItem find = edit.addItem("Find/Replace", null);

    find.addItem("Google Search", click);
    find.addSeparator();
    find.addItem("Find/Replace...", click);
    find.addItem("Find Next", click);
    find.addItem("Find Previous", click);

    Command check = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show(selectedItem.isChecked() ? "Checked" : "Unchecked");
        }
    };

    final MenuBar.MenuItem view = menubar.addItem("View", null);
    view.addItem("Show Status Bar", check).setCheckable(true);
    MenuItem title = view.addItem("Show Title Bar", check);
    title.setCheckable(true);
    title.setChecked(true);
    view.addItem("Customize Toolbar...", click);
    view.addSeparator();

    view.addItem("Actual Size", click);
    view.addItem("Zoom In", click);
    view.addItem("Zoom Out", click);

    TestIcon testIcon = new TestIcon(50);

    MenuItem fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setChecked(true);

    fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setCheckable(true);

    menubar.addItem("Attach", click).setIcon(FontAwesome.PAPERCLIP);
    menubar.addItem("Undo", click).setIcon(FontAwesome.UNDO);
    MenuItem redo = menubar.addItem("Redo", click);
    redo.setIcon(FontAwesome.REPEAT);
    redo.setEnabled(false);
    menubar.addItem("Upload", click).setIcon(FontAwesome.UPLOAD);

    return menubar;
}

From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java

License:Apache License

static MenuBar getToolBar() {
    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");

    MenuItem fav = menubar.addItem("", null);
    fav.setIcon(FontAwesome.ALIGN_LEFT);
    fav.setStyleName("icon-only");
    fav.setCheckable(true);/*from  www.j  av a2s  .  co m*/
    // fav.setChecked(true);

    fav = menubar.addItem("", null);
    fav.setIcon(FontAwesome.ALIGN_CENTER);
    fav.setStyleName("icon-only");
    fav.setCheckable(true);

    fav = menubar.addItem("", null);
    fav.setIcon(FontAwesome.ALIGN_RIGHT);
    fav.setStyleName("icon-only");
    fav.setCheckable(true);

    MenuItem clip = menubar.addItem("", null);
    clip.setIcon(FontAwesome.PAPERCLIP);
    clip.setStyleName("icon-only");

    MenuItem undo = menubar.addItem("", null);
    undo.setIcon(FontAwesome.UNDO);
    undo.setStyleName("icon-only");

    MenuItem redo = menubar.addItem("", null);
    redo.setIcon(FontAwesome.REPEAT);
    redo.setEnabled(false);
    redo.setStyleName("icon-only");

    return menubar;
}

From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java

License:Apache License

static MenuBar getMenuButton(String caption, boolean splitButton) {
    MenuBar split = new MenuBar();
    MenuBar.MenuItem dropdown = split.addItem(caption, null);
    if (splitButton) {
        dropdown = split.addItem("", null);
    }/*from  w  w  w .  j a v a 2s.com*/
    dropdown.addItem("Another Action", null);
    dropdown.addItem("Secondary Action", null);
    dropdown.addSeparator();
    dropdown.addItem("Last Action", null);

    return split;
}

From source file:com.cavisson.gui.dashboard.components.controls.Panels.java

License:Apache License

public Panels() {
    setMargin(true);//ww  w  .  ja  v a  2s .  co  m

    Label h1 = new Label("Panels & Layout panels");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);
    TestIcon testIcon = new TestIcon(60);

    Panel panel = new Panel("Normal");
    panel.setIcon(testIcon.get());
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Sized");
    panel.setIcon(testIcon.get());
    panel.setWidth("10em");
    panel.setHeight("250px");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Custom Caption");
    panel.setIcon(testIcon.get());
    panel.addStyleName("color1");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Custom Caption");
    panel.setIcon(testIcon.get());
    panel.addStyleName("color2");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Custom Caption");
    panel.setIcon(testIcon.get());
    panel.addStyleName("color3");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Borderless style");
    panel.setIcon(testIcon.get());
    panel.addStyleName("borderless");
    panel.setContent(panelContent());
    row.addComponent(panel);

    panel = new Panel("Borderless + scroll divider");
    panel.setIcon(testIcon.get());
    panel.addStyleName("borderless");
    panel.addStyleName("scroll-divider");
    panel.setContent(panelContentScroll());
    panel.setHeight("17em");
    row.addComponent(panel);

    panel = new Panel("Well style");
    panel.setIcon(testIcon.get());
    panel.addStyleName("well");
    panel.setContent(panelContent());
    row.addComponent(panel);

    CssLayout layout = new CssLayout();
    layout.setIcon(testIcon.get());
    layout.setCaption("Panel style layout");
    layout.addStyleName("card");
    layout.addComponent(panelContent());
    row.addComponent(layout);

    layout = new CssLayout();
    layout.addStyleName("card");
    row.addComponent(layout);
    HorizontalLayout panelCaption = new HorizontalLayout();
    panelCaption.addStyleName("v-panel-caption");
    panelCaption.setWidth("100%");
    // panelCaption.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label label = new Label("Panel style layout");
    panelCaption.addComponent(label);
    panelCaption.setExpandRatio(label, 1);

    Button action = new Button();
    action.setIcon(FontAwesome.PENCIL);
    action.addStyleName("borderless-colored");
    action.addStyleName("small");
    action.addStyleName("icon-only");
    panelCaption.addComponent(action);
    MenuBar dropdown = new MenuBar();
    dropdown.addStyleName("borderless");
    dropdown.addStyleName("small");
    MenuItem addItem = dropdown.addItem("", FontAwesome.CHEVRON_DOWN, null);
    addItem.setStyleName("icon-only");
    addItem.addItem("Settings", null);
    addItem.addItem("Preferences", null);
    addItem.addSeparator();
    addItem.addItem("Sign Out", null);
    panelCaption.addComponent(dropdown);

    layout.addComponent(panelCaption);
    layout.addComponent(panelContent());
    layout.setWidth("14em");

    layout = new CssLayout();
    layout.setIcon(testIcon.get());
    layout.setCaption("Well style layout");
    layout.addStyleName("well");
    layout.addComponent(panelContent());
    row.addComponent(layout);
}

From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java

License:Apache License

CssLayout buildMenu() {
    // Add items/*from  w  w  w  .ja  v a2 s  .  c o m*/
    menuItems.put("common", "Common UI Elements");
    menuItems.put("labels", "Labels");
    menuItems.put("buttons-and-links", "Buttons & Links");
    menuItems.put("textfields", "Text Fields");
    menuItems.put("datefields", "Date Fields");
    menuItems.put("comboboxes", "Combo Boxes");
    menuItems.put("selects", "Selects");
    menuItems.put("checkboxes", "Check Boxes & Option Groups");
    menuItems.put("sliders", "Sliders & Progress Bars");
    menuItems.put("colorpickers", "Color Pickers");
    menuItems.put("menubars", "Menu Bars");
    menuItems.put("trees", "Trees");
    menuItems.put("tables", "Tables");
    menuItems.put("dragging", "Drag and Drop");
    menuItems.put("panels", "Panels");
    menuItems.put("splitpanels", "Split Panels");
    menuItems.put("tabs", "Tabs");
    menuItems.put("accordions", "Accordions");
    menuItems.put("popupviews", "Popup Views");
    // menuItems.put("calendar", "Calendar");
    menuItems.put("forms", "Forms");

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    menu.addComponent(createThemeSelect());

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    final StringGenerator sg = new StringGenerator();
    final MenuItem settingsItem = settings.addItem(
            sg.nextString(true) + " " + sg.nextString(true) + sg.nextString(false),
            new ThemeResource("../tests-valo/img/profile-pic-300px.jpg"), null);
    settingsItem.addItem("Edit Profile", null);
    settingsItem.addItem("Preferences", null);
    settingsItem.addSeparator();
    settingsItem.addItem("Sign Out", null);
    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    Label label = null;
    int count = -1;
    for (final Entry<String, String> item : menuItems.entrySet()) {
        if (item.getKey().equals("labels")) {
            label = new Label("Components", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("panels")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Containers", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("forms")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Other", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        if (count == 2) {
            b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>");
        }
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        b.setIcon(testIcon.get());
        menuItemsLayout.addComponent(b);
        count++;
    }
    label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}

From source file:com.example.themes.valo.MenuBars.java

License:Apache License

static MenuBar getMenuBar() {
    Command click = new Command() {
        @Override/*w  w  w  . ja v  a 2 s .c  o  m*/
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Clicked " + selectedItem.getText());
        }
    };

    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");
    final MenuBar.MenuItem file = menubar.addItem("Draft", null);
    final MenuBar.MenuItem newItem = file.addItem("New", null);
    file.addItem("Open file...", click);
    file.addSeparator();

    newItem.addItem("File", click);
    newItem.addItem("Folder", click);
    newItem.addItem("Project...", click);

    file.addItem("Close", click);
    file.addItem("Close All", click);
    file.addSeparator();

    file.addItem("Save", click);
    file.addItem("Save As...", click);
    file.addItem("Save All", click);

    final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
    edit.addItem("Undo", click);
    edit.addItem("Redo", click).setEnabled(false);
    edit.addSeparator();

    edit.addItem("Cut", click);
    edit.addItem("Copy", click);
    edit.addItem("Paste", click);
    edit.addSeparator();

    final MenuBar.MenuItem find = edit.addItem("Find/Replace", null);

    find.addItem("Google Search", click);
    find.addSeparator();
    find.addItem("Find/Replace...", click);
    find.addItem("Find Next", click);
    find.addItem("Find Previous", click);

    Command check = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show(selectedItem.isChecked() ? "Checked" : "Unchecked");
        }
    };

    final MenuBar.MenuItem view = menubar.addItem("View", null);
    view.addItem("Show Status Bar", check).setCheckable(true);
    MenuItem title = view.addItem("Show Title Bar", check);
    title.setCheckable(true);
    title.setChecked(true);
    view.addItem("Customize Toolbar...", click);
    view.addSeparator();

    view.addItem("Actual Size", click);
    view.addItem("Zoom In", click);
    view.addItem("Zoom Out", click);

    TestIcon testIcon = new TestIcon(50);

    MenuItem fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setChecked(true);

    fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setCheckable(true);

    menubar.addItem("Attach", click).setIcon(FontAwesome.PAPERCLIP);
    menubar.addItem("Undo", click).setIcon(FontAwesome.UNDO);
    MenuItem redo = menubar.addItem("Redo", click);
    redo.setIcon(FontAwesome.REPEAT);
    redo.setEnabled(false);
    menubar.addItem("Upload", click).setIcon(FontAwesome.UPLOAD);

    return menubar;
}

From source file:com.expressui.core.view.menu.MenuBarNode.java

License:Open Source License

MenuBar createMenuBar() {
    MenuBar menuBar = new MenuBar();
    menuBar.setSizeUndefined();//w ww. ja va2s .c  o m
    menuBar.setAutoOpen(true);
    menuBar.setHtmlContentAllowed(true);

    for (MenuBarNode child : children.values()) {
        if (child.isViewAllowed() && child.isVisible()) {
            MenuBar.MenuItem childMenuItem = menuBar.addItem(child.caption, child.command);
            child.populate(childMenuItem);
        }
    }

    return menuBar;
}

From source file:com.freebox.engeneering.application.web.layout.LeftSideBarController.java

License:Apache License

private void createFooterSideBar() {
    VerticalLayout verticalLayout = super.getView();

    sideBarFooter.setSizeUndefined();/* ww w.  j  a va  2  s  . c om*/
    sideBarFooter.addStyleName("user");
    Image profilePic = new Image(null, new ThemeResource("img/profile-pic.png"));
    profilePic.setWidth("34px");
    sideBarFooter.addComponent(profilePic);
    Label userName = new Label("MOHELLEBI ATAF");
    userName.setSizeUndefined();
    sideBarFooter.addComponent(userName);

    Command cmd = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    };
    MenuBar settings = new MenuBar();
    MenuItem settingsMenu = settings.addItem("", null);
    settingsMenu.setStyleName("icon-cog");
    settingsMenu.addItem("Settings", cmd);
    settingsMenu.addItem("Preferences", cmd);
    settingsMenu.addSeparator();
    settingsMenu.addItem("My Account", cmd);
    sideBarFooter.addComponent(settings);

    Button exit = new NativeButton("Exit");
    exit.addStyleName("icon-cancel");
    exit.setDescription("Sign Out");
    sideBarFooter.addComponent(exit);
    exit.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
        }
    });

    verticalLayout.addComponent(sideBarFooter);
}

From source file:com.github.moscaville.contactsdb.ValoSideBarUI.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    super.init(vaadinRequest);
    CssLayout header = new CssLayout();

    MenuBar menuBar = new MenuBar();
    header.addComponent(menuBar);//w  w  w.jav  a2  s  .  c o m

    MenuBar.MenuItem settingsItem = menuBar.addItem("", FontAwesome.WRENCH, null);

    sideBar.setHeader(header);
    //categories = categoryController.loadItems(100, 0, new CategoryRecord());
    //representatives = representativeController.loadItems(100, 0, new RepresentativeRecord());
}