Example usage for com.vaadin.ui NativeButton removeStyleName

List of usage examples for com.vaadin.ui NativeButton removeStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui NativeButton removeStyleName.

Prototype

@Override
    public void removeStyleName(String style) 

Source Link

Usage

From source file:at.peppol.webgui.app.MainWindow.java

License:Mozilla Public License

@SuppressWarnings("serial")
private void initUI() {

    final VerticalLayout root = new VerticalLayout();
    root.setMargin(false);/*from  w  ww .  j  a  v  a 2s.  c om*/
    setContent(root);

    // createTopBar();
    // Changed with menuBar -- under testing
    createMenuBar();
    // Changed with custom layout using bootstrap -- under testing
    // createHeaderMenu();

    final UserFolder<File> userFolder = new UserFolder<File>();
    final long polling = 20000;
    int draftInvoicesNum = um.countItemsInSpace(um.getDrafts());
    int inboxInvoicesNum = um.countItemsInSpace(um.getInbox());
    int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox());
    //Buttons
    final NativeButton inboxInvoices = new NativeButton("Invoices (" + inboxInvoicesNum + ")");
    final NativeButton outboxInvoices = new NativeButton("Invoices (" + outboxInvoicesNum + ")");
    final NativeButton draftInvoices = new NativeButton("Invoices (" + draftInvoicesNum + ")");

    //thread
    final Thread tFolderCount = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                while (true) {
                    int countDrafts = um.countItemsInSpace(um.getDrafts());
                    int countInbox = um.countItemsInSpace(um.getInbox());
                    int countOutbox = um.countItemsInSpace(um.getOutbox());
                    synchronized (MainWindow.this.getApplication()) {
                        String labelD = draftInvoices.getCaption();
                        labelD = labelD.replaceFirst("[\\d]+", "" + countDrafts);
                        draftInvoices.setCaption(labelD);

                        String labelI = inboxInvoices.getCaption();
                        labelI = labelI.replaceFirst("[\\d]+", "" + countInbox);
                        inboxInvoices.setCaption(labelI);

                        String labelO = outboxInvoices.getCaption();
                        labelO = labelO.replaceFirst("[\\d]+", "" + countOutbox);
                        outboxInvoices.setCaption(labelO);

                        itemsPanel.reloadTable(userFolder);
                    }
                    Thread.sleep(polling);
                }
            } catch (InterruptedException e) {
                System.out.println("Thread folders interrupted!!!");
            }
        }
    });

    // ------ START: Left NavBar -------
    final CssLayout leftNavBar = new CssLayout();
    leftNavBar.setStyleName("sidebar-menu");
    leftNavBar.setSizeFull();
    leftNavBar.setWidth("220px");

    // User theUser = (User) getApplication().getUser();
    final Label homeLbl = new Label("HOME");
    homeLbl.addStyleName("blue");
    leftNavBar.addComponent(homeLbl);

    leftNavBar.addComponent(new Label("INBOX"));
    final NativeButton catalogueBtn = new NativeButton("Catalogue");
    leftNavBar.addComponent(catalogueBtn);
    leftNavBar.addComponent(new NativeButton("Orders"));
    //leftNavBar.addComponent (new NativeButton ("Invoices"));
    //int inboxInvoicesNum = um.countItemsInSpace(um.getInbox());
    //inboxInvoices = new NativeButton ("Invoices ("+inboxInvoicesNum+")");
    inboxInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            inboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getInbox()) + ")");
            userFolder.setFolder(um.getInbox().getFolder());
            userFolder.setName(um.getInbox().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(inboxInvoices);

    leftNavBar.addComponent(new Label("DRAFTS"));
    leftNavBar.addComponent(new NativeButton("Catalogue"));
    leftNavBar.addComponent(new NativeButton("Orders"));
    //int draftInvoicesNum = um.countItemsInSpace(um.getDrafts());
    //draftInvoices = new NativeButton ("Invoices ("+draftInvoicesNum+")");
    draftInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            draftInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getDrafts()) + ")");
            userFolder.setFolder(um.getDrafts().getFolder());
            userFolder.setName(um.getDrafts().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(draftInvoices);

    leftNavBar.addComponent(new Label("OUTBOX"));
    leftNavBar.addComponent(new NativeButton("Catalogue"));
    leftNavBar.addComponent(new NativeButton("Orders"));
    //leftNavBar.addComponent (new NativeButton ("Invoices"));
    //int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox());
    //outboxInvoices = new NativeButton ("Invoices ("+outboxInvoicesNum+")");
    outboxInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            outboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getOutbox()) + ")");
            userFolder.setFolder(um.getOutbox().getFolder());
            userFolder.setName(um.getOutbox().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(outboxInvoices);

    leftNavBar.addComponent(new Label("SETTINGS"));
    leftNavBar.addComponent(new NativeButton("My Profile"));
    leftNavBar.addComponent(new NativeButton("Customers"));
    leftNavBar.addComponent(new NativeButton("Suppliers"));

    final Embedded peppolLogoImg = new Embedded(null, new ExternalResource("img/peppol_logo.png"));

    peppolLogoImg.setStyleName("logo");
    leftNavBar.addComponent(peppolLogoImg);

    middleContentLayout.addComponent(leftNavBar);

    /*Button refreshButton = new Button("Refresh");
    refreshButton.addListener(new Button.ClickListener() {
      @Override
      public void buttonClick(ClickEvent event) {
         int draftInvoices = um.countItemsInSpace(um.getDrafts());
         invoices.setCaption("Invoices ("+draftInvoices+")");
      }
    });
    leftNavBar.addComponent(refreshButton);*/

    //workaround so that thread refreshes UI. It seems that when a ProgressIndicator is present,
    //all components receive server side refreshes
    ProgressIndicator p = new ProgressIndicator();
    p.setPollingInterval((int) polling);
    p.setWidth("0px");
    p.setHeight("0px");
    leftNavBar.addComponent(p);

    showInitialMainContent(null);
    draftInvoices.click();
    tFolderCount.start();
    draftInvoices.addStyleName("v-bold-nativebuttoncaption");
}

From source file:com.foc.vaadin.FocWebVaadinWindow.java

License:Apache License

public void menuBarIcons_Highlight(NativeButton button) {
    if (menuBarIconsMap != null) {
        Iterator<NativeButton> iter = menuBarIconsMap.values().iterator();
        while (iter != null && iter.hasNext()) {
            NativeButton b = iter.next();
            if (b != null) {
                if (b == button) {
                    b.addStyleName("foc-textOrange");
                } else {
                    b.removeStyleName("foc-textOrange");
                }// www  .  j a v a 2  s.co  m
            }
        }
    }
}

From source file:org.vaadin.melodion.Melodion.java

License:Open Source License

private void updateStyles() {
    for (NativeButton b : buttons) {
        b.removeStyleName("selected");
    }/*from   ww w .  j av  a 2s. c o m*/
    for (Tab t : tabs) {
        t.label.removeStyleName("selected");
    }
}