Example usage for com.vaadin.server FontAwesome SIGN_OUT

List of usage examples for com.vaadin.server FontAwesome SIGN_OUT

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome SIGN_OUT.

Prototype

FontAwesome SIGN_OUT

To view the source code for com.vaadin.server FontAwesome SIGN_OUT.

Click Source Link

Usage

From source file:org.jumpmind.metl.ui.common.TopBar.java

License:Open Source License

public TopBar(ViewManager vm, ApplicationContext context) {
    setWidth(100, Unit.PERCENTAGE);/*from   w w w.jav  a 2  s  . co  m*/
    this.context = context;
    this.viewManager = vm;
    this.viewManager.addViewChangeListener(this);

    viewToButtonMapping = new HashMap<String, MenuItem>();

    menuBar = new MenuBar();
    menuBar.setWidth(100, Unit.PERCENTAGE);
    addComponent(menuBar);
    setExpandRatio(menuBar, 1.0f);

    String systemText = getGlobalSetting(GlobalSetting.SYSTEM_TEXT, "").getValue();
    if (isNotBlank(systemText)) {
        Button systemLabel = new Button(systemText, FontAwesome.WARNING);
        systemLabel.setHtmlContentAllowed(true);
        addComponent(systemLabel);
    }

    Button helpButton = new Button("Help", FontAwesome.QUESTION_CIRCLE);
    helpButton.addClickListener(event -> openHelp(event));
    addComponent(helpButton);

    Button settingsButton = new Button(context.getUser().getLoginId(), FontAwesome.GEAR);
    settingsButton.addClickListener((event) -> {
    });
    addComponent(settingsButton);

    Button logoutButton = new Button("Logout", FontAwesome.SIGN_OUT);
    logoutButton.addClickListener(event -> logout());
    addComponent(logoutButton);

    Map<Category, List<TopBarLink>> menuItemsByCategory = viewManager.getMenuItemsByCategory();
    Set<Category> categories = menuItemsByCategory.keySet();
    for (Category category : categories) {
        if (!context.getUser().hasPrivilege(category.name())) {
            log.info("'{}' does not have access to the {} menu tab", context.getUser(), category.name());
            continue;
        }
        List<TopBarLink> links = menuItemsByCategory.get(category);
        boolean needDefaultView = viewManager.getDefaultView() == null && links.size() > 0;
        MenuItem categoryItem = null;
        if (links.size() > 1) {
            categoryItem = menuBar.addItem(category.name(), null);
            categoryItems.add(categoryItem);
        }

        if (needDefaultView) {
            viewManager.setDefaultView(links.get(0).id());
        }

        for (final TopBarLink menuLink : links) {
            Command command = new Command() {

                private static final long serialVersionUID = 1L;

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    uncheckAll();
                    selectedItem.setChecked(true);
                    viewManager.navigateTo(menuLink.id());
                }
            };
            MenuItem menuItem = null;
            if (categoryItem == null) {
                menuItem = menuBar.addItem(menuLink.name(), command);
            } else {
                menuItem = categoryItem.addItem(menuLink.name(), command);
            }
            menuItem.setCheckable(true);
            viewToButtonMapping.put(menuLink.id(), menuItem);
        }
    }
    viewManager.navigateTo(viewManager.getDefaultView());
}

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

public navigationMenu() {

    //Main Panel/*from   www  .j ava  2  s.co m*/
    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");
}