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.ocs.dynamo.ui.menu.MenuService.java

License:Apache License

/**
 * Constructs a menu//from w  ww  . ja v  a2s . c  o  m
 * 
 * @param rootName
 *            the root name (prefix) of the messages that are used to populate the menu
 * @param navigator
 *            Vaadin navigator
 * @return
 */
public MenuBar constructMenu(String rootName, Navigator navigator) {
    MenuBar mainMenu = new MenuBar();

    // look up any messages of the form "rootName.i"
    int i = 1;
    while (true) {
        if (constructMenu(mainMenu, rootName + "." + i, navigator) == null) {
            break;
        }
        i++;
    }

    // hide any menu items for which the user has no access rights
    hideRecursively(mainMenu);

    return mainMenu;
}

From source file:com.parship.roperty.ui.LoginUI.java

License:Apache License

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);/*  ww w .j  av  a2  s  .c om*/
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // menuBar
    menuBar = new MenuBar();
    menuBar.setImmediate(false);
    menuBar.setWidth("100.0%");
    menuBar.setHeight("-1px");
    mainLayout.addComponent(menuBar, "top:0.0px;right:0.0px;left:0.0px;");

    // screenLayout
    screenLayout = buildScreenLayout();
    mainLayout.addComponent(screenLayout, "top:22.0px;right:0.0px;bottom:0.0px;left:0.0px;");

    return mainLayout;
}

From source file:com.parship.roperty.ui.NavigationViewUI.java

License:Apache License

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);//from w ww. j a  v a 2  s  .  co m
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // mainMenuBar
    mainMenuBar = new MenuBar();
    mainMenuBar.setImmediate(false);
    mainMenuBar.setWidth("100.0%");
    mainMenuBar.setHeight("-1px");
    mainLayout.addComponent(mainMenuBar, "top:0.0px;right:0.0px;left:0.0px;");

    // workBenchSplitViewUI
    workBenchSplitViewUI = new WorkBenchSplitViewUI();
    workBenchSplitViewUI.setImmediate(false);
    workBenchSplitViewUI.setWidth("100.0%");
    workBenchSplitViewUI.setHeight("100.0%");
    mainLayout.addComponent(workBenchSplitViewUI, "top:40.0px;right:20.0px;bottom:20.0px;left:20.0px;");

    return mainLayout;
}

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 w  w w.  j a va2  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.selzlein.lojavirtual.vaadin.core.NavigationMenu.java

License:Open Source License

private void buildUserMenu() {
    Command logoutCmd = new Command() {

        private static final long serialVersionUID = 1L;

        @Override/*ww w. j  ava 2s  . c  o m*/
        public void menuSelected(MenuItem selectedItem) {
            ui.logout();
        }
    };
    Command settingsCmd = new Command() {

        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            ui.navigateTo(SettingsView.ID);
        }
    };
    Command mobileMenu = new Command() {

        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            removeMenuStyles();
            ui.addStyleName(MENU_MOBILE);
            user.setSetting("l-menu", MENU_MOBILE);
            mobileMenuStyleItem.setStyleName("l-hidden");
        }
    };
    Command tabletMenu = new Command() {

        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            removeMenuStyles();
            ui.addStyleName(MENU_TABLET);
            user.setSetting("l-menu", MENU_TABLET);
            tabletMenuStyleItem.setStyleName("l-hidden");
        }
    };
    Command desktopMenu = new Command() {

        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            removeMenuStyles();
            user.setSetting("l-menu", "");
            desktopMenuStyleItem.setStyleName("l-hidden");
        }
    };
    final MenuBar userMenu = new MenuBar();
    userMenu.addStyleName("user-menu");
    final MenuItem userMenuItem = userMenu.addItem(user.getPerson().getFullName(),
            new ThemeResource("../lsps-valo-base/img/profile-pic-300px.jpg"), null);
    mobileMenuStyleItem = userMenuItem.addItem("Mobile Menu", mobileMenu);
    tabletMenuStyleItem = userMenuItem.addItem("Tablet Menu", tabletMenu);
    desktopMenuStyleItem = userMenuItem.addItem("Desktop Menu", desktopMenu);
    userMenuItem.addSeparator();
    MenuItem currentItem = userMenuItem.addItem(ui.getMessage(SettingsView.TITLE), settingsCmd);
    currentItem.setStyleName("l-menu-settings");
    currentItem = userMenuItem.addItem(ui.getMessage("nav.logout", ""), logoutCmd);
    currentItem.setStyleName("l-menu-logout");
    this.addComponent(userMenu);
}

From source file:com.selzlein.lojavirtual.vaadin.page.TodoListView.java

License:Open Source License

@SuppressWarnings("serial")
@Override// w ww. j a v a2s .c om
protected Component createHeader(Component titleComponent) {
    LspsUI ui = (LspsUI) getUI();

    actionBtn = new MenuBar();
    actionBtn.addStyleName("menu-button-action");
    actionBtn.setVisible(false); //initially hidden
    MenuItem actions = actionBtn.addItem("", null, null);

    final ViewAction refreshTodos = new ViewAction() {

        @Override
        public void invoke() {
            toggleSelectionMode(false);
            container.refresh();
        }
    };

    actions.addItem(ui.getMessage("action.lock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            lock();
        }
    });
    actions.addItem(ui.getMessage("action.annotate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoAnnotation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.unlock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            unlock();
        }
    });
    actions.addItem(ui.getMessage("action.reject") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoRejection(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.delegate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoDelegation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.escalate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoEscalation(getSelectedTodoIds(), refreshTodos));
        }
    });

    selectBtn = new Button(ui.getMessage("action.select"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(true);
        }
    });
    selectBtn.addStyleName("menu-button");

    cancelBtn = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(false);
        }
    });
    cancelBtn.setVisible(false); //initially hidden
    cancelBtn.addStyleName("menu-button");

    titleComponent.addStyleName("l-content-title");

    HorizontalLayout layout = new HorizontalLayout();
    HorizontalLayout btnLayout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.addComponent(titleComponent);
    layout.addComponent(btnLayout);
    layout.setSpacing(true);
    btnLayout.addComponent(actionBtn);
    btnLayout.addComponent(cancelBtn);
    btnLayout.addComponent(selectBtn);
    layout.setComponentAlignment(btnLayout, Alignment.MIDDLE_RIGHT);
    return layout;
}

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//from   w ww . j  a  va2s  .  c  o m
        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.studiodojo.qwikinvoice.QwikInvoiceApplication.java

License:Apache License

@Override
public void init() {
    this.mainWindow = new Window(
            "QwikInvoice CRM Tools - Developed by StudioDojo. Engineered by Vaadin. Powered by Google.");
    setMainWindow(mainWindow);/*from   w w w  .  j  a  v a2  s .  c o m*/
    //
    // Check if a user is logged in
    //
    UserService us = UserServiceFactory.getUserService();
    this.logoutURL = us.createLogoutURL(super.getURL().toExternalForm());
    if (us.getCurrentUser() == null || us.getCurrentUser().getEmail() == null) {
        super.setLogoutURL(logoutURL);
        super.close();
        return;
    }
    String login = us.getCurrentUser().getEmail();
    this.userKey = KeyFactory.createKey(TokenBean.class.getSimpleName(), us.getCurrentUser().getEmail());
    //
    Key ucKey = KeyFactory.createKey(UserCompanyBean.class.getSimpleName(), us.getCurrentUser().getEmail());
    UserCompanyBean ucBean = UserDAO.getUserCompanyBean(us.getCurrentUser().getEmail());

    this.theSession = new SessionBean(login, ucBean);
    //
    // SETUP WORKING AREA
    //
    HorizontalLayout appLayout = new HorizontalLayout();
    appLayout.setSizeFull();
    // The Main Layout
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setWidth(APP_WIDTH);
    mainLayout.setHeight(APP_HEIGHT);
    appLayout.addComponent(mainLayout);
    appLayout.setComponentAlignment(mainLayout, Alignment.TOP_CENTER);
    appLayout.setExpandRatio(mainLayout, 2);
    //
    // Setup Header (Welcome Message)
    //
    Label welcome = new Label(
            "<h1>QWIK!NVOICE</h1> You are " + (us.isUserLoggedIn() ? "logged in" : "logged out") + " as <b>"
                    + us.getCurrentUser().getNickname() + "</b>",
            Label.CONTENT_XHTML);
    mainLayout.addComponent(welcome);
    mainLayout.setComponentAlignment(welcome, Alignment.TOP_LEFT);
    //
    // Menu Bar
    //
    MenuBar menuBar = new MenuBar();
    menuBar.setWidth(APP_WIDTH);
    MenuBar.MenuItem fileMenuItem = menuBar.addItem("File", null, null);
    MenuItem newMenuItem = fileMenuItem.addItem("New...", null, null);
    newMenuItem.addItem("Invoice/Quote", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(InvoiceApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading panel", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }

        }
    });
    newMenuItem.addItem("Order", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(FFOrderApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading panel", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }

        }
    });
    /** SAVE */
    fileMenuItem.addItem("Save", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                TokenBean userTokenBean = TokenStore.getToken(QwikInvoiceApplication.this.userKey);
                // User must have an OAuth AUTH Token to access Google Doc service
                if (userTokenBean != null) {
                    /*
                    GDocFileWindow saveWindow = new GDocFileWindow("Save As...");
                    saveWindow.init(QwikInvoiceApplication.this, PdfWriter.getFilename(QwikInvoiceApplication.this.theSession));
                    QwikInvoiceApplication.this.mainWindow.addWindow(saveWindow);
                    */
                    QwikInvoiceApplication.this.activePanel.validate();
                    QwikInvoiceApplication.this.activePanel.onSave();
                } else {
                    AuthSubWindow authsubWindow = new AuthSubWindow("Service Authorization Required");
                    authsubWindow.init(QwikInvoiceApplication.this.userKey);
                    QwikInvoiceApplication.this.mainWindow.addWindow(authsubWindow);
                }
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error Saving file", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    /**
     * SETTINGS
     */
    fileMenuItem.addSeparator();
    MenuItem settingsMenuItem = fileMenuItem.addItem("Settings...", null, null);
    settingsMenuItem.addItem("Profile", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                UserCompanySetupWindow aWindow = new UserCompanySetupWindow();
                aWindow.init(QwikInvoiceApplication.this);
                QwikInvoiceApplication.this.mainWindow.addWindow(aWindow);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error Saving Profile", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    fileMenuItem.addSeparator();

    fileMenuItem.addItem("Logout", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            QwikInvoiceApplication.this.setLogoutURL(logoutURL);
            QwikInvoiceApplication.this.close();

        }
    });
    /**
     * Products
     */
    MenuBar.MenuItem productsMenuItem = menuBar.addItem("Products", null, null);
    productsMenuItem.addItem("Products", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(ProductApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading products", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    productsMenuItem.addItem("Categories", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                ProductCategorySettingsWindow window = new ProductCategorySettingsWindow();
                window.setCaption("Product Category");
                window.init(QwikInvoiceApplication.this.theSession, QwikInvoiceApplication.this);
                QwikInvoiceApplication.this.mainWindow.addWindow(window);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error Loading Products", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    productsMenuItem.addItem("Catalogs", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(CatalogApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading catalogs", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    /**
     * Help
     */
    MenuBar.MenuItem helpMenuItem = menuBar.addItem("Help", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            AboutWindow aboutWindow = new AboutWindow();
            aboutWindow.init();
            QwikInvoiceApplication.this.mainWindow.addWindow(aboutWindow);
        }
    });
    helpMenuItem.addItem("About...", null, null);
    mainLayout.addComponent(menuBar);
    mainLayout.setComponentAlignment(menuBar, Alignment.TOP_CENTER);
    //
    // Load Main Panel
    //
    IApplicationPanel invoiceApplicationPanel = (IApplicationPanel) this.map.get(InvoiceApplicationPanel.class);
    try {
        invoiceApplicationPanel.init(this.theSession, this);
        mainLayout.addComponent((Component) invoiceApplicationPanel);
        mainLayout.setComponentAlignment((Component) invoiceApplicationPanel, Alignment.TOP_CENTER);
        this.activePanel = invoiceApplicationPanel;
    } catch (Exception e) {
    }
    //
    // Setup Footer
    //
    //Label footerMessage = new Label("QwikInvoice <b>version "+_VERSION_+"</b>. This service is provided as is. E&O accepted. Developed by <a href='mailto:public@studiodojo.com?subject=QwikInvoice' target='_blank'>StudioDojo</a>. Engineered by Vaadin. Powered by Google. Apache License 2.0", Label.CONTENT_XHTML);
    //mainLayout.addComponent(footerMessage);
    //mainLayout.setComponentAlignment(footerMessage, Alignment.TOP_CENTER);
    Panel mainPanel = new Panel();
    mainPanel.setScrollable(true);
    mainPanel.setContent(appLayout);
    this.mainWindow.setContent(mainPanel);
}

From source file:com.terralcode.gestion.frontend.view.widgets.example.crudtestform.CrudExampleForm.java

protected Component buildContent() {
    initTable();/*w  w  w  .j  ava2 s .  com*/
    table.setPageLength(table.size());
    addMenuItems(new MenuBar().new MenuItem("", FontAwesome.PLUS, add()),
            new MenuBar().new MenuItem("", FontAwesome.EDIT, edit()),
            new MenuBar().new MenuItem("", FontAwesome.SAVE, save()),
            new MenuBar().new MenuItem("", FontAwesome.TRASH_O, delete()));
    return table;
}

From source file:com.trender.user.component.Header.java

private void init() {
    setSizeFull();/*from   w w  w.  j a v a2  s  .  c om*/
    addStyleName("v-background");
    setHeight(70, Unit.PIXELS);

    nameCompany = new Label();
    nameCompany.setValue("Trender");
    nameCompany.addStyleName("v-label");
    nameCompany.addStyleName("v-label-align-center");
    nameCompany.addStyleName("v-logo");
    nameCompany.setWidth(150, Unit.PIXELS);

    menuBar = new MenuBar();
    menuBar.setSizeFull();
    menuBar.setWidth(100.6F, Unit.PERCENTAGE);
    menuBar.setHeight(35, Unit.PIXELS);
    menuBar.addStyleName("v-menubar");
    menuBar.addStyleName("v-menu");

    addComponentAsFirst(nameCompany);
}