Example usage for com.vaadin.ui MenuBar setSizeFull

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

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

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  w  ww.ja  va2s  . c o  m*/
    // 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:de.mendelson.comm.as2.webclient2.AS2WebUI.java

private MenuBar createMenuBar() {
    MenuBar.Command logoutCommand = new MenuBar.Command() {
        @Override/*www . j a v  a2  s.  c  o m*/
        public void menuSelected(MenuItem selectedItem) {
            logout();
        }
    };
    MenuBar.Command stateCommand = new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            OkDialog dialog = new StateDialog();
            dialog.init();
            AS2WebUI.this.mainWindow.addWindow(dialog);
        }
    };
    MenuBar.Command aboutCommand = new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            OkDialog dialog = new AboutDialog();
            dialog.init();
            AS2WebUI.this.mainWindow.addWindow(dialog);
        }
    };
    MenuBar menubar = new MenuBar();
    MenuBar.MenuItem fileItem = menubar.addItem("AS2 server", null, null);
    fileItem.addItem("State", null, stateCommand);
    fileItem.addItem("Logout", null, logoutCommand);
    MenuBar.MenuItem helpItem = menubar.addItem("Help", null, null);
    helpItem.addItem("About", null, aboutCommand);
    menubar.setSizeFull();
    return (menubar);
}

From source file:org.vaadin.addon.ewopener.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    EnhancedBrowserWindowOpener opener1 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true);
    Button button1 = new Button("Click me");
    button1.addClickListener(e -> {// w ww . j a v  a2  s.  c  om
        opener1.open(generateResource());
    });
    opener1.extend(button1);

    EnhancedBrowserWindowOpener opener4 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true);
    Button button4 = new Button("Nothing to open here");
    button4.addClickListener(e -> {
        opener4.open((Resource) null);
    });
    opener4.extend(button4);

    Button button2 = new Button("Click me");
    button2.addClickListener(e -> {
        EnhancedBrowserWindowOpener.extendOnce(button2).open(generateResource());
    });

    Button button3 = new Button("Click me");
    EnhancedBrowserWindowOpener opener3 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true)
            .withGeneratedContent("myFileName.txt", this::generateContent).doExtend(button3);
    button3.addClickListener(opener3::open);

    Link link = new Link("Click me", null);
    new EnhancedBrowserWindowOpener().clientSide(true)
            .withGeneratedContent("myFileName.txt", this::generateContent).doExtend(link);

    Link link2 = new Link("Click me", null);
    new EnhancedBrowserWindowOpener().clientSide(true)
            .withGeneratedContent("myFileName.txt", this::generateContent, resource -> {
                resource.setCacheTime(0);
                resource.setFilename("runtimeFileName-" + Instant.now().getEpochSecond() + ".txt");
            }).doExtend(link2);

    EnhancedBrowserWindowOpener opener5 = new EnhancedBrowserWindowOpener(
            new ClassResource(DemoUI.class, "static.txt"));
    CssLayout hiddenComponent = new MCssLayout().withWidth("0").withHeight("0");
    opener5.extend(hiddenComponent);
    CompletableFuture.runAsync(this::doSomeLongProcessing).thenRun(() -> getUI().access(opener5::open));

    table = new Table("Select items to download",
            new BeanItemContainer<>(DummyService.Person.class, DummyService.data()));
    table.setImmediate(true);
    table.setVisibleColumns("name", "age");
    table.setColumnHeaders("Name", "Age");
    table.setWidth("100%");
    table.setPageLength(20);
    table.setMultiSelectMode(MultiSelectMode.DEFAULT);
    table.setMultiSelect(true);
    table.setSelectable(true);

    final MyPopupContent popupContent = new MyPopupContent();
    Button popupButton = new Button("Open modal", event -> {
        Window window = new Window("Test", popupContent);
        window.setWidth(40, Sizeable.Unit.PERCENTAGE);
        window.setHeight(200, Sizeable.Unit.PIXELS);
        window.setModal(true);
        window.setDraggable(false);
        window.setResizable(false);
        window.center();
        getUI().addWindow(window);
    });

    MenuBar.Command cmd = selectedItem -> Notification.show("Item clicked",
            "Item is " + selectedItem.getDescription(), Notification.Type.TRAY_NOTIFICATION);
    MenuBar menuBar = new MenuBar();
    menuBar.setSizeFull();
    EnhancedBrowserWindowOpener opener6 = new EnhancedBrowserWindowOpener()
            .withGeneratedContent("menu-item-serverside.txt", this::generateContent)
            .popupBlockerWorkaround(true);
    EnhancedBrowserWindowOpener opener7 = new EnhancedBrowserWindowOpener()
            .withGeneratedContent("menu-item-clientside-1.txt", this::generateContent).clientSide(true);
    EnhancedBrowserWindowOpener opener8 = new EnhancedBrowserWindowOpener()
            .withGeneratedContent("menu-item-clientside-2.txt", this::generateContent).clientSide(true);
    MenuBar.MenuItem menuItem = menuBar.addItem("Download from Menu (Client side)", selectedItem -> {
        System.out.println("OK, Invoked");
    });
    MenuBar.MenuItem subMenu = menuBar.addItem("Sub menu", null);
    subMenu.addItem("Item 1", cmd);
    subMenu.addItem("Item 2", cmd);
    MenuBar.MenuItem subItem = subMenu.addItem("Download (client side)", cmd);
    MenuBar.MenuItem subItem2 = subMenu.addItem("Download (server side)", selectedItem -> opener6.open());
    opener7.doExtend(menuBar, menuItem);
    opener6.doExtend(menuBar, subItem2);
    opener8.doExtend(menuBar, subItem);

    // Show it in the middle of the screen
    final Layout layout = new MVerticalLayout(
            new MLabel("Enhanced Window Opener Demo").withStyleName(ValoTheme.LABEL_COLORED,
                    ValoTheme.LABEL_H1),
            new MHorizontalLayout().add(table, 1)
                    .add(new MCssLayout(menuBar, readMarkdown("code_menu.md").withFullWidth(),
                            new MVerticalLayout(readMarkdown("code1.md"), button1)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code2.md"), button2)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code7.md"), button3)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code5.md"), link)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code6.md"), link2)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code3.md"), button4)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code8.md"), popupButton)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code4.md"), hiddenComponent)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false))
                                            .withFullWidth().withStyleName("demo-samples"),
                            5)
                    .withFullWidth()).withFullWidth().withMargin(true);

    setContent(layout);

}

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

License:Apache License

public void refresh() {
    final MenuBar menuBar = new MenuBar();
    menuBar.setStyleName("menu-bar-navigation");
    menuBar.setSizeFull();
    //menuBar.setHeight(32, Unit.PIXELS);
    setCompositionRoot(menuBar);//from  w w  w.j  av a 2 s. c  o  m

    final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion();

    for (final String pageName : navigationVersion.getRootPages()) {
        processRootPage(navigationVersion, menuBar, pageName);
    }

    if (getSite().getSecurityProvider().getUser() != null) {
        final String localizedPageName = getSite().localize("button-logout");
        final Resource iconResource = getSite().getIcon("page-icon-logout");

        menuBar.addItem(localizedPageName, iconResource, new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                final Company company = getSite().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());
                getSession().close();
            }
        }).setStyleName("navigation-logout");
    }
}

From source file:rs.co.micro.bwNet.navigationMenu.java

public navigationMenu() {

    //Main Panel/*from   w ww . j  a  v a  2  s .  com*/
    setResponsive(true);
    setSpacing(true);
    setMargin(false);

    HorizontalLayout topMenu = new HorizontalLayout();
    topMenu.setSizeFull();

    //Logout Dugme
    MenuBar logout = new MenuBar();
    logout.setId("logoutDugme");
    logout.setSizeFull();
    logout.setResponsive(true);
    logout.setDescription("Izadjite iz programa");

    MenuBar.MenuItem logoutDugme = logout.addItem("Logout", FontAwesome.SIGN_OUT, new MenuBar.Command() {
        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            getUI().getSession().close();
            navigator.addView("login", new login());
            navigator.navigateTo("login");
        }
    });

    //Navigacioni meni
    MenuBar navMeni = new MenuBar();
    navMeni.setId("navMeni");
    navMeni.setSizeFull();
    navMeni.setResponsive(true);

    // A top-level menu item that opens a submenu
    MenuBar.MenuItem uvidi = navMeni.addItem("Uvidi", null, null);
    //Nesto poput click listenera
    MenuBar.Command mycommand = new MenuBar.Command() {
        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            Notification.show("radi");
        }
    };

    //        karticaPartnera.addItem("Tea",
    //                FontAwesome.DROPBOX, mycommand);
    //        karticaPartnera.addItem("Coffee",
    //                FontAwesome.COFFEE, mycommand);
    // Another top-level item
    MenuBar.MenuItem snacks = navMeni.addItem("Snacks", null, null);
    snacks.addItem("Weisswurst", null, mycommand);
    snacks.addItem("Bratwurst", null, mycommand);
    snacks.addItem("Currywurst", null, mycommand);
    snacks.addItem("Test1", null, mycommand);
    snacks.addItem("test2", null, mycommand);

    // Yet another top-level item
    MenuBar.MenuItem servs = navMeni.addItem("Services", null, null);
    servs.addItem("Car Service", null, mycommand);

    topMenu.addComponents(navMeni, logout);
    addComponents(topMenu);

    // Kreira Kartica Partnera submeni i pokazuje Karticu 
    MenuBar.MenuItem karticaPartnera;
    karticaPartnera = uvidi.addItem("Kartica Partnera", null, new MenuBar.Command() {
        @Override
        public void menuSelected(MenuBar.MenuItem selectedItem) {

            try {
                navigator.addView("BWKarticaPartnera", new BWkarticaPartnera());

            } catch (SQLException ex) {
                System.out.println("Greska (BWnFinex klasa)" + SQLException.class);
            }
            navigator.navigateTo("BWKarticaPartnera");
        }
    });

    System.out.println("ubacen meni");
}