Package com.vaadin.ui

Examples of com.vaadin.ui.MenuBar$MenuItem


        getTooltipConfiguration().setCloseTimeout(1000);

    }

    private Component buildMenu(String label) {
        MenuBar menu = new MenuBar();
        MenuItem item = menu.addItem(label, null);

        item.addItem("Item 1", null).setDescription("TOOLTIP 1");
        item.addItem("Item 2", null).setDescription("TOOLTIP 2");
        item.addItem("Item 3", null).setDescription("TOOLTIP 3");
        item.addItem("Item 4", null).setDescription("TOOLTIP 4");
View Full Code Here


        return c;
    }

    /** Create new MenuBar and add it to current component container. */
    public MenuBar menubar() {
        MenuBar c = new MenuBar();
        c.setImmediate(true);
        add(c);
        return c;
    }
View Full Code Here

    /**
     * Create new MenuBar with given caption and add it to current component
     * container.
     */
    public MenuBar menubar(String caption) {
        MenuBar c = menubar();
        c.setCaption(caption);
        return c;
    }
View Full Code Here

        action.setIcon(FontAwesome.PENCIL);
        action.addStyleName("borderless-colored");
        action.addStyleName("small");
        action.addStyleName("icon-only");
        panelCaption.addComponent(action);
        MenuBar dropdown = new MenuBar();
        dropdown.addStyleName("borderless");
        dropdown.addStyleName("small");
        MenuItem addItem = dropdown.addItem("", FontAwesome.CHEVRON_DOWN, null);
        addItem.setStyleName("icon-only");
        addItem.addItem("Settings", null);
        addItem.addItem("Preferences", null);
        addItem.addSeparator();
        addItem.addItem("Sign Out", null);
View Full Code Here

        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();
            {
                setSpacing(true);
                setMargin(true);

                title.setInputPrompt("Title for the notification");
                title.addValueChangeListener(new ValueChangeListener() {
                    @Override
                    public void valueChange(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(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(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(MenuItem selectedItem) {
                        styleString = "";
View Full Code Here

            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;
                    }
                    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(
                                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(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 Toolbar")) {
                            toolbarVisible = selectedItem.isChecked();
                        }

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

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

                        if (selectedItem.getText()
                                .equals("Borderless Toolbars")) {
                            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 Toolbar", optionsCommand).setCheckable(
                        true);
                options.addItem("Top Toolbar", optionsCommand).setCheckable(
                        true);
                options.addItem("Top Toolbar layout", optionsCommand)
                        .setCheckable(true);
                options.addItem("Borderless Toolbars", optionsCommand)
                        .setCheckable(true);
                options.addStyleName("small");
                addComponent(options);

                Command optionsCommand2 = new Command() {
                    @Override
                    public void menuSelected(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
View Full Code Here

  @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");
View Full Code Here

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // menuBar_1
    menubar = new MenuBar();
    menubar.setImmediate(false);
    menubar.setWidth("100.0%");
    menubar.setHeight("-1px");
    mainLayout.addComponent(menubar, "top:0.0px;left:0.0px;");
View Full Code Here

    initialized = true;
  }

  @SuppressWarnings("serial")
  private MenuBar getMenu() {
    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");
    actionMenu = menubar.addItem("Action", null);

    actionMenu.addItem("Built-in Action...", new Command() {
      @Override
      public void menuSelected(MenuItem selectedItem) {
        main.showNotification("Built-in Action executed!");
      }
    });
    actionMenu.addSeparator();

    final MenuBar.MenuItem viewMenu = menubar.addItem("Help", null);
    viewMenu.addItem("About...", new Command() {
      @Override
      public void menuSelected(MenuItem selectedItem) {
        main.addWindow(getAboutDialog());
      }
View Full Code Here

 
  protected void initProfileButton() {
    final LoggedInUser user = ExplorerApp.get().getLoggedInUser();

    // User name + link to profile
    MenuBar profileMenu = new MenuBar();
    profileMenu.addStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_BOX);
    MenuItem rootItem = profileMenu.addItem(user.getFirstName() + " " + user.getLastName(), null);
    rootItem.setStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_MENU);
   
    if(useProfile()) {
      // Show profile
      rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_SHOW), new Command() {
View Full Code Here

TOP

Related Classes of com.vaadin.ui.MenuBar$MenuItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.