Example usage for com.vaadin.ui MenuBar addItem

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

Introduction

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

Prototype

public MenuBar.MenuItem addItem(String caption, MenuBar.Command command) 

Source Link

Document

Add a new item to the menu bar.

Usage

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

License:Apache License

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

    sideBarFooter.setSizeUndefined();/* w w  w. j  a v a2  s  .  c  o  m*/
    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.klwork.explorer.project.ProjectSearchPanel.java

License:Apache License

protected void initSortMenu() {
    MenuBar menuBar = new MenuBar();
    menuBar.addStyleName(ExplorerLayout.STYLE_SEARCHBOX_SORTMENU);

    //TODO: Adding types of sorting manually and listener/events
    MenuItem rootItem = menuBar.addItem("Sort by", null);
    rootItem.addItem("Id", null);
    rootItem.addItem("Name", null);
    rootItem.addItem("Due date", null);
    rootItem.addItem("Creation date", null);

    layout.addComponent(menuBar);//from   w w  w .j a  v a2 s  .  c o  m
    layout.setComponentAlignment(menuBar, Alignment.MIDDLE_RIGHT);
}

From source file:com.klwork.explorer.ui.mainlayout.MainMenuBar.java

License:Apache License

private void initProjectButton() {
    MenuBar helpMenu = new MenuBar();
    helpMenu.addStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_BOX);

    MenuItem rootItem = helpMenu.addItem("?", null);
    rootItem.setStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_MENU);
    rootItem.addItem("", new Command() {
        public void menuSelected(MenuItem selectedItem) {
            ViewToolManager.getMainView().showProjectPage();
        }/*from  w w  w  . j a va2  s. co  m*/
    });
    rootItem.addItem("", new Command() {
        public void menuSelected(MenuItem selectedItem) {
            ViewToolManager.getMainView().showMySchedulePage();
        }
    });

    addComponent(helpMenu);
    setComponentAlignment(helpMenu, Alignment.TOP_RIGHT);
    setExpandRatio(helpMenu, 1.0f);
}

From source file:com.klwork.explorer.ui.mainlayout.MainMenuBar.java

License:Apache License

protected void initProfileButton() {
    final LoggedInUser user = LoginHandler.getLoggedInUser();
    // LoggedInUser user = new LoggedInUser();
    // User name + link to profile
    MenuBar profileMenu = new MenuBar();
    profileMenu.addStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_BOX);
    MenuItem rootItem = profileMenu.addItem(user.getFirstName() + " " + user.getLastName(), null);
    rootItem.setStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_MENU);

    if (useProfile()) {
        // Show profile//?
        rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_SHOW), new Command() {
            public void menuSelected(MenuItem selectedItem) {
                ViewToolManager.showPopupWindow(new ProfilePopupWindow(user.getId()));
            }/*from  w ww. j  a  v a 2 s .  c  o m*/
        });

        // Edit profile
        rootItem.addItem("?", new Command() {

            public void menuSelected(MenuItem selectedItem) {
                ViewToolManager.showPopupWindow(new ProfilePopupWindow(user.getId()));
            }
        });

        // Change password
        rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() {
            public void menuSelected(MenuItem selectedItem) {
                ViewToolManager.showPopupWindow(new ChangePasswordPopupWindow());
            }
        });
    }

    // Logout
    rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() {
        public void menuSelected(MenuItem selectedItem) {
            // xx.close();
            ViewToolManager.logout();
        }
    });
    rootItem.addSeparator();
    // ?
    rootItem.addItem("?", new Command() {
        public void menuSelected(MenuItem selectedItem) {
            // xx.close();
            // ViewToolManager.logout();
        }
    });

    // 
    rootItem.addItem("", new Command() {
        public void menuSelected(MenuItem selectedItem) {
            // xx.close();
            // ViewToolManager.logout();
        }
    });

    addComponent(profileMenu);
    setComponentAlignment(profileMenu, Alignment.TOP_RIGHT);
    // setExpandRatio(profileMenu, 1.0f);
}

From source file:com.morevaadin.vaadin7.navigation.NavigationRoot.java

License:Apache License

@Override
protected void init(WrappedRequest request) {

    VerticalLayout layout = new VerticalLayout();

    MenuBar bar = new MenuBar();

    layout.addComponent(bar);//w  w w  .ja  va 2  s . c  o m

    Panel panel = new Panel() {

        {
            addComponent(new Label("Default"));
        }
    };

    layout.addComponent(panel);

    setContent(layout);

    final Navigator navigator = new Navigator(panel);

    for (final String view : VIEWS) {

        bar.addItem(view, new Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {

                navigator.navigateTo(view);
            }
        });

        navigator.addView(view, new ViewLayout(view));
    }
}

From source file:com.pms.component.ganttchart.DemoUI.java

License:Apache License

private MenuBar controlsMenuBar() {
    MenuBar menu = new MenuBar();
    MenuItem editItem = menu.addItem("Edit", null);
    MenuItem formatItem = menu.addItem("Format", null);
    MenuItem viewItem = menu.addItem("View", null);

    MenuItem item = editItem.addItem("Enabled", new Command() {

        @Override//from  ww w.  ja v a 2  s .  c o  m
        public void menuSelected(MenuItem selectedItem) {
            gantt.setEnabled(!gantt.isEnabled());
            selectedItem.setChecked(gantt.isEnabled());
        }
    });
    item.setCheckable(true);
    item.setChecked(gantt.isEnabled());

    item = editItem.addItem("Read-only", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setReadOnly(!gantt.isReadOnly());
            selectedItem.setChecked(gantt.isReadOnly());
        }
    });
    item.setCheckable(true);
    item.setChecked(gantt.isReadOnly());

    item = formatItem.addItem("Set 'MMM' month format", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setTimelineMonthFormat("MMM");
        }
    });
    item = formatItem.addItem("Set 'MMMM' month format", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setTimelineMonthFormat("MMMM");
        }
    });
    item = formatItem.addItem("Set 'yyyy MMMM' month format", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setTimelineMonthFormat("yyyy MMMM");
        }
    });
    item = formatItem.addItem("Set 'dd.' week format", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setTimelineWeekFormat("dd.");
        }
    });
    item = formatItem.addItem("Set week number week format", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setTimelineWeekFormat(null);
        }
    });
    item = formatItem.addItem("Set 'dd. EEEE' day format for Hour resolution", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setTimelineDayFormat("dd. EEEE");
        }
    });

    item = viewItem.addItem("Show years", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setYearsVisible(!gantt.isYearsVisible());
            selectedItem.setChecked(gantt.isYearsVisible());
        }
    });
    item.setCheckable(true);
    item.setChecked(gantt.isYearsVisible());

    item = viewItem.addItem("Show months", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            gantt.setMonthsVisible(!gantt.isMonthsVisible());
            selectedItem.setChecked(gantt.isMonthsVisible());
        }
    });
    item.setCheckable(true);
    item.setChecked(gantt.isMonthsVisible());

    item = viewItem.addItem("Show Gantt with Table", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            DashboardUI.getCurrent().getUI().getPage().setLocation("#table");
            DashboardUI.getCurrent().getUI().getPage().reload();
        }
    });
    item = viewItem.addItem("Show Gantt with TreeTable", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            DashboardUI.getCurrent().getUI().getPage().setLocation("#treetable");
            DashboardUI.getCurrent().getUI().getPage().reload();
        }
    });
    item = viewItem.addItem("Show Gantt alone", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            DashboardUI.getCurrent().getUI().getPage().setLocation("#");
            DashboardUI.getCurrent().getUI().getPage().reload();
        }
    });

    return menu;
}

From source file:com.siemens.ct.osgi.vaadin.pm.main.MainApplication.java

License:Open Source License

@SuppressWarnings("serial")
private MenuBar getMenu() {
    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");
    actionMenu = menubar.addItem("Action", null);

    actionMenu.addItem("Built-in Action...", new Command() {
        @Override/*  ww  w . j a v  a2 s  . c  om*/
        public void menuSelected(MenuItem selectedItem) {
            main.showNotification("Built-in Action executed!");
        }
    });
    actionMenu.addSeparator();

    final MenuBar.MenuItem viewMenu = menubar.addItem("Help", null);
    viewMenu.addItem("About...", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            main.addWindow(getAboutDialog());
        }
    });

    return menubar;
}

From source file:com.vaadHL.window.base.FWindow.java

License:Apache License

protected MenuBar makeDefaultMenu() {
    MenuBar mb = super.makeMainMenu();
    if (mb == null)
        mb = new MenuBar();

    MenuItem menEd = mb.addItem(getI18S("mnEdition"), null);
    getAction(ActionsIds.AC_EDIT).attach(menEd.addItem(getI18S("btEdit"), null));
    getAction(ActionsIds.AC_DELETE).attach(menEd.addItem(getI18S("btDelete"), null));
    getAction(ActionsIds.AC_CREATE).attach(menEd.addItem(getI18S("btCreate"), null));

    MenuItem toolIt = mb.addItem(getI18S("mnTools"), null);
    addStateMenu(toolIt);/*from   w  w w . j a v  a  2s.c  om*/
    return mb;
}

From source file:com.vaadHL.window.base.LWindow.java

License:Apache License

protected MenuBar makeDefaultMenu() {
    MenuBar mb = super.makeMainMenu();
    if (mb == null)
        mb = new MenuBar();

    MenuItem menEd = mb.addItem(getI18S("mnEdition"), null);

    if (isDetailsFunc())
        getAction(ActionsIds.AC_DETAILS).attach(menEd.addItem(getI18S("btDetails"), null));
    if (isAddFunc())
        getAction(ActionsIds.AC_CREATE).attach(menEd.addItem(getI18S("btCreate"), null));

    if (isDeleteFunc())
        getAction(ActionsIds.AC_DELETE).attach(menEd.addItem(getI18S("btDelete"), null));

    if (isEditFunc())
        getAction(ActionsIds.AC_EDIT).attach(menEd.addItem(getI18S("btEdit"), null));
    if (isViewFunc())
        getAction(ActionsIds.AC_VIEW).attach(menEd.addItem(getI18S("btView"), null));

    MenuItem toolIt = mb.addItem(getI18S("mnTools"), null);
    getAction(ActionsIds.AC_REFRESH).attach(toolIt.addItem(getI18S("mnRefresh"), null));
    getAction(ActionsIds.AC_DESELECT_ALL).attach(toolIt.addItem(getI18S("mnUnselAll"), null));
    addStateMenu(toolIt);/*from  www .j  a v a 2 s  .co m*/
    return mb;
}

From source file:com.yoncabt.ebr.ui.ReportWindow.java

private MenuBar createMenuBar() throws IOException, JRException {
    MenuBar mb = new MenuBar();
    File dir = new File(EBRConf.INSTANCE.getValue(EBRParams.REPORTS_JRXML_PATH, "/home/myururdurmaz/reports"));
    createMenuBar(mb.addItem("Raporlar", null), dir);
    return mb;// w w w  .  j ava2  s  .c  om
}