Example usage for com.vaadin.ui Button setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.esofthead.mycollab.module.crm.view.campaign.CampaignSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 2);
    layoutSearchPane.setSpacing(true);/* w  w w  . j  av  a2 s  .co  m*/

    final ValueComboBox group = new ValueComboBox(false, "Campaign Name", "Start Date", "End Date");
    group.select("Campaign Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Campaign Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Start Date")) {
                addDateFieldSearch();
            } else if (searchType.equals("End Date")) {
                addDateFieldSearch();
            }
        }
    });

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

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            searchCriteria = new CampaignSearchCriteria();
            searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));

            String searchType = (String) group.getValue();
            if (StringUtils.isNotBlank(searchType)) {

                if (textValueField != null) {
                    String strSearch = textValueField.getValue();
                    if (StringUtils.isNotBlank(strSearch)) {

                        if (searchType.equals("Campaign Name")) {
                            searchCriteria.setCampaignName(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Email")) {
                        } else if (searchType.equals("Phone")) {
                        }
                    }
                }

            }
            CampaignSimpleSearchPanel.this.notifySearchHandler(searchCriteria);
        }
    });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
}

From source file:com.esofthead.mycollab.module.crm.view.cases.CaseContactListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();/* www . j  a v a  2  s . c o m*/
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT));
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void splitButtonClick(SplitButton.SplitButtonClickEvent event) {
            fireNewRelatedItem("");
        }
    });
    Button selectBtn = new Button("Select from existing contacts", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            CaseContactSelectionWindow contactsWindow = new CaseContactSelectionWindow(
                    CaseContactListComp.this);
            ContactSearchCriteria criteria = new ContactSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            UI.getCurrent().addWindow(contactsWindow);
            contactsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }
    });
    selectBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_select));
    selectBtn.setStyleName("link");

    VerticalLayout buttonControlsLayout = new VerticalLayout();
    buttonControlsLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlsLayout);

    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}

From source file:com.esofthead.mycollab.module.crm.view.cases.CaseContactSelectionWindow.java

License:Open Source License

@Override
protected void initUI() {
    tableItem = new ContactTableDisplay(ContactTableFieldDef.selected, Arrays.asList(ContactTableFieldDef.name,
            ContactTableFieldDef.email, ContactTableFieldDef.phoneOffice, ContactTableFieldDef.account));

    Button selectBtn = new Button("Select", new Button.ClickListener() {
        @Override/*  w w  w .j a v a2 s .c  om*/
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    selectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    ContactSimpleSearchPanel contactSimpleSearchPanel = new ContactSimpleSearchPanel();
    contactSimpleSearchPanel.addSearchHandler(new SearchHandler<ContactSearchCriteria>() {
        @Override
        public void onSearch(ContactSearchCriteria criteria) {
            tableItem.setSearchCriteria(criteria);
        }
    });

    this.bodyContent.addComponent(contactSimpleSearchPanel);
    this.bodyContent.addComponent(selectBtn);
    this.bodyContent.addComponent(tableItem);
}

From source file:com.esofthead.mycollab.module.crm.view.cases.CaseSearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%").withSpacing(true)
            .withMargin(new MarginInfo(true, false, true, false)).withStyleName(UIConstants.HEADER_VIEW);

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.CASE,
            AppContext.getMessage(CaseI18nEnum.VIEW_LIST_TITLE));
    searchtitle.setStyleName(UIConstants.HEADER_TEXT);

    layout.with(searchtitle).expand(searchtitle).withAlign(searchtitle, Alignment.MIDDLE_LEFT);

    final Button createAccountBtn = new Button(AppContext.getMessage(CaseI18nEnum.BUTTON_NEW_CASE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override// w w w  . j a  va 2  s . c  o  m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new CaseEvent.GotoAdd(this, null));
                }
            });
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE));
    layout.with(createAccountBtn).withAlign(createAccountBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.cases.CaseSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 3);
    layoutSearchPane.setSpacing(true);//from   ww  w  .j a v a2s  . c  o  m

    final ValueComboBox group = new ValueComboBox(false, "Subject", "Account Name", "Status",
            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("Subject")) {
                addTextFieldSearch();
            } else if (searchType.equals("Account Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Status")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

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

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            searchCriteria = new CaseSearchCriteria();
            searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));

            String searchType = (String) group.getValue();
            if (StringUtils.isNotBlank(searchType)) {

                if (textValueField != null) {
                    String strSearch = textValueField.getValue();
                    if (StringUtils.isNotBlank(strSearch)) {

                        if (searchType.equals("Subject")) {
                            searchCriteria.setSubject(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Status")) {
                            searchCriteria.setStatuses(
                                    new SetSearchField<String>(SearchField.AND, new String[] { strSearch }));
                        }
                    }
                }

                if (userBox != null) {
                    String user = (String) userBox.getValue();
                    if (StringUtils.isNotBlank(user)) {
                        searchCriteria.setAssignUsers(
                                new SetSearchField<String>(SearchField.AND, new String[] { user }));
                    }
                }
            }

            CaseSimpleSearchPanel.this.notifySearchHandler(searchCriteria);
        }
    });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
}

From source file:com.esofthead.mycollab.module.crm.view.contact.ContactOpportunityListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption(AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY));
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*from  w w w. j  av a 2s .c  o m*/
        public void splitButtonClick(SplitButton.SplitButtonClickEvent event) {
            fireNewRelatedItem("");
        }
    });
    controlsBtn.setSizeUndefined();
    Button selectBtn = new Button("Select from existing opportunities", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ContactOpportunitySelectionWindow opportunitiesWindow = new ContactOpportunitySelectionWindow(
                    ContactOpportunityListComp.this);
            OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            UI.getCurrent().addWindow(opportunitiesWindow);
            opportunitiesWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }
    });
    selectBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_select));
    selectBtn.setStyleName("link");

    VerticalLayout buttonControlsLayout = new VerticalLayout();
    buttonControlsLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlsLayout);

    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}

From source file:com.esofthead.mycollab.module.crm.view.contact.ContactOpportunitySelectionWindow.java

License:Open Source License

@Override
protected void initUI() {
    tableItem = new OpportunityTableDisplay(OpportunityTableFieldDef.selected,
            Arrays.asList(OpportunityTableFieldDef.opportunityName, OpportunityTableFieldDef.saleStage,
                    OpportunityTableFieldDef.expectedCloseDate));

    Button selectBtn = new Button("Select", new Button.ClickListener() {

        @Override/*from   w  w w .j  a v  a  2 s. co m*/
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    selectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    OpportunitySimpleSearchPanel opportunitySimpleSearchPanel = new OpportunitySimpleSearchPanel();
    opportunitySimpleSearchPanel.addSearchHandler(new SearchHandler<OpportunitySearchCriteria>() {

        @Override
        public void onSearch(OpportunitySearchCriteria criteria) {
            tableItem.setSearchCriteria(criteria);
        }

    });

    this.bodyContent.addComponent(opportunitySimpleSearchPanel);
    this.bodyContent.addComponent(selectBtn);
    this.bodyContent.addComponent(tableItem);
}

From source file:com.esofthead.mycollab.module.crm.view.contact.ContactReadFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    SimpleContact contact = attachForm.getBean();

    if (propertyId.equals("accountid")) {
        return new LinkViewField(contact.getAccountName(),
                CrmLinkBuilder.generateAccountPreviewLinkFull(contact.getAccountid()),
                CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT));
    } else if (propertyId.equals("email")) {
        return new EmailViewField(attachForm.getBean().getEmail());
    } else if (propertyId.equals("assignuser")) {
        return new UserLinkViewField(contact.getAssignuser(), contact.getAssignUserAvatarId(),
                contact.getAssignUserFullName());
    } else if (propertyId.equals("iscallable")) {
        if (contact.getIscallable() == null || Boolean.FALSE == contact.getIscallable()) {
            return new DefaultViewField(AppContext.getMessage(GenericI18Enum.BUTTON_NO));
        } else {/*from   ww  w.j  a v a2s  . c o m*/
            return new DefaultViewField(AppContext.getMessage(GenericI18Enum.BUTTON_YES));
        }
    } else if (propertyId.equals("birthday")) {
        return new DateViewField(contact.getBirthday());
    } else if (propertyId.equals("firstname")) {
        final ContainerHorizontalViewField containerField = new ContainerHorizontalViewField();
        String displayName = "";
        if (contact.getPrefix() != null) {
            displayName = contact.getPrefix();
        }
        if (contact.getFirstname() != null) {
            displayName += contact.getFirstname();
        }

        final Label nameLbl = new Label(displayName);
        containerField.addComponentField(nameLbl);
        containerField.getLayout().setExpandRatio(nameLbl, 1.0f);
        final Button vcardDownloadBtn = new Button("");
        VCardStreamSource streamSource = new VCardStreamSource();
        OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
        downloaderExt.extend(vcardDownloadBtn);

        vcardDownloadBtn.setIcon(MyCollabResource.newResource("icons/12/vcard.png"));
        vcardDownloadBtn.setStyleName(UIConstants.THEME_TRANSPARENT_LINK);
        containerField.addComponentField(vcardDownloadBtn);
        containerField.getLayout().setComponentAlignment(vcardDownloadBtn, Alignment.TOP_RIGHT);
        return containerField;
    } else if (propertyId.equals("description")) {
        return new RichTextViewField(contact.getDescription());
    }

    return null;
}

From source file:com.esofthead.mycollab.module.crm.view.contact.ContactSearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withStyleName(UIConstants.HEADER_VIEW)
            .withWidth("100%").withSpacing(true).withMargin(new MarginInfo(true, false, true, false));

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.CONTACT,
            AppContext.getMessage(ContactI18nEnum.VIEW_LIST_TITLE));
    searchtitle.setStyleName(UIConstants.HEADER_TEXT);
    layout.with(searchtitle).withAlign(searchtitle, Alignment.MIDDLE_LEFT).expand(searchtitle);

    final Button createBtn = new Button(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override/*from   w  w  w . j av a2 s . c o m*/
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new ContactEvent.GotoAdd(this, null));
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    layout.with(createBtn).withAlign(createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.contact.ContactSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 3);
    layoutSearchPane.setSpacing(true);//from  w w w.  j a v  a2  s. co  m

    final ValueComboBox group = new ValueComboBox(false, "Name", "Email", "Phone",
            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("Email")) {
                addTextFieldSearch();
            } else if (searchType.equals("Phone")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

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

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            searchCriteria = new ContactSearchCriteria();
            searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));

            String searchType = (String) group.getValue();
            if (StringUtils.isNotBlank(searchType)) {

                if (textValueField != null) {
                    String strSearch = textValueField.getValue();
                    if (StringUtils.isNotBlank(strSearch)) {

                        if (searchType.equals("Name")) {
                            searchCriteria.setContactName(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Email")) {
                            searchCriteria.setAnyEmail(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Phone")) {
                            searchCriteria.setAnyPhone(new StringSearchField(SearchField.AND, strSearch));
                        }
                    }
                }

                if (userBox != null) {
                    String user = (String) userBox.getValue();
                    if (StringUtils.isNotBlank(user)) {
                        searchCriteria.setAssignUsers(
                                new SetSearchField<String>(SearchField.AND, new String[] { user }));
                    }
                }
            }

            ContactSimpleSearchPanel.this.notifySearchHandler(searchCriteria);
        }
    });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
}