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

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

Introduction

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

Prototype

@Override
    public void setVisible(boolean visible) 

Source Link

Usage

From source file:annis.gui.flatquerybuilder.FlatQueryBuilder.java

License:Apache License

private void initialize() {
    // try to remove all existing menus
    try {/*from w  w w  . j  a v  a 2 s. com*/
        language.removeComponent(addMenu);
        span.removeComponent(addMenuSpan);
        meta.removeComponent(addMenuMeta);
    } catch (Exception e) {
        log.error(null, e);
    }

    //init variables:
    final FlatQueryBuilder sq = this;
    Collection<String> annonames = getAvailableAnnotationNames();
    Collection<String> metanames = getAvailableMetaNames();

    //Code from btInitLanguage:    
    addMenu = new MenuBar();
    //addMenu.setDescription(INFO_INIT_LANG);
    addMenu.setAutoOpen(false);
    final MenuBar.MenuItem add = addMenu.addItem(ADD_LING_PARAM, null);
    for (final String annoname : annonames) {
        add.addItem(annoname, new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                if (!vnodes.isEmpty()) {
                    EdgeBox eb = new EdgeBox(sq);
                    languagenodes.addComponent(eb);
                    eboxes.add(eb);
                }
                VerticalNode vn = new VerticalNode(annoname, sq);
                languagenodes.addComponent(vn);
                vnodes.add(vn);
                addMenu.setAutoOpen(false);
            }
        });
    }
    language.removeComponent(btInitLanguage);
    language.addComponent(addMenu);

    //Code from btInitSpan:    
    addMenuSpan = new MenuBar();
    //addMenuSpan.setDescription(INFO_INIT_SPAN);
    addMenuSpan.setAutoOpen(false);
    final MenuBar.MenuItem addSpan = addMenuSpan.addItem(ADD_SPAN_PARAM, null);
    for (final String annoname : annonames) {
        addSpan.addItem(annoname, new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                sq.removeSpanBox();
                sq.addSpanBox(annoname);
                addMenuSpan.setAutoOpen(false);
            }
        });
    }
    spanMenu = addSpan;
    span.removeComponent(btInitSpan);
    span.addComponent(addMenuSpan);

    //Code from btInitMeta:    
    addMenuMeta = new MenuBar();
    //addMenuMeta.setDescription(INFO_INIT_META);  
    addMenuMeta.setAutoOpen(false);
    final MenuBar.MenuItem addMeta = addMenuMeta.addItem(ADD_META_PARAM, null);
    int i = 0;
    for (final String annoname : metanames) {
        addMeta.addItem(annoname, new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                MetaBox mb = new MetaBox(annoname, sq);
                meta.addComponent(mb);
                mboxes.add(mb);
                addMenuMeta.setAutoOpen(false);
                //addMeta.removeChild(selectedItem);
                selectedItem.setVisible(false);
            }
        });
    }
    meta.removeComponent(btInitMeta);
    meta.addComponent(addMenuMeta);
}

From source file:annis.gui.flatquerybuilder.FlatQueryBuilder.java

License:Apache License

public void removeMetaBox(MetaBox v) {
    meta.removeComponent(v);/* w ww.  j  av  a2  s  . c  o  m*/
    mboxes.remove(v);
    List<MenuBar.MenuItem> items = addMenuMeta.getItems().get(0).getChildren();
    boolean found = false;
    String metalevel = v.getMetaDatum();
    for (int i = 0; (i < items.size()) & !found; i++) {
        MenuBar.MenuItem itm = items.get(i);
        if (itm.getText().equals(metalevel)) {
            itm.setVisible(true);
            found = true;
        }
    }
}