Example usage for com.vaadin.ui MenuBar getItems

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

Introduction

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

Prototype

public List<MenuItem> getItems() 

Source Link

Document

Returns a list with all the MenuItem objects in the menu bar.

Usage

From source file:com.jain.addon.i18N.handlers.I18NMenuBarHandler.java

License:Apache License

private void populateI18NItemCaptions(final MenuBar component) {
    Collection<MenuItem> items = (Collection<MenuItem>) component.getItems();
    processMenuItem(items);//from   w w  w .  j  av a2s .  c o  m
}

From source file:com.ocs.dynamo.ui.menu.MenuService.java

License:Apache License

/**
 * Recursively process all menu items and hides the items that have no visible children
 * //ww w.jav a 2s  . c  o m
 * @param bar
 */
private void hideRecursively(MenuBar bar) {
    for (MenuItem item : bar.getItems()) {
        hideIfAllChildrenHidden(item);
    }
}

From source file:com.ocs.dynamo.ui.menu.MenuService.java

License:Apache License

/**
 * Sets the visibility of a certain item identified by its destination
 * //from  w  w  w  . j  a  v  a2  s. co m
 * @param menu
 *            the menu bar
 * @param destination
 *            the destination
 * @param visible
 *            the desired visibility
 */
public void setVisible(MenuBar menu, String destination, boolean visible) {

    List<MenuItem> items = menu.getItems();
    for (MenuItem item : items) {
        setVisible(item, destination, visible);
    }
}

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  w  w  w  .j  av a  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:nz.co.senanque.perspectivemanager.MenuCloner.java

License:Apache License

public static void merge(MenuBar target, MenuBar source, List<MenuBar.MenuItem> added) {
    if (source != null) {
        List<MenuBar.MenuItem> targetItems = target.getItems();
        for (MenuBar.MenuItem sourceItem : source.getItems()) {
            MenuBar.MenuItem targetItem = findItem(sourceItem.getText(), targetItems);
            if (targetItem == null) {
                targetItem = target.addItem(sourceItem.getText(), sourceItem.getCommand());
                fixMenuItem(targetItem, sourceItem);
                added.add(targetItem);/*from   ww  w.  j  a  v  a 2s.  c  om*/
            }
            merge(targetItem, sourceItem, added);
        }
    }
}

From source file:nz.co.senanque.perspectivemanager.MenuCloner.java

License:Apache License

public static void clean(MenuBar target, List<MenuBar.MenuItem> added) {
    if (target != null) {
        List<MenuBar.MenuItem> items = target.getItems();
        for (MenuBar.MenuItem r : added) {
            for (MenuBar.MenuItem targetItem : items) {
                if (r.getId() == targetItem.getId()) {
                    items.remove(r);//from w w  w . j a  va 2s. c  o m
                    break;
                }
            }
        }
        for (MenuBar.MenuItem targetItem : items) {
            clean(targetItem, added);
        }
    }
    added.clear();
}

From source file:nz.co.senanque.perspectiveslibrary.MenuCloner.java

License:Apache License

public static void merge(MenuBar target, MenuBar source, List<MenuBar.MenuItem> added) {
    if (source != null) {
        List<MenuBar.MenuItem> targetItems = target.getItems();
        for (MenuBar.MenuItem sourceItem : source.getItems()) {
            MenuBar.MenuItem targetItem = findItem(sourceItem.getText(), targetItems);
            if (targetItem == null) {
                try {
                    int sizeOfTarget = target.getSize();
                    if (sizeOfTarget > 0) {
                        targetItem = target.addItemBefore(sourceItem.getText(), null, sourceItem.getCommand(),
                                target.getItems().get(sizeOfTarget - 1));
                    }/*from w  w  w .  j a  va2  s.c o m*/
                } catch (Exception e) {
                }
                if (targetItem == null) {
                    targetItem = target.addItem(sourceItem.getText(), sourceItem.getCommand());
                }
                fixMenuItem(targetItem, sourceItem);
                added.add(targetItem);
            }
            merge(targetItem, sourceItem, added);
        }
    }
}

From source file:org.opennms.features.topology.app.internal.menu.TopologyContextMenu.java

License:Open Source License

private void addItems(MenuBar menuBar) {
    for (MenuBar.MenuItem eachItem : menuBar.getItems()) {
        addItems(() -> this.addItem(eachItem.getText(), eachItem.getIcon()), eachItem);
    }/* w  w w.j  ava2  s  .co m*/
}

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   ww w  . j  a  v  a2s  . 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);
}

From source file:ru.codeinside.gses.webui.manager.ManagerWorkplace.java

License:Mozilla Public License

private void chooseTab(MenuBar.MenuItem selectedItem, MenuBar menu, Component componentToShow,
        Component... componentToHides) {
    List<MenuBar.MenuItem> items = menu.getItems();
    for (MenuBar.MenuItem i : items) {
        i.setEnabled(true);//from ww  w.jav a2 s  .  c o  m
    }
    selectedItem.setEnabled(false);
    for (Component componentToHide : componentToHides) {
        if (components.contains(componentToHide)) {
            removeComponent(componentToHide);
        }
    }
    addComponent(componentToShow);
    setExpandRatio(componentToShow, 0.99f);
}