Example usage for com.vaadin.ui MenuBar.MenuItem setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.haulmont.cuba.web.gui.components.presentations.TablePresentations.java

License:Apache License

protected void applyStylesForItem(com.vaadin.ui.MenuBar.MenuItem item, List<String> styles) {
    styles.remove(CUSTOM_STYLE_NAME_PREFIX);
    StringBuilder joinedStyle = new StringBuilder(CUSTOM_STYLE_NAME_PREFIX);
    for (String style : styles) {
        joinedStyle.append(" ").append(style);
    }/*from ww w. j a v a 2  s .  com*/
    item.setStyleName(joinedStyle.toString());
}

From source file:de.gedoplan.webclients.vaadin.VaadinDemoUi.java

public MenuBar createMenu() {
    User user = userProvider.get();// www  .  ja v a2  s  . co  m
    MenuBar mainMenu = new MenuBar();
    mainMenu.setWidth(100, Unit.PERCENTAGE);
    mainMenu.setStyleName("main");
    mainMenu.addItem("", new ThemeResource("images/vaadin-logo.png"),
            e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_INDEX)).setStyleName("logo");
    if (user.isInRole(User.UserRole.ADMIN)) {
        mainMenu.addItem(Messages.menu_customer.value(),
                e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_CUSTOMERS));
    }
    mainMenu.addItem(Messages.menu_orders.value(), e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_ORDERS));
    if (user.isInRole(User.UserRole.CUSTOMER)) {
        mainMenu.addItem(Messages.menu_customerdetails.value(), e -> navigator
                .navigateTo(Konstanten.VAADIN_VIEW_CUSTOMER_DETAILS + "/" + user.getCustomerID()));
    }
    MenuBar.MenuItem userMenu = mainMenu.addItem(user.getLogin(), null);
    userMenu.setStyleName("align-right");
    userMenu.addItem(Messages.logout.value(), e -> {
        try {
            JaasAccessControl.logout();
            VaadinSession.getCurrent().close();
            Page.getCurrent().setLocation(Konstanten.VAADIN_LOGIN_PATH);
        } catch (ServletException ex) {
            Logger.getLogger(VaadinDemoUi.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    return mainMenu;
}

From source file:eu.lod2.stat.dsdrepo.DSDRepoComponent.java

public DSDRepoComponent(Repository repository, String dataGraph, String repoGraph) {
    this.repository = repository;
    this.dataGraph = dataGraph;
    this.repoGraph = repoGraph;

    initializeRepoGraph();/*from   www.j  ava  2s  . c  o  m*/

    dcRepo = new SparqlDCRepository(repository);
    graph = new SparqlDCGraph(repository, dataGraph);

    setSizeFull();
    VerticalLayout rootLayout = new VerticalLayout();
    rootLayout.setSizeFull();
    rootLayout.setSpacing(true);
    setDebugId("dsd-repo");

    mainLayout = new VerticalLayout();
    mainLayout.setSizeUndefined();
    mainLayout.setWidth("100%");
    //        mainLayout.setHeight("800px");
    mainLayout.setSpacing(true);

    HorizontalLayout menuLayout = new HorizontalLayout();
    menuLayout.setSpacing(true);
    menuLayout.setWidth("100%");
    rootLayout.addComponent(menuLayout);
    rootLayout.setExpandRatio(menuLayout, 0.0f);

    final MenuBar menu = new MenuBar();
    menu.addStyleName("dsd");
    cmdFindDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        findDSDs();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Find Suitable DSDs", cmdFindDSD).setStyleName("bleja");
    cmdCreateDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        createDSD();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Create DSD", cmdCreateDSD).setStyleName("bleja");
    cmdStoreDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        storeDSD();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Store DSD", cmdStoreDSD).setStyleName("bleja");

    menuLayout.addComponent(menu);
    Label spaceLbl = new Label("");
    menuLayout.addComponent(spaceLbl);
    menuLayout.setExpandRatio(spaceLbl, 2.0f);
    Label lbl = new Label("Choose dataset: ");
    lbl.setSizeUndefined();
    menuLayout.addComponent(lbl);

    Collection<DataSet> colDataSets = graph.getDataSets();
    if (colDataSets == null)
        colDataSets = new LinkedList<DataSet>();
    selectDataSet = new ComboBox(null, colDataSets);
    selectDataSet.setImmediate(true);
    selectDataSet.setNewItemsAllowed(false);
    selectDataSet.setNullSelectionAllowed(false);
    selectDataSet.setWidth("300px");
    selectDataSet.addListener(new Property.ValueChangeListener() {
        public void valueChange(Property.ValueChangeEvent event) {
            ds = (DataSet) event.getProperty().getValue();
        }
    });
    menuLayout.addComponent(selectDataSet);

    Panel mainPanel = new Panel(mainLayout);
    mainPanel.setSizeFull();
    mainPanel.setScrollable(true);
    mainPanel.setStyleName(Reindeer.PANEL_LIGHT);

    Label hrLabel = new Label("<hr/>", Label.CONTENT_XHTML);
    rootLayout.addComponent(hrLabel);
    rootLayout.setExpandRatio(hrLabel, 0.0f);
    rootLayout.addComponent(mainPanel);
    rootLayout.setExpandRatio(mainPanel, 2.0f);
    rootLayout.setMargin(true, false, true, false);

    setCompositionRoot(rootLayout);
}

From source file:org.balisunrise.vaadin.components.header.ModuleMenu.java

private void init() {
    setHeight("100%");
    setWidthUndefined();/*from w  w w .  j a  v  a2  s .c o  m*/

    menuBar = new MenuBar();
    menuBar.setStyleName("b-module-menu");

    setCompositionRoot(menuBar);

    MenuBar.MenuItem item;
    item = menuBar.addItem("Menu 1", new ItemCommand());
    item.setStyleName("b-module-menu-item");
    item.setDescription("1 Item do menu");

    MenuBar.MenuItem subMenu;
    subMenu = menuBar.addItem("Sub Menus 1", null);
    subMenu.setStyleName("b-module-menu-item");

    item = subMenu.addItem("Menu 2", new ItemCommand());
    item.setStyleName("b-module-menu-item");
    item.setDescription("2 Item do menu");

    item = subMenu.addItem("Menu 3", new ItemCommand());
    item.setStyleName("b-module-menu-item");
    item.setDescription("3 Item do menu");

    subMenu = menuBar.addItem("Sub Menus 2", null);
    subMenu.setStyleName("b-module-menu-item");

    MenuBar.MenuItem subMenu2;
    subMenu2 = subMenu.addItem("Sub Sub Menu 1", null);
    subMenu2.setStyleName("b-module-menu-item");

    item = subMenu2.addItem("Menu 4", new ItemCommand());
    item.setStyleName("b-module-menu-item");
    item.setDescription("4 Item do menu");

    item = subMenu2.addItem("Menu 5", new ItemCommand());
    item.setStyleName("b-module-menu-item");
    item.setDescription("5 Item do menu");

    subMenu2 = subMenu.addItem("Sub Sub Menu 2", null);
    subMenu2.setStyleName("b-module-menu-item");

    item = subMenu2.addItem("Menu 6", new ItemCommand());
    item.setStyleName("b-module-menu-item");
    item.setDescription("6 Item do menu");

    item = subMenu2.addItem("Menu 7", new ItemCommand());
    item.setStyleName("b-module-menu-item");
    item.setDescription("7 Item do menu");
}

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

License:Open Source License

private void menuItemSelected(MenuBar.MenuItem selectedItem, Element e) {
    removeSelected();/*w ww.j a  va 2 s  . c  o  m*/
    app.navigateTo("/" + e.getAttributeValue("action"));
    selectedItem.setStyleName("underline");
}

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

License:Open Source License

private void removeSelected() {
    for (String s : menuOptions.keySet()) {
        MenuBar.MenuItem item = menuOptions.get(s);
        item.setStyleName("menuitem");
    }//from   w ww.j a  va2  s.  c  om
}

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

License:Open Source License

private void decorate(MenuBar.MenuItem mi, Element e) {
    String style = e.getAttributeValue("style");
    if (style != null)
        mi.setStyleName(e.getAttributeValue("style"));
    String iconName = e.getAttributeValue("icon");
    if (iconName != null) {
        try {//from  w  ww  .j a  v a  2 s .  co  m
            mi.setIcon(VaadinIcons.valueOf(iconName));
        } catch (IllegalArgumentException ex) {
            mi.setIcon(VaadinIcons.EXCLAMATION);
            mi.setEnabled(false);
        }
    }
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.MenuNavigationViewlet.java

License:Apache License

private void processRootPage(final NavigationVersion navigationVersion, final MenuBar menuBar,
        final String pageName) {
    final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
    if (pageVersion == null) {
        throw new SiteException("Unknown page: " + pageName);
    }/*  w  ww  .j av a2 s  .  c  om*/
    if (pageVersion.getViewerRoles().length > 0) {
        boolean roleMatch = false;
        for (final String role : pageVersion.getViewerRoles()) {
            if (getSite().getSecurityProvider().getRoles().contains(role)) {
                roleMatch = true;
                break;
            }
        }
        if (!roleMatch) {
            return;
        }
    }

    final String localizedPageName = pageVersion.isDynamic() ? pageName
            : getSite().localize("page-link-" + pageName);
    final Resource iconResource = pageVersion.isDynamic()
            ? navigationVersion.hasChildPages(pageName) ? getSite().getIcon("page-icon-folder")
                    : getSite().getIcon("page-icon-page")
            : getSite().getIcon("page-icon-" + pageName);

    final MenuBar.MenuItem menuItem = menuBar.addItem(localizedPageName, iconResource,
            navigationVersion.hasChildPages(pageName) ? null : new MenuBar.Command() {
                @Override
                public void menuSelected(MenuBar.MenuItem selectedItem) {
                    UI.getCurrent().getNavigator().navigateTo(pageName);
                }
            });
    menuItem.setStyleName("navigation-" + pageName);

    if (navigationVersion.hasChildPages(pageName)) {
        for (final String childPage : navigationVersion.getChildPages(pageName)) {
            processChildPage(navigationVersion, menuItem, childPage);
        }
    }
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.MenuNavigationViewlet.java

License:Apache License

private void processChildPage(final NavigationVersion navigationVersion, final MenuBar.MenuItem parentItem,
        final String pageName) {
    final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
    if (pageVersion == null) {
        throw new SiteException("Unknown page: " + pageName);
    }/*from   w ww  .  ja va  2s. c om*/
    if (pageVersion.getViewerRoles().length > 0) {
        boolean roleMatch = false;
        for (final String role : pageVersion.getViewerRoles()) {
            if (getSite().getSecurityProvider().getRoles().contains(role)) {
                roleMatch = true;
                break;
            }
        }
        if (!roleMatch) {
            return;
        }
    }

    final String localizedPageName = pageVersion.isDynamic() ? pageName
            : getSite().localize("page-link-" + pageName);
    final Resource iconResource = pageVersion.isDynamic()
            ? navigationVersion.hasChildPages(pageName) ? getSite().getIcon("page-icon-folder")
                    : getSite().getIcon("page-icon-page")
            : getSite().getIcon("page-icon-" + pageName);

    final MenuBar.MenuItem menuItem = parentItem.addItem(localizedPageName, iconResource,
            navigationVersion.hasChildPages(pageName) ? null : new MenuBar.Command() {
                @Override
                public void menuSelected(MenuBar.MenuItem selectedItem) {
                    UI.getCurrent().getNavigator().navigateTo(pageName);
                }
            });
    menuItem.setStyleName("navigation-" + pageName);
    menuItem.setEnabled(true);

    if (navigationVersion.hasChildPages(pageName)) {
        for (final String childPage : navigationVersion.getChildPages(pageName)) {
            processChildPage(navigationVersion, menuItem, childPage);
        }
    }
}

From source file:rs.pupin.jpo.esta_ld.DSDRepoComponent.java

public DSDRepoComponent(Repository repository, String dataGraph, String repoGraph) {
    this.repository = repository;
    this.dataGraph = dataGraph;
    this.repoGraph = repoGraph;

    initializeRepoGraph();/*from  w  w  w.  j av  a2  s. c o m*/

    dcRepo = new SparqlDCRepository(repository);
    graph = new SparqlDCGraph(repository, dataGraph);

    VerticalLayout rootLayout = new VerticalLayout();
    rootLayout.setWidth("100%");
    rootLayout.setSpacing(true);

    mainLayout = new VerticalLayout();
    mainLayout.setWidth("100%");
    mainLayout.setSpacing(true);

    HorizontalLayout menuLayout = new HorizontalLayout();
    menuLayout.setSpacing(true);
    menuLayout.setWidth("100%");
    rootLayout.addComponent(menuLayout);

    final MenuBar menu = new MenuBar();
    menu.addStyleName("dsd");
    cmdFindDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        findDSDs();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Find Suitable DSDs", cmdFindDSD).setStyleName("bleja");
    cmdCreateDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        createDSD();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Create DSD", cmdCreateDSD).setStyleName("bleja");
    cmdStoreDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        storeDSD();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Store DSD", cmdStoreDSD).setStyleName("bleja");

    menuLayout.addComponent(menu);
    Label spaceLbl = new Label("");
    menuLayout.addComponent(spaceLbl);
    menuLayout.setExpandRatio(spaceLbl, 2.0f);
    Label lbl = new Label("Choose dataset: ");
    lbl.setSizeUndefined();
    menuLayout.addComponent(lbl);

    selectDataSet = new ComboBox(null, graph.getDataSets());
    selectDataSet.setImmediate(true);
    selectDataSet.setNewItemsAllowed(false);
    selectDataSet.setNullSelectionAllowed(false);
    selectDataSet.setWidth("300px");
    selectDataSet.addListener(new Property.ValueChangeListener() {
        public void valueChange(Property.ValueChangeEvent event) {
            ds = (DataSet) event.getProperty().getValue();
        }
    });
    menuLayout.addComponent(selectDataSet);

    rootLayout.addComponent(new Label("<hr/>", Label.CONTENT_XHTML));
    rootLayout.addComponent(mainLayout);

    setCompositionRoot(rootLayout);
}