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:annis.gui.components.NavigateableSinglePage.java

License:Apache License

private MenuBar createMenubarFromHTML(File localFile, URI externalURI, Map<String, MenuItem> idToMenuItem) {

    MenuBar mbNavigation = new MenuBar();
    mbNavigation.setStyleName("huge");
    MenuItem navRoot = mbNavigation.addItem("Choose topic", null);
    navRoot.setStyleName("huge");

    try (FileInputStream input = new FileInputStream(localFile)) {
        Document doc = Jsoup.parse(input, "UTF-8", externalURI.toASCIIString());

        ArrayList<MenuItem> itemPath = new ArrayList<>();
        // find all headers that have an ID
        for (Element e : doc.getElementsByAttribute("id")) {
            Matcher m = regexHeader.matcher(e.tagName());
            if (m.matches()) {
                int level = Integer.parseInt(m.group(1)) - 1;

                // decide wether to expand the path (one level deeper) or to truncate
                if (level == 0) {
                    itemPath.clear();/*from w  w  w.  j a v  a  2 s  . c om*/
                } else if (itemPath.size() >= level) {
                    // truncate
                    itemPath = new ArrayList<>(itemPath.subList(0, level));
                }

                if (itemPath.isEmpty() && level > 0) {
                    // fill the path with empty elements
                    for (int i = 0; i < level; i++) {
                        itemPath.add(createItem(navRoot, itemPath, "<empty>", null));
                    }
                }
                MenuItem item = createItem(navRoot, itemPath, e.text(), e.id());
                itemPath.add(item);
                idToMenuItem.put(e.id(), item);
            }
        }
    } catch (IOException ex) {
        log.error("Could not parse iframe source", ex);
    }
    return mbNavigation;
}

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

License:Apache License

private void initialize() {
    // try to remove all existing menus
    try {// w w  w  .j a va  2s. c o  m
        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.resultview.ResultViewPanel.java

License:Apache License

public ResultViewPanel(AnnisUI ui, PluginSystem ps, InstanceConfig instanceConfig,
        DisplayedResultQuery initialQuery) {
    this.sui = ui;
    this.tokenAnnoVisible = new TreeMap<>();
    this.ps = ps;
    this.controller = ui.getQueryController();
    this.initialQuery = initialQuery;

    cacheResolver = Collections/*from   www. j a  va 2 s . c  o  m*/
            .synchronizedMap(new HashMap<HashSet<SingleResolverRequest>, List<ResolverEntry>>());

    resultPanelList = Collections.synchronizedList(new LinkedList<SingleResultPanel>());

    resultLayout = new CssLayout();
    resultLayout.addStyleName("result-view-css");
    Panel resultPanel = new Panel(resultLayout);
    resultPanel.setSizeFull();
    resultPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    resultPanel.addStyleName("result-view-panel");

    this.instanceConfig = instanceConfig;

    setSizeFull();
    setMargin(false);

    MenuBar mbResult = new MenuBar();
    mbResult.setWidth("100%");
    mbResult.addStyleName("menu-hover");
    addComponent(mbResult);

    miSegmentation = mbResult.addItem("Base text", null);
    miTokAnnos = mbResult.addItem("Token Annotations", null);

    addComponent(resultPanel);

    setExpandRatio(mbResult, 0.0f);
    setExpandRatio(resultPanel, 1.0f);

    paging = new PagingComponent();

    addComponent(paging, 1);

    setComponentAlignment(paging, Alignment.TOP_CENTER);
    setExpandRatio(paging, 0.0f);
}

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  www .  j a  va 2  s.c  om
    // 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:br.gov.frameworkdemoiselle.vaadin.ui.StructuredView.java

License:Open Source License

@Override
public void init() {
    footer = new VerticalLayout();
    header = new VerticalLayout();
    content = new VerticalLayout();
    menuBar = new MenuBar();

    content.setHeight("600px");
    content.setWidth("100%");

    header.setHeight("80px");
    header.setWidth("100%");

    footer.setHeight("100px");
    footer.setWidth("100%");

    addComponent(header);/*w  w  w  .  j  ava  2  s .  c  o  m*/
    addComponent(menuBar);
    addComponent(content);
    addComponent(footer);

    super.init();
}

From source file:by.bigvova.MainUI.java

License:Apache License

private Component buildUserMenu() {
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    final UserTo userTo = controller.getUserTo();
    settingsItem = settings.addItem("", resource, null);
    updateUserMenu(null);/*ww w .  j a  v  a  2s.  c  o m*/
    settingsItem.addItem("Edit Profile", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuBar.MenuItem selectedItem) {
            ProfilePreferencesWindow.open(userTo, resource, controller, pathToProfileImage);
        }
    });
    settingsItem.addSeparator();
    settingsItem.addItem("Sign Out", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuBar.MenuItem selectedItem) {
            vaadinSecurity.logout();
        }
    });
    return settings;
}

From source file:co.shift.pcs.basic.web.client.MenuPanel.java

License:Open Source License

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);/*from   w  w w. j  a  va2s  . c  o m*/
    mainLayout.setWidth("1024px");
    mainLayout.setHeight("23px");

    // top-level component properties
    setWidth("1024px");
    setHeight("23px");

    // menuBar
    menuBar = new MenuBar();
    menuBar.setImmediate(false);
    menuBar.setWidth("1024px");
    menuBar.setHeight("23px");
    mainLayout.addComponent(menuBar, "top:0.0px;left:0.0px;");

    return mainLayout;
}

From source file:com.blogspot.markogronroos.MainUI.java

License:GNU General Public License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout main = new VerticalLayout();
    main.setMargin(true);/*from   w w  w  . j a v a 2 s.c o  m*/
    setContent(main);

    //Window main = new Window("Test Application");

    // Create a menu bar
    final MenuBar menubar = new MenuBar();
    main.addComponent(menubar);

    // A feedback component
    final Label selection = new Label("-");
    main.addComponent(selection);

    MenuBar.MenuItem menuitem1 = menubar.addItem("JPA Examples", null, null);

    MenuBar.MenuItem menuitem2 = menuitem1.addItem("Other Example", null, null);

    MenuBar.Command mycommand = new MenuBar.Command() {
        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            selection.setValue("Ordered a " + selectedItem.getText() + " from menu.");
            String selectedText = selectedItem.getText();
            if (selectedText.contains("1.1"))
                jpaContTable(main);
            else if (selectedText.contains("1.2"))
                jpaContTable2(main);
            else if (selectedText.contains("1.3"))
                jpaContForm1(main);
            else if (selectedText.contains("1.4"))
                pureJPAExample(main);
            //selectedItem.
        }
    };

    menuitem1.addItem("1.1 demo JPAContainer Table component", null, mycommand);
    menuitem1.addItem("1.2 demo JPAContainer Table component, explicit EntityManager", null, mycommand);
    menuitem1.addItem("1.3 demo JPAContainer Form", null, mycommand);

    menuitem1.addItem("1.4 demo JPA batch", null, mycommand);
    //menuitem1.addItem(menuitem2);

    // Define a common menu command for all the menu items.

    //  initEx2(request);
}

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel notifications() {
    Panel p = new Panel("Notifications");
    VerticalLayout content = new VerticalLayout() {
        Notification notification = new Notification("");
        TextField title = new TextField("Title");
        TextArea description = new TextArea("Description");
        MenuBar style = new MenuBar();
        MenuBar type = new MenuBar();
        String typeString = "";
        String styleString = "";
        TextField delay = new TextField();
        {//from  w  ww .j av  a  2 s .c om
            setSpacing(true);
            setMargin(true);

            title.setInputPrompt("Title for the notification");
            title.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (title.getValue() == null || title.getValue().length() == 0) {
                        notification.setCaption(null);
                    } else {
                        notification.setCaption(title.getValue());
                    }
                }
            });
            title.setValue("Notification Title");
            title.setWidth("100%");
            addComponent(title);

            description.setInputPrompt("Description for the notification");
            description.addStyleName("small");
            description.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (description.getValue() == null || description.getValue().length() == 0) {
                        notification.setDescription(null);
                    } else {
                        notification.setDescription(description.getValue());
                    }
                }
            });
            description.setValue(
                    "A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
            description.setWidth("100%");
            addComponent(description);

            Command typeCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Humanized")) {
                        typeString = "";
                        notification.setStyleName(styleString.trim());
                    } else {
                        typeString = selectedItem.getText().toLowerCase();
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    }
                    for (MenuItem item : type.getItems()) {
                        item.setChecked(false);
                    }
                    selectedItem.setChecked(true);
                }
            };

            type.setCaption("Type");
            MenuItem humanized = type.addItem("Humanized", typeCommand);
            humanized.setCheckable(true);
            humanized.setChecked(true);
            type.addItem("Tray", typeCommand).setCheckable(true);
            type.addItem("Warning", typeCommand).setCheckable(true);
            type.addItem("Error", typeCommand).setCheckable(true);
            type.addItem("System", typeCommand).setCheckable(true);
            addComponent(type);
            type.addStyleName("small");

            Command styleCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    styleString = "";
                    for (MenuItem item : style.getItems()) {
                        if (item.isChecked()) {
                            styleString += " " + item.getText().toLowerCase();
                        }
                    }
                    if (styleString.trim().length() > 0) {
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    } else if (typeString.length() > 0) {
                        notification.setStyleName(typeString.trim());
                    } else {
                        notification.setStyleName(null);
                    }
                }
            };

            style.setCaption("Additional style");
            style.addItem("Dark", styleCommand).setCheckable(true);
            style.addItem("Success", styleCommand).setCheckable(true);
            style.addItem("Failure", styleCommand).setCheckable(true);
            style.addItem("Bar", styleCommand).setCheckable(true);
            style.addItem("Small", styleCommand).setCheckable(true);
            style.addItem("Closable", styleCommand).setCheckable(true);
            addComponent(style);
            style.addStyleName("small");

            CssLayout group = new CssLayout();
            group.setCaption("Fade delay");
            group.addStyleName("v-component-group");
            addComponent(group);

            delay.setInputPrompt("Infinite");
            delay.addStyleName("align-right");
            delay.addStyleName("small");
            delay.setWidth("7em");
            delay.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    try {
                        notification.setDelayMsec(Integer.parseInt(delay.getValue()));
                    } catch (Exception e) {
                        notification.setDelayMsec(-1);
                        delay.setValue("");
                    }

                }
            });
            delay.setValue("1000");
            group.addComponent(delay);

            Button clear = new Button(null, new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    delay.setValue("");
                }
            });
            clear.setIcon(FontAwesome.TIMES_CIRCLE);
            clear.addStyleName("last");
            clear.addStyleName("small");
            clear.addStyleName("icon-only");
            group.addComponent(clear);
            group.addComponent(new Label("&nbsp; msec", ContentMode.HTML));

            GridLayout grid = new GridLayout(3, 3);
            grid.setCaption("Show in position");
            addComponent(grid);
            grid.setSpacing(true);

            Button pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

        }
    };
    p.setContent(content);

    return p;
}

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel windows() {
    Panel p = new Panel("Dialogs");
    VerticalLayout content = new VerticalLayout() {
        final Window win = new Window("Window Caption");
        String prevHeight = "300px";
        boolean footerVisible = true;
        boolean autoHeight = false;
        boolean tabsVisible = false;
        boolean toolbarVisible = false;
        boolean footerToolbar = false;
        boolean toolbarLayout = false;
        String toolbarStyle = null;

        VerticalLayout windowContent() {
            VerticalLayout root = new VerticalLayout();

            if (toolbarVisible) {
                MenuBar menuBar = MenuBars.getToolBar();
                menuBar.setSizeUndefined();
                menuBar.setStyleName(toolbarStyle);
                Component toolbar = menuBar;
                if (toolbarLayout) {
                    menuBar.setWidth(null);
                    HorizontalLayout toolbarLayout = new HorizontalLayout();
                    toolbarLayout.setWidth("100%");
                    toolbarLayout.setSpacing(true);
                    Label label = new Label("Tools");
                    label.setSizeUndefined();
                    toolbarLayout.addComponents(label, menuBar);
                    toolbarLayout.setExpandRatio(menuBar, 1);
                    toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT);
                    toolbar = toolbarLayout;
                }/*w  ww  .j  av a2s . com*/
                toolbar.addStyleName("v-window-top-toolbar");
                root.addComponent(toolbar);
            }

            Component content = null;

            if (tabsVisible) {
                TabSheet tabs = new TabSheet();
                tabs.setSizeFull();
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                tabs.addTab(l, "Selected");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "Another");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "One more");
                tabs.addStyleName("padded-tabbar");
                tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {
                    @Override
                    public void selectedTabChange(final SelectedTabChangeEvent event) {
                        try {
                            Thread.sleep(600);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                });
                content = tabs;
            } else if (!autoHeight) {
                Panel p = new Panel();
                p.setSizeFull();
                p.addStyleName("borderless");
                if (!toolbarVisible || !toolbarLayout) {
                    p.addStyleName("scroll-divider");
                }
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                p.setContent(l);
                content = p;
            } else {
                content = new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML);
                root.setMargin(true);
            }

            root.addComponent(content);

            if (footerVisible) {
                HorizontalLayout footer = new HorizontalLayout();
                footer.setWidth("100%");
                footer.setSpacing(true);
                footer.addStyleName("v-window-bottom-toolbar");

                Label footerText = new Label("Footer text");
                footerText.setSizeUndefined();

                Button ok = new Button("OK");
                ok.addStyleName("primary");

                Button cancel = new Button("Cancel");

                footer.addComponents(footerText, ok, cancel);
                footer.setExpandRatio(footerText, 1);

                if (footerToolbar) {
                    MenuBar menuBar = MenuBars.getToolBar();
                    menuBar.setStyleName(toolbarStyle);
                    menuBar.setWidth(null);
                    footer.removeAllComponents();
                    footer.addComponent(menuBar);
                }

                root.addComponent(footer);
            }

            if (!autoHeight) {
                root.setSizeFull();
                root.setExpandRatio(content, 1);
            }

            return root;
        }

        {
            setSpacing(true);
            setMargin(true);
            win.setWidth("380px");
            win.setHeight(prevHeight);
            win.setClosable(false);
            win.setResizable(false);
            win.setContent(windowContent());
            win.setCloseShortcut(KeyCode.ESCAPE, null);

            Command optionsCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Footer")) {
                        footerVisible = selectedItem.isChecked();
                    }
                    if (selectedItem.getText().equals("Auto Height")) {
                        autoHeight = selectedItem.isChecked();
                        if (!autoHeight) {
                            win.setHeight(prevHeight);
                        } else {
                            prevHeight = win.getHeight() + win.getHeightUnits().toString();
                            win.setHeight(null);
                        }
                    }
                    if (selectedItem.getText().equals("Tabs")) {
                        tabsVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top")) {
                        toolbarVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Footer")) {
                        footerToolbar = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top layout")) {
                        toolbarLayout = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Borderless")) {
                        toolbarStyle = selectedItem.isChecked() ? "borderless" : null;
                    }

                    win.setContent(windowContent());
                }
            };

            MenuBar options = new MenuBar();
            options.setCaption("Content");
            options.addItem("Auto Height", optionsCommand).setCheckable(true);
            options.addItem("Tabs", optionsCommand).setCheckable(true);
            MenuItem option = options.addItem("Footer", optionsCommand);
            option.setCheckable(true);
            option.setChecked(true);
            options.addStyleName("small");
            addComponent(options);

            options = new MenuBar();
            options.setCaption("Toolbars");
            options.addItem("Footer", optionsCommand).setCheckable(true);
            options.addItem("Top", optionsCommand).setCheckable(true);
            options.addItem("Top layout", optionsCommand).setCheckable(true);
            options.addItem("Borderless", optionsCommand).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            Command optionsCommand2 = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Caption")) {
                        win.setCaption(selectedItem.isChecked() ? "Window Caption" : null);
                    } else if (selectedItem.getText().equals("Closable")) {
                        win.setClosable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Resizable")) {
                        win.setResizable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Modal")) {
                        win.setModal(selectedItem.isChecked());
                    }
                }
            };

            options = new MenuBar();
            options.setCaption("Options");
            MenuItem caption = options.addItem("Caption", optionsCommand2);
            caption.setCheckable(true);
            caption.setChecked(true);
            options.addItem("Closable", optionsCommand2).setCheckable(true);
            options.addItem("Resizable", optionsCommand2).setCheckable(true);
            options.addItem("Modal", optionsCommand2).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            final Button show = new Button("Open Window", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    getUI().addWindow(win);
                    win.center();
                    win.focus();
                    event.getButton().setEnabled(false);
                }
            });
            show.addStyleName("primary");
            addComponent(show);

            final CheckBox hidden = new CheckBox("Hidden");
            hidden.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    win.setVisible(!hidden.getValue());
                }
            });
            addComponent(hidden);

            win.addCloseListener(new CloseListener() {
                @Override
                public void windowClose(final CloseEvent e) {
                    show.setEnabled(true);
                }
            });
        }
    };
    p.setContent(content);
    return p;

}