Example usage for com.vaadin.ui MenuBar setHtmlContentAllowed

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

Introduction

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

Prototype

public void setHtmlContentAllowed(boolean htmlContentAllowed) 

Source Link

Document

Sets whether html is allowed in the item captions.

Usage

From source file:at.peppol.webgui.app.MainWindow.java

License:Mozilla Public License

private void createMenuBar() {

    topBarLayout.setMargin(false, false, false, false);
    topBarLayout.setSizeFull();/*from w w  w  .  j a  va2 s  .com*/
    // topBarLayout.setStyleName("v-menubar");
    topBarLayoutLeft = new HorizontalLayout();
    topBarLayoutRight = new HorizontalLayout();

    // Label pawgLabel = new Label("PAWG",Label.CONTENT_XHTML);
    // pawgLabel.setStyleName("v-menubar");
    // pawgLabel.addStyleName("v-label-big");
    // pawgLabel.setSizeFull();
    // topBarLayoutLeft.addComponent(pawgLabel);

    final MenuBar lMenuBar = new MenuBar();
    lMenuBar.setHtmlContentAllowed(true);
    lMenuBar.addItem("<b>PAWG<b>", new MenuBar.Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {

            removeComponent(mainContentComponent);
            showInitialMainContent(um.getDrafts());
        }
    });
    final MenuBar.MenuItem docItem = lMenuBar.addItem("Document", null);
    lMenuBar.addItem("Preferences", null);
    lMenuBar.addItem("Logout", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            PawgApp.getInstance().logout();
            PawgApp.getInstance().showLoginWindow();
        }
    });
    lMenuBar.addItem("About", null);
    lMenuBar.setSizeFull();

    final MenuBar.MenuItem invItem = docItem.addItem("Invoice", null);
    final MenuBar.MenuItem orderItem = docItem.addItem("Order", null);
    invItem.addItem("New ...", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showInvoiceForm();
            //showInvoiceForm (null);
        }
    });
    invItem.addItem("View ... ", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showTestForm();
        }
    });
    invItem.addItem("Upload ...", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showInvUploadWindow();
        }
    });

    orderItem.addItem("New", null);
    orderItem.addItem("View", null);
    orderItem.addItem("Upload ...", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showOrdUploadWindow();
        }
    });

    topBarLayoutLeft.addComponent(lMenuBar);

    final IUser user = (IUser) PawgApp.getInstance().getUser();

    topBarLayoutLeft.setComponentAlignment(lMenuBar, Alignment.MIDDLE_CENTER);
    topBarLayoutLeft.setSpacing(false);
    topBarLayoutLeft.setSizeFull();
    topBarLayoutRight.setSizeUndefined();

    final MenuBar rMenuBar = new MenuBar();
    rMenuBar.setHtmlContentAllowed(true);
    final MenuBar.MenuItem userLabel = rMenuBar.addItem("<b>" + user.getEmailAddress() + "<b>", null);
    userLabel.addItem("Logout", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            PawgApp.getInstance().logout();
        }
    });
    topBarLayoutRight.addComponent(rMenuBar);
    topBarLayout.addComponent(topBarLayoutLeft);
    topBarLayout.addComponent(topBarLayoutRight);
    topBarLayout.setComponentAlignment(topBarLayoutRight, Alignment.MIDDLE_RIGHT);
    topBarLayout.setExpandRatio(topBarLayoutLeft, 1);
    // topBarLayout.setExpandRatio(topBarLayoutRight, 1);
    addComponent(topBarLayout);

}

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

License:Open Source License

MenuBar createMenuBar() {
    MenuBar menuBar = new MenuBar();
    menuBar.setSizeUndefined();/*  www  .  ja va2  s  .  co 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:de.uni_tuebingen.qbic.qbicmainportlet.ToolBar.java

License:Open Source License

void init() {
    // setWidth(100.0f, Unit.PERCENTAGE);
    // addStyleName("user-menu");
    // setWidth((UI.getCurrent().getPage().getBrowserWindowWidth() * 0.6f), Unit.PIXELS);

    MenuBar menuBar = new MenuBar();
    menuBar.addStyleName("user-menu");

    menuBar.setHtmlContentAllowed(true);
    download = menuBar.addItem("Download your data", null, null);
    download.setEnabled(false);/* w ww.ja v a 2  s  . com*/

    download.setIcon(new ThemeResource("computer_higher.png"));
    download.addSeparator();
    this.downloadwhole = download.addItem("<a href=\"" + resourceUrl
            + "\" target=\"_blank\" style=\"text-decoration: none ; color:#2c2f34\">Download everything belonging to this entity.</a>",
            null);
    this.downloadwhole.setEnabled(false);
    // Open DatasetView
    this.datasetoverview = download.addItem("Dataset Overview", null);
    this.datasetoverview.setEnabled(false);
    manage = menuBar.addItem("Manage your data", null, null);
    manage.setIcon(new ThemeResource("barcode_higher.png"));
    manage.setEnabled(false);
    // Another submenu item with a sub-submenu
    this.createBarcodes = manage.addItem("Create Barcodes", null, null);
    createBarcodes.setEnabled(false);

    workflows = menuBar.addItem("Run workflows", null, null);
    workflows.setIcon(new ThemeResource("dna_higher.png"));
    workflows.setEnabled(false);

    addComponent(menuBar);
    // menuBar.setWidth((UI.getCurrent().getPage().getBrowserWindowWidth() * 0.3f), Unit.PIXELS);
    // searchEngineView.setWidth((UI.getCurrent().getPage().getBrowserWindowWidth() * 0.2f),
    // Unit.PIXELS);
    // searchEngineView.setWidth("100%");
    addComponent(searchEngineView);
    setComponentAlignment(searchEngineView, Alignment.TOP_RIGHT);
    // setExpandRatio(menuBar, 0.7f);
    // setExpandRatio(searchEngineView, 0.3f);
}

From source file:org.eclipse.hawkbit.ui.menu.DashboardMenu.java

License:Open Source License

private Component buildUserMenu(final UiProperties uiProperties) {
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    settings.setHtmlContentAllowed(true);

    final MenuItem settingsItem = settings.addItem("", getImage(uiProperties.isGravatar()), null);

    final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
    if (!StringUtils.isEmpty(formattedTenant)) {
        settingsItem.setText(formattedTenant);
        UserDetailsFormatter.getCurrentTenant()
                .ifPresent(tenant -> settingsItem.setDescription(i18n.getMessage("menu.user.description",
                        tenant, UserDetailsFormatter.getCurrentUser().getUsername())));
    } else {//from w  w w  . j  av  a 2  s.  com
        settingsItem.setText("...");
    }

    settingsItem.setStyleName("user-menuitem");

    final String logoutUrl = generateLogoutUrl();

    settingsItem.addItem(i18n.getMessage("label.sign.out"),
            selectedItem -> Page.getCurrent().setLocation(logoutUrl));
    return settings;
}

From source file:org.jpos.qi.Header.java

License:Open Source License

@SuppressWarnings("unchecked")
private MenuBar createMenu() {
    menuOptions = new LinkedHashMap<>();
    MenuBar mb = new MenuBar();
    mb.addStyleName(ValoTheme.MENUBAR_SMALL);
    mb.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    mb.setHtmlContentAllowed(true);
    Element cfg = app.getXmlConfiguration();
    if (cfg != null) {
        Element menubar = cfg.getChild("menubar");
        if (menubar != null) {
            for (Element e : menubar.getChildren()) {
                addMenubarItem(mb, e);/*from  ww w . jav a  2  s  .c o  m*/
            }
        }
    }
    userMenuItem = mb.addItem(app.getUser().getNick(), null);
    userMenuItem.setIcon(VaadinIcons.USER);
    userMenuItem.addItem("Profile", selectedItem -> {
        removeSelected();
        app.navigateTo("/profile");
    });
    userMenuItem.addItem("Log Out", selectedItem -> app.logout());
    return mb;
}