Example usage for com.vaadin.ui Button addClickListener

List of usage examples for com.vaadin.ui Button addClickListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addClickListener.

Prototype

public Registration addClickListener(ClickListener listener) 

Source Link

Document

Adds the button click listener.

Usage

From source file:com.freebox.engeneering.application.web.layout.LeftSideBarController.java

License:Apache License

private void createFooterSideBar() {
    VerticalLayout verticalLayout = super.getView();

    sideBarFooter.setSizeUndefined();/*from ww w.ja  v  a2s.co m*/
    sideBarFooter.addStyleName("user");
    Image profilePic = new Image(null, new ThemeResource("img/profile-pic.png"));
    profilePic.setWidth("34px");
    sideBarFooter.addComponent(profilePic);
    Label userName = new Label("MOHELLEBI ATAF");
    userName.setSizeUndefined();
    sideBarFooter.addComponent(userName);

    Command cmd = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    };
    MenuBar settings = new MenuBar();
    MenuItem settingsMenu = settings.addItem("", null);
    settingsMenu.setStyleName("icon-cog");
    settingsMenu.addItem("Settings", cmd);
    settingsMenu.addItem("Preferences", cmd);
    settingsMenu.addSeparator();
    settingsMenu.addItem("My Account", cmd);
    sideBarFooter.addComponent(settings);

    Button exit = new NativeButton("Exit");
    exit.addStyleName("icon-cancel");
    exit.setDescription("Sign Out");
    sideBarFooter.addComponent(exit);
    exit.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
        }
    });

    verticalLayout.addComponent(sideBarFooter);
}

From source file:com.freebox.engeneering.application.web.layout.LeftSideBarController.java

License:Apache License

private void createMenuSideBar() {

    menu.addStyleName("no-vertical-drag-hints");
    menu.addStyleName("no-horizontal-drag-hints");
    menu.addStyleName("menu");
    menu.setHeight("100%");

    Button freeboxState;
    Button freeboxDownloads;/*  w  w w.j av a 2s.  c  om*/
    Button freeboxContacts;
    Button freeboxCalls;

    freeboxState = new NativeButton("Etat Freebox");//Etat de la freebox
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxState);

    freeboxDownloads = new NativeButton("Dashbord");//Tlchargement
    freeboxDownloads.addStyleName("icon-sales");

    freeboxDownloads.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            eventProcessor.fireEvent("dashboard", "");
        }
    });

    menu.addComponent(freeboxDownloads);

    freeboxContacts = new NativeButton("Contacts");
    freeboxContacts.addStyleName("icon-transactions");

    freeboxContacts.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxContacts);

    freeboxCalls = new NativeButton("Journal");
    freeboxCalls.addStyleName("icon-reports");

    freeboxCalls.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxCalls);

    freeboxState = new NativeButton("Explorateur");
    freeboxState.addStyleName("icon-schedule");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("explorer");
        }
    });

    menu.addComponent(freeboxState);

    freeboxState = new NativeButton("Etat");
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxState);

    freeboxState = new NativeButton("Etat");
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {

            getEventProcessor().fireEvent("register");
        }
    });

    menu.addComponent(freeboxState);

    freeboxState = new NativeButton("Etat");
    freeboxState.addStyleName("icon-dashboard");

    freeboxState.addClickListener(new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getEventProcessor().fireEvent("register");
        }
    });

    VerticalLayout verticalLayout = super.getView();
    verticalLayout.addComponent(menu);
    verticalLayout.setExpandRatio(menu, 1);

}

From source file:com.garyclayburg.vconsole.VConsole.java

License:Open Source License

private void populateExceptionMessage(String message, boolean visible) {
    VerticalLayout windowContent = new VerticalLayout();
    windowContent.setMargin(true);/*from w  w w.j  ava  2  s.  c om*/

    Label messageLabel = new Label(message, ContentMode.PREFORMATTED);
    messageLabel.setStyleName(Runo.LABEL_SMALL);
    //        messageLabel.setWidth("120em");
    windowContent.addComponent(messageLabel);
    Button closeButton = new Button("Close");
    closeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            exceptionWindow.setVisible(false);
        }
    });

    windowContent.addComponent(closeButton);
    UI ui = exceptionWindow.getUI();
    if (ui != null) {
        VaadinSession session = ui.getSession();
        if (session != null) {
            session.getLockInstance().lock();
            try {
                exceptionWindow.setContent(windowContent);
                exceptionWindow.setVisible(visible);
            } finally {
                session.getLockInstance().unlock();
            }
        } else {
            exceptionWindow.setContent(windowContent);
            exceptionWindow.setVisible(visible);
        }
    } else {
        exceptionWindow.setContent(windowContent);
        exceptionWindow.setVisible(visible);
    }
}

From source file:com.github.carljmosca.MainLayout.java

private void init() {
    setSizeFull();//from  w w w.  jav a2s.c  om
    addStyleName("menylayout");
    Responsive.makeResponsive(this);
    ComboBox<Person> cmbPerson = new ComboBox<>();
    cmbPerson.setItems(personProcessor.findAll());
    cmbPerson.setItemCaptionGenerator(c -> c.getTitle() + " " + c.getFirstName() + " " + c.getLastName());
    cmbPerson.addValueChangeListener((HasValue.ValueChangeEvent<Person> event) -> {
        binder.setBean(cmbPerson.getValue());
    });
    title = new ComboBox("Title", Arrays.asList(titles));
    firstName = new TextField("First");
    middleName = new TextField("Middle");
    lastName = new TextField("Last");
    Button btnNew = new Button("New");
    btnNew.addClickListener((Button.ClickEvent event) -> {
        person = new Person();
        binder.setBean(person);
    });
    Button btnSave = new Button("Save");
    btnSave.addClickListener((Button.ClickEvent event) -> {
        personProcessor.addPerson(person);
        cmbPerson.setItems(personProcessor.findAll());
    });
    personLayout.setWidth(null);
    personLayout.setSpacing(true);
    personLayout.addStyleName("menu");
    personLayout.addComponent(title);
    personLayout.addComponent(firstName);
    personLayout.addComponent(middleName);
    personLayout.addComponent(lastName);
    personLayout.addComponent(btnNew);
    addComponent(btnSave);
    addComponent(cmbPerson);
    addComponent(personLayout);
    //addComponent(buttonLayout);
    doBinding();
}

From source file:com.github.carljmosca.ui.MainUI.java

private void addHeader() {
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);/*from ww  w  .  ja  v  a 2  s .  com*/
    cmbWidgets = new ComboBox();
    cmbWidgets.setContainerDataSource(widgets);
    cmbWidgets.setItemCaptionPropertyId("name");
    hl.addComponent(cmbWidgets);

    Button btnUpdate = new Button("Update", FontAwesome.ADJUST);
    btnUpdate.addClickListener((Button.ClickEvent event) -> {
        cmbWidgets.select(widgets.getIdByIndex(0));
    });
    hl.addComponent(btnUpdate);

    Button btnShow = new Button("Show", FontAwesome.DASHBOARD);
    btnShow.addClickListener((Button.ClickEvent event) -> {
        try {
            fgWidget.commit();
        } catch (FieldGroup.CommitException ex) {
            Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        }
        System.out.println(demoAppData.getSelectedWidget().getName());
    });
    hl.addComponent(btnShow);

    Button btnChange = new Button("Change", FontAwesome.REFRESH);
    btnChange.addClickListener((Button.ClickEvent event) -> {
        Widget widget = (Widget) biDemoAppData.getItemProperty("selectedWidget").getValue();
        widget.setName("test xxxx");
        System.out.println(demoAppData.getSelectedWidget().getName());
    });
    hl.addComponent(btnChange);

    mainLayout.addComponent(hl);
}

From source file:com.github.carljmosca.ui.MenuView.java

@PostConstruct
private void init() {
    setCaption("Menu");

    final VerticalComponentGroup content = new VerticalComponentGroup();
    Button btnSearch = new Button("Search");
    btnSearch.addClickListener((ClickEvent event) -> {
        getNavigationManager().navigateTo(searchView);
        Notification.show("navigateTo");
    });//  w ww.ja v  a2  s .  c  om
    content.addComponent(btnSearch);
    setContent(content);
}

From source file:com.github.carljmosca.ui.SearchView.java

@PostConstruct
private void init() {
    setCaption("ZoneMinderV");
    VerticalComponentGroup content = new VerticalComponentGroup();

    cmbMonitors = new NativeSelect<>();
    if (monitorsRepository.count() > 0) {
        List<Monitors> monitors = monitorsRepository.findAll();
        cmbMonitors.setItems(monitors);/*from   www.j a  va  2 s .co m*/
        cmbMonitors.setValue(monitors.get(0));
    }
    cmbMonitors.setItemCaptionGenerator(p -> p.getName());
    cmbMonitors.setEmptySelectionAllowed(false);
    cmbMonitors.setEmptySelectionCaption("Select monitor");
    content.addComponent(cmbMonitors);
    datePicker = new DatePicker("Event Date");
    datePicker.setValue(new Date());
    content.addComponent(datePicker);

    final Button btnSearch = new Button("Search");
    btnSearch.addClickListener((ClickEvent event) -> {
        DemoUI demoUI = (DemoUI) this.getUI();
        if (cmbMonitors.getValue() != null && datePicker.getValue() != null) {
            demoUI.setMonitorId(cmbMonitors.getValue().getId());
            demoUI.setEventStartTime(datePicker.getValue());
            getNavigationManager().navigateTo(eventsView);
        } else {
            Notification.show("Select monitor and date");
        }
    });

    setContent(new CssLayout(content, btnSearch));
}

From source file:com.github.daytron.sqlcontainer.DatabaseTableScreen.java

public DatabaseTableScreen() {
    setMargin(true);//  w w w  .  j a v a  2s  .c  o  m

    table = new Table();
    table.setPageLength(10);
    table.setEditable(true);
    table.setSizeFull();

    table.addGeneratedColumn("", new RemoveItemColumnGenerator());

    HorizontalLayout buttonBar = new HorizontalLayout();

    buttonBar.setMargin(true);
    buttonBar.setSpacing(true);

    Button commitButton = new Button("Commit");
    commitButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                container.commit();
                Notification.show("Changes committed");
            } catch (UnsupportedOperationException | SQLException ex) {
                Logger.getLogger(DatabaseTableScreen.class.getName()).log(Level.SEVERE, null, ex);
                Notification.show("Unable to commit", Notification.Type.ERROR_MESSAGE);
            }

        }
    });

    buttonBar.addComponent(commitButton);
    Button rollbackButton = new Button("Rollback");

    rollbackButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                container.rollback();
                Notification.show("Changes rollback");
            } catch (UnsupportedOperationException | SQLException ex) {
                Logger.getLogger(DatabaseTableScreen.class.getName()).log(Level.SEVERE, null, ex);
                Notification.show("Unable to rollback", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    buttonBar.addComponent(rollbackButton);
    addComponent(table);
    addComponent(buttonBar);
}

From source file:com.github.daytron.tablebean.tableColumn.DateSourcePlay.java

License:Open Source License

public DateSourcePlay() {

    Property<String> property = new ObjectProperty<>("ABC");
    final TextField tf = new TextField(property);
    tf.setBuffered(true);/*from   w ww  .  j  av  a 2s .c om*/

    tf.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            Notification.show("Text change (event): " + event.getText(), Notification.Type.TRAY_NOTIFICATION);
        }
    });

    Button commitButton = new Button("Save");
    commitButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Notification.show("Before commit (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);

            tf.commit();

            Notification.show("After commit (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);
        }
    });

    Button discardButton = new Button("Cancel");
    discardButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Notification.show("Before discard (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);

            tf.discard();

            Notification.show("After discard (property): " + tf.getPropertyDataSource().getValue(),
                    Notification.Type.TRAY_NOTIFICATION);
        }
    });

    addComponent(tf);
    addComponent(commitButton);
    addComponent(discardButton);
}

From source file:com.github.daytron.twaattin.ui.TimelineScreen.java

License:Open Source License

public TimelineScreen() {
    setMargin(true);//ww  w .j  a  v a  2  s  .c o  m

    Label label = new Label(VaadinSession.getCurrent().getAttribute(Principal.class).getName());

    Button logoutButton = new Button("Logout");
    logoutButton.addClickListener(new LogoutBehaviour());

    HorizontalLayout menuBar = new HorizontalLayout(label, logoutButton);
    menuBar.setWidth(100, Unit.PERCENTAGE);
    menuBar.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);
    addComponent(menuBar);

    addComponentAttachListener(new TweetRefresherBehaviour());

    Table table = new Table();
    addComponent(table);

    table.addGeneratedColumn("source", new SourceColumnDecorator());
    table.addGeneratedColumn("screenName", new ScreenNameColumnGenerator());
    table.addGeneratedColumn("name", new NameColumnGenerator());
    table.addGeneratedColumn("profileImage", new ProfileImageColumnGenerator());
    table.addGeneratedColumn("text", new TweetColumnDecorator());

    table.setColumnHeader("source", "via");
    table.setColumnHeader("screenName", "Screen name");
    table.setColumnHeader("profileImage", "");
    table.setColumnHeader("text", "Tweet");

    table.setVisibleColumns(
            new Object[] { "text", "name", "screenName", "profileImage", "createdAt", "source" });

}