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.mycollab.module.crm.view.lead.LeadSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    searchPanel = new GridLayout(3, 3);
    searchPanel.setSpacing(true);/*from   w  w w .  j av a2 s .  c o m*/

    group = new ValueComboBox(false, "Name", "Email", "Phone",
            AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE));
    group.select("Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Email")) {
                addTextFieldSearch();
            } else if (searchType.equals("Phone")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

    searchPanel.addComponent(group, 1, 0);
    searchPanel.setComponentAlignment(group, Alignment.MIDDLE_CENTER);
    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            doSearch();
        }
    });
    searchPanel.addComponent(searchBtn, 2, 0);
    searchPanel.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(searchPanel);
}

From source file:com.mycollab.module.crm.view.opportunity.OpportunitySimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    searchPanel = new GridLayout(3, 3);
    searchPanel.setSpacing(true);/*from www  .j a  v a 2  s  .  c om*/

    group = new ValueComboBox(false, "Name", "Account Name", "Sales Stage",
            AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE));
    group.select("Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Account Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Sales Stage")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

    searchPanel.addComponent(group, 1, 0);
    searchPanel.setComponentAlignment(group, Alignment.MIDDLE_CENTER);
    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            doSearch();
        }
    });
    searchPanel.addComponent(searchBtn, 2, 0);
    searchPanel.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(searchPanel);
}

From source file:com.mycollab.module.project.view.settings.component.InviteUserTokenField.java

License:Open Source License

private Component generateToken(final String email) {
    final Button btn = new Button(email, FontAwesome.TIMES);
    btn.addClickListener(clickEvent -> {
        InviteUserTokenField.this.removeComponent(btn);
        inviteEmails.remove(email);//from   w w  w .j a v  a2s.c  om
    });
    btn.addStyleName("token-field");
    return btn;
}

From source file:com.mycollab.module.project.view.settings.component.InviteUserTokenField.java

License:Open Source License

private Component generateToken(final SimpleUser user) {
    final Button btn = new Button("", FontAwesome.TIMES);
    btn.setCaptionAsHtml(true);/*w w w  .  j a  va 2  s.c om*/
    btn.setCaption((new Img("", StorageFactory.getAvatarPath(user.getAvatarid(), 16))).write() + " "
            + user.getDisplayName());
    btn.addClickListener(clickEvent -> {
        InviteUserTokenField.this.removeComponent(btn);
        inviteEmails.remove(user.getEmail());
    });
    btn.setStyleName("token-field");
    return btn;
}

From source file:com.mycollab.vaadin.web.ui.ProjectPreviewFormControlsGenerator.java

License:Open Source License

public void addOptionButton(Button button) {
    button.addClickListener(clickEvent -> optionBtn.setPopupVisible(false));
    popupButtonsControl.addOption(button);
}

From source file:com.mycollab.vaadin.web.ui.SplitButton.java

License:Open Source License

public SplitButton(Button parentButton) {
    this.setImmediate(true);
    HorizontalLayout contentLayout = new HorizontalLayout();
    contentLayout.setStyleName("splitbutton");
    this.parentButton = parentButton;
    parentButton.addStyleName("parent-button");
    parentButton.setImmediate(true);/*from  ww w.  j av a  2 s  . c om*/
    parentButton.addClickListener(clickEvent -> fireEvent(new SplitButtonClickEvent(SplitButton.this)));

    popupButton = new PopupButton();
    popupButton.addClickListener(clickEvent -> {
        isPopupVisible = !isPopupVisible;
        fireEvent(new SplitButtonPopupVisibilityEvent(SplitButton.this, isPopupVisible));
    });

    contentLayout.addComponent(parentButton);
    contentLayout.addComponent(popupButton);

    this.setCompositionRoot(contentLayout);
}

From source file:com.mycollab.vaadin.web.ui.ToggleButtonGroup.java

License:Open Source License

@Override
public Button addButton(Button button) {
    super.addButton(button);
    button.addClickListener(clickEvent -> {
        if (!clickEvent.getButton().equals(selectedBtn)) {
            selectedBtn = clickEvent.getButton();
            Iterator<Component> iterator = ToggleButtonGroup.this.iterator();
            while (iterator.hasNext()) {
                iterator.next().removeStyleName(WebThemes.BTN_ACTIVE);
            }//w  w  w  . j  av  a2  s .c om
            selectedBtn.addStyleName(WebThemes.BTN_ACTIVE);
        }
    });
    return button;
}

From source file:com.mycompany.exodious.login.java

public login() {
    this.setId("loginPanel");
    this.setSpacing(true);
    Image logo = new Image();
    logo.setId("logo");
    logo.setSource(slikaLogo);//w w  w.  j  a  v  a2 s  .c  o m
    logo.setHeight("18em");
    logo.setWidth("30em");
    Label welcome = new Label("Welcome, please login");
    welcome.setId("welcome");
    TextField username = new TextField("Your ID");
    PasswordField password = new PasswordField("Password");
    Button submit = new Button("Login");
    submit.setIcon(FontAwesome.SIGN_IN);
    submit.addStyleName(ValoTheme.BUTTON_PRIMARY);

    submit.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {

        }
    });

    addComponents(logo, welcome, username, password, submit);
    setComponentAlignment(logo, Alignment.MIDDLE_CENTER);
    setComponentAlignment(welcome, Alignment.MIDDLE_CENTER);
    setComponentAlignment(username, Alignment.MIDDLE_CENTER);
    setComponentAlignment(password, Alignment.MIDDLE_CENTER);
    setComponentAlignment(submit, Alignment.MIDDLE_CENTER);
}

From source file:com.mycompany.project.components.ContactDetails.java

public ContactDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//  w w  w.  j  a v a2s.  co m
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    tfName.setSizeFull();
    tfAddress.setSizeFull();
    tfPhone.setSizeFull();
    tfEmail.setSizeFull();

    Panel panel = new Panel("Grupos");
    panel.setWidth("100%");
    panel.setHeight("50px");
    panel.setContent(groupsHLayout);

    mainVLayout.addComponent(tfName);
    mainVLayout.addComponent(tfAddress);
    mainVLayout.addComponent(tfPhone);
    mainVLayout.addComponent(tfEmail);
    mainVLayout.addComponent(groupsHLayout);

    Button btnUpdate = new Button("Actualizar");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();
            String address = tfAddress.getValue();
            String phone = tfPhone.getValue();
            String email = tfEmail.getValue();

            ArrayList<String> selectedGroupIds = new ArrayList<String>();
            Set<String> groupIdSet = groupsMap.keySet();
            for (String groupId : groupIdSet) {
                CheckBox cb = groupsMap.get(groupId);
                if (cb.getValue()) {
                    selectedGroupIds.add(groupId);
                }
            }

            boolean success = bl.updateContact(selectedContactId, name, address, phone, email,
                    selectedGroupIds);
            if (success) {
                load(selectedContactId);
                Notification.show("Informacion", "Contacto Actualizado", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    ContactDetails.this.setVisible(false);
}

From source file:com.mycompany.project.components.GroupDetails.java

public GroupDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);// w  ww. j  a  v a2  s.  c o  m
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);
    tfName.setSizeFull();
    mainVLayout.addComponent(tfName);

    Button btnUpdate = new Button("Update");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();

            boolean success = bl.updateGroup(selectedGroupId, name);
            if (success) {
                load(selectedGroupId);
                Notification.show("Success", "Group updated", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    GroupDetails.this.setVisible(false);
}